/**
  * {@inheritdoc}
  */
 public function getJS()
 {
     // Ensure the options are properly set and clean.
     $this->setOption('dataType', array_filter($this->getOption('dataType', array('WKT' => 'WKT'))));
     $this->setOption('typeOfFeature', array_filter($this->getOption('typeOfFeature', array())));
     $this->setOption('actionFeature', array_filter($this->getOption('actionFeature', array())));
     $initial_data = $this->getOption('initialData');
     // Process initial data. Ensure it's WKT.
     if (isset($initial_data)) {
         // Process strings and arrays likewise.
         geophp_load();
         if (!is_array($initial_data)) {
             $initial_data = array($initial_data);
         }
         $geoms = array();
         foreach ($initial_data as $delta => $item) {
             if (is_array($item) && array_key_exists('geom', $item)) {
                 $geoms[] = geoPHP::load($item['geom']);
             } else {
                 // Is this really necessary ? Commented for now.
                 // $geoms[] = geoPHP::load('');
             }
         }
         $combined_geom = geoPHP::geometryReduce($geoms);
         // If we could parse the geom process further.
         if ($combined_geom && !$combined_geom->isEmpty()) {
             // We want to force the combined_geom into a geometryCollection.
             $geom_type = $combined_geom->geometryType();
             if ($geom_type == 'MultiPolygon' || $geom_type == 'MultiLineString' || $geom_type == 'MultiPoint') {
                 $combined_geom = new \GeometryCollection($combined_geom->getComponents());
             }
             // Ensure proper initial data in the textarea / hidden field.
             $data_type = key($this->getOption('dataType', array('WKT' => 'WKT')));
             $this->setOption('initialData', $combined_geom->out(strtolower($data_type)));
             $this->setOption('initialDataType', $data_type);
         } else {
             // Set initial data to NULL if the data couldn't be evaluated.
             $this->setOption('initialData', NULL);
             $this->setOption('initialDataType', key($this->getOption('dataType', array('WKT' => 'WKT'))));
         }
     }
     return parent::getJS();
 }
Ejemplo n.º 2
0
 public function __construct($srid = null, $with_z = false, $with_m = false)
 {
     parent::__construct($srid, $with_z, $with_m);
     $this->binary_type = 6;
     $this->text_type = 'MULTIPOLYGON';
 }
Ejemplo n.º 3
0
 public function __construct($srid = null, $with_z = false, $with_m = false)
 {
     parent::__construct($srid, $with_z, $with_m);
     $this->binary_type = 5;
     $this->text_type = 'MULTILINESTRING';
 }