/** 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 = GISGeometry::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 = GISGeometry::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; }
/** * 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 = GISGeometry::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 doesn't 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; }
/** * 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 = GISGeometry::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 = mb_substr($wkt, 11, mb_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; }
/** * 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 = GISGeometry::generateParams($value); $params['srid'] = $data['srid']; $wkt = $data['wkt']; // Trim to remove leading 'GEOMETRYCOLLECTION(' and trailing ')' $goem_col = mb_substr($wkt, 19, mb_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 = mb_stripos($sub_part, '('); $type = mb_substr($sub_part, 0, $type_pos); $gis_obj = GISFactory::factory($type); if (!$gis_obj) { continue; } $params = array_merge($params, $gis_obj->generateParams($sub_part, $i)); $i++; } return $params; }