diff --git a/libraries/gis/pma_gis_factory.php b/libraries/gis/pma_gis_factory.php index 39a6ab040b..1184ae3460 100644 --- a/libraries/gis/pma_gis_factory.php +++ b/libraries/gis/pma_gis_factory.php @@ -1,5 +1,11 @@ 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 .= ')'; @@ -294,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) @@ -334,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 ac3964961d..01e0a54645 100644 --- a/libraries/gis/pma_gis_geometrycollection.php +++ b/libraries/gis/pma_gis_geometrycollection.php @@ -1,11 +1,17 @@ prepareRowAsPng($sub_part, $label, $color, $scale_data, $image); + $image = $gis_obj->prepareRowAsPng( + $sub_part, $label, $color, $scale_data, $image + ); } return $image; } @@ -150,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; } @@ -183,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; } @@ -218,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 0a5c146aac..9c4951224b 100644 --- a/libraries/gis/pma_gis_linestring.php +++ b/libraries/gis/pma_gis_linestring.php @@ -1,11 +1,17 @@ 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 9a8febae6e..0f49a0c197 100644 --- a/libraries/gis/pma_gis_multilinestring.php +++ b/libraries/gis/pma_gis_multilinestring.php @@ -1,11 +1,17 @@ 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 1d3089a5b6..3625e77d33 100644 --- a/libraries/gis/pma_gis_multipoint.php +++ b/libraries/gis/pma_gis_multipoint.php @@ -1,11 +1,17 @@ $val) { $row .= ' ' . $option . '="' . trim($val) . '"'; @@ -188,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', @@ -258,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 7a64cb0aed..ffeb7621fb 100644 --- a/libraries/gis/pma_gis_multipolygon.php +++ b/libraries/gis/pma_gis_multipolygon.php @@ -1,11 +1,17 @@ extractPoints($inner_poly, $scale_data, true) + $points_arr, + $this->extractPoints($inner_poly, $scale_data, true) ); } } @@ -126,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; } @@ -382,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 c872445aec..e1e4d23708 100644 --- a/libraries/gis/pma_gis_point.php +++ b/libraries/gis/pma_gis_point.php @@ -1,11 +1,17 @@ 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]); @@ -155,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) . '"'; } @@ -178,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', @@ -219,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 f85ea3e423..9623edc402 100644 --- a/libraries/gis/pma_gis_polygon.php +++ b/libraries/gis/pma_gis_polygon.php @@ -1,11 +1,17 @@ _userSpecifiedSettings)) { - $this->_settings = array_merge($this->_settings, $this->_userSpecifiedSettings); + $this->_settings = array_merge( + $this->_settings, + $this->_userSpecifiedSettings + ); } } @@ -120,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; @@ -159,7 +170,8 @@ class PMA_GIS_Visualization $output = '' . "\n"; $output .= ''; $output .= ''; @@ -210,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); @@ -318,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); @@ -367,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']; diff --git a/libraries/import/shp.php b/libraries/import/shp.php index 3b8703712f..252f114a95 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() { @@ -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;