Completed
Push — master ( 73f088...7f17b6 )
by Yannick
07:13
created
require/libs/geoPHP/tests/tests/placeholdersTest.php 2 patches
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -9,65 +9,65 @@
 block discarded – undo
9 9
   }
10 10
 
11 11
   function testPlaceholders() {
12
-    foreach (scandir('./input') as $file) {
13
-      $parts = explode('.',$file);
14
-      if ($parts[0]) {
15
-        $format = $parts[1];
16
-        $value = file_get_contents('./input/'.$file);
17
-        $geometry = geoPHP::load($value, $format);
12
+	foreach (scandir('./input') as $file) {
13
+	  $parts = explode('.',$file);
14
+	  if ($parts[0]) {
15
+		$format = $parts[1];
16
+		$value = file_get_contents('./input/'.$file);
17
+		$geometry = geoPHP::load($value, $format);
18 18
 
19
-        $placeholders = array(
20
-          array('name' => 'hasZ'),
21
-          array('name' => 'is3D'),
22
-          array('name' => 'isMeasured'),
23
-          array('name' => 'isEmpty'),
24
-          array('name' => 'coordinateDimension'),
25
-          array('name' => 'z'),
26
-          array('name' => 'm'),
27
-        );
19
+		$placeholders = array(
20
+		  array('name' => 'hasZ'),
21
+		  array('name' => 'is3D'),
22
+		  array('name' => 'isMeasured'),
23
+		  array('name' => 'isEmpty'),
24
+		  array('name' => 'coordinateDimension'),
25
+		  array('name' => 'z'),
26
+		  array('name' => 'm'),
27
+		);
28 28
 
29
-        foreach($placeholders as $method) {
30
-          $argument = NULL;
31
-          $method_name = $method['name'];
32
-          if (isset($method['argument'])) {
33
-            $argument = $method['argument'];
34
-          }
29
+		foreach($placeholders as $method) {
30
+		  $argument = NULL;
31
+		  $method_name = $method['name'];
32
+		  if (isset($method['argument'])) {
33
+			$argument = $method['argument'];
34
+		  }
35 35
 
36
-          switch ($method_name) {
37
-            case 'm':
38
-            case 'z':
39
-              if ($geometry->geometryType() == 'Point') {
40
-                $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
41
-              }
42
-              if ($geometry->geometryType() == 'LineString') {
43
-                $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
44
-              }
45
-              if ($geometry->geometryType() == 'MultiLineString') {
46
-                $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
47
-              }
48
-              break;
49
-            case 'coordinateDimension':
50
-            case 'isEmpty':
51
-            case 'isMeasured':
52
-            case 'is3D':
53
-            case 'hasZ':
54
-              if ($geometry->geometryType() == 'Point') {
55
-                $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
56
-              }
57
-              if ($geometry->geometryType() == 'LineString') {
58
-                $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
59
-              }
60
-              if ($geometry->geometryType() == 'MultiLineString') {
61
-                $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
62
-              }
63
-              break;
64
-            default:
65
-              $this->assertTrue($geometry->$method_name($argument), 'Failed on ' . $method_name);
66
-          }
67
-        }
36
+		  switch ($method_name) {
37
+			case 'm':
38
+			case 'z':
39
+			  if ($geometry->geometryType() == 'Point') {
40
+				$this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
41
+			  }
42
+			  if ($geometry->geometryType() == 'LineString') {
43
+				$this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
44
+			  }
45
+			  if ($geometry->geometryType() == 'MultiLineString') {
46
+				$this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
47
+			  }
48
+			  break;
49
+			case 'coordinateDimension':
50
+			case 'isEmpty':
51
+			case 'isMeasured':
52
+			case 'is3D':
53
+			case 'hasZ':
54
+			  if ($geometry->geometryType() == 'Point') {
55
+				$this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
56
+			  }
57
+			  if ($geometry->geometryType() == 'LineString') {
58
+				$this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
59
+			  }
60
+			  if ($geometry->geometryType() == 'MultiLineString') {
61
+				$this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
62
+			  }
63
+			  break;
64
+			default:
65
+			  $this->assertTrue($geometry->$method_name($argument), 'Failed on ' . $method_name);
66
+		  }
67
+		}
68 68
 
69
-      }
70
-    }
69
+	  }
70
+	}
71 71
 
72 72
   }
73 73
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 
11 11
   function testPlaceholders() {
12 12
     foreach (scandir('./input') as $file) {
13
-      $parts = explode('.',$file);
13
+      $parts = explode('.', $file);
14 14
       if ($parts[0]) {
15 15
         $format = $parts[1];
16 16
         $value = file_get_contents('./input/'.$file);
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
           array('name' => 'm'),
27 27
         );
28 28
 
29
-        foreach($placeholders as $method) {
29
+        foreach ($placeholders as $method) {
30 30
           $argument = NULL;
31 31
           $method_name = $method['name'];
32 32
           if (isset($method['argument'])) {
@@ -37,13 +37,13 @@  discard block
 block discarded – undo
37 37
             case 'm':
38 38
             case 'z':
39 39
               if ($geometry->geometryType() == 'Point') {
40
-                $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
40
+                $this->assertNotNull($geometry->$method_name($argument), 'Failed on '.$method_name);
41 41
               }
42 42
               if ($geometry->geometryType() == 'LineString') {
43
-                $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
43
+                $this->assertNotNull($geometry->$method_name($argument), 'Failed on '.$method_name);
44 44
               }
45 45
               if ($geometry->geometryType() == 'MultiLineString') {
46
-                $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
46
+                $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
47 47
               }
48 48
               break;
49 49
             case 'coordinateDimension':
@@ -52,17 +52,17 @@  discard block
 block discarded – undo
52 52
             case 'is3D':
53 53
             case 'hasZ':
54 54
               if ($geometry->geometryType() == 'Point') {
55
-                $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
55
+                $this->assertNotNull($geometry->$method_name($argument), 'Failed on '.$method_name);
56 56
               }
57 57
               if ($geometry->geometryType() == 'LineString') {
58
-                $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
58
+                $this->assertNotNull($geometry->$method_name($argument), 'Failed on '.$method_name);
59 59
               }
60 60
               if ($geometry->geometryType() == 'MultiLineString') {
61
-                $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
61
+                $this->assertNotNull($geometry->$method_name($argument), 'Failed on '.$method_name);
62 62
               }
63 63
               break;
64 64
             default:
65
-              $this->assertTrue($geometry->$method_name($argument), 'Failed on ' . $method_name);
65
+              $this->assertTrue($geometry->$method_name($argument), 'Failed on '.$method_name);
66 66
           }
67 67
         }
68 68
 
Please login to merge, or discard this patch.
require/libs/geoPHP/lib/adapters/EWKT.class.php 3 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -13,15 +13,15 @@
 block discarded – undo
13 13
    * @return string The Extended-WKT string representation of the input geometries
14 14
    */
15 15
   public function write(Geometry $geometry) {
16
-    $srid = $geometry->SRID();
17
-    $wkt = '';
18
-    if ($srid) {
19
-      $wkt = 'SRID=' . $srid . ';';
20
-      $wkt .= $geometry->out('wkt');
21
-      return $wkt;
22
-    }
23
-    else {
24
-      return $geometry->out('wkt');
25
-    }
16
+	$srid = $geometry->SRID();
17
+	$wkt = '';
18
+	if ($srid) {
19
+	  $wkt = 'SRID=' . $srid . ';';
20
+	  $wkt .= $geometry->out('wkt');
21
+	  return $wkt;
22
+	}
23
+	else {
24
+	  return $geometry->out('wkt');
25
+	}
26 26
   }
27 27
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@
 block discarded – undo
16 16
     $srid = $geometry->SRID();
17 17
     $wkt = '';
18 18
     if ($srid) {
19
-      $wkt = 'SRID=' . $srid . ';';
19
+      $wkt = 'SRID='.$srid.';';
20 20
       $wkt .= $geometry->out('wkt');
21 21
       return $wkt;
22 22
     }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,8 +19,7 @@
 block discarded – undo
19 19
       $wkt = 'SRID=' . $srid . ';';
20 20
       $wkt .= $geometry->out('wkt');
21 21
       return $wkt;
22
-    }
23
-    else {
22
+    } else {
24 23
       return $geometry->out('wkt');
25 24
     }
26 25
   }
Please login to merge, or discard this patch.
require/libs/geoPHP/lib/adapters/GoogleGeocode.class.php 3 patches
Indentation   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -30,55 +30,55 @@  discard block
 block discarded – undo
30 30
    * @return Geometry|GeometryCollection
31 31
    */
32 32
   public function read($address, $return_type = 'point', $bounds = FALSE, $return_multiple = FALSE) {
33
-    if (is_array($address)) $address = join(',', $address);
33
+	if (is_array($address)) $address = join(',', $address);
34 34
     
35
-    if (gettype($bounds) == 'object') {
36
-      $bounds = $bounds->getBBox();
37
-    }
38
-    if (gettype($bounds) == 'array') {
39
-      $bounds_string = '&bounds='.$bounds['miny'].','.$bounds['minx'].'|'.$bounds['maxy'].','.$bounds['maxx'];
40
-    }
41
-    else {
42
-      $bounds_string = '';
43
-    }
35
+	if (gettype($bounds) == 'object') {
36
+	  $bounds = $bounds->getBBox();
37
+	}
38
+	if (gettype($bounds) == 'array') {
39
+	  $bounds_string = '&bounds='.$bounds['miny'].','.$bounds['minx'].'|'.$bounds['maxy'].','.$bounds['maxx'];
40
+	}
41
+	else {
42
+	  $bounds_string = '';
43
+	}
44 44
     
45
-    $url = "http://maps.googleapis.com/maps/api/geocode/json";
46
-    $url .= '?address='. urlencode($address);
47
-    $url .= $bounds_string;
48
-    $url .= '&sensor=false';
49
-    $this->result = json_decode(@file_get_contents($url));
45
+	$url = "http://maps.googleapis.com/maps/api/geocode/json";
46
+	$url .= '?address='. urlencode($address);
47
+	$url .= $bounds_string;
48
+	$url .= '&sensor=false';
49
+	$this->result = json_decode(@file_get_contents($url));
50 50
     
51
-    if ($this->result->status == 'OK') {
52
-      if ($return_multiple == FALSE) {
53
-        if ($return_type == 'point') {
54
-          return $this->getPoint();
55
-        }
56
-        if ($return_type == 'bounds' || $return_type == 'polygon') {
57
-          return $this->getPolygon();
58
-        }
59
-      }
60
-      if ($return_multiple == TRUE) {
61
-        if ($return_type == 'point') {
62
-          $points = array();
63
-          foreach ($this->result->results as $delta => $item) {
64
-            $points[] = $this->getPoint($delta);
65
-          }
66
-          return new MultiPoint($points);
67
-        }
68
-        if ($return_type == 'bounds' || $return_type == 'polygon') {
69
-          $polygons = array();
70
-          foreach ($this->result->results as $delta => $item) {
71
-            $polygons[] = $this->getPolygon($delta);
72
-          }
73
-          return new MultiPolygon($polygons);
74
-        }
75
-      }
76
-    }
77
-    else {
78
-      if ($this->result->status) throw new Exception('Error in Google Geocoder: '.$this->result->status);
79
-      else throw new Exception('Unknown error in Google Geocoder');
80
-      return FALSE;
81
-    }
51
+	if ($this->result->status == 'OK') {
52
+	  if ($return_multiple == FALSE) {
53
+		if ($return_type == 'point') {
54
+		  return $this->getPoint();
55
+		}
56
+		if ($return_type == 'bounds' || $return_type == 'polygon') {
57
+		  return $this->getPolygon();
58
+		}
59
+	  }
60
+	  if ($return_multiple == TRUE) {
61
+		if ($return_type == 'point') {
62
+		  $points = array();
63
+		  foreach ($this->result->results as $delta => $item) {
64
+			$points[] = $this->getPoint($delta);
65
+		  }
66
+		  return new MultiPoint($points);
67
+		}
68
+		if ($return_type == 'bounds' || $return_type == 'polygon') {
69
+		  $polygons = array();
70
+		  foreach ($this->result->results as $delta => $item) {
71
+			$polygons[] = $this->getPolygon($delta);
72
+		  }
73
+		  return new MultiPolygon($polygons);
74
+		}
75
+	  }
76
+	}
77
+	else {
78
+	  if ($this->result->status) throw new Exception('Error in Google Geocoder: '.$this->result->status);
79
+	  else throw new Exception('Unknown error in Google Geocoder');
80
+	  return FALSE;
81
+	}
82 82
   }
83 83
 
84 84
   /**
@@ -90,69 +90,69 @@  discard block
 block discarded – undo
90 90
    * @return string Does a reverse geocode of the geometry
91 91
    */
92 92
   public function write(Geometry $geometry, $return_type = 'string') {
93
-    $centroid = $geometry->getCentroid();
94
-    $lat = $centroid->getY();
95
-    $lon = $centroid->getX();
93
+	$centroid = $geometry->getCentroid();
94
+	$lat = $centroid->getY();
95
+	$lon = $centroid->getX();
96 96
     
97
-    $url = "http://maps.googleapis.com/maps/api/geocode/json";
98
-    $url .= '?latlng='.$lat.','.$lon;
99
-    $url .= '&sensor=false';
100
-    $this->result = json_decode(@file_get_contents($url));
97
+	$url = "http://maps.googleapis.com/maps/api/geocode/json";
98
+	$url .= '?latlng='.$lat.','.$lon;
99
+	$url .= '&sensor=false';
100
+	$this->result = json_decode(@file_get_contents($url));
101 101
     
102
-    if ($this->result->status == 'OK') {
103
-      if ($return_type == 'string') {
104
-        return $this->result->results[0]->formatted_address;
105
-      }
106
-      if ($return_type == 'array') {
107
-        return $this->result->results[0]->address_components;
108
-      }
109
-    }
110
-    else {
111
-      if ($this->result->status) throw new Exception('Error in Google Reverse Geocoder: '.$this->result->status);
112
-      else throw new Exception('Unknown error in Google Reverse Geocoder');
113
-      return FALSE;
114
-    }
102
+	if ($this->result->status == 'OK') {
103
+	  if ($return_type == 'string') {
104
+		return $this->result->results[0]->formatted_address;
105
+	  }
106
+	  if ($return_type == 'array') {
107
+		return $this->result->results[0]->address_components;
108
+	  }
109
+	}
110
+	else {
111
+	  if ($this->result->status) throw new Exception('Error in Google Reverse Geocoder: '.$this->result->status);
112
+	  else throw new Exception('Unknown error in Google Reverse Geocoder');
113
+	  return FALSE;
114
+	}
115 115
   }
116 116
   
117 117
   private function getPoint($delta = 0) {
118
-    $lat = $this->result->results[$delta]->geometry->location->lat;
119
-    $lon = $this->result->results[$delta]->geometry->location->lng;
120
-    return new Point($lon, $lat);
118
+	$lat = $this->result->results[$delta]->geometry->location->lat;
119
+	$lon = $this->result->results[$delta]->geometry->location->lng;
120
+	return new Point($lon, $lat);
121 121
   }
122 122
 
123 123
   private function getPolygon($delta = 0) {
124
-    $points = array (
125
-      $this->getTopLeft($delta),
126
-      $this->getTopRight($delta),
127
-      $this->getBottomRight($delta),
128
-      $this->getBottomLeft($delta),
129
-      $this->getTopLeft($delta),
130
-    );
131
-    $outer_ring = new LineString($points);
132
-    return new Polygon(array($outer_ring));
124
+	$points = array (
125
+	  $this->getTopLeft($delta),
126
+	  $this->getTopRight($delta),
127
+	  $this->getBottomRight($delta),
128
+	  $this->getBottomLeft($delta),
129
+	  $this->getTopLeft($delta),
130
+	);
131
+	$outer_ring = new LineString($points);
132
+	return new Polygon(array($outer_ring));
133 133
   }
134 134
 
135 135
   private function getTopLeft($delta = 0) {
136
-    $lat = $this->result->results[$delta]->geometry->bounds->northeast->lat;
137
-    $lon = $this->result->results[$delta]->geometry->bounds->southwest->lng;
138
-    return new Point($lon, $lat);
136
+	$lat = $this->result->results[$delta]->geometry->bounds->northeast->lat;
137
+	$lon = $this->result->results[$delta]->geometry->bounds->southwest->lng;
138
+	return new Point($lon, $lat);
139 139
   }
140 140
 
141 141
   private function getTopRight($delta = 0) {
142
-    $lat = $this->result->results[$delta]->geometry->bounds->northeast->lat;
143
-    $lon = $this->result->results[$delta]->geometry->bounds->northeast->lng;
144
-    return new Point($lon, $lat);
142
+	$lat = $this->result->results[$delta]->geometry->bounds->northeast->lat;
143
+	$lon = $this->result->results[$delta]->geometry->bounds->northeast->lng;
144
+	return new Point($lon, $lat);
145 145
   }
146 146
   
147 147
   private function getBottomLeft($delta = 0) {
148
-    $lat = $this->result->results[$delta]->geometry->bounds->southwest->lat;
149
-    $lon = $this->result->results[$delta]->geometry->bounds->southwest->lng;
150
-     return new Point($lon, $lat);
148
+	$lat = $this->result->results[$delta]->geometry->bounds->southwest->lat;
149
+	$lon = $this->result->results[$delta]->geometry->bounds->southwest->lng;
150
+	 return new Point($lon, $lat);
151 151
   }
152 152
 
153 153
   private function getBottomRight($delta = 0) {
154
-    $lat = $this->result->results[$delta]->geometry->bounds->southwest->lat;
155
-    $lon = $this->result->results[$delta]->geometry->bounds->northeast->lng;
156
-    return new Point($lon, $lat);
154
+	$lat = $this->result->results[$delta]->geometry->bounds->southwest->lat;
155
+	$lon = $this->result->results[$delta]->geometry->bounds->northeast->lng;
156
+	return new Point($lon, $lat);
157 157
   }
158 158
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     }
44 44
     
45 45
     $url = "http://maps.googleapis.com/maps/api/geocode/json";
46
-    $url .= '?address='. urlencode($address);
46
+    $url .= '?address='.urlencode($address);
47 47
     $url .= $bounds_string;
48 48
     $url .= '&sensor=false';
49 49
     $this->result = json_decode(@file_get_contents($url));
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
   }
122 122
 
123 123
   private function getPolygon($delta = 0) {
124
-    $points = array (
124
+    $points = array(
125 125
       $this->getTopLeft($delta),
126 126
       $this->getTopRight($delta),
127 127
       $this->getBottomRight($delta),
Please login to merge, or discard this patch.
Braces   +16 added lines, -11 removed lines patch added patch discarded remove patch
@@ -30,15 +30,16 @@  discard block
 block discarded – undo
30 30
    * @return Geometry|GeometryCollection
31 31
    */
32 32
   public function read($address, $return_type = 'point', $bounds = FALSE, $return_multiple = FALSE) {
33
-    if (is_array($address)) $address = join(',', $address);
33
+    if (is_array($address)) {
34
+    	$address = join(',', $address);
35
+    }
34 36
     
35 37
     if (gettype($bounds) == 'object') {
36 38
       $bounds = $bounds->getBBox();
37 39
     }
38 40
     if (gettype($bounds) == 'array') {
39 41
       $bounds_string = '&bounds='.$bounds['miny'].','.$bounds['minx'].'|'.$bounds['maxy'].','.$bounds['maxx'];
40
-    }
41
-    else {
42
+    } else {
42 43
       $bounds_string = '';
43 44
     }
44 45
     
@@ -73,10 +74,12 @@  discard block
 block discarded – undo
73 74
           return new MultiPolygon($polygons);
74 75
         }
75 76
       }
76
-    }
77
-    else {
78
-      if ($this->result->status) throw new Exception('Error in Google Geocoder: '.$this->result->status);
79
-      else throw new Exception('Unknown error in Google Geocoder');
77
+    } else {
78
+      if ($this->result->status) {
79
+      	throw new Exception('Error in Google Geocoder: '.$this->result->status);
80
+      } else {
81
+      	throw new Exception('Unknown error in Google Geocoder');
82
+      }
80 83
       return FALSE;
81 84
     }
82 85
   }
@@ -106,10 +109,12 @@  discard block
 block discarded – undo
106 109
       if ($return_type == 'array') {
107 110
         return $this->result->results[0]->address_components;
108 111
       }
109
-    }
110
-    else {
111
-      if ($this->result->status) throw new Exception('Error in Google Reverse Geocoder: '.$this->result->status);
112
-      else throw new Exception('Unknown error in Google Reverse Geocoder');
112
+    } else {
113
+      if ($this->result->status) {
114
+      	throw new Exception('Error in Google Reverse Geocoder: '.$this->result->status);
115
+      } else {
116
+      	throw new Exception('Unknown error in Google Reverse Geocoder');
117
+      }
113 118
       return FALSE;
114 119
     }
115 120
   }
Please login to merge, or discard this patch.
require/libs/geoPHP/lib/adapters/EWKB.class.php 3 patches
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -13,33 +13,33 @@  discard block
 block discarded – undo
13 13
    * @return Geometry
14 14
    */
15 15
   public function read($wkb, $is_hex_string = FALSE) {
16
-    if ($is_hex_string) {
17
-      $wkb = pack('H*',$wkb);
18
-    }
16
+	if ($is_hex_string) {
17
+	  $wkb = pack('H*',$wkb);
18
+	}
19 19
     
20
-    // Open the wkb up in memory so we can examine the SRID
21
-    $mem = fopen('php://memory', 'r+');
22
-    fwrite($mem, $wkb);
23
-    fseek($mem, 0);
24
-    $base_info = unpack("corder/ctype/cz/cm/cs", fread($mem, 5));
25
-    if ($base_info['s']) {
26
-      $srid = current(unpack("Lsrid", fread($mem, 4)));
27
-    }
28
-    else {
29
-      $srid = NULL;
30
-    }
31
-    fclose($mem);
20
+	// Open the wkb up in memory so we can examine the SRID
21
+	$mem = fopen('php://memory', 'r+');
22
+	fwrite($mem, $wkb);
23
+	fseek($mem, 0);
24
+	$base_info = unpack("corder/ctype/cz/cm/cs", fread($mem, 5));
25
+	if ($base_info['s']) {
26
+	  $srid = current(unpack("Lsrid", fread($mem, 4)));
27
+	}
28
+	else {
29
+	  $srid = NULL;
30
+	}
31
+	fclose($mem);
32 32
     
33
-    // Run the wkb through the normal WKB reader to get the geometry
34
-    $wkb_reader = new WKB();
35
-    $geom = $wkb_reader->read($wkb);
33
+	// Run the wkb through the normal WKB reader to get the geometry
34
+	$wkb_reader = new WKB();
35
+	$geom = $wkb_reader->read($wkb);
36 36
     
37
-    // If there is an SRID, add it to the geometry
38
-    if ($srid) {
39
-      $geom->setSRID($srid);
40
-    }
37
+	// If there is an SRID, add it to the geometry
38
+	if ($srid) {
39
+	  $geom->setSRID($srid);
40
+	}
41 41
     
42
-    return $geom;
42
+	return $geom;
43 43
   }
44 44
   
45 45
   /**
@@ -50,47 +50,47 @@  discard block
 block discarded – undo
50 50
    * @return string The Extended-WKB binary string representation of the input geometries
51 51
    */
52 52
   public function write(Geometry $geometry, $write_as_hex = FALSE) {
53
-    // We always write into NDR (little endian)
54
-    $wkb = pack('c',1);
53
+	// We always write into NDR (little endian)
54
+	$wkb = pack('c',1);
55 55
     
56
-    switch ($geometry->getGeomType()) {
57
-      case 'Point';
58
-        $wkb .= pack('L',1);
59
-        $wkb .= $this->writePoint($geometry);
60
-        break;
61
-      case 'LineString';
62
-        $wkb .= pack('L',2);
63
-        $wkb .= $this->writeLineString($geometry);
64
-        break;
65
-      case 'Polygon';
66
-        $wkb .= pack('L',3);
67
-        $wkb .= $this->writePolygon($geometry);
68
-        break;
69
-      case 'MultiPoint';
70
-        $wkb .= pack('L',4);
71
-        $wkb .= $this->writeMulti($geometry);
72
-        break;
73
-      case 'MultiLineString';
74
-        $wkb .= pack('L',5);
75
-        $wkb .= $this->writeMulti($geometry);
76
-        break;
77
-      case 'MultiPolygon';
78
-        $wkb .= pack('L',6);
79
-        $wkb .= $this->writeMulti($geometry);
80
-        break;
81
-      case 'GeometryCollection';
82
-        $wkb .= pack('L',7);
83
-        $wkb .= $this->writeMulti($geometry);
84
-        break;
85
-    }
56
+	switch ($geometry->getGeomType()) {
57
+	  case 'Point';
58
+		$wkb .= pack('L',1);
59
+		$wkb .= $this->writePoint($geometry);
60
+		break;
61
+	  case 'LineString';
62
+		$wkb .= pack('L',2);
63
+		$wkb .= $this->writeLineString($geometry);
64
+		break;
65
+	  case 'Polygon';
66
+		$wkb .= pack('L',3);
67
+		$wkb .= $this->writePolygon($geometry);
68
+		break;
69
+	  case 'MultiPoint';
70
+		$wkb .= pack('L',4);
71
+		$wkb .= $this->writeMulti($geometry);
72
+		break;
73
+	  case 'MultiLineString';
74
+		$wkb .= pack('L',5);
75
+		$wkb .= $this->writeMulti($geometry);
76
+		break;
77
+	  case 'MultiPolygon';
78
+		$wkb .= pack('L',6);
79
+		$wkb .= $this->writeMulti($geometry);
80
+		break;
81
+	  case 'GeometryCollection';
82
+		$wkb .= pack('L',7);
83
+		$wkb .= $this->writeMulti($geometry);
84
+		break;
85
+	}
86 86
     
87
-    if ($write_as_hex) {
88
-      $unpacked = unpack('H*',$wkb);
89
-      return $unpacked[1];
90
-    }
91
-    else {
92
-      return $wkb;
93
-    }
87
+	if ($write_as_hex) {
88
+	  $unpacked = unpack('H*',$wkb);
89
+	  return $unpacked[1];
90
+	}
91
+	else {
92
+	  return $wkb;
93
+	}
94 94
   }
95 95
 
96 96
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
    */
15 15
   public function read($wkb, $is_hex_string = FALSE) {
16 16
     if ($is_hex_string) {
17
-      $wkb = pack('H*',$wkb);
17
+      $wkb = pack('H*', $wkb);
18 18
     }
19 19
     
20 20
     // Open the wkb up in memory so we can examine the SRID
@@ -51,41 +51,41 @@  discard block
 block discarded – undo
51 51
    */
52 52
   public function write(Geometry $geometry, $write_as_hex = FALSE) {
53 53
     // We always write into NDR (little endian)
54
-    $wkb = pack('c',1);
54
+    $wkb = pack('c', 1);
55 55
     
56 56
     switch ($geometry->getGeomType()) {
57 57
       case 'Point';
58
-        $wkb .= pack('L',1);
58
+        $wkb .= pack('L', 1);
59 59
         $wkb .= $this->writePoint($geometry);
60 60
         break;
61 61
       case 'LineString';
62
-        $wkb .= pack('L',2);
62
+        $wkb .= pack('L', 2);
63 63
         $wkb .= $this->writeLineString($geometry);
64 64
         break;
65 65
       case 'Polygon';
66
-        $wkb .= pack('L',3);
66
+        $wkb .= pack('L', 3);
67 67
         $wkb .= $this->writePolygon($geometry);
68 68
         break;
69 69
       case 'MultiPoint';
70
-        $wkb .= pack('L',4);
70
+        $wkb .= pack('L', 4);
71 71
         $wkb .= $this->writeMulti($geometry);
72 72
         break;
73 73
       case 'MultiLineString';
74
-        $wkb .= pack('L',5);
74
+        $wkb .= pack('L', 5);
75 75
         $wkb .= $this->writeMulti($geometry);
76 76
         break;
77 77
       case 'MultiPolygon';
78
-        $wkb .= pack('L',6);
78
+        $wkb .= pack('L', 6);
79 79
         $wkb .= $this->writeMulti($geometry);
80 80
         break;
81 81
       case 'GeometryCollection';
82
-        $wkb .= pack('L',7);
82
+        $wkb .= pack('L', 7);
83 83
         $wkb .= $this->writeMulti($geometry);
84 84
         break;
85 85
     }
86 86
     
87 87
     if ($write_as_hex) {
88
-      $unpacked = unpack('H*',$wkb);
88
+      $unpacked = unpack('H*', $wkb);
89 89
       return $unpacked[1];
90 90
     }
91 91
     else {
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -24,8 +24,7 @@  discard block
 block discarded – undo
24 24
     $base_info = unpack("corder/ctype/cz/cm/cs", fread($mem, 5));
25 25
     if ($base_info['s']) {
26 26
       $srid = current(unpack("Lsrid", fread($mem, 4)));
27
-    }
28
-    else {
27
+    } else {
29 28
       $srid = NULL;
30 29
     }
31 30
     fclose($mem);
@@ -87,8 +86,7 @@  discard block
 block discarded – undo
87 86
     if ($write_as_hex) {
88 87
       $unpacked = unpack('H*',$wkb);
89 88
       return $unpacked[1];
90
-    }
91
-    else {
89
+    } else {
92 90
       return $wkb;
93 91
     }
94 92
   }
Please login to merge, or discard this patch.
require/libs/geoPHP/lib/adapters/GeoHash.class.php 3 patches
Indentation   +118 added lines, -118 removed lines patch added patch discarded remove patch
@@ -16,21 +16,21 @@  discard block
 block discarded – undo
16 16
    * @see GeoAdapter::read()
17 17
    */
18 18
   public function read($hash, $as_grid = FALSE) {
19
-    $ll = $this->decode($hash);
20
-    if (!$as_grid) {
21
-      return new Point($ll['medlon'], $ll['medlat']);
22
-    }
23
-    else {
24
-      return new Polygon(array(
25
-        new LineString(array(
26
-          new Point($ll['minlon'], $ll['maxlat']),
27
-          new Point($ll['maxlon'], $ll['maxlat']),
28
-          new Point($ll['maxlon'], $ll['minlat']),
29
-          new Point($ll['minlon'], $ll['minlat']),
30
-          new Point($ll['minlon'], $ll['maxlat']),
31
-        ))
32
-      ));
33
-    }
19
+	$ll = $this->decode($hash);
20
+	if (!$as_grid) {
21
+	  return new Point($ll['medlon'], $ll['medlat']);
22
+	}
23
+	else {
24
+	  return new Polygon(array(
25
+		new LineString(array(
26
+		  new Point($ll['minlon'], $ll['maxlat']),
27
+		  new Point($ll['maxlon'], $ll['maxlat']),
28
+		  new Point($ll['maxlon'], $ll['minlat']),
29
+		  new Point($ll['minlon'], $ll['minlat']),
30
+		  new Point($ll['minlon'], $ll['maxlat']),
31
+		))
32
+	  ));
33
+	}
34 34
   }
35 35
 
36 36
   /**
@@ -40,32 +40,32 @@  discard block
 block discarded – undo
40 40
    * @see GeoAdapter::write()
41 41
    */
42 42
   public function write(Geometry $geometry, $precision = NULL){
43
-    if ($geometry->isEmpty()) return '';
43
+	if ($geometry->isEmpty()) return '';
44 44
 
45
-    if($geometry->geometryType() === 'Point'){
46
-      return $this->encodePoint($geometry, $precision);
47
-    }
48
-    else {
49
-      // The geohash is the hash grid ID that fits the envelope
50
-      $envelope = $geometry->envelope();
51
-      $geohashes = array();
52
-      $geohash = '';
53
-      foreach ($envelope->getPoints() as $point) {
54
-        $geohashes[] = $this->encodePoint($point, 0.0000001);
55
-      }
56
-      $i = 0;
57
-      while ($i < strlen($geohashes[0])) {
58
-        $char = $geohashes[0][$i];
59
-        foreach ($geohashes as $hash) {
60
-          if ($hash[$i] != $char) {
61
-            return $geohash;
62
-          }
63
-        }
64
-        $geohash .= $char;
65
-        $i++;
66
-      }
67
-      return $geohash;
68
-    }
45
+	if($geometry->geometryType() === 'Point'){
46
+	  return $this->encodePoint($geometry, $precision);
47
+	}
48
+	else {
49
+	  // The geohash is the hash grid ID that fits the envelope
50
+	  $envelope = $geometry->envelope();
51
+	  $geohashes = array();
52
+	  $geohash = '';
53
+	  foreach ($envelope->getPoints() as $point) {
54
+		$geohashes[] = $this->encodePoint($point, 0.0000001);
55
+	  }
56
+	  $i = 0;
57
+	  while ($i < strlen($geohashes[0])) {
58
+		$char = $geohashes[0][$i];
59
+		foreach ($geohashes as $hash) {
60
+		  if ($hash[$i] != $char) {
61
+			return $geohash;
62
+		  }
63
+		}
64
+		$geohash .= $char;
65
+		$i++;
66
+	  }
67
+	  return $geohash;
68
+	}
69 69
   }
70 70
 
71 71
   /**
@@ -75,51 +75,51 @@  discard block
 block discarded – undo
75 75
    * @see https://github.com/asonge/php-geohash/issues/1
76 76
    */
77 77
   private function encodePoint($point, $precision = NULL){
78
-    if ($precision === NULL) {
79
-      $lap = strlen($point->y())-strpos($point->y(),".");
80
-      $lop = strlen($point->x())-strpos($point->x(),".");
81
-      $precision = pow(10,-max($lap-1,$lop-1,0))/2;
82
-    }
78
+	if ($precision === NULL) {
79
+	  $lap = strlen($point->y())-strpos($point->y(),".");
80
+	  $lop = strlen($point->x())-strpos($point->x(),".");
81
+	  $precision = pow(10,-max($lap-1,$lop-1,0))/2;
82
+	}
83 83
 
84
-    $minlat =  -90;
85
-    $maxlat =   90;
86
-    $minlon = -180;
87
-    $maxlon =  180;
88
-    $latE   =   90;
89
-    $lonE   =  180;
90
-    $i = 0;
91
-    $error = 180;
92
-    $hash='';
93
-    while($error>=$precision) {
94
-      $chr = 0;
95
-      for($b=4;$b>=0;--$b) {
96
-        if((1&$b) == (1&$i)) {
97
-          // even char, even bit OR odd char, odd bit...a lon
98
-          $next = ($minlon+$maxlon)/2;
99
-          if($point->x()>$next) {
100
-            $chr |= pow(2,$b);
101
-            $minlon = $next;
102
-          } else {
103
-            $maxlon = $next;
104
-          }
105
-          $lonE /= 2;
106
-        } else {
107
-          // odd char, even bit OR even char, odd bit...a lat
108
-          $next = ($minlat+$maxlat)/2;
109
-          if($point->y()>$next) {
110
-            $chr |= pow(2,$b);
111
-            $minlat = $next;
112
-          } else {
113
-            $maxlat = $next;
114
-          }
115
-          $latE /= 2;
116
-        }
117
-      }
118
-      $hash .= $this->table[$chr];
119
-      $i++;
120
-      $error = min($latE,$lonE);
121
-    }
122
-    return $hash;
84
+	$minlat =  -90;
85
+	$maxlat =   90;
86
+	$minlon = -180;
87
+	$maxlon =  180;
88
+	$latE   =   90;
89
+	$lonE   =  180;
90
+	$i = 0;
91
+	$error = 180;
92
+	$hash='';
93
+	while($error>=$precision) {
94
+	  $chr = 0;
95
+	  for($b=4;$b>=0;--$b) {
96
+		if((1&$b) == (1&$i)) {
97
+		  // even char, even bit OR odd char, odd bit...a lon
98
+		  $next = ($minlon+$maxlon)/2;
99
+		  if($point->x()>$next) {
100
+			$chr |= pow(2,$b);
101
+			$minlon = $next;
102
+		  } else {
103
+			$maxlon = $next;
104
+		  }
105
+		  $lonE /= 2;
106
+		} else {
107
+		  // odd char, even bit OR even char, odd bit...a lat
108
+		  $next = ($minlat+$maxlat)/2;
109
+		  if($point->y()>$next) {
110
+			$chr |= pow(2,$b);
111
+			$minlat = $next;
112
+		  } else {
113
+			$maxlat = $next;
114
+		  }
115
+		  $latE /= 2;
116
+		}
117
+	  }
118
+	  $hash .= $this->table[$chr];
119
+	  $i++;
120
+	  $error = min($latE,$lonE);
121
+	}
122
+	return $hash;
123 123
   }
124 124
 
125 125
   /**
@@ -128,39 +128,39 @@  discard block
 block discarded – undo
128 128
    * @see https://github.com/asonge/php-geohash/issues/1
129 129
    */
130 130
   private function decode($hash){
131
-    $ll = array();
132
-    $minlat =  -90;
133
-    $maxlat =   90;
134
-    $minlon = -180;
135
-    $maxlon =  180;
136
-    $latE   =   90;
137
-    $lonE   =  180;
138
-    for($i=0,$c=strlen($hash);$i<$c;$i++) {
139
-      $v = strpos($this->table,$hash[$i]);
140
-      if(1&$i) {
141
-        if(16&$v)$minlat = ($minlat+$maxlat)/2; else $maxlat = ($minlat+$maxlat)/2;
142
-        if(8&$v) $minlon = ($minlon+$maxlon)/2; else $maxlon = ($minlon+$maxlon)/2;
143
-        if(4&$v) $minlat = ($minlat+$maxlat)/2; else $maxlat = ($minlat+$maxlat)/2;
144
-        if(2&$v) $minlon = ($minlon+$maxlon)/2; else $maxlon = ($minlon+$maxlon)/2;
145
-        if(1&$v) $minlat = ($minlat+$maxlat)/2; else $maxlat = ($minlat+$maxlat)/2;
146
-        $latE /= 8;
147
-        $lonE /= 4;
148
-      } else {
149
-        if(16&$v)$minlon = ($minlon+$maxlon)/2; else $maxlon = ($minlon+$maxlon)/2;
150
-        if(8&$v) $minlat = ($minlat+$maxlat)/2; else $maxlat = ($minlat+$maxlat)/2;
151
-        if(4&$v) $minlon = ($minlon+$maxlon)/2; else $maxlon = ($minlon+$maxlon)/2;
152
-        if(2&$v) $minlat = ($minlat+$maxlat)/2; else $maxlat = ($minlat+$maxlat)/2;
153
-        if(1&$v) $minlon = ($minlon+$maxlon)/2; else $maxlon = ($minlon+$maxlon)/2;
154
-        $latE /= 4;
155
-        $lonE /= 8;
156
-      }
157
-    }
158
-    $ll['minlat'] = $minlat;
159
-    $ll['minlon'] = $minlon;
160
-    $ll['maxlat'] = $maxlat;
161
-    $ll['maxlon'] = $maxlon;
162
-    $ll['medlat'] = round(($minlat+$maxlat)/2, max(1, -round(log10($latE)))-1);
163
-    $ll['medlon'] = round(($minlon+$maxlon)/2, max(1, -round(log10($lonE)))-1);
164
-    return $ll;
131
+	$ll = array();
132
+	$minlat =  -90;
133
+	$maxlat =   90;
134
+	$minlon = -180;
135
+	$maxlon =  180;
136
+	$latE   =   90;
137
+	$lonE   =  180;
138
+	for($i=0,$c=strlen($hash);$i<$c;$i++) {
139
+	  $v = strpos($this->table,$hash[$i]);
140
+	  if(1&$i) {
141
+		if(16&$v)$minlat = ($minlat+$maxlat)/2; else $maxlat = ($minlat+$maxlat)/2;
142
+		if(8&$v) $minlon = ($minlon+$maxlon)/2; else $maxlon = ($minlon+$maxlon)/2;
143
+		if(4&$v) $minlat = ($minlat+$maxlat)/2; else $maxlat = ($minlat+$maxlat)/2;
144
+		if(2&$v) $minlon = ($minlon+$maxlon)/2; else $maxlon = ($minlon+$maxlon)/2;
145
+		if(1&$v) $minlat = ($minlat+$maxlat)/2; else $maxlat = ($minlat+$maxlat)/2;
146
+		$latE /= 8;
147
+		$lonE /= 4;
148
+	  } else {
149
+		if(16&$v)$minlon = ($minlon+$maxlon)/2; else $maxlon = ($minlon+$maxlon)/2;
150
+		if(8&$v) $minlat = ($minlat+$maxlat)/2; else $maxlat = ($minlat+$maxlat)/2;
151
+		if(4&$v) $minlon = ($minlon+$maxlon)/2; else $maxlon = ($minlon+$maxlon)/2;
152
+		if(2&$v) $minlat = ($minlat+$maxlat)/2; else $maxlat = ($minlat+$maxlat)/2;
153
+		if(1&$v) $minlon = ($minlon+$maxlon)/2; else $maxlon = ($minlon+$maxlon)/2;
154
+		$latE /= 4;
155
+		$lonE /= 8;
156
+	  }
157
+	}
158
+	$ll['minlat'] = $minlat;
159
+	$ll['minlon'] = $minlon;
160
+	$ll['maxlat'] = $maxlat;
161
+	$ll['maxlon'] = $maxlon;
162
+	$ll['medlat'] = round(($minlat+$maxlat)/2, max(1, -round(log10($latE)))-1);
163
+	$ll['medlon'] = round(($minlon+$maxlon)/2, max(1, -round(log10($lonE)))-1);
164
+	return $ll;
165 165
   }
166 166
 }
Please login to merge, or discard this patch.
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @see http://en.wikipedia.org/wiki/Geohash
7 7
  *
8 8
  */
9
-class GeoHash extends GeoAdapter{
9
+class GeoHash extends GeoAdapter {
10 10
   private $table = "0123456789bcdefghjkmnpqrstuvwxyz";
11 11
 
12 12
   /**
@@ -39,10 +39,10 @@  discard block
 block discarded – undo
39 39
    * @param Point $geometry
40 40
    * @see GeoAdapter::write()
41 41
    */
42
-  public function write(Geometry $geometry, $precision = NULL){
42
+  public function write(Geometry $geometry, $precision = NULL) {
43 43
     if ($geometry->isEmpty()) return '';
44 44
 
45
-    if($geometry->geometryType() === 'Point'){
45
+    if ($geometry->geometryType() === 'Point') {
46 46
       return $this->encodePoint($geometry, $precision);
47 47
     }
48 48
     else {
@@ -74,30 +74,30 @@  discard block
 block discarded – undo
74 74
    * @author algorithm based on code by Alexander Songe <[email protected]>
75 75
    * @see https://github.com/asonge/php-geohash/issues/1
76 76
    */
77
-  private function encodePoint($point, $precision = NULL){
77
+  private function encodePoint($point, $precision = NULL) {
78 78
     if ($precision === NULL) {
79
-      $lap = strlen($point->y())-strpos($point->y(),".");
80
-      $lop = strlen($point->x())-strpos($point->x(),".");
81
-      $precision = pow(10,-max($lap-1,$lop-1,0))/2;
79
+      $lap = strlen($point->y()) - strpos($point->y(), ".");
80
+      $lop = strlen($point->x()) - strpos($point->x(), ".");
81
+      $precision = pow(10, -max($lap - 1, $lop - 1, 0))/2;
82 82
     }
83 83
 
84
-    $minlat =  -90;
85
-    $maxlat =   90;
84
+    $minlat = -90;
85
+    $maxlat = 90;
86 86
     $minlon = -180;
87
-    $maxlon =  180;
88
-    $latE   =   90;
89
-    $lonE   =  180;
87
+    $maxlon = 180;
88
+    $latE   = 90;
89
+    $lonE   = 180;
90 90
     $i = 0;
91 91
     $error = 180;
92
-    $hash='';
93
-    while($error>=$precision) {
92
+    $hash = '';
93
+    while ($error >= $precision) {
94 94
       $chr = 0;
95
-      for($b=4;$b>=0;--$b) {
96
-        if((1&$b) == (1&$i)) {
95
+      for ($b = 4; $b >= 0; --$b) {
96
+        if ((1&$b) == (1&$i)) {
97 97
           // even char, even bit OR odd char, odd bit...a lon
98
-          $next = ($minlon+$maxlon)/2;
99
-          if($point->x()>$next) {
100
-            $chr |= pow(2,$b);
98
+          $next = ($minlon + $maxlon)/2;
99
+          if ($point->x() > $next) {
100
+            $chr |= pow(2, $b);
101 101
             $minlon = $next;
102 102
           } else {
103 103
             $maxlon = $next;
@@ -105,9 +105,9 @@  discard block
 block discarded – undo
105 105
           $lonE /= 2;
106 106
         } else {
107 107
           // odd char, even bit OR even char, odd bit...a lat
108
-          $next = ($minlat+$maxlat)/2;
109
-          if($point->y()>$next) {
110
-            $chr |= pow(2,$b);
108
+          $next = ($minlat + $maxlat)/2;
109
+          if ($point->y() > $next) {
110
+            $chr |= pow(2, $b);
111 111
             $minlat = $next;
112 112
           } else {
113 113
             $maxlat = $next;
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
       }
118 118
       $hash .= $this->table[$chr];
119 119
       $i++;
120
-      $error = min($latE,$lonE);
120
+      $error = min($latE, $lonE);
121 121
     }
122 122
     return $hash;
123 123
   }
@@ -127,30 +127,30 @@  discard block
 block discarded – undo
127 127
    * @author algorithm based on code by Alexander Songe <[email protected]>
128 128
    * @see https://github.com/asonge/php-geohash/issues/1
129 129
    */
130
-  private function decode($hash){
130
+  private function decode($hash) {
131 131
     $ll = array();
132
-    $minlat =  -90;
133
-    $maxlat =   90;
132
+    $minlat = -90;
133
+    $maxlat = 90;
134 134
     $minlon = -180;
135
-    $maxlon =  180;
136
-    $latE   =   90;
137
-    $lonE   =  180;
138
-    for($i=0,$c=strlen($hash);$i<$c;$i++) {
139
-      $v = strpos($this->table,$hash[$i]);
140
-      if(1&$i) {
141
-        if(16&$v)$minlat = ($minlat+$maxlat)/2; else $maxlat = ($minlat+$maxlat)/2;
142
-        if(8&$v) $minlon = ($minlon+$maxlon)/2; else $maxlon = ($minlon+$maxlon)/2;
143
-        if(4&$v) $minlat = ($minlat+$maxlat)/2; else $maxlat = ($minlat+$maxlat)/2;
144
-        if(2&$v) $minlon = ($minlon+$maxlon)/2; else $maxlon = ($minlon+$maxlon)/2;
145
-        if(1&$v) $minlat = ($minlat+$maxlat)/2; else $maxlat = ($minlat+$maxlat)/2;
135
+    $maxlon = 180;
136
+    $latE   = 90;
137
+    $lonE   = 180;
138
+    for ($i = 0, $c = strlen($hash); $i < $c; $i++) {
139
+      $v = strpos($this->table, $hash[$i]);
140
+      if (1&$i) {
141
+        if (16&$v)$minlat = ($minlat + $maxlat)/2; else $maxlat = ($minlat + $maxlat)/2;
142
+        if (8&$v) $minlon = ($minlon + $maxlon)/2; else $maxlon = ($minlon + $maxlon)/2;
143
+        if (4&$v) $minlat = ($minlat + $maxlat)/2; else $maxlat = ($minlat + $maxlat)/2;
144
+        if (2&$v) $minlon = ($minlon + $maxlon)/2; else $maxlon = ($minlon + $maxlon)/2;
145
+        if (1&$v) $minlat = ($minlat + $maxlat)/2; else $maxlat = ($minlat + $maxlat)/2;
146 146
         $latE /= 8;
147 147
         $lonE /= 4;
148 148
       } else {
149
-        if(16&$v)$minlon = ($minlon+$maxlon)/2; else $maxlon = ($minlon+$maxlon)/2;
150
-        if(8&$v) $minlat = ($minlat+$maxlat)/2; else $maxlat = ($minlat+$maxlat)/2;
151
-        if(4&$v) $minlon = ($minlon+$maxlon)/2; else $maxlon = ($minlon+$maxlon)/2;
152
-        if(2&$v) $minlat = ($minlat+$maxlat)/2; else $maxlat = ($minlat+$maxlat)/2;
153
-        if(1&$v) $minlon = ($minlon+$maxlon)/2; else $maxlon = ($minlon+$maxlon)/2;
149
+        if (16&$v)$minlon = ($minlon + $maxlon)/2; else $maxlon = ($minlon + $maxlon)/2;
150
+        if (8&$v) $minlat = ($minlat + $maxlat)/2; else $maxlat = ($minlat + $maxlat)/2;
151
+        if (4&$v) $minlon = ($minlon + $maxlon)/2; else $maxlon = ($minlon + $maxlon)/2;
152
+        if (2&$v) $minlat = ($minlat + $maxlat)/2; else $maxlat = ($minlat + $maxlat)/2;
153
+        if (1&$v) $minlon = ($minlon + $maxlon)/2; else $maxlon = ($minlon + $maxlon)/2;
154 154
         $latE /= 4;
155 155
         $lonE /= 8;
156 156
       }
@@ -159,8 +159,8 @@  discard block
 block discarded – undo
159 159
     $ll['minlon'] = $minlon;
160 160
     $ll['maxlat'] = $maxlat;
161 161
     $ll['maxlon'] = $maxlon;
162
-    $ll['medlat'] = round(($minlat+$maxlat)/2, max(1, -round(log10($latE)))-1);
163
-    $ll['medlon'] = round(($minlon+$maxlon)/2, max(1, -round(log10($lonE)))-1);
162
+    $ll['medlat'] = round(($minlat + $maxlat)/2, max(1, -round(log10($latE))) - 1);
163
+    $ll['medlon'] = round(($minlon + $maxlon)/2, max(1, -round(log10($lonE))) - 1);
164 164
     return $ll;
165 165
   }
166 166
 }
Please login to merge, or discard this patch.
Braces   +55 added lines, -15 removed lines patch added patch discarded remove patch
@@ -19,8 +19,7 @@  discard block
 block discarded – undo
19 19
     $ll = $this->decode($hash);
20 20
     if (!$as_grid) {
21 21
       return new Point($ll['medlon'], $ll['medlat']);
22
-    }
23
-    else {
22
+    } else {
24 23
       return new Polygon(array(
25 24
         new LineString(array(
26 25
           new Point($ll['minlon'], $ll['maxlat']),
@@ -40,12 +39,13 @@  discard block
 block discarded – undo
40 39
    * @see GeoAdapter::write()
41 40
    */
42 41
   public function write(Geometry $geometry, $precision = NULL){
43
-    if ($geometry->isEmpty()) return '';
42
+    if ($geometry->isEmpty()) {
43
+    	return '';
44
+    }
44 45
 
45 46
     if($geometry->geometryType() === 'Point'){
46 47
       return $this->encodePoint($geometry, $precision);
47
-    }
48
-    else {
48
+    } else {
49 49
       // The geohash is the hash grid ID that fits the envelope
50 50
       $envelope = $geometry->envelope();
51 51
       $geohashes = array();
@@ -138,19 +138,59 @@  discard block
 block discarded – undo
138 138
     for($i=0,$c=strlen($hash);$i<$c;$i++) {
139 139
       $v = strpos($this->table,$hash[$i]);
140 140
       if(1&$i) {
141
-        if(16&$v)$minlat = ($minlat+$maxlat)/2; else $maxlat = ($minlat+$maxlat)/2;
142
-        if(8&$v) $minlon = ($minlon+$maxlon)/2; else $maxlon = ($minlon+$maxlon)/2;
143
-        if(4&$v) $minlat = ($minlat+$maxlat)/2; else $maxlat = ($minlat+$maxlat)/2;
144
-        if(2&$v) $minlon = ($minlon+$maxlon)/2; else $maxlon = ($minlon+$maxlon)/2;
145
-        if(1&$v) $minlat = ($minlat+$maxlat)/2; else $maxlat = ($minlat+$maxlat)/2;
141
+        if(16&$v) {
142
+        	$minlat = ($minlat+$maxlat)/2;
143
+        } else {
144
+        	$maxlat = ($minlat+$maxlat)/2;
145
+        }
146
+        if(8&$v) {
147
+        	$minlon = ($minlon+$maxlon)/2;
148
+        } else {
149
+        	$maxlon = ($minlon+$maxlon)/2;
150
+        }
151
+        if(4&$v) {
152
+        	$minlat = ($minlat+$maxlat)/2;
153
+        } else {
154
+        	$maxlat = ($minlat+$maxlat)/2;
155
+        }
156
+        if(2&$v) {
157
+        	$minlon = ($minlon+$maxlon)/2;
158
+        } else {
159
+        	$maxlon = ($minlon+$maxlon)/2;
160
+        }
161
+        if(1&$v) {
162
+        	$minlat = ($minlat+$maxlat)/2;
163
+        } else {
164
+        	$maxlat = ($minlat+$maxlat)/2;
165
+        }
146 166
         $latE /= 8;
147 167
         $lonE /= 4;
148 168
       } else {
149
-        if(16&$v)$minlon = ($minlon+$maxlon)/2; else $maxlon = ($minlon+$maxlon)/2;
150
-        if(8&$v) $minlat = ($minlat+$maxlat)/2; else $maxlat = ($minlat+$maxlat)/2;
151
-        if(4&$v) $minlon = ($minlon+$maxlon)/2; else $maxlon = ($minlon+$maxlon)/2;
152
-        if(2&$v) $minlat = ($minlat+$maxlat)/2; else $maxlat = ($minlat+$maxlat)/2;
153
-        if(1&$v) $minlon = ($minlon+$maxlon)/2; else $maxlon = ($minlon+$maxlon)/2;
169
+        if(16&$v) {
170
+        	$minlon = ($minlon+$maxlon)/2;
171
+        } else {
172
+        	$maxlon = ($minlon+$maxlon)/2;
173
+        }
174
+        if(8&$v) {
175
+        	$minlat = ($minlat+$maxlat)/2;
176
+        } else {
177
+        	$maxlat = ($minlat+$maxlat)/2;
178
+        }
179
+        if(4&$v) {
180
+        	$minlon = ($minlon+$maxlon)/2;
181
+        } else {
182
+        	$maxlon = ($minlon+$maxlon)/2;
183
+        }
184
+        if(2&$v) {
185
+        	$minlat = ($minlat+$maxlat)/2;
186
+        } else {
187
+        	$maxlat = ($minlat+$maxlat)/2;
188
+        }
189
+        if(1&$v) {
190
+        	$minlon = ($minlon+$maxlon)/2;
191
+        } else {
192
+        	$maxlon = ($minlon+$maxlon)/2;
193
+        }
154 194
         $latE /= 4;
155 195
         $lonE /= 8;
156 196
       }
Please login to merge, or discard this patch.
require/libs/geoPHP/lib/geometry/GeometryCollection.class.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -12,14 +12,14 @@
 block discarded – undo
12 12
   // MultiPoint or a LineString, since they share the same structure (collection
13 13
   // of points). So we need to call out the type explicitly. 
14 14
   public function asArray() {
15
-    $array = array();
16
-    foreach ($this->components as $component) {
17
-      $array[] = array(
18
-        'type' => $component->geometryType(),
19
-        'components' => $component->asArray(),
20
-      );
21
-    }
22
-    return $array;
15
+	$array = array();
16
+	foreach ($this->components as $component) {
17
+	  $array[] = array(
18
+		'type' => $component->geometryType(),
19
+		'components' => $component->asArray(),
20
+	  );
21
+	}
22
+	return $array;
23 23
   }
24 24
   
25 25
   // Not valid for this geomettry
Please login to merge, or discard this patch.
require/libs/geoPHP/lib/geometry/Point.class.php 3 patches
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -18,31 +18,31 @@  discard block
 block discarded – undo
18 18
    * @param numeric $z The z coordinate (or altitude) - optional
19 19
    */
20 20
   public function __construct($x, $y, $z = NULL) {
21
-    // Basic validation on x and y
22
-    if (!is_numeric($x) || !is_numeric($y)) {
23
-      throw new Exception("Cannot construct Point. x and y should be numeric");
24
-    }
25
-
26
-    // Check to see if this is a 3D point
27
-    if ($z !== NULL) {
28
-      if (!is_numeric($z)) {
29
-       throw new Exception("Cannot construct Point. z should be numeric");
30
-      }
31
-      $this->dimention = 3;
32
-    }
33
-
34
-    // Convert to floatval in case they are passed in as a string or integer etc.
35
-    $x = floatval($x);
36
-    $y = floatval($y);
37
-    $z = floatval($z);
38
-
39
-    // Add poitional elements
40
-    if ($this->dimention == 2) {
41
-      $this->coords = array($x, $y);
42
-    }
43
-    if ($this->dimention == 3) {
44
-      $this->coords = array($x, $y, $z);
45
-    }
21
+	// Basic validation on x and y
22
+	if (!is_numeric($x) || !is_numeric($y)) {
23
+	  throw new Exception("Cannot construct Point. x and y should be numeric");
24
+	}
25
+
26
+	// Check to see if this is a 3D point
27
+	if ($z !== NULL) {
28
+	  if (!is_numeric($z)) {
29
+	   throw new Exception("Cannot construct Point. z should be numeric");
30
+	  }
31
+	  $this->dimention = 3;
32
+	}
33
+
34
+	// Convert to floatval in case they are passed in as a string or integer etc.
35
+	$x = floatval($x);
36
+	$y = floatval($y);
37
+	$z = floatval($z);
38
+
39
+	// Add poitional elements
40
+	if ($this->dimention == 2) {
41
+	  $this->coords = array($x, $y);
42
+	}
43
+	if ($this->dimention == 3) {
44
+	  $this->coords = array($x, $y, $z);
45
+	}
46 46
   }
47 47
 
48 48
   /**
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
    * @return float The X coordinate
52 52
    */
53 53
   public function x() {
54
-    return $this->coords[0];
54
+	return $this->coords[0];
55 55
   }
56 56
 
57 57
   /**
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
    * @return float The Y coordinate
61 61
    */
62 62
   public function y() {
63
-    return $this->coords[1];
63
+	return $this->coords[1];
64 64
   }
65 65
 
66 66
   /**
@@ -69,73 +69,73 @@  discard block
 block discarded – undo
69 69
    * @return float The Z coordinate or NULL is not a 3D point
70 70
    */
71 71
   public function z() {
72
-    if ($this->dimention == 3) {
73
-      return $this->coords[2];
74
-    }
75
-    else return NULL;
72
+	if ($this->dimention == 3) {
73
+	  return $this->coords[2];
74
+	}
75
+	else return NULL;
76 76
   }
77 77
 
78 78
   // A point's centroid is itself
79 79
   public function centroid() {
80
-    return $this;
80
+	return $this;
81 81
   }
82 82
 
83 83
   public function getBBox() {
84
-    return array(
85
-      'maxy' => $this->getY(),
86
-      'miny' => $this->getY(),
87
-      'maxx' => $this->getX(),
88
-      'minx' => $this->getX(),
89
-    );
84
+	return array(
85
+	  'maxy' => $this->getY(),
86
+	  'miny' => $this->getY(),
87
+	  'maxx' => $this->getX(),
88
+	  'minx' => $this->getX(),
89
+	);
90 90
   }
91 91
 
92 92
   public function asArray($assoc = FALSE) {
93
-    return $this->coords;
93
+	return $this->coords;
94 94
   }
95 95
 
96 96
   public function area() {
97
-    return 0;
97
+	return 0;
98 98
   }
99 99
 
100 100
   public function length() {
101
-    return 0;
101
+	return 0;
102 102
   }
103 103
 
104 104
   public function greatCircleLength() {
105
-    return 0;
105
+	return 0;
106 106
   }
107 107
 
108 108
   public function haversineLength() {
109
-    return 0;
109
+	return 0;
110 110
   }
111 111
 
112 112
   // The boundary of a point is itself
113 113
   public function boundary() {
114
-    return $this;
114
+	return $this;
115 115
   }
116 116
 
117 117
   public function dimension() {
118
-    return 0;
118
+	return 0;
119 119
   }
120 120
 
121 121
   public function isEmpty() {
122
-    return FALSE;
122
+	return FALSE;
123 123
   }
124 124
 
125 125
   public function numPoints() {
126
-    return 1;
126
+	return 1;
127 127
   }
128 128
 
129 129
   public function getPoints() {
130
-    return array($this);
130
+	return array($this);
131 131
   }
132 132
 
133 133
   public function equals($geometry) {
134
-    return ($this->x() == $geometry->x() && $this->y() == $geometry->y());
134
+	return ($this->x() == $geometry->x() && $this->y() == $geometry->y());
135 135
   }
136 136
 
137 137
   public function isSimple() {
138
-    return TRUE;
138
+	return TRUE;
139 139
   }
140 140
 
141 141
   // Not valid for this geometry type
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -139,17 +139,17 @@
 block discarded – undo
139 139
   }
140 140
 
141 141
   // Not valid for this geometry type
142
-  public function numGeometries()    { return NULL; }
143
-  public function geometryN($n)      { return NULL; }
144
-  public function startPoint()       { return NULL; }
145
-  public function endPoint()         { return NULL; }
146
-  public function isRing()           { return NULL; }
147
-  public function isClosed()         { return NULL; }
148
-  public function pointN($n)         { return NULL; }
149
-  public function exteriorRing()     { return NULL; }
142
+  public function numGeometries() { return NULL; }
143
+  public function geometryN($n) { return NULL; }
144
+  public function startPoint() { return NULL; }
145
+  public function endPoint() { return NULL; }
146
+  public function isRing() { return NULL; }
147
+  public function isClosed() { return NULL; }
148
+  public function pointN($n) { return NULL; }
149
+  public function exteriorRing() { return NULL; }
150 150
   public function numInteriorRings() { return NULL; }
151
-  public function interiorRingN($n)  { return NULL; }
152
-  public function pointOnSurface()   { return NULL; }
153
-  public function explode()          { return NULL; }
151
+  public function interiorRingN($n) { return NULL; }
152
+  public function pointOnSurface() { return NULL; }
153
+  public function explode() { return NULL; }
154 154
 }
155 155
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -71,8 +71,9 @@
 block discarded – undo
71 71
   public function z() {
72 72
     if ($this->dimention == 3) {
73 73
       return $this->coords[2];
74
+    } else {
75
+    	return NULL;
74 76
     }
75
-    else return NULL;
76 77
   }
77 78
 
78 79
   // A point's centroid is itself
Please login to merge, or discard this patch.
require/libs/geoPHP/lib/geometry/MultiPoint.class.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -7,11 +7,11 @@
 block discarded – undo
7 7
   protected $geom_type = 'MultiPoint';
8 8
   
9 9
   public function numPoints() {
10
-    return $this->numGeometries();
10
+	return $this->numGeometries();
11 11
   }
12 12
   
13 13
   public function isSimple() {
14
-    return TRUE;
14
+	return TRUE;
15 15
   }
16 16
   
17 17
   // Not valid for this geometry type
Please login to merge, or discard this patch.
require/libs/geoPHP/lib/geometry/MultiLineString.class.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -8,12 +8,12 @@
 block discarded – undo
8 8
 
9 9
   // MultiLineString is closed if all it's components are closed
10 10
   public function isClosed() {
11
-    foreach ($this->components as $line) {
12
-      if (!$line->isClosed()) {
13
-        return FALSE;
14
-      }
15
-    }
16
-    return TRUE;
11
+	foreach ($this->components as $line) {
12
+	  if (!$line->isClosed()) {
13
+		return FALSE;
14
+	  }
15
+	}
16
+	return TRUE;
17 17
   }
18 18
 
19 19
 }
Please login to merge, or discard this patch.