static function geoPHP::load in geoPHP 7
Same name and namespace in other branches
- 8 geoPHP/geoPHP.inc \geoPHP::load()
12 calls to geoPHP::load()
- AdaptersTests::testAdapters in geoPHP/tests/tests/adaptersTest.php
- geoPHP::geosToGeometry in geoPHP/geoPHP.inc
- GeosTests::testGeos in geoPHP/tests/tests/geosTest.php
- MethodsTests::testMethods in geoPHP/tests/tests/methodsTest.php
- MethodsTests::_methods_tester_with_geos in geoPHP/tests/tests/methodsTest.php
... See full list
File
- geoPHP/geoPHP.inc, line 43
Class
- geoPHP
Code
static function load() {
$args = func_get_args();
$data = array_shift($args);
$type = array_shift($args);
if (empty($data)) {
return null;
}
$type_map = geoPHP::getAdapterMap();
if (!$type) {
if (is_object($data)) {
if ($data instanceof Geometry) {
return $data;
}
}
$detected = geoPHP::detectFormat($data);
if (!$detected) {
return FALSE;
}
$format = explode(':', $detected);
$type = array_shift($format);
$args = $format;
}
$processor_type = $type_map[$type];
if (!$processor_type) {
throw new exception('geoPHP could not find an adapter of type ' . htmlentities($type));
exit;
}
$processor = new $processor_type();
if (!is_array($data)) {
$result = call_user_func_array(array(
$processor,
"read",
), array_merge(array(
$data,
), $args));
}
else {
$geoms = array();
foreach ($data as $item) {
$geoms[] = call_user_func_array(array(
$processor,
"read",
), array_merge(array(
$item,
), $args));
}
$result = geoPHP::geometryReduce($geoms);
}
return $result;
}