public function geos()
 {
     // If it's already been set, just return it
     if ($this->geos && FOX_geo::geosInstalled()) {
         return $this->geos;
     }
     // It hasn't been set yet, generate it
     if (FOX_geo::geosInstalled()) {
         $reader = new GEOSWKBReader();
         $this->geos = $reader->readHEX($this->out('wkb', true));
     } else {
         $this->geos = false;
     }
     return $this->geos;
 }
Exemple #2
0
 /**
  * Serialize geometries into a WKT string.
  *
  * @param Geometry $geometry
  *
  * @return string The WKT string representation of the input geometries
  */
 public function write(FOX_geometry $geometry)
 {
     // If geos is installed, then we take a shortcut and let it write the WKT
     if (FOX_geo::geosInstalled()) {
         $writer = new GEOSWKTWriter();
         $writer->setTrim(true);
         return $writer->write($geometry->geos());
     }
     if ($geometry->isEmpty()) {
         return strtoupper($geometry->geometryType()) . ' EMPTY';
     } else {
         $data = $this->extractData($geometry);
         if ($data) {
             return strtoupper($geometry->geometryType()) . ' (' . $data . ')';
         } else {
             return null;
         }
     }
 }