Skip to content

Commit

Permalink
Can now pass in an array of items into geoPHP::load and get back a co…
Browse files Browse the repository at this point in the history
…mbined geometry
  • Loading branch information
root committed Jan 26, 2012
1 parent 2574a27 commit ea37c16
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions geoPHP.inc
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ class geoPHP
}

// geoPHP::load($data, $type, $other_args);
// if $data is an array, all passed in values will be combined into a single geometry
static function load() {

$args = func_get_args();

$data = array_shift($args);
Expand All @@ -48,7 +48,18 @@ class geoPHP
$processor_type = $type_map[$type];
$processor = new $processor_type();

$result = call_user_func_array(array($processor, "read"), array_merge(array($data), $args));
// Data is not an array, just pass it normally
if (!is_array($data)) {
$result = call_user_func_array(array($processor, "read"), array_merge(array($data), $args));
}
// Data is an array, combine all passed in items into a single geomtetry
else {
$geoms = array();
foreach ($data as $item) {
$geoms[] = call_user_func_array(array($processor, "read"), array_merge(array($data), $args));
}
$result = geoPHP::geometryReduce($geoms);
}

return $result;
}
Expand Down

0 comments on commit ea37c16

Please sign in to comment.