/**
  * Generate parameters for the GIS data editor from the value of the GIS column.
  *
  * @param string  $value Value of the GIS column
  * @param integer $index Index of the geometry
  *
  * @return array params for the GIS data editor from the value of the GIS column
  * @access public
  */
 public function generateParams($value, $index = -1)
 {
     $params = array();
     if ($index == -1) {
         $index = 0;
         $data = PMA_GIS_Geometry::generateParams($value);
         $params['srid'] = $data['srid'];
         $wkt = $data['wkt'];
     } else {
         $params[$index]['gis_type'] = 'MULTIPOINT';
         $wkt = $value;
     }
     /** @var PMA_String $pmaString */
     $pmaString = $GLOBALS['PMA_String'];
     // Trim to remove leading 'MULTIPOINT(' and trailing ')'
     $points = $pmaString->substr($wkt, 11, $pmaString->strlen($wkt) - 12);
     $points_arr = $this->extractPoints($points, null);
     $no_of_points = count($points_arr);
     $params[$index]['MULTIPOINT']['no_of_points'] = $no_of_points;
     for ($i = 0; $i < $no_of_points; $i++) {
         $params[$index]['MULTIPOINT'][$i]['x'] = $points_arr[$i][0];
         $params[$index]['MULTIPOINT'][$i]['y'] = $points_arr[$i][1];
     }
     return $params;
 }
 /**
  * Generate parameters for the GIS data editor from the value of the GIS column.
  *
  * @param string $value of the GIS column
  * @param index  $index of the geometry
  *
  * @return  parameters for the GIS data editor from the value of the GIS column
  */
 public function generateParams($value, $index = -1)
 {
     if ($index == -1) {
         $index = 0;
         $params = array();
         $data = PMA_GIS_Geometry::generateParams($value);
         $params['srid'] = $data['srid'];
         $wkt = $data['wkt'];
     } else {
         $params[$index]['gis_type'] = 'LINESTRING';
         $wkt = $value;
     }
     // Trim to remove leading 'LINESTRING(' and trailing ')'
     $linestring = substr($wkt, 11, strlen($wkt) - 12);
     $points_arr = $this->extractPoints($linestring, null);
     $no_of_points = count($points_arr);
     $params[$index]['LINESTRING']['no_of_points'] = $no_of_points;
     for ($i = 0; $i < $no_of_points; $i++) {
         $params[$index]['LINESTRING'][$i]['x'] = $points_arr[$i][0];
         $params[$index]['LINESTRING'][$i]['y'] = $points_arr[$i][1];
     }
     return $params;
 }
 /** Generate parameters for the GIS data editor from the value of the GIS column.
  *
  * @param string $value Value of the GIS column
  * @param int    $index Index of the geometry
  *
  * @return array params for the GIS data editor from the value of the GIS column
  * @access public
  */
 public function generateParams($value, $index = -1)
 {
     $params = array();
     if ($index == -1) {
         $index = 0;
         $data = PMA_GIS_Geometry::generateParams($value);
         $params['srid'] = $data['srid'];
         $wkt = $data['wkt'];
     } else {
         $params[$index]['gis_type'] = 'POLYGON';
         $wkt = $value;
     }
     // Trim to remove leading 'POLYGON((' and trailing '))'
     $polygon = mb_substr($wkt, 9, mb_strlen($wkt) - 11);
     // Separate each linestring
     $linerings = explode("),(", $polygon);
     $params[$index]['POLYGON']['no_of_lines'] = count($linerings);
     $j = 0;
     foreach ($linerings as $linering) {
         $points_arr = $this->extractPoints($linering, null);
         $no_of_points = count($points_arr);
         $params[$index]['POLYGON'][$j]['no_of_points'] = $no_of_points;
         for ($i = 0; $i < $no_of_points; $i++) {
             $params[$index]['POLYGON'][$j][$i]['x'] = $points_arr[$i][0];
             $params[$index]['POLYGON'][$j][$i]['y'] = $points_arr[$i][1];
         }
         $j++;
     }
     return $params;
 }
 /**
  * Generate parameters for the GIS data editor from the value of the GIS column.
  *
  * @param string $value of the GIS column
  * @param int    $index of the geometry
  *
  * @return array params for the GIS data editor from the value of the GIS column
  * @access public
  */
 public function generateParams($value, $index = -1)
 {
     $params = array();
     if ($index == -1) {
         $index = 0;
         $data = PMA_GIS_Geometry::generateParams($value);
         $params['srid'] = $data['srid'];
         $wkt = $data['wkt'];
     } else {
         $params[$index]['gis_type'] = 'POINT';
         $wkt = $value;
     }
     // Trim to remove leading 'POINT(' and trailing ')'
     $point = mb_substr($wkt, 6, mb_strlen($wkt) - 7);
     $points_arr = $this->extractPoints($point, null);
     $params[$index]['POINT']['x'] = $points_arr[0][0];
     $params[$index]['POINT']['y'] = $points_arr[0][1];
     return $params;
 }
 /**
  * Generates parameters for the GIS data editor from the value of the GIS column.
  *
  * @param string $value of the GIS column
  *
  * @return array parameters for the GIS editor from the value of the GIS column
  * @access public
  */
 public function generateParams($value)
 {
     $params = array();
     $data = PMA_GIS_Geometry::generateParams($value);
     $params['srid'] = $data['srid'];
     $wkt = $data['wkt'];
     // Trim to remove leading 'GEOMETRYCOLLECTION(' and trailing ')'
     $goem_col = substr($wkt, 19, strlen($wkt) - 20);
     // Split the geometry collection object to get its constituents.
     $sub_parts = $this->_explodeGeomCol($goem_col);
     $params['GEOMETRYCOLLECTION']['geom_count'] = count($sub_parts);
     $i = 0;
     foreach ($sub_parts as $sub_part) {
         $type_pos = stripos($sub_part, '(');
         $type = substr($sub_part, 0, $type_pos);
         $gis_obj = PMA_GIS_Factory::factory($type);
         if (!$gis_obj) {
             continue;
         }
         $params = array_merge($params, $gis_obj->generateParams($sub_part, $i));
         $i++;
     }
     return $params;
 }
 /**
  * Generate parameters for the GIS data editor from the value of the GIS column.
  *
  * @param string $value Value of the GIS column
  * @param int    $index Index of the geometry
  *
  * @return array params for the GIS data editor from the value of the GIS column
  * @access public
  */
 public function generateParams($value, $index = -1)
 {
     $params = array();
     if ($index == -1) {
         $index = 0;
         $data = PMA_GIS_Geometry::generateParams($value);
         $params['srid'] = $data['srid'];
         $wkt = $data['wkt'];
     } else {
         $params[$index]['gis_type'] = 'MULTILINESTRING';
         $wkt = $value;
     }
     /** @var PMA_String $pmaString */
     $pmaString = $GLOBALS['PMA_String'];
     // Trim to remove leading 'MULTILINESTRING((' and trailing '))'
     $multilinestirng = $pmaString->substr($wkt, 17, $pmaString->strlen($wkt) - 19);
     // Seperate each linestring
     $linestirngs = explode("),(", $multilinestirng);
     $params[$index]['MULTILINESTRING']['no_of_lines'] = count($linestirngs);
     $j = 0;
     foreach ($linestirngs as $linestring) {
         $points_arr = $this->extractPoints($linestring, null);
         $no_of_points = count($points_arr);
         $params[$index]['MULTILINESTRING'][$j]['no_of_points'] = $no_of_points;
         for ($i = 0; $i < $no_of_points; $i++) {
             $params[$index]['MULTILINESTRING'][$j][$i]['x'] = $points_arr[$i][0];
             $params[$index]['MULTILINESTRING'][$j][$i]['y'] = $points_arr[$i][1];
         }
         $j++;
     }
     return $params;
 }
 /**
  * Generate parameters for the GIS data editor from the value of the GIS column.
  *
  * @param string $value Value of the GIS column
  * @param int    $index Index of the geometry
  *
  * @return array params for the GIS data editor from the value of the GIS column
  * @access public
  */
 public function generateParams($value, $index = -1)
 {
     $params = array();
     if ($index == -1) {
         $index = 0;
         $data = PMA_GIS_Geometry::generateParams($value);
         $params['srid'] = $data['srid'];
         $wkt = $data['wkt'];
     } else {
         $params[$index]['gis_type'] = 'MULTIPOLYGON';
         $wkt = $value;
     }
     // Trim to remove leading 'MULTIPOLYGON(((' and trailing ')))'
     $multipolygon = mb_substr($wkt, 15, mb_strlen($wkt) - 18);
     // Separate each polygon
     $polygons = explode(")),((", $multipolygon);
     $param_row =& $params[$index]['MULTIPOLYGON'];
     $param_row['no_of_polygons'] = count($polygons);
     $k = 0;
     foreach ($polygons as $polygon) {
         // If the polygon doesnt have an inner polygon
         if (mb_strpos($polygon, "),(") === false) {
             $param_row[$k]['no_of_lines'] = 1;
             $points_arr = $this->extractPoints($polygon, null);
             $no_of_points = count($points_arr);
             $param_row[$k][0]['no_of_points'] = $no_of_points;
             for ($i = 0; $i < $no_of_points; $i++) {
                 $param_row[$k][0][$i]['x'] = $points_arr[$i][0];
                 $param_row[$k][0][$i]['y'] = $points_arr[$i][1];
             }
         } else {
             // Separate outer and inner polygons
             $parts = explode("),(", $polygon);
             $param_row[$k]['no_of_lines'] = count($parts);
             $j = 0;
             foreach ($parts as $ring) {
                 $points_arr = $this->extractPoints($ring, null);
                 $no_of_points = count($points_arr);
                 $param_row[$k][$j]['no_of_points'] = $no_of_points;
                 for ($i = 0; $i < $no_of_points; $i++) {
                     $param_row[$k][$j][$i]['x'] = $points_arr[$i][0];
                     $param_row[$k][$j][$i]['y'] = $points_arr[$i][1];
                 }
                 $j++;
             }
         }
         $k++;
     }
     return $params;
 }