示例#1
0
文件: GeoPHP.php 项目: kitbs/geoPHP
 static function load()
 {
     $args = func_get_args();
     $data = array_shift($args);
     $type = array_shift($args);
     $type_map = GeoPHP::getAdapterMap();
     // Auto-detect type if needed
     if (!$type) {
         // If the user is trying to load a Geometry from a Geometry... Just pass it back
         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 = 'GeoPHP\\Adapters\\' . $type_map[$type];
     if (!$processor_type) {
         throw new Exception('GeoPHP could not find an adapter of type ' . htmlentities($type));
     }
     $processor = new $processor_type();
     // 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));
     } 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;
 }
示例#2
0
文件: Geometry.php 项目: kitbs/geoPHP
 public function out()
 {
     $args = func_get_args();
     $format = array_shift($args);
     $type_map = GeoPHP::getAdapterMap();
     $processor_type = 'GeoPHP\\Adapters\\' . $type_map[$format];
     $processor = new $processor_type();
     array_unshift($args, $this);
     $result = call_user_func_array(array($processor, 'write'), $args);
     return $result;
 }