Exemplo n.º 1
0
 /**
  * Extract geometry to a WKT string
  *
  * @param Geometry $geometry A Geometry object
  *
  * @return string
  */
 public function extractData($geometry)
 {
     $parts = array();
     switch ($geometry->geometryType()) {
         case 'Point':
             return $geometry->getX() . ' ' . $geometry->getY();
         case 'LineString':
             foreach ($geometry->getComponents() as $component) {
                 $parts[] = $this->extractData($component);
             }
             return implode(', ', $parts);
         case 'Polygon':
         case 'MultiPoint':
         case 'MultiLineString':
         case 'MultiPolygon':
             foreach ($geometry->getComponents() as $component) {
                 $parts[] = '(' . $this->extractData($component) . ')';
             }
             return implode(', ', $parts);
         case 'GeometryCollection':
             foreach ($geometry->getComponents() as $component) {
                 $parts[] = strtoupper($component->geometryType()) . ' (' . $this->extractData($component) . ')';
             }
             return implode(', ', $parts);
     }
 }
Exemplo n.º 2
0
 /**
  * Extract geometry to a WKT string
  *
  * @param Geometry $geometry A Geometry object
  *
  * @return string
  */
 public function extractData($geometry)
 {
     $type = strtolower($geometry->geometryType());
     switch ($type) {
         case "point":
             return $geometry->getX() . ' ' . $geometry->getY();
             break;
         case "linestring":
             $parts = array();
             foreach ($geometry->getComponents() as $component) {
                 $parts[] = $this->extractData($component);
             }
             return implode(', ', $parts);
             break;
         case "polygon":
         case 'multipoint':
         case 'multilinestring':
         case 'multipolygon':
             $parts = array();
             foreach ($geometry->getComponents() as $component) {
                 $parts[] = '(' . $this->extractData($component) . ')';
             }
             return implode(', ', $parts);
             break;
         case 'geometrycollection':
             $parts = array();
             foreach ($geometry->getComponents() as $component) {
                 $parts[] = strtoupper($component->geometryType()) . ' (' . $this->extractData($component) . ')';
             }
             return implode(', ', $parts);
             break;
         default:
             throw new FOX_exception(array('numeric' => 1, 'text' => "Unknown geometry type", 'data' => $geometry, 'file' => __FILE__, 'class' => __CLASS__, 'function' => __FUNCTION__, 'line' => __LINE__, 'child' => null));
     }
 }