From 4fa4fdac9171c4759025ca0939fa1a5c301c84f2 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Sun, 6 May 2012 10:28:59 +0530 Subject: [PATCH 1/4] Fix doc comment --- libraries/import/shp.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/import/shp.php b/libraries/import/shp.php index 3b8703712f..d5bd00b184 100644 --- a/libraries/import/shp.php +++ b/libraries/import/shp.php @@ -75,7 +75,7 @@ if (isset($plugin_list)) { /** * Returns whether the 'dbase' extension is loaded * - * @return whether the 'dbase' extension is loaded + * @return boolean whether the 'dbase' extension is loaded */ function _isDbaseLoaded() { From a965c1ca5d6e666e90b9b3a15fadc043e355edf0 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Sun, 6 May 2012 10:57:16 +0530 Subject: [PATCH 2/4] Add missing file doc comments --- libraries/gis/pma_gis_factory.php | 6 ++++++ libraries/gis/pma_gis_geometry.php | 6 ++++++ libraries/gis/pma_gis_geometrycollection.php | 8 +++++++- libraries/gis/pma_gis_linestring.php | 8 +++++++- libraries/gis/pma_gis_multilinestring.php | 8 +++++++- libraries/gis/pma_gis_multipoint.php | 8 +++++++- libraries/gis/pma_gis_multipolygon.php | 8 +++++++- libraries/gis/pma_gis_point.php | 8 +++++++- libraries/gis/pma_gis_polygon.php | 8 +++++++- libraries/gis/pma_gis_visualization.php | 8 +++++++- 10 files changed, 68 insertions(+), 8 deletions(-) diff --git a/libraries/gis/pma_gis_factory.php b/libraries/gis/pma_gis_factory.php index 39a6ab040b..579ddcdf8b 100644 --- a/libraries/gis/pma_gis_factory.php +++ b/libraries/gis/pma_gis_factory.php @@ -1,5 +1,11 @@ Date: Sun, 6 May 2012 14:32:00 +0530 Subject: [PATCH 3/4] Wrap some long lines --- libraries/gis/pma_gis_geometry.php | 38 +++++++++++++------ libraries/gis/pma_gis_geometrycollection.php | 16 ++++++-- libraries/gis/pma_gis_linestring.php | 20 +++++++--- libraries/gis/pma_gis_multilinestring.php | 19 +++++++--- libraries/gis/pma_gis_multipoint.php | 25 +++++++----- libraries/gis/pma_gis_multipolygon.php | 15 +++++--- libraries/gis/pma_gis_point.php | 40 +++++++++++++------- libraries/gis/pma_gis_polygon.php | 9 +++-- libraries/gis/pma_gis_visualization.php | 25 +++++++++--- 9 files changed, 145 insertions(+), 62 deletions(-) diff --git a/libraries/gis/pma_gis_geometry.php b/libraries/gis/pma_gis_geometry.php index a44ec38877..5d849ec03e 100644 --- a/libraries/gis/pma_gis_geometry.php +++ b/libraries/gis/pma_gis_geometry.php @@ -42,7 +42,9 @@ abstract class PMA_GIS_Geometry * @return object the modified image object * @access public */ - public abstract function prepareRowAsPng($spatial, $label, $color, $scale_data, $image); + public abstract function prepareRowAsPng($spatial, $label, $color, + $scale_data, $image + ); /** * Adds to the TCPDF instance, the data related to a row in the GIS dataset. @@ -56,7 +58,9 @@ abstract class PMA_GIS_Geometry * @return object the modified TCPDF instance * @access public */ - public abstract function prepareRowAsPdf($spatial, $label, $color, $scale_data, $pdf); + public abstract function prepareRowAsPdf($spatial, $label, $color, + $scale_data, $pdf + ); /** * Prepares the JavaScript related to a row in the GIS dataset @@ -71,7 +75,9 @@ abstract class PMA_GIS_Geometry * @return string the JavaScript related to a row in the GIS dataset * @access public */ - public abstract function prepareRowAsOl($spatial, $srid, $label, $color, $scale_data); + public abstract function prepareRowAsOl($spatial, $srid, $label, + $color, $scale_data + ); /** * Scales each row. @@ -166,7 +172,8 @@ abstract class PMA_GIS_Geometry */ protected function generateParams($value) { - $geom_types = '(POINT|MULTIPOINT|LINESTRING|MULTILINESTRING|POLYGON|MULTIPOLYGON|GEOMETRYCOLLECTION)'; + $geom_types = '(POINT|MULTIPOINT|LINESTRING|MULTILINESTRING' + . '|POLYGON|MULTIPOLYGON|GEOMETRYCOLLECTION)'; $srid = 0; $wkt = ''; if (preg_match("/^'" . $geom_types . "\(.*\)',[0-9]*$/i", $value)) { @@ -205,7 +212,8 @@ abstract class PMA_GIS_Geometry ) { if ($scale_data != null) { $x = ($cordinates[0] - $scale_data['x']) * $scale_data['scale']; - $y = $scale_data['height'] - ($cordinates[1] - $scale_data['y']) * $scale_data['scale']; + $y = $scale_data['height'] + - ($cordinates[1] - $scale_data['y']) * $scale_data['scale']; } else { $x = trim($cordinates[0]); $y = trim($cordinates[1]); @@ -277,12 +285,16 @@ abstract class PMA_GIS_Geometry * or LineRing to OpenLayers * @access protected */ - protected function getLineArrayForOpenLayers($lines, $srid, $is_line_string = true) - { + protected function getLineArrayForOpenLayers($lines, $srid, + $is_line_string = true + ) { $ol_array = 'new Array('; foreach ($lines as $line) { $points_arr = $this->extractPoints($line, null); - $ol_array .= $this->getLineForOpenLayers($points_arr, $srid, $is_line_string) . ', '; + $ol_array .= $this->getLineForOpenLayers( + $points_arr, $srid, $is_line_string + ); + $ol_array .= ', '; } $ol_array = substr($ol_array, 0, strlen($ol_array) - 2); $ol_array .= ')'; @@ -300,8 +312,9 @@ abstract class PMA_GIS_Geometry * @return string JavaScript for adding a LineString or LineRing to OpenLayers * @access protected */ - protected function getLineForOpenLayers($points_arr, $srid, $is_line_string = true) - { + protected function getLineForOpenLayers($points_arr, $srid, + $is_line_string = true + ) { return 'new OpenLayers.Geometry.' . ($is_line_string ? 'LineString' : 'LinearRing') . '(' . $this->getPointsArrayForOpenLayers($points_arr, $srid) @@ -340,8 +353,9 @@ abstract class PMA_GIS_Geometry */ protected function getPointForOpenLayers($point, $srid) { - return '(new OpenLayers.Geometry.Point(' . $point[0] . ', ' . $point[1] . '))' - . '.transform(new OpenLayers.Projection("EPSG:' . $srid . '"), map.getProjectionObject())'; + return '(new OpenLayers.Geometry.Point(' . $point[0] . ',' . $point[1] . '))' + . '.transform(new OpenLayers.Projection("EPSG:' + . $srid . '"), map.getProjectionObject())'; } } ?> diff --git a/libraries/gis/pma_gis_geometrycollection.php b/libraries/gis/pma_gis_geometrycollection.php index 7f4be7e020..01e0a54645 100644 --- a/libraries/gis/pma_gis_geometrycollection.php +++ b/libraries/gis/pma_gis_geometrycollection.php @@ -124,7 +124,9 @@ class PMA_GIS_Geometrycollection extends PMA_GIS_Geometry if (! $gis_obj) { continue; } - $image = $gis_obj->prepareRowAsPng($sub_part, $label, $color, $scale_data, $image); + $image = $gis_obj->prepareRowAsPng( + $sub_part, $label, $color, $scale_data, $image + ); } return $image; } @@ -156,7 +158,9 @@ class PMA_GIS_Geometrycollection extends PMA_GIS_Geometry if (! $gis_obj) { continue; } - $pdf = $gis_obj->prepareRowAsPdf($sub_part, $label, $color, $scale_data, $pdf); + $pdf = $gis_obj->prepareRowAsPdf( + $sub_part, $label, $color, $scale_data, $pdf + ); } return $pdf; } @@ -189,7 +193,9 @@ class PMA_GIS_Geometrycollection extends PMA_GIS_Geometry if (! $gis_obj) { continue; } - $row .= $gis_obj->prepareRowAsSvg($sub_part, $label, $color, $scale_data); + $row .= $gis_obj->prepareRowAsSvg( + $sub_part, $label, $color, $scale_data + ); } return $row; } @@ -224,7 +230,9 @@ class PMA_GIS_Geometrycollection extends PMA_GIS_Geometry if (! $gis_obj) { continue; } - $row .= $gis_obj->prepareRowAsOl($sub_part, $srid, $label, $color, $scale_data); + $row .= $gis_obj->prepareRowAsOl( + $sub_part, $srid, $label, $color, $scale_data + ); } return $row; } diff --git a/libraries/gis/pma_gis_linestring.php b/libraries/gis/pma_gis_linestring.php index 4bdcc6ed14..9c4951224b 100644 --- a/libraries/gis/pma_gis_linestring.php +++ b/libraries/gis/pma_gis_linestring.php @@ -72,8 +72,9 @@ class PMA_GIS_Linestring extends PMA_GIS_Geometry * @return object the modified image object * @access public */ - public function prepareRowAsPng($spatial, $label, $line_color, $scale_data, $image) - { + public function prepareRowAsPng($spatial, $label, $line_color, + $scale_data, $image + ) { // allocate colors $black = imagecolorallocate($image, 0, 0, 0); $red = hexdec(substr($line_color, 1, 2)); @@ -90,13 +91,19 @@ class PMA_GIS_Linestring extends PMA_GIS_Geometry $temp_point = $point; } else { // draw line section - imageline($image, $temp_point[0], $temp_point[1], $point[0], $point[1], $color); + imageline( + $image, $temp_point[0], $temp_point[1], + $point[0], $point[1], $color + ); $temp_point = $point; } } // print label if applicable if (isset($label) && trim($label) != '') { - imagestring($image, 1, $points_arr[1][0], $points_arr[1][1], trim($label), $black); + imagestring( + $image, 1, $points_arr[1][0], + $points_arr[1][1], trim($label), $black + ); } return $image; } @@ -130,7 +137,10 @@ class PMA_GIS_Linestring extends PMA_GIS_Geometry $temp_point = $point; } else { // draw line section - $pdf->Line($temp_point[0], $temp_point[1], $point[0], $point[1], $line); + $pdf->Line( + $temp_point[0], $temp_point[1], + $point[0], $point[1], $line + ); $temp_point = $point; } } diff --git a/libraries/gis/pma_gis_multilinestring.php b/libraries/gis/pma_gis_multilinestring.php index d6963f5531..0f49a0c197 100644 --- a/libraries/gis/pma_gis_multilinestring.php +++ b/libraries/gis/pma_gis_multilinestring.php @@ -81,8 +81,9 @@ class PMA_GIS_Multilinestring extends PMA_GIS_Geometry * @return object the modified image object * @access public */ - public function prepareRowAsPng($spatial, $label, $line_color, $scale_data, $image) - { + public function prepareRowAsPng($spatial, $label, $line_color, + $scale_data, $image + ) { // allocate colors $black = imagecolorallocate($image, 0, 0, 0); $red = hexdec(substr($line_color, 1, 2)); @@ -103,14 +104,20 @@ class PMA_GIS_Multilinestring extends PMA_GIS_Geometry $temp_point = $point; } else { // draw line section - imageline($image, $temp_point[0], $temp_point[1], $point[0], $point[1], $color); + imageline( + $image, $temp_point[0], $temp_point[1], + $point[0], $point[1], $color + ); $temp_point = $point; } } unset($temp_point); // print label if applicable if (isset($label) && trim($label) != '' && $first_line) { - imagestring($image, 1, $points_arr[1][0], $points_arr[1][1], trim($label), $black); + imagestring( + $image, 1, $points_arr[1][0], + $points_arr[1][1], trim($label), $black + ); } $first_line = false; } @@ -150,7 +157,9 @@ class PMA_GIS_Multilinestring extends PMA_GIS_Geometry $temp_point = $point; } else { // draw line section - $pdf->Line($temp_point[0], $temp_point[1], $point[0], $point[1], $line); + $pdf->Line( + $temp_point[0], $temp_point[1], $point[0], $point[1], $line + ); $temp_point = $point; } } diff --git a/libraries/gis/pma_gis_multipoint.php b/libraries/gis/pma_gis_multipoint.php index 99cf492537..3625e77d33 100644 --- a/libraries/gis/pma_gis_multipoint.php +++ b/libraries/gis/pma_gis_multipoint.php @@ -72,8 +72,9 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry * @return object the modified image object * @access public */ - public function prepareRowAsPng($spatial, $label, $point_color, $scale_data, $image) - { + public function prepareRowAsPng($spatial, $label, $point_color, + $scale_data, $image + ) { // allocate colors $black = imagecolorallocate($image, 0, 0, 0); $red = hexdec(substr($point_color, 1, 2)); @@ -95,7 +96,9 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry if ((isset($label) && trim($label) != '') && ($points_arr[0][0] != '' && $points_arr[0][1] != '') ) { - imagestring($image, 1, $points_arr[0][0], $points_arr[0][1], trim($label), $black); + imagestring( + $image, 1, $points_arr[0][0], $points_arr[0][1], trim($label), $black + ); } return $image; } @@ -112,8 +115,9 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry * @return object the modified TCPDF instance * @access public */ - public function prepareRowAsPdf($spatial, $label, $point_color, $scale_data, $pdf) - { + public function prepareRowAsPdf($spatial, $label, $point_color, + $scale_data, $pdf + ) { // allocate colors $red = hexdec(substr($point_color, 1, 2)); $green = hexdec(substr($point_color, 3, 2)); @@ -169,7 +173,8 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry $row = ''; foreach ($points_arr as $point) { if ($point[0] != '' && $point[1] != '') { - $row .= ' $val) { $row .= ' ' . $option . '="' . trim($val) . '"'; @@ -194,8 +199,9 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry * @return string JavaScript related to a row in the GIS dataset * @access public */ - public function prepareRowAsOl($spatial, $srid, $label, $point_color, $scale_data) - { + public function prepareRowAsOl($spatial, $srid, $label, + $point_color, $scale_data + ) { $style_options = array( 'pointRadius' => 3, 'fillColor' => '#ffffff', @@ -264,7 +270,8 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry { $wkt = 'MULTIPOINT('; for ($i = 0; $i < $row_data['numpoints']; $i++) { - $wkt .= $row_data['points'][$i]['x'] . ' ' . $row_data['points'][$i]['y'] . ','; + $wkt .= $row_data['points'][$i]['x'] . ' ' + . $row_data['points'][$i]['y'] . ','; } $wkt = substr($wkt, 0, strlen($wkt) - 1); $wkt .= ')'; diff --git a/libraries/gis/pma_gis_multipolygon.php b/libraries/gis/pma_gis_multipolygon.php index a45f057da2..ffeb7621fb 100644 --- a/libraries/gis/pma_gis_multipolygon.php +++ b/libraries/gis/pma_gis_multipolygon.php @@ -89,8 +89,9 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry * @return object the modified image object * @access public */ - public function prepareRowAsPng($spatial, $label, $fill_color, $scale_data, $image) - { + public function prepareRowAsPng($spatial, $label, $fill_color, + $scale_data, $image + ) { // allocate colors $black = imagecolorallocate($image, 0, 0, 0); $red = hexdec(substr($fill_color, 1, 2)); @@ -118,7 +119,8 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry foreach ($inner as $inner_poly) { $points_arr = array_merge( - $points_arr, $this->extractPoints($inner_poly, $scale_data, true) + $points_arr, + $this->extractPoints($inner_poly, $scale_data, true) ); } } @@ -132,7 +134,9 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry } // print label if applicable if (isset($label_point)) { - imagestring($image, 1, $points_arr[2], $points_arr[3], trim($label), $black); + imagestring( + $image, 1, $points_arr[2], $points_arr[3], trim($label), $black + ); } return $image; } @@ -388,7 +392,8 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry // correctly classify inner rings to their respective outer rings. include_once './libraries/gis/pma_gis_polygon.php'; foreach ($row_data['parts'] as $i => $ring) { - $row_data['parts'][$i]['isOuter'] = PMA_GIS_Polygon::isOuterRing($ring['points']); + $row_data['parts'][$i]['isOuter'] + = PMA_GIS_Polygon::isOuterRing($ring['points']); } // Find points on surface for inner rings diff --git a/libraries/gis/pma_gis_point.php b/libraries/gis/pma_gis_point.php index 1bb35ec3e7..e1e4d23708 100644 --- a/libraries/gis/pma_gis_point.php +++ b/libraries/gis/pma_gis_point.php @@ -72,8 +72,9 @@ class PMA_GIS_Point extends PMA_GIS_Geometry * @return object the modified image object * @access public */ - public function prepareRowAsPng($spatial, $label, $point_color, $scale_data, $image) - { + public function prepareRowAsPng($spatial, $label, $point_color, + $scale_data, $image + ) { // allocate colors $black = imagecolorallocate($image, 0, 0, 0); $red = hexdec(substr($point_color, 1, 2)); @@ -87,10 +88,15 @@ class PMA_GIS_Point extends PMA_GIS_Geometry // draw a small circle to mark the point if ($points_arr[0][0] != '' && $points_arr[0][1] != '') { - imagearc($image, $points_arr[0][0], $points_arr[0][1], 7, 7, 0, 360, $color); + imagearc( + $image, $points_arr[0][0], $points_arr[0][1], 7, 7, 0, 360, $color + ); // print label if applicable if (isset($label) && trim($label) != '') { - imagestring($image, 1, $points_arr[0][0], $points_arr[0][1], trim($label), $black); + imagestring( + $image, 1, $points_arr[0][0], + $points_arr[0][1], trim($label), $black + ); } } return $image; @@ -108,8 +114,9 @@ class PMA_GIS_Point extends PMA_GIS_Geometry * @return object the modified TCPDF instance * @access public */ - public function prepareRowAsPdf($spatial, $label, $point_color, $scale_data, $pdf) - { + public function prepareRowAsPdf($spatial, $label, $point_color, + $scale_data, $pdf + ) { // allocate colors $red = hexdec(substr($point_color, 1, 2)); $green = hexdec(substr($point_color, 3, 2)); @@ -122,7 +129,9 @@ class PMA_GIS_Point extends PMA_GIS_Geometry // draw a small circle to mark the point if ($points_arr[0][0] != '' && $points_arr[0][1] != '') { - $pdf->Circle($points_arr[0][0], $points_arr[0][1], 2, 0, 360, 'D', $line); + $pdf->Circle( + $points_arr[0][0], $points_arr[0][1], 2, 0, 360, 'D', $line + ); // print label if applicable if (isset($label) && trim($label) != '') { $pdf->SetXY($points_arr[0][0], $points_arr[0][1]); @@ -161,7 +170,8 @@ class PMA_GIS_Point extends PMA_GIS_Geometry $row = ''; if ($points_arr[0][0] != '' && $points_arr[0][1] != '') { - $row .= ' $val) { $row .= ' ' . $option . '="' . trim($val) . '"'; } @@ -184,8 +194,9 @@ class PMA_GIS_Point extends PMA_GIS_Geometry * @return string JavaScript related to a row in the GIS dataset * @access public */ - public function prepareRowAsOl($spatial, $srid, $label, $point_color, $scale_data) - { + public function prepareRowAsOl($spatial, $srid, $label, + $point_color, $scale_data + ) { $style_options = array( 'pointRadius' => 3, 'fillColor' => '#ffffff', @@ -225,9 +236,12 @@ class PMA_GIS_Point extends PMA_GIS_Geometry public function generateWkt($gis_data, $index, $empty = '') { return 'POINT(' - . ((isset($gis_data[$index]['POINT']['x']) && trim($gis_data[$index]['POINT']['x']) != '') - ? $gis_data[$index]['POINT']['x'] : '') . ' ' - . ((isset($gis_data[$index]['POINT']['y']) && trim($gis_data[$index]['POINT']['y']) != '') + . ((isset($gis_data[$index]['POINT']['x']) + && trim($gis_data[$index]['POINT']['x']) != '') + ? $gis_data[$index]['POINT']['x'] : '') + . ' ' + . ((isset($gis_data[$index]['POINT']['y']) + && trim($gis_data[$index]['POINT']['y']) != '') ? $gis_data[$index]['POINT']['y'] : '') . ')'; } diff --git a/libraries/gis/pma_gis_polygon.php b/libraries/gis/pma_gis_polygon.php index 9df77fef9a..9623edc402 100644 --- a/libraries/gis/pma_gis_polygon.php +++ b/libraries/gis/pma_gis_polygon.php @@ -81,8 +81,9 @@ class PMA_GIS_Polygon extends PMA_GIS_Geometry * @return object the modified image object * @access public */ - public function prepareRowAsPng($spatial, $label, $fill_color, $scale_data, $image) - { + public function prepareRowAsPng($spatial, $label, $fill_color, + $scale_data, $image + ) { // allocate colors $black = imagecolorallocate($image, 0, 0, 0); $red = hexdec(substr($fill_color, 1, 2)); @@ -115,7 +116,9 @@ class PMA_GIS_Polygon extends PMA_GIS_Geometry imagefilledpolygon($image, $points_arr, sizeof($points_arr) / 2, $color); // print label if applicable if (isset($label) && trim($label) != '') { - imagestring($image, 1, $points_arr[2], $points_arr[3], trim($label), $black); + imagestring( + $image, 1, $points_arr[2], $points_arr[3], trim($label), $black + ); } return $image; } diff --git a/libraries/gis/pma_gis_visualization.php b/libraries/gis/pma_gis_visualization.php index 916214f6c8..7efad9e6ee 100644 --- a/libraries/gis/pma_gis_visualization.php +++ b/libraries/gis/pma_gis_visualization.php @@ -106,7 +106,10 @@ class PMA_GIS_Visualization private function _handleOptions() { if (! is_null($this->_userSpecifiedSettings)) { - $this->_settings = array_merge($this->_settings, $this->_userSpecifiedSettings); + $this->_settings = array_merge( + $this->_settings, + $this->_userSpecifiedSettings + ); } } @@ -126,7 +129,9 @@ class PMA_GIS_Visualization // Check if the user already added extension; // get the substring where the extension would be if it was included $extension_start_pos = strlen($file_name) - strlen($ext) - 1; - $user_extension = substr($file_name, $extension_start_pos, strlen($file_name)); + $user_extension = substr( + $file_name, $extension_start_pos, strlen($file_name) + ); $required_extension = "." . $ext; if (strtolower($user_extension) != $required_extension) { $file_name .= $required_extension; @@ -165,7 +170,8 @@ class PMA_GIS_Visualization $output = '' . "\n"; $output .= ''; $output .= ''; @@ -216,7 +222,10 @@ class PMA_GIS_Visualization $this->init(); // create image - $image = imagecreatetruecolor($this->_settings['width'], $this->_settings['height']); + $image = imagecreatetruecolor( + $this->_settings['width'], + $this->_settings['height'] + ); // fill the background $bg = imagecolorallocate($image, 229, 229, 229); @@ -324,7 +333,9 @@ class PMA_GIS_Visualization include_once './libraries/tcpdf/tcpdf.php'; // create pdf - $pdf = new TCPDF('', 'pt', $GLOBALS['cfg']['PDFDefaultPageSize'], true, 'UTF-8', false); + $pdf = new TCPDF( + '', 'pt', $GLOBALS['cfg']['PDFDefaultPageSize'], true, 'UTF-8', false + ); // disable header and footer $pdf->setPrintHeader(false); @@ -373,7 +384,9 @@ class PMA_GIS_Visualization if (! $gis_obj) { continue; } - $scale_data = $gis_obj->scaleRow($row[$this->_settings['spatialColumn']]); + $scale_data = $gis_obj->scaleRow( + $row[$this->_settings['spatialColumn']] + ); // Upadate minimum/maximum values for x and y cordinates. $c_maxX = (float) $scale_data['maxX']; From 34cf0987a2345d4cc74a8eb26145c2fe2539f2cd Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Sun, 6 May 2012 14:57:37 +0530 Subject: [PATCH 4/4] Use the factory class --- libraries/gis/pma_gis_factory.php | 2 +- libraries/import/shp.php | 21 +++++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/libraries/gis/pma_gis_factory.php b/libraries/gis/pma_gis_factory.php index 579ddcdf8b..1184ae3460 100644 --- a/libraries/gis/pma_gis_factory.php +++ b/libraries/gis/pma_gis_factory.php @@ -35,7 +35,7 @@ class PMA_GIS_Factory return false; } if (include_once './libraries/gis/pma_gis_' . $type_lower . '.php') { - switch($type) { + switch(strtoupper($type)) { case 'MULTIPOLYGON' : return PMA_GIS_Multipolygon::singleton(); case 'POLYGON' : diff --git a/libraries/import/shp.php b/libraries/import/shp.php index d5bd00b184..252f114a95 100644 --- a/libraries/import/shp.php +++ b/libraries/import/shp.php @@ -384,31 +384,25 @@ if (isset($plugin_list)) { 31 => 'MultiPatch', ); - include_once './libraries/gis/pma_gis_geometry.php'; switch ($shp->shapeType) { // ESRI Null Shape case 0: - $gis_obj = null; break; // ESRI Point case 1: - include_once './libraries/gis/pma_gis_point.php'; - $gis_obj = PMA_GIS_Point::singleton(); + $gis_type = 'point'; break; // ESRI PolyLine case 3: - include_once './libraries/gis/pma_gis_multilinestring.php'; - $gis_obj = PMA_GIS_Multilinestring::singleton(); + $gis_type = 'multilinestring'; break; // ESRI Polygon case 5: - include_once './libraries/gis/pma_gis_multipolygon.php'; - $gis_obj = PMA_GIS_Multipolygon::singleton(); + $gis_type = 'multipolygon'; break; // ESRI MultiPoint case 8: - include_once './libraries/gis/pma_gis_multipoint.php'; - $gis_obj = PMA_GIS_Multipoint::singleton(); + $gis_type = 'multipoint'; break; default: $error = true; @@ -421,6 +415,13 @@ if (isset($plugin_list)) { return; } + if (isset($gis_type)) { + include_once './libraries/gis/pma_gis_factory.php'; + $gis_obj = PMA_GIS_Factory::factory($gis_type); + } else { + $gis_obj = null; + } + $num_rows = count($shp->records); // If .dbf file is loaded, the number of extra data columns $num_data_cols = isset($shp->DBFHeader) ? count($shp->DBFHeader) : 0;