[Phpmyadmin-git] [SCM] phpMyAdmin branch, master, updated. RELEASE_3_4_3_1-11416-gc7c532e

Madhura Jayaratne madhuracj at users.sourceforge.net
Thu Jul 21 17:08:22 CEST 2011


The branch, master has been updated
       via  c7c532e1f335079fe65cac3f30adae1b1ddb8e34 (commit)
       via  c01b63d01a20fab8fb96897304834ed0357ee580 (commit)
       via  1e8914fe508d06774f8bf4159587db35cb24b3ef (commit)
       via  338756306b9b795fb9e320aeca994f5993120f5d (commit)
       via  dc9312cae327017ef623619940c7eb99d10aeb81 (commit)
       via  ffa28f0f7cb5b901702e943b69e3dfcfbcd05a66 (commit)
       via  24b28f1017a555e06023eac4a9868d655de378e7 (commit)
      from  6cb1bdc030e1d50aa11fa50e83649ad77eb6fadf (commit)


- Log -----------------------------------------------------------------
commit c7c532e1f335079fe65cac3f30adae1b1ddb8e34
Merge: c01b63d01a20fab8fb96897304834ed0357ee580 6cb1bdc030e1d50aa11fa50e83649ad77eb6fadf
Author: Madhura Jayaratne <madhura.cj at gmail.com>
Date:   Thu Jul 21 20:37:38 2011 +0530

    Merge branch 'master' of ssh://phpmyadmin.git.sourceforge.net/gitroot/phpmyadmin/phpmyadmin

commit c01b63d01a20fab8fb96897304834ed0357ee580
Merge: 1e8914fe508d06774f8bf4159587db35cb24b3ef 147ba5e5cb1155ff71252cd4ad1ed4f97510567a
Author: Madhura Jayaratne <madhura.cj at gmail.com>
Date:   Thu Jul 21 20:31:48 2011 +0530

    Merge branch 'master' of ssh://phpmyadmin.git.sourceforge.net/gitroot/phpmyadmin/phpmyadmin

commit 1e8914fe508d06774f8bf4159587db35cb24b3ef
Author: Madhura Jayaratne <madhura.cj at gmail.com>
Date:   Thu Jul 21 20:19:24 2011 +0530

    Avoid code duplication

commit 338756306b9b795fb9e320aeca994f5993120f5d
Author: Madhura Jayaratne <madhura.cj at gmail.com>
Date:   Thu Jul 21 19:35:03 2011 +0530

    Better variable naming

commit dc9312cae327017ef623619940c7eb99d10aeb81
Author: Madhura Jayaratne <madhura.cj at gmail.com>
Date:   Thu Jul 21 18:35:53 2011 +0530

    Return assigned to wrong variable

commit ffa28f0f7cb5b901702e943b69e3dfcfbcd05a66
Author: Madhura Jayaratne <madhura.cj at gmail.com>
Date:   Thu Jul 21 18:33:45 2011 +0530

    Avoid variables with short names

commit 24b28f1017a555e06023eac4a9868d655de378e7
Author: Madhura Jayaratne <madhura.cj at gmail.com>
Date:   Thu Jul 21 18:29:51 2011 +0530

    Unused variable

-----------------------------------------------------------------------

Summary of changes:
 libraries/gis/pma_gis_geometry.php           |   49 ++++++++++++++++++++++---
 libraries/gis/pma_gis_geometrycollection.php |    6 ++--
 libraries/gis/pma_gis_linestring.php         |   20 +++++-----
 libraries/gis/pma_gis_multilinestring.php    |   20 +++++-----
 libraries/gis/pma_gis_multipoint.php         |   44 +++++++++++-----------
 libraries/gis/pma_gis_multipolygon.php       |   48 ++++++-------------------
 libraries/gis/pma_gis_point.php              |   44 +++++++++++-----------
 libraries/gis/pma_gis_polygon.php            |   51 +++++++-------------------
 8 files changed, 135 insertions(+), 147 deletions(-)

diff --git a/libraries/gis/pma_gis_geometry.php b/libraries/gis/pma_gis_geometry.php
index 9ff2c2c..8decdcc 100644
--- a/libraries/gis/pma_gis_geometry.php
+++ b/libraries/gis/pma_gis_geometry.php
@@ -36,13 +36,13 @@ abstract class PMA_GIS_Geometry
      *
      * @param string $spatial    GIS data object
      * @param string $label      Label for the GIS data object
-     * @param string $line_color Color for the GIS data object
+     * @param string $color      Color for the GIS data object
      * @param array  $scale_data Array containing data related to scaling
      * @param image  $pdf        TCPDF instance
      *
      * @return the modified TCPDF instance
      */
-    public abstract function prepareRowAsPdf($spatial, $label, $line_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 to visualize it with OpenLayers.
@@ -50,12 +50,12 @@ abstract class PMA_GIS_Geometry
      * @param string $spatial     GIS data object
      * @param int    $srid        Spatial reference ID
      * @param string $label       Label for the GIS data object
-     * @param string $point_color Color for the GIS data object
+     * @param string $color       Color for the GIS data object
      * @param array  $scale_data  Array containing data related to scaling
      *
      * @return the JavaScript related to a row in the GIS dataset
      */
-    public abstract function prepareRowAsOl($spatial, $srid, $label, $point_color, $scale_data);
+    public abstract function prepareRowAsOl($spatial, $srid, $label, $color, $scale_data);
 
     /**
      * Scales each row.
@@ -152,10 +152,49 @@ abstract class PMA_GIS_Geometry
                 $points_arr[] = $x;
                 $points_arr[] = $y;
             }
-            unset($cordinate_arr);
         }
 
         return $points_arr;
     }
+
+    /**
+     * Generates JavaScriipt for adding points for OpenLayers polygon.
+     *
+     * @param string $polygon points of a polygon in WKT form
+     * @param string $srid    spatial reference id
+     *
+     * @return JavaScriipt for adding points for OpenLayers polygon
+     */
+    protected function addPointsForOpenLayersPolygon($polygon, $srid)
+    {
+        $row = 'new OpenLayers.Geometry.Polygon(new Array(';
+        // If the polygon doesnt have an inner polygon
+        if (strpos($polygon, "),(") === false) {
+            $points_arr = $this->extractPoints($polygon, null);
+            $row .= 'new OpenLayers.Geometry.LinearRing(new Array(';
+            foreach ($points_arr as $point) {
+                $row .= '(new OpenLayers.Geometry.Point(' . $point[0] . ', ' . $point[1] . '))'
+                . '.transform(new OpenLayers.Projection("EPSG:' . $srid . '"), map.getProjectionObject()), ';
+            }
+            $row = substr($row, 0, strlen($row) - 2);
+            $row .= '))';
+        } else {
+            // Seperate outer and inner polygons
+            $parts = explode("),(", $polygon);
+            foreach ($parts as $ring) {
+                $points_arr = $this->extractPoints($ring, null);
+                $row .= 'new OpenLayers.Geometry.LinearRing(new Array(';
+                foreach ($points_arr as $point) {
+                    $row .= '(new OpenLayers.Geometry.Point(' . $point[0] . ', ' . $point[1] . '))'
+                    . '.transform(new OpenLayers.Projection("EPSG:' . $srid . '"), map.getProjectionObject()), ';
+                }
+                $row = substr($row, 0, strlen($row) - 2);
+                $row .= ')), ';
+            }
+            $row = substr($row, 0, strlen($row) - 2);
+        }
+        $row .= ')), ';
+        return $row;
+    }
 }
 ?>
diff --git a/libraries/gis/pma_gis_geometrycollection.php b/libraries/gis/pma_gis_geometrycollection.php
index 43a7cf4..ca48f08 100644
--- a/libraries/gis/pma_gis_geometrycollection.php
+++ b/libraries/gis/pma_gis_geometrycollection.php
@@ -24,8 +24,8 @@ class PMA_GIS_Geometrycollection extends PMA_GIS_Geometry
     public static function singleton()
     {
         if (!isset(self::$_instance)) {
-            $c = __CLASS__;
-            self::$_instance = new $c;
+            $class = __CLASS__;
+            self::$_instance = new $class;
         }
 
         return self::$_instance;
@@ -130,7 +130,7 @@ class PMA_GIS_Geometrycollection extends PMA_GIS_Geometry
             $type = substr($sub_part, 0, $type_pos);
 
             $gis_obj = PMA_GIS_Factory::factory($type);
-            $image = $gis_obj->prepareRowAsPdf($sub_part, $label, $color, $scale_data, $pdf);
+            $pdf = $gis_obj->prepareRowAsPdf($sub_part, $label, $color, $scale_data, $pdf);
         }
         return $pdf;
     }
diff --git a/libraries/gis/pma_gis_linestring.php b/libraries/gis/pma_gis_linestring.php
index 05483be..dad4f9b 100644
--- a/libraries/gis/pma_gis_linestring.php
+++ b/libraries/gis/pma_gis_linestring.php
@@ -24,8 +24,8 @@ class PMA_GIS_Linestring extends PMA_GIS_Geometry
     public static function singleton()
     {
         if (!isset(self::$_instance)) {
-            $c = __CLASS__;
-            self::$_instance = new $c;
+            $class = __CLASS__;
+            self::$_instance = new $class;
         }
 
         return self::$_instance;
@@ -59,10 +59,10 @@ class PMA_GIS_Linestring extends PMA_GIS_Geometry
     public function prepareRowAsPng($spatial, $label, $line_color, $scale_data, $image)
     {
         // allocate colors
-        $r = hexdec(substr($line_color, 1, 2));
-        $g = hexdec(substr($line_color, 3, 2));
-        $b = hexdec(substr($line_color, 4, 2));
-        $color = imagecolorallocate($image, $r, $g, $b);
+        $red   = hexdec(substr($line_color, 1, 2));
+        $green = hexdec(substr($line_color, 3, 2));
+        $blue  = hexdec(substr($line_color, 4, 2));
+        $color = imagecolorallocate($image, $red, $green, $blue);
 
         // Trim to remove leading 'LINESTRING(' and trailing ')'
         $linesrting = substr($spatial, 11, (strlen($spatial) - 12));
@@ -94,10 +94,10 @@ class PMA_GIS_Linestring extends PMA_GIS_Geometry
     public function prepareRowAsPdf($spatial, $label, $line_color, $scale_data, $pdf)
     {
         // allocate colors
-        $r = hexdec(substr($line_color, 1, 2));
-        $g = hexdec(substr($line_color, 3, 2));
-        $b = hexdec(substr($line_color, 4, 2));
-        $line = array('width' => 1.5, 'color' => array($r, $g, $b));
+        $red   = hexdec(substr($line_color, 1, 2));
+        $green = hexdec(substr($line_color, 3, 2));
+        $blue  = hexdec(substr($line_color, 4, 2));
+        $line  = array('width' => 1.5, 'color' => array($red, $green, $blue));
 
         // Trim to remove leading 'LINESTRING(' and trailing ')'
         $linesrting = substr($spatial, 11, (strlen($spatial) - 12));
diff --git a/libraries/gis/pma_gis_multilinestring.php b/libraries/gis/pma_gis_multilinestring.php
index 9291202..1289a93 100644
--- a/libraries/gis/pma_gis_multilinestring.php
+++ b/libraries/gis/pma_gis_multilinestring.php
@@ -24,8 +24,8 @@ class PMA_GIS_Multilinestring extends PMA_GIS_Geometry
     public static function singleton()
     {
         if (!isset(self::$_instance)) {
-            $c = __CLASS__;
-            self::$_instance = new $c;
+            $class = __CLASS__;
+            self::$_instance = new $class;
         }
 
         return self::$_instance;
@@ -68,10 +68,10 @@ class PMA_GIS_Multilinestring extends PMA_GIS_Geometry
     public function prepareRowAsPng($spatial, $label, $line_color, $scale_data, $image)
     {
         // allocate colors
-        $r = hexdec(substr($line_color, 1, 2));
-        $g = hexdec(substr($line_color, 3, 2));
-        $b = hexdec(substr($line_color, 4, 2));
-        $color = imagecolorallocate($image, $r, $g, $b);
+        $red   = hexdec(substr($line_color, 1, 2));
+        $green = hexdec(substr($line_color, 3, 2));
+        $blue  = hexdec(substr($line_color, 4, 2));
+        $color = imagecolorallocate($image, $red, $green, $blue);
 
         // Trim to remove leading 'MULTILINESTRING((' and trailing '))'
         $multilinestirng = substr($spatial, 17, (strlen($spatial) - 19));
@@ -108,10 +108,10 @@ class PMA_GIS_Multilinestring extends PMA_GIS_Geometry
     public function prepareRowAsPdf($spatial, $label, $line_color, $scale_data, $pdf)
     {
         // allocate colors
-        $r = hexdec(substr($line_color, 1, 2));
-        $g = hexdec(substr($line_color, 3, 2));
-        $b = hexdec(substr($line_color, 4, 2));
-        $line = array('width' => 1.5, 'color' => array($r, $g, $b));
+        $red   = hexdec(substr($line_color, 1, 2));
+        $green = hexdec(substr($line_color, 3, 2));
+        $blue  = hexdec(substr($line_color, 4, 2));
+        $line  = array('width' => 1.5, 'color' => array($red, $green, $blue));
 
         // Trim to remove leading 'MULTILINESTRING((' and trailing '))'
         $multilinestirng = substr($spatial, 17, (strlen($spatial) - 19));
diff --git a/libraries/gis/pma_gis_multipoint.php b/libraries/gis/pma_gis_multipoint.php
index 8b66022..48e9099 100644
--- a/libraries/gis/pma_gis_multipoint.php
+++ b/libraries/gis/pma_gis_multipoint.php
@@ -24,8 +24,8 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry
     public static function singleton()
     {
         if (!isset(self::$_instance)) {
-            $c = __CLASS__;
-            self::$_instance = new $c;
+            $class = __CLASS__;
+            self::$_instance = new $class;
         }
 
         return self::$_instance;
@@ -48,21 +48,21 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry
     /**
      * Adds to the PNG image object, the data related to a row in the GIS dataset.
      *
-     * @param string $spatial    GIS MULTIPOINT object
-     * @param string $label      Label for the GIS MULTIPOINT object
-     * @param string $line_color Color for the GIS MULTIPOINT object
-     * @param array  $scale_data Array containing data related to scaling
-     * @param image  $image      Image object
+     * @param string $spatial     GIS MULTIPOINT object
+     * @param string $label       Label for the GIS MULTIPOINT object
+     * @param string $point_color Color for the GIS MULTIPOINT object
+     * @param array  $scale_data  Array containing data related to scaling
+     * @param image  $image       Image object
      *
      * @return the modified image object
      */
-    public function prepareRowAsPng($spatial, $label, $line_color, $scale_data, $image)
+    public function prepareRowAsPng($spatial, $label, $point_color, $scale_data, $image)
     {
         // allocate colors
-        $r = hexdec(substr($line_color, 1, 2));
-        $g = hexdec(substr($line_color, 3, 2));
-        $b = hexdec(substr($line_color, 4, 2));
-        $color = imagecolorallocate($image, $r, $g, $b);
+        $red   = hexdec(substr($point_color, 1, 2));
+        $green = hexdec(substr($point_color, 3, 2));
+        $blue  = hexdec(substr($point_color, 4, 2));
+        $color = imagecolorallocate($image, $red, $green, $blue);
 
         // Trim to remove leading 'MULTIPOINT(' and trailing ')'
         $multipoint = substr($spatial, 11, (strlen($spatial) - 12));
@@ -78,21 +78,21 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry
     /**
      * Adds to the TCPDF instance, the data related to a row in the GIS dataset.
      *
-     * @param string $spatial    GIS MULTIPOINT object
-     * @param string $label      Label for the GIS MULTIPOINT object
-     * @param string $line_color Color for the GIS MULTIPOINT object
-     * @param array  $scale_data Array containing data related to scaling
-     * @param image  $pdf        TCPDF instance
+     * @param string $spatial     GIS MULTIPOINT object
+     * @param string $label       Label for the GIS MULTIPOINT object
+     * @param string $point_color Color for the GIS MULTIPOINT object
+     * @param array  $scale_data  Array containing data related to scaling
+     * @param image  $pdf         TCPDF instance
      *
      * @return the modified TCPDF instance
      */
-    public function prepareRowAsPdf($spatial, $label, $line_color, $scale_data, $pdf)
+    public function prepareRowAsPdf($spatial, $label, $point_color, $scale_data, $pdf)
     {
         // allocate colors
-        $r = hexdec(substr($line_color, 1, 2));
-        $g = hexdec(substr($line_color, 3, 2));
-        $b = hexdec(substr($line_color, 4, 2));
-        $line = array('width' => 1.25, 'color' => array($r, $g, $b));
+        $red   = hexdec(substr($point_color, 1, 2));
+        $green = hexdec(substr($point_color, 3, 2));
+        $blue  = hexdec(substr($point_color, 4, 2));
+        $line  = array('width' => 1.25, 'color' => array($red, $green, $blue));
 
         // Trim to remove leading 'MULTIPOINT(' and trailing ')'
         $multipoint = substr($spatial, 11, (strlen($spatial) - 12));
diff --git a/libraries/gis/pma_gis_multipolygon.php b/libraries/gis/pma_gis_multipolygon.php
index c0adcd1..db6f6cb 100644
--- a/libraries/gis/pma_gis_multipolygon.php
+++ b/libraries/gis/pma_gis_multipolygon.php
@@ -24,8 +24,8 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
     public static function singleton()
     {
         if (!isset(self::$_instance)) {
-            $c = __CLASS__;
-            self::$_instance = new $c;
+            $class = __CLASS__;
+            self::$_instance = new $class;
         }
 
         return self::$_instance;
@@ -82,10 +82,10 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
     public function prepareRowAsPng($spatial, $label, $fill_color, $scale_data, $image)
     {
         // allocate colors
-        $r = hexdec(substr($fill_color, 1, 2));
-        $g = hexdec(substr($fill_color, 3, 2));
-        $b = hexdec(substr($fill_color, 4, 2));
-        $color = imagecolorallocate($image, $r, $g, $b);
+        $red   = hexdec(substr($fill_color, 1, 2));
+        $green = hexdec(substr($fill_color, 3, 2));
+        $blue  = hexdec(substr($fill_color, 4, 2));
+        $color = imagecolorallocate($image, $red, $green, $blue);
 
         // Trim to remove leading 'MULTIPOLYGON(((' and trailing ')))'
         $multipolygon = substr($spatial, 15, (strlen($spatial) - 18));
@@ -130,10 +130,10 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
     public function prepareRowAsPdf($spatial, $label, $fill_color, $scale_data, $pdf)
     {
         // allocate colors
-        $r = hexdec(substr($fill_color, 1, 2));
-        $g = hexdec(substr($fill_color, 3, 2));
-        $b = hexdec(substr($fill_color, 4, 2));
-        $color = array($r, $g, $b);
+        $red   = hexdec(substr($fill_color, 1, 2));
+        $green = hexdec(substr($fill_color, 3, 2));
+        $blue  = hexdec(substr($fill_color, 4, 2));
+        $color = array($red, $green, $blue);
 
         // Trim to remove leading 'MULTIPOLYGON(((' and trailing ')))'
         $multipolygon = substr($spatial, 15, (strlen($spatial) - 18));
@@ -257,33 +257,7 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
             . 'new OpenLayers.Geometry.MultiPolygon(new Array(';
 
         foreach ($polygons as $polygon) {
-            $row .= 'new OpenLayers.Geometry.Polygon(new Array(';
-            // If the polygon doesnt have an inner polygon
-            if (strpos($polygon, "),(") === false) {
-                $points_arr = $this->extractPoints($polygon, null);
-                $row .= 'new OpenLayers.Geometry.LinearRing(new Array(';
-                foreach ($points_arr as $point) {
-                    $row .= '(new OpenLayers.Geometry.Point(' . $point[0] . ', ' . $point[1] . '))'
-                        . '.transform(new OpenLayers.Projection("EPSG:' . $srid . '"), map.getProjectionObject()), ';
-                }
-                $row = substr($row, 0, strlen($row) - 2);
-                $row .= '))';
-            } else {
-                // Seperate outer and inner polygons
-                $parts = explode("),(", $polygon);
-                foreach ($parts as $ring) {
-                    $points_arr = $this->extractPoints($ring, null);
-                    $row .= 'new OpenLayers.Geometry.LinearRing(new Array(';
-                    foreach ($points_arr as $point) {
-                        $row .= '(new OpenLayers.Geometry.Point(' . $point[0] . ', ' . $point[1] . '))'
-                            . '.transform(new OpenLayers.Projection("EPSG:' . $srid . '"), map.getProjectionObject()), ';
-                    }
-                    $row = substr($row, 0, strlen($row) - 2);
-                    $row .= ')), ';
-                }
-                $row = substr($row, 0, strlen($row) - 2);
-            }
-            $row .= ')), ';
+            $row .= $this->addPointsForOpenLayersPolygon($polygon, $srid);
         }
         $row = substr($row, 0, strlen($row) - 2);
         $row .= ')), null, ' . json_encode($style_options) . '));';
diff --git a/libraries/gis/pma_gis_point.php b/libraries/gis/pma_gis_point.php
index 365eae4..4318572 100644
--- a/libraries/gis/pma_gis_point.php
+++ b/libraries/gis/pma_gis_point.php
@@ -24,8 +24,8 @@ class PMA_GIS_Point extends PMA_GIS_Geometry
     public static function singleton()
     {
         if (!isset(self::$_instance)) {
-            $c = __CLASS__;
-            self::$_instance = new $c;
+            $class = __CLASS__;
+            self::$_instance = new $class;
         }
 
         return self::$_instance;
@@ -48,21 +48,21 @@ class PMA_GIS_Point extends PMA_GIS_Geometry
     /**
      * Adds to the PNG image object, the data related to a row in the GIS dataset.
      *
-     * @param string $spatial    GIS POINT object
-     * @param string $label      Label for the GIS POINT object
-     * @param string $line_color Color for the GIS POINT object
-     * @param array  $scale_data Array containing data related to scaling
-     * @param image  $image      Image object
+     * @param string $spatial     GIS POINT object
+     * @param string $label       Label for the GIS POINT object
+     * @param string $point_color Color for the GIS POINT object
+     * @param array  $scale_data  Array containing data related to scaling
+     * @param image  $image       Image object
      *
      * @return the modified image object
      */
-    public function prepareRowAsPng($spatial, $label, $line_color, $scale_data, $image)
+    public function prepareRowAsPng($spatial, $label, $point_color, $scale_data, $image)
     {
         // allocate colors
-        $r = hexdec(substr($line_color, 1, 2));
-        $g = hexdec(substr($line_color, 3, 2));
-        $b = hexdec(substr($line_color, 4, 2));
-        $color = imagecolorallocate($image, $r, $g, $b);
+        $red   = hexdec(substr($point_color, 1, 2));
+        $green = hexdec(substr($point_color, 3, 2));
+        $blue  = hexdec(substr($point_color, 4, 2));
+        $color = imagecolorallocate($image, $red, $green, $blue);
 
         // Trim to remove leading 'POINT(' and trailing ')'
         $point = substr($spatial, 6, (strlen($spatial) - 7));
@@ -76,21 +76,21 @@ class PMA_GIS_Point extends PMA_GIS_Geometry
     /**
      * Adds to the TCPDF instance, the data related to a row in the GIS dataset.
      *
-     * @param string $spatial    GIS POINT object
-     * @param string $label      Label for the GIS POINT object
-     * @param string $line_color Color for the GIS POINT object
-     * @param array  $scale_data Array containing data related to scaling
-     * @param image  $pdf        TCPDF instance
+     * @param string $spatial     GIS POINT object
+     * @param string $label       Label for the GIS POINT object
+     * @param string $point_color Color for the GIS POINT object
+     * @param array  $scale_data  Array containing data related to scaling
+     * @param image  $pdf         TCPDF instance
      *
      * @return the modified TCPDF instance
      */
-    public function prepareRowAsPdf($spatial, $label, $line_color, $scale_data, $pdf)
+    public function prepareRowAsPdf($spatial, $label, $point_color, $scale_data, $pdf)
     {
         // allocate colors
-        $r = hexdec(substr($line_color, 1, 2));
-        $g = hexdec(substr($line_color, 3, 2));
-        $b = hexdec(substr($line_color, 4, 2));
-        $line = array('width' => 1.25, 'color' => array($r, $g, $b));
+        $red   = hexdec(substr($point_color, 1, 2));
+        $green = hexdec(substr($point_color, 3, 2));
+        $blue  = hexdec(substr($point_color, 4, 2));
+        $line  = array('width' => 1.25, 'color' => array($red, $green, $blue));
 
         // Trim to remove leading 'POINT(' and trailing ')'
         $point = substr($spatial, 6, (strlen($spatial) - 7));
diff --git a/libraries/gis/pma_gis_polygon.php b/libraries/gis/pma_gis_polygon.php
index 5da0d25..ce8ffa8 100644
--- a/libraries/gis/pma_gis_polygon.php
+++ b/libraries/gis/pma_gis_polygon.php
@@ -24,8 +24,8 @@ class PMA_GIS_Polygon extends PMA_GIS_Geometry
     public static function singleton()
     {
         if (!isset(self::$_instance)) {
-            $c = __CLASS__;
-            self::$_instance = new $c;
+            $class = __CLASS__;
+            self::$_instance = new $class;
         }
 
         return self::$_instance;
@@ -77,10 +77,10 @@ class PMA_GIS_Polygon extends PMA_GIS_Geometry
     public function prepareRowAsPng($spatial, $label, $fill_color, $scale_data, $image)
     {
         // allocate colors
-        $r = hexdec(substr($fill_color, 1, 2));
-        $g = hexdec(substr($fill_color, 3, 2));
-        $b = hexdec(substr($fill_color, 4, 2));
-        $color = imagecolorallocate($image, $r, $g, $b);
+        $red   = hexdec(substr($fill_color, 1, 2));
+        $green = hexdec(substr($fill_color, 3, 2));
+        $blue  = hexdec(substr($fill_color, 4, 2));
+        $color = imagecolorallocate($image, $red, $green, $blue);
 
         // Trim to remove leading 'POLYGON((' and trailing '))'
         $polygon = substr($spatial, 9, (strlen($spatial) - 11));
@@ -122,10 +122,10 @@ class PMA_GIS_Polygon extends PMA_GIS_Geometry
     public function prepareRowAsPdf($spatial, $label, $fill_color, $scale_data, $pdf)
     {
         // allocate colors
-        $r = hexdec(substr($fill_color, 1, 2));
-        $g = hexdec(substr($fill_color, 3, 2));
-        $b = hexdec(substr($fill_color, 4, 2));
-        $color = array($r, $g, $b);
+        $red   = hexdec(substr($fill_color, 1, 2));
+        $green = hexdec(substr($fill_color, 3, 2));
+        $blue  = hexdec(substr($fill_color, 4, 2));
+        $color = array($red, $green, $blue);
 
         // Trim to remove leading 'POLYGON((' and trailing '))'
         $polygon = substr($spatial, 9, (strlen($spatial) - 11));
@@ -234,34 +234,9 @@ class PMA_GIS_Polygon extends PMA_GIS_Geometry
         // Trim to remove leading 'POLYGON((' and trailing '))'
         $polygon = substr($spatial, 9, (strlen($spatial) - 11));
 
-        $row .= 'vectorLayer.addFeatures(new OpenLayers.Feature.Vector('
-            . 'new OpenLayers.Geometry.Polygon(new Array(';
-        // If the polygon doesnt have an inner polygon
-        if (strpos($polygon, "),(") === false) {
-            $points_arr = $this->extractPoints($polygon, null);
-            $row .= 'new OpenLayers.Geometry.LinearRing(new Array(';
-            foreach ($points_arr as $point) {
-                $row .= '(new OpenLayers.Geometry.Point(' . $point[0] . ', ' . $point[1] . '))'
-                    . '.transform(new OpenLayers.Projection("EPSG:' . $srid . '"), map.getProjectionObject()), ';
-            }
-            $row = substr($row, 0, strlen($row) - 2);
-            $row .= '))';
-        } else {
-            // Seperate outer and inner polygons
-            $parts = explode("),(", $polygon);
-            foreach ($parts as $ring) {
-                $points_arr = $this->extractPoints($ring, null);
-                $row .= 'new OpenLayers.Geometry.LinearRing(new Array(';
-                foreach ($points_arr as $point) {
-                    $row .= '(new OpenLayers.Geometry.Point(' . $point[0] . ', ' . $point[1] . '))'
-                        . '.transform(new OpenLayers.Projection("EPSG:' . $srid . '"), map.getProjectionObject()), ';
-                }
-                $row = substr($row, 0, strlen($row) - 2);
-                $row .= ')), ';
-            }
-            $row = substr($row, 0, strlen($row) - 2);
-        }
-        $row .= ')), null, ' . json_encode($style_options) . '));';
+        $row .= 'vectorLayer.addFeatures(new OpenLayers.Feature.Vector(';
+        $row .= $this->addPointsForOpenLayersPolygon($polygon, $srid);
+        $row .= 'null, ' . json_encode($style_options) . '));';
         return $row;
     }
 


hooks/post-receive
-- 
phpMyAdmin




More information about the Git mailing list