Completed
Push — master ( 84e658...75d861 )
by Yannick
09:05
created
require/libs/geoPHP/tests/tests/20120702Test.php 2 patches
Indentation   +268 added lines, -268 removed lines patch added patch discarded remove patch
@@ -9,281 +9,281 @@
 block discarded – undo
9 9
   }
10 10
 
11 11
   function testMethods() {
12
-    $format = 'gpx';
13
-    $value = file_get_contents('./input/20120702.gpx');
14
-    $geometry = geoPHP::load($value, $format);
12
+	$format = 'gpx';
13
+	$value = file_get_contents('./input/20120702.gpx');
14
+	$geometry = geoPHP::load($value, $format);
15 15
 
16
-    $methods = array(
17
-      array('name' => 'area'),
18
-      array('name' => 'boundary'),
19
-      array('name' => 'getBBox'),
20
-      array('name' => 'centroid'),
21
-      array('name' => 'length'),
22
-      array('name' => 'greatCircleLength', 'argument' => 6378137),
23
-      array('name' => 'haversineLength'),
24
-      array('name' => 'y'),
25
-      array('name' => 'x'),
26
-      array('name' => 'numGeometries'),
27
-      array('name' => 'geometryN', 'argument' => '1'),
28
-      array('name' => 'startPoint'),
29
-      array('name' => 'endPoint'),
30
-      array('name' => 'isRing'),
31
-      array('name' => 'isClosed'),
32
-      array('name' => 'numPoints'),
33
-      array('name' => 'pointN', 'argument' => '1'),
34
-      array('name' => 'exteriorRing'),
35
-      array('name' => 'numInteriorRings'),
36
-      array('name' => 'interiorRingN', 'argument' => '1'),
37
-      array('name' => 'dimension'),
38
-      array('name' => 'geometryType'),
39
-      array('name' => 'SRID'),
40
-      array('name' => 'setSRID', 'argument' => '4326'),
41
-    );
16
+	$methods = array(
17
+	  array('name' => 'area'),
18
+	  array('name' => 'boundary'),
19
+	  array('name' => 'getBBox'),
20
+	  array('name' => 'centroid'),
21
+	  array('name' => 'length'),
22
+	  array('name' => 'greatCircleLength', 'argument' => 6378137),
23
+	  array('name' => 'haversineLength'),
24
+	  array('name' => 'y'),
25
+	  array('name' => 'x'),
26
+	  array('name' => 'numGeometries'),
27
+	  array('name' => 'geometryN', 'argument' => '1'),
28
+	  array('name' => 'startPoint'),
29
+	  array('name' => 'endPoint'),
30
+	  array('name' => 'isRing'),
31
+	  array('name' => 'isClosed'),
32
+	  array('name' => 'numPoints'),
33
+	  array('name' => 'pointN', 'argument' => '1'),
34
+	  array('name' => 'exteriorRing'),
35
+	  array('name' => 'numInteriorRings'),
36
+	  array('name' => 'interiorRingN', 'argument' => '1'),
37
+	  array('name' => 'dimension'),
38
+	  array('name' => 'geometryType'),
39
+	  array('name' => 'SRID'),
40
+	  array('name' => 'setSRID', 'argument' => '4326'),
41
+	);
42 42
 
43
-    foreach($methods as $method) {
44
-      $argument = NULL;
45
-      $method_name = $method['name'];
46
-      if (isset($method['argument'])) {
47
-        $argument = $method['argument'];
48
-      }
49
-      $this->_methods_tester($geometry, $method_name, $argument);
50
-    }
43
+	foreach($methods as $method) {
44
+	  $argument = NULL;
45
+	  $method_name = $method['name'];
46
+	  if (isset($method['argument'])) {
47
+		$argument = $method['argument'];
48
+	  }
49
+	  $this->_methods_tester($geometry, $method_name, $argument);
50
+	}
51 51
   }
52 52
 
53 53
   function _methods_tester($geometry, $method_name, $argument) {
54 54
 
55
-    if (!method_exists($geometry, $method_name)) {
56
-      $this->fail("Method ".$method_name.'() doesn\'t exists.');
57
-      return;
58
-    }
55
+	if (!method_exists($geometry, $method_name)) {
56
+	  $this->fail("Method ".$method_name.'() doesn\'t exists.');
57
+	  return;
58
+	}
59 59
 
60
-    switch ($method_name) {
61
-      case 'y':
62
-      case 'x':
63
-        if ($geometry->geometryType() == 'Point') {
64
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
65
-        }
66
-        if ($geometry->geometryType() == 'LineString') {
67
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
68
-        }
69
-        if ($geometry->geometryType() == 'MultiLineString') {
70
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
71
-        }
72
-        break;
73
-      case 'geometryN':
74
-        if ($geometry->geometryType() == 'Point') {
75
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
76
-        }
77
-        if ($geometry->geometryType() == 'LineString') {
78
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
79
-        }
80
-        if ($geometry->geometryType() == 'MultiLineString') {
81
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
82
-        }
83
-        break;
84
-      case 'startPoint':
85
-        if ($geometry->geometryType() == 'Point') {
86
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
87
-        }
88
-        if ($geometry->geometryType() == 'LineString') {
89
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
90
-        }
91
-        if ($geometry->geometryType() == 'MultiLineString') {
92
-          //TODO: Add a method startPoint() to MultiLineString.
93
-          //$this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
94
-        }
95
-        break;
96
-      case 'endPoint':
97
-        if ($geometry->geometryType() == 'Point') {
98
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
99
-        }
100
-        if ($geometry->geometryType() == 'LineString') {
101
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
102
-        }
103
-        if ($geometry->geometryType() == 'MultiLineString') {
104
-          //TODO: Add a method endPoint() to MultiLineString.
105
-          //$this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
106
-        }
107
-        break;
108
-      case 'isRing':
109
-        if ($geometry->geometryType() == 'Point') {
110
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
111
-        }
112
-        if ($geometry->geometryType() == 'LineString') {
113
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
114
-        }
115
-        if ($geometry->geometryType() == 'MultiLineString') {
116
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
117
-        }
118
-        break;
119
-      case 'isClosed':
120
-        if ($geometry->geometryType() == 'Point') {
121
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
122
-        }
123
-        if ($geometry->geometryType() == 'LineString') {
124
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
125
-        }
126
-        if ($geometry->geometryType() == 'MultiLineString') {
127
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
128
-        }
129
-        break;
130
-      case 'pointN':
131
-        if ($geometry->geometryType() == 'Point') {
132
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
133
-        }
134
-        if ($geometry->geometryType() == 'LineString') {
135
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
136
-        }
137
-        if ($geometry->geometryType() == 'MultiLineString') {
138
-          //TODO: Add a method pointN() to MultiLineString.
139
-          //$this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
140
-        }
141
-        break;
142
-      case 'exteriorRing':
143
-        if ($geometry->geometryType() == 'Point') {
144
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
145
-        }
146
-        if ($geometry->geometryType() == 'LineString') {
147
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
148
-        }
149
-        if ($geometry->geometryType() == 'MultiLineString') {
150
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
151
-        }
152
-        break;
153
-      case 'numInteriorRings':
154
-        if ($geometry->geometryType() == 'Point') {
155
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
156
-        }
157
-        if ($geometry->geometryType() == 'LineString') {
158
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
159
-        }
160
-        if ($geometry->geometryType() == 'MultiLineString') {
161
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
162
-        }
163
-        break;
164
-      case 'interiorRingN':
165
-        if ($geometry->geometryType() == 'Point') {
166
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
167
-        }
168
-        if ($geometry->geometryType() == 'LineString') {
169
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
170
-        }
171
-        if ($geometry->geometryType() == 'MultiLineString') {
172
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
173
-        }
174
-        break;
175
-      case 'setSRID':
176
-        //TODO: The method setSRID() should return TRUE.
177
-        break;
178
-      case 'SRID':
179
-        if ($geometry->geometryType() == 'Point') {
180
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
181
-        }
182
-        if ($geometry->geometryType() == 'LineString') {
183
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
184
-        }
185
-        if ($geometry->geometryType() == 'MultiLineString') {
186
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
187
-        }
188
-        break;
189
-      case 'getBBox':
190
-        if ($geometry->geometryType() == 'Point') {
191
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
192
-        }
193
-        if ($geometry->geometryType() == 'LineString') {
194
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
195
-        }
196
-        if ($geometry->geometryType() == 'MultiLineString') {
197
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
198
-        }
199
-        break;
200
-      case 'centroid':
201
-        if ($geometry->geometryType() == 'Point') {
202
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
203
-        }
204
-        if ($geometry->geometryType() == 'LineString') {
205
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
206
-        }
207
-        if ($geometry->geometryType() == 'MultiLineString') {
208
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
209
-        }
210
-        break;
211
-      case 'length':
212
-        if ($geometry->geometryType() == 'Point') {
213
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
214
-        }
215
-        if ($geometry->geometryType() == 'LineString') {
216
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
217
-        }
218
-        if ($geometry->geometryType() == 'MultiLineString') {
219
-          $this->assertEquals($geometry->$method_name($argument), (float) '0.11624637315233', 'Failed on ' . $method_name);
220
-        }
221
-        break;
222
-      case 'numGeometries':
223
-        if ($geometry->geometryType() == 'Point') {
224
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
225
-        }
226
-        if ($geometry->geometryType() == 'LineString') {
227
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
228
-        }
229
-        if ($geometry->geometryType() == 'MultiLineString') {
230
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
231
-        }
232
-        break;
233
-      case 'numPoints':
234
-        if ($geometry->geometryType() == 'Point') {
235
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
236
-        }
237
-        if ($geometry->geometryType() == 'LineString') {
238
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
239
-        }
240
-        if ($geometry->geometryType() == 'MultiLineString') {
241
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
242
-        }
243
-        break;
244
-      case 'dimension':
245
-        if ($geometry->geometryType() == 'Point') {
246
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
247
-        }
248
-        if ($geometry->geometryType() == 'LineString') {
249
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
250
-        }
251
-        if ($geometry->geometryType() == 'MultiLineString') {
252
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
253
-        }
254
-        break;
255
-      case 'boundary':
256
-        if ($geometry->geometryType() == 'Point') {
257
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
258
-        }
259
-        if ($geometry->geometryType() == 'LineString') {
260
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
261
-        }
262
-        if ($geometry->geometryType() == 'MultiLineString') {
263
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
264
-        }
265
-        break;
266
-      case 'greatCircleLength':
267
-        if ($geometry->geometryType() == 'Point') {
268
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
269
-        }
270
-        if ($geometry->geometryType() == 'LineString') {
271
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
272
-        }
273
-        if ($geometry->geometryType() == 'MultiLineString') {
274
-          $this->assertNotEquals($geometry->$method_name($argument), '9500.9359867418', 'Failed on ' . $method_name);
275
-        }
276
-        break;
277
-      case 'haversineLength':
278
-      case 'area':
279
-        $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
280
-        break;
281
-      case 'geometryType':
282
-        $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
283
-        break;
284
-      default:
285
-        $this->assertTrue($geometry->$method_name($argument), 'Failed on ' . $method_name);
286
-    }
60
+	switch ($method_name) {
61
+	  case 'y':
62
+	  case 'x':
63
+		if ($geometry->geometryType() == 'Point') {
64
+		  $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
65
+		}
66
+		if ($geometry->geometryType() == 'LineString') {
67
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
68
+		}
69
+		if ($geometry->geometryType() == 'MultiLineString') {
70
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
71
+		}
72
+		break;
73
+	  case 'geometryN':
74
+		if ($geometry->geometryType() == 'Point') {
75
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
76
+		}
77
+		if ($geometry->geometryType() == 'LineString') {
78
+		  $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
79
+		}
80
+		if ($geometry->geometryType() == 'MultiLineString') {
81
+		  $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
82
+		}
83
+		break;
84
+	  case 'startPoint':
85
+		if ($geometry->geometryType() == 'Point') {
86
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
87
+		}
88
+		if ($geometry->geometryType() == 'LineString') {
89
+		  $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
90
+		}
91
+		if ($geometry->geometryType() == 'MultiLineString') {
92
+		  //TODO: Add a method startPoint() to MultiLineString.
93
+		  //$this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
94
+		}
95
+		break;
96
+	  case 'endPoint':
97
+		if ($geometry->geometryType() == 'Point') {
98
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
99
+		}
100
+		if ($geometry->geometryType() == 'LineString') {
101
+		  $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
102
+		}
103
+		if ($geometry->geometryType() == 'MultiLineString') {
104
+		  //TODO: Add a method endPoint() to MultiLineString.
105
+		  //$this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
106
+		}
107
+		break;
108
+	  case 'isRing':
109
+		if ($geometry->geometryType() == 'Point') {
110
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
111
+		}
112
+		if ($geometry->geometryType() == 'LineString') {
113
+		  $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
114
+		}
115
+		if ($geometry->geometryType() == 'MultiLineString') {
116
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
117
+		}
118
+		break;
119
+	  case 'isClosed':
120
+		if ($geometry->geometryType() == 'Point') {
121
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
122
+		}
123
+		if ($geometry->geometryType() == 'LineString') {
124
+		  $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
125
+		}
126
+		if ($geometry->geometryType() == 'MultiLineString') {
127
+		  $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
128
+		}
129
+		break;
130
+	  case 'pointN':
131
+		if ($geometry->geometryType() == 'Point') {
132
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
133
+		}
134
+		if ($geometry->geometryType() == 'LineString') {
135
+		  $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
136
+		}
137
+		if ($geometry->geometryType() == 'MultiLineString') {
138
+		  //TODO: Add a method pointN() to MultiLineString.
139
+		  //$this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
140
+		}
141
+		break;
142
+	  case 'exteriorRing':
143
+		if ($geometry->geometryType() == 'Point') {
144
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
145
+		}
146
+		if ($geometry->geometryType() == 'LineString') {
147
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
148
+		}
149
+		if ($geometry->geometryType() == 'MultiLineString') {
150
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
151
+		}
152
+		break;
153
+	  case 'numInteriorRings':
154
+		if ($geometry->geometryType() == 'Point') {
155
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
156
+		}
157
+		if ($geometry->geometryType() == 'LineString') {
158
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
159
+		}
160
+		if ($geometry->geometryType() == 'MultiLineString') {
161
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
162
+		}
163
+		break;
164
+	  case 'interiorRingN':
165
+		if ($geometry->geometryType() == 'Point') {
166
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
167
+		}
168
+		if ($geometry->geometryType() == 'LineString') {
169
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
170
+		}
171
+		if ($geometry->geometryType() == 'MultiLineString') {
172
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
173
+		}
174
+		break;
175
+	  case 'setSRID':
176
+		//TODO: The method setSRID() should return TRUE.
177
+		break;
178
+	  case 'SRID':
179
+		if ($geometry->geometryType() == 'Point') {
180
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
181
+		}
182
+		if ($geometry->geometryType() == 'LineString') {
183
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
184
+		}
185
+		if ($geometry->geometryType() == 'MultiLineString') {
186
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
187
+		}
188
+		break;
189
+	  case 'getBBox':
190
+		if ($geometry->geometryType() == 'Point') {
191
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
192
+		}
193
+		if ($geometry->geometryType() == 'LineString') {
194
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
195
+		}
196
+		if ($geometry->geometryType() == 'MultiLineString') {
197
+		  $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
198
+		}
199
+		break;
200
+	  case 'centroid':
201
+		if ($geometry->geometryType() == 'Point') {
202
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
203
+		}
204
+		if ($geometry->geometryType() == 'LineString') {
205
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
206
+		}
207
+		if ($geometry->geometryType() == 'MultiLineString') {
208
+		  $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
209
+		}
210
+		break;
211
+	  case 'length':
212
+		if ($geometry->geometryType() == 'Point') {
213
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
214
+		}
215
+		if ($geometry->geometryType() == 'LineString') {
216
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
217
+		}
218
+		if ($geometry->geometryType() == 'MultiLineString') {
219
+		  $this->assertEquals($geometry->$method_name($argument), (float) '0.11624637315233', 'Failed on ' . $method_name);
220
+		}
221
+		break;
222
+	  case 'numGeometries':
223
+		if ($geometry->geometryType() == 'Point') {
224
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
225
+		}
226
+		if ($geometry->geometryType() == 'LineString') {
227
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
228
+		}
229
+		if ($geometry->geometryType() == 'MultiLineString') {
230
+		  $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
231
+		}
232
+		break;
233
+	  case 'numPoints':
234
+		if ($geometry->geometryType() == 'Point') {
235
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
236
+		}
237
+		if ($geometry->geometryType() == 'LineString') {
238
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
239
+		}
240
+		if ($geometry->geometryType() == 'MultiLineString') {
241
+		  $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
242
+		}
243
+		break;
244
+	  case 'dimension':
245
+		if ($geometry->geometryType() == 'Point') {
246
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
247
+		}
248
+		if ($geometry->geometryType() == 'LineString') {
249
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
250
+		}
251
+		if ($geometry->geometryType() == 'MultiLineString') {
252
+		  $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
253
+		}
254
+		break;
255
+	  case 'boundary':
256
+		if ($geometry->geometryType() == 'Point') {
257
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
258
+		}
259
+		if ($geometry->geometryType() == 'LineString') {
260
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
261
+		}
262
+		if ($geometry->geometryType() == 'MultiLineString') {
263
+		  $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
264
+		}
265
+		break;
266
+	  case 'greatCircleLength':
267
+		if ($geometry->geometryType() == 'Point') {
268
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
269
+		}
270
+		if ($geometry->geometryType() == 'LineString') {
271
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
272
+		}
273
+		if ($geometry->geometryType() == 'MultiLineString') {
274
+		  $this->assertNotEquals($geometry->$method_name($argument), '9500.9359867418', 'Failed on ' . $method_name);
275
+		}
276
+		break;
277
+	  case 'haversineLength':
278
+	  case 'area':
279
+		$this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
280
+		break;
281
+	  case 'geometryType':
282
+		$this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
283
+		break;
284
+	  default:
285
+		$this->assertTrue($geometry->$method_name($argument), 'Failed on ' . $method_name);
286
+	}
287 287
   }
288 288
 }
289 289
 
Please login to merge, or discard this patch.
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
       array('name' => 'setSRID', 'argument' => '4326'),
41 41
     );
42 42
 
43
-    foreach($methods as $method) {
43
+    foreach ($methods as $method) {
44 44
       $argument = NULL;
45 45
       $method_name = $method['name'];
46 46
       if (isset($method['argument'])) {
@@ -61,32 +61,32 @@  discard block
 block discarded – undo
61 61
       case 'y':
62 62
       case 'x':
63 63
         if ($geometry->geometryType() == 'Point') {
64
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
64
+          $this->assertNotNull($geometry->$method_name($argument), 'Failed on '.$method_name);
65 65
         }
66 66
         if ($geometry->geometryType() == 'LineString') {
67
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
67
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
68 68
         }
69 69
         if ($geometry->geometryType() == 'MultiLineString') {
70
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
70
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
71 71
         }
72 72
         break;
73 73
       case 'geometryN':
74 74
         if ($geometry->geometryType() == 'Point') {
75
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
75
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
76 76
         }
77 77
         if ($geometry->geometryType() == 'LineString') {
78
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
78
+          $this->assertNotNull($geometry->$method_name($argument), 'Failed on '.$method_name);
79 79
         }
80 80
         if ($geometry->geometryType() == 'MultiLineString') {
81
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
81
+          $this->assertNotNull($geometry->$method_name($argument), 'Failed on '.$method_name);
82 82
         }
83 83
         break;
84 84
       case 'startPoint':
85 85
         if ($geometry->geometryType() == 'Point') {
86
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
86
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
87 87
         }
88 88
         if ($geometry->geometryType() == 'LineString') {
89
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
89
+          $this->assertNotNull($geometry->$method_name($argument), 'Failed on '.$method_name);
90 90
         }
91 91
         if ($geometry->geometryType() == 'MultiLineString') {
92 92
           //TODO: Add a method startPoint() to MultiLineString.
@@ -95,10 +95,10 @@  discard block
 block discarded – undo
95 95
         break;
96 96
       case 'endPoint':
97 97
         if ($geometry->geometryType() == 'Point') {
98
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
98
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
99 99
         }
100 100
         if ($geometry->geometryType() == 'LineString') {
101
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
101
+          $this->assertNotNull($geometry->$method_name($argument), 'Failed on '.$method_name);
102 102
         }
103 103
         if ($geometry->geometryType() == 'MultiLineString') {
104 104
           //TODO: Add a method endPoint() to MultiLineString.
@@ -107,32 +107,32 @@  discard block
 block discarded – undo
107 107
         break;
108 108
       case 'isRing':
109 109
         if ($geometry->geometryType() == 'Point') {
110
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
110
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
111 111
         }
112 112
         if ($geometry->geometryType() == 'LineString') {
113
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
113
+          $this->assertNotNull($geometry->$method_name($argument), 'Failed on '.$method_name);
114 114
         }
115 115
         if ($geometry->geometryType() == 'MultiLineString') {
116
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
116
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
117 117
         }
118 118
         break;
119 119
       case 'isClosed':
120 120
         if ($geometry->geometryType() == 'Point') {
121
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
121
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
122 122
         }
123 123
         if ($geometry->geometryType() == 'LineString') {
124
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
124
+          $this->assertNotNull($geometry->$method_name($argument), 'Failed on '.$method_name);
125 125
         }
126 126
         if ($geometry->geometryType() == 'MultiLineString') {
127
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
127
+          $this->assertNotNull($geometry->$method_name($argument), 'Failed on '.$method_name);
128 128
         }
129 129
         break;
130 130
       case 'pointN':
131 131
         if ($geometry->geometryType() == 'Point') {
132
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
132
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
133 133
         }
134 134
         if ($geometry->geometryType() == 'LineString') {
135
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
135
+          $this->assertNotNull($geometry->$method_name($argument), 'Failed on '.$method_name);
136 136
         }
137 137
         if ($geometry->geometryType() == 'MultiLineString') {
138 138
           //TODO: Add a method pointN() to MultiLineString.
@@ -141,35 +141,35 @@  discard block
 block discarded – undo
141 141
         break;
142 142
       case 'exteriorRing':
143 143
         if ($geometry->geometryType() == 'Point') {
144
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
144
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
145 145
         }
146 146
         if ($geometry->geometryType() == 'LineString') {
147
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
147
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
148 148
         }
149 149
         if ($geometry->geometryType() == 'MultiLineString') {
150
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
150
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
151 151
         }
152 152
         break;
153 153
       case 'numInteriorRings':
154 154
         if ($geometry->geometryType() == 'Point') {
155
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
155
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
156 156
         }
157 157
         if ($geometry->geometryType() == 'LineString') {
158
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
158
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
159 159
         }
160 160
         if ($geometry->geometryType() == 'MultiLineString') {
161
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
161
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
162 162
         }
163 163
         break;
164 164
       case 'interiorRingN':
165 165
         if ($geometry->geometryType() == 'Point') {
166
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
166
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
167 167
         }
168 168
         if ($geometry->geometryType() == 'LineString') {
169
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
169
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
170 170
         }
171 171
         if ($geometry->geometryType() == 'MultiLineString') {
172
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
172
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
173 173
         }
174 174
         break;
175 175
       case 'setSRID':
@@ -177,112 +177,112 @@  discard block
 block discarded – undo
177 177
         break;
178 178
       case 'SRID':
179 179
         if ($geometry->geometryType() == 'Point') {
180
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
180
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
181 181
         }
182 182
         if ($geometry->geometryType() == 'LineString') {
183
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
183
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
184 184
         }
185 185
         if ($geometry->geometryType() == 'MultiLineString') {
186
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
186
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
187 187
         }
188 188
         break;
189 189
       case 'getBBox':
190 190
         if ($geometry->geometryType() == 'Point') {
191
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
191
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
192 192
         }
193 193
         if ($geometry->geometryType() == 'LineString') {
194
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
194
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
195 195
         }
196 196
         if ($geometry->geometryType() == 'MultiLineString') {
197
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
197
+          $this->assertNotNull($geometry->$method_name($argument), 'Failed on '.$method_name);
198 198
         }
199 199
         break;
200 200
       case 'centroid':
201 201
         if ($geometry->geometryType() == 'Point') {
202
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
202
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
203 203
         }
204 204
         if ($geometry->geometryType() == 'LineString') {
205
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
205
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
206 206
         }
207 207
         if ($geometry->geometryType() == 'MultiLineString') {
208
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
208
+          $this->assertNotNull($geometry->$method_name($argument), 'Failed on '.$method_name);
209 209
         }
210 210
         break;
211 211
       case 'length':
212 212
         if ($geometry->geometryType() == 'Point') {
213
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
213
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
214 214
         }
215 215
         if ($geometry->geometryType() == 'LineString') {
216
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
216
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
217 217
         }
218 218
         if ($geometry->geometryType() == 'MultiLineString') {
219
-          $this->assertEquals($geometry->$method_name($argument), (float) '0.11624637315233', 'Failed on ' . $method_name);
219
+          $this->assertEquals($geometry->$method_name($argument), (float) '0.11624637315233', 'Failed on '.$method_name);
220 220
         }
221 221
         break;
222 222
       case 'numGeometries':
223 223
         if ($geometry->geometryType() == 'Point') {
224
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
224
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
225 225
         }
226 226
         if ($geometry->geometryType() == 'LineString') {
227
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
227
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
228 228
         }
229 229
         if ($geometry->geometryType() == 'MultiLineString') {
230
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
230
+          $this->assertNotNull($geometry->$method_name($argument), 'Failed on '.$method_name);
231 231
         }
232 232
         break;
233 233
       case 'numPoints':
234 234
         if ($geometry->geometryType() == 'Point') {
235
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
235
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
236 236
         }
237 237
         if ($geometry->geometryType() == 'LineString') {
238
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
238
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
239 239
         }
240 240
         if ($geometry->geometryType() == 'MultiLineString') {
241
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
241
+          $this->assertNotNull($geometry->$method_name($argument), 'Failed on '.$method_name);
242 242
         }
243 243
         break;
244 244
       case 'dimension':
245 245
         if ($geometry->geometryType() == 'Point') {
246
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
246
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
247 247
         }
248 248
         if ($geometry->geometryType() == 'LineString') {
249
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
249
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
250 250
         }
251 251
         if ($geometry->geometryType() == 'MultiLineString') {
252
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
252
+          $this->assertNotNull($geometry->$method_name($argument), 'Failed on '.$method_name);
253 253
         }
254 254
         break;
255 255
       case 'boundary':
256 256
         if ($geometry->geometryType() == 'Point') {
257
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
257
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
258 258
         }
259 259
         if ($geometry->geometryType() == 'LineString') {
260
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
260
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
261 261
         }
262 262
         if ($geometry->geometryType() == 'MultiLineString') {
263
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
263
+          $this->assertNotNull($geometry->$method_name($argument), 'Failed on '.$method_name);
264 264
         }
265 265
         break;
266 266
       case 'greatCircleLength':
267 267
         if ($geometry->geometryType() == 'Point') {
268
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
268
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
269 269
         }
270 270
         if ($geometry->geometryType() == 'LineString') {
271
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
271
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
272 272
         }
273 273
         if ($geometry->geometryType() == 'MultiLineString') {
274
-          $this->assertNotEquals($geometry->$method_name($argument), '9500.9359867418', 'Failed on ' . $method_name);
274
+          $this->assertNotEquals($geometry->$method_name($argument), '9500.9359867418', 'Failed on '.$method_name);
275 275
         }
276 276
         break;
277 277
       case 'haversineLength':
278 278
       case 'area':
279
-        $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
279
+        $this->assertNotNull($geometry->$method_name($argument), 'Failed on '.$method_name);
280 280
         break;
281 281
       case 'geometryType':
282
-        $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
282
+        $this->assertNotNull($geometry->$method_name($argument), 'Failed on '.$method_name);
283 283
         break;
284 284
       default:
285
-        $this->assertTrue($geometry->$method_name($argument), 'Failed on ' . $method_name);
285
+        $this->assertTrue($geometry->$method_name($argument), 'Failed on '.$method_name);
286 286
     }
287 287
   }
288 288
 }
Please login to merge, or discard this patch.
require/libs/geoPHP/tests/tests/geosTest.php 2 patches
Indentation   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -9,78 +9,78 @@
 block discarded – undo
9 9
   }
10 10
 
11 11
   function testGeos() {
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
-        $geosMethods = array(
20
-          array('name' => 'geos'),
21
-          array('name' => 'setGeos', 'argument' => $geometry->geos()),
22
-          array('name' => 'PointOnSurface'),
23
-          array('name' => 'equals', 'argument' => $geometry),
24
-          array('name' => 'equalsExact', 'argument' => $geometry),
25
-          array('name' => 'relate', 'argument' => $geometry),
26
-          array('name' => 'checkValidity'),
27
-          array('name' => 'isSimple'),
28
-          array('name' => 'buffer', 'argument' => '10'),
29
-          array('name' => 'intersection', 'argument' => $geometry),
30
-          array('name' => 'convexHull'),
31
-          array('name' => 'difference', 'argument' => $geometry),
32
-          array('name' => 'symDifference', 'argument' => $geometry),
33
-          array('name' => 'union', 'argument' => $geometry),
34
-          array('name' => 'simplify', 'argument' => '0'),
35
-          array('name' => 'disjoint', 'argument' => $geometry),
36
-          array('name' => 'touches', 'argument' => $geometry),
37
-          array('name' => 'intersects', 'argument' => $geometry),
38
-          array('name' => 'crosses', 'argument' => $geometry),
39
-          array('name' => 'within', 'argument' => $geometry),
40
-          array('name' => 'contains', 'argument' => $geometry),
41
-          array('name' => 'overlaps', 'argument' => $geometry),
42
-          array('name' => 'covers', 'argument' => $geometry),
43
-          array('name' => 'coveredBy', 'argument' => $geometry),
44
-          array('name' => 'distance', 'argument' => $geometry),
45
-          array('name' => 'hausdorffDistance', 'argument' => $geometry),
46
-        );
19
+		$geosMethods = array(
20
+		  array('name' => 'geos'),
21
+		  array('name' => 'setGeos', 'argument' => $geometry->geos()),
22
+		  array('name' => 'PointOnSurface'),
23
+		  array('name' => 'equals', 'argument' => $geometry),
24
+		  array('name' => 'equalsExact', 'argument' => $geometry),
25
+		  array('name' => 'relate', 'argument' => $geometry),
26
+		  array('name' => 'checkValidity'),
27
+		  array('name' => 'isSimple'),
28
+		  array('name' => 'buffer', 'argument' => '10'),
29
+		  array('name' => 'intersection', 'argument' => $geometry),
30
+		  array('name' => 'convexHull'),
31
+		  array('name' => 'difference', 'argument' => $geometry),
32
+		  array('name' => 'symDifference', 'argument' => $geometry),
33
+		  array('name' => 'union', 'argument' => $geometry),
34
+		  array('name' => 'simplify', 'argument' => '0'),
35
+		  array('name' => 'disjoint', 'argument' => $geometry),
36
+		  array('name' => 'touches', 'argument' => $geometry),
37
+		  array('name' => 'intersects', 'argument' => $geometry),
38
+		  array('name' => 'crosses', 'argument' => $geometry),
39
+		  array('name' => 'within', 'argument' => $geometry),
40
+		  array('name' => 'contains', 'argument' => $geometry),
41
+		  array('name' => 'overlaps', 'argument' => $geometry),
42
+		  array('name' => 'covers', 'argument' => $geometry),
43
+		  array('name' => 'coveredBy', 'argument' => $geometry),
44
+		  array('name' => 'distance', 'argument' => $geometry),
45
+		  array('name' => 'hausdorffDistance', 'argument' => $geometry),
46
+		);
47 47
 
48
-        foreach($geosMethods as $method) {
49
-          $argument = NULL;
50
-          $method_name = $method['name'];
51
-          if (isset($method['argument'])) {
52
-            $argument = $method['argument'];
53
-          }
48
+		foreach($geosMethods as $method) {
49
+		  $argument = NULL;
50
+		  $method_name = $method['name'];
51
+		  if (isset($method['argument'])) {
52
+			$argument = $method['argument'];
53
+		  }
54 54
 
55
-          switch ($method_name) {
56
-            case 'isSimple':
57
-            case 'equals':
58
-            case 'geos':
59
-              if ($geometry->geometryType() == 'Point') {
60
-                $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
61
-              }
62
-              if ($geometry->geometryType() == 'LineString') {
63
-                $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
64
-              }
65
-              if ($geometry->geometryType() == 'MultiLineString') {
66
-                $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
67
-              }
68
-              break;
69
-            default:
70
-              if ($geometry->geometryType() == 'Point') {
71
-                $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
72
-              }
73
-              if ($geometry->geometryType() == 'LineString') {
74
-                $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
75
-              }
76
-              if ($geometry->geometryType() == 'MultiLineString') {
77
-                $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
78
-              }
79
-          }
80
-        }
55
+		  switch ($method_name) {
56
+			case 'isSimple':
57
+			case 'equals':
58
+			case 'geos':
59
+			  if ($geometry->geometryType() == 'Point') {
60
+				$this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
61
+			  }
62
+			  if ($geometry->geometryType() == 'LineString') {
63
+				$this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
64
+			  }
65
+			  if ($geometry->geometryType() == 'MultiLineString') {
66
+				$this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
67
+			  }
68
+			  break;
69
+			default:
70
+			  if ($geometry->geometryType() == 'Point') {
71
+				$this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
72
+			  }
73
+			  if ($geometry->geometryType() == 'LineString') {
74
+				$this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
75
+			  }
76
+			  if ($geometry->geometryType() == 'MultiLineString') {
77
+				$this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
78
+			  }
79
+		  }
80
+		}
81 81
 
82
-      }
83
-    }
82
+	  }
83
+	}
84 84
   }
85 85
 
86 86
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 
11 11
   function testGeos() {
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);
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
           array('name' => 'hausdorffDistance', 'argument' => $geometry),
46 46
         );
47 47
 
48
-        foreach($geosMethods as $method) {
48
+        foreach ($geosMethods as $method) {
49 49
           $argument = NULL;
50 50
           $method_name = $method['name'];
51 51
           if (isset($method['argument'])) {
@@ -57,24 +57,24 @@  discard block
 block discarded – undo
57 57
             case 'equals':
58 58
             case 'geos':
59 59
               if ($geometry->geometryType() == 'Point') {
60
-                $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
60
+                $this->assertNotNull($geometry->$method_name($argument), 'Failed on '.$method_name);
61 61
               }
62 62
               if ($geometry->geometryType() == 'LineString') {
63
-                $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
63
+                $this->assertNotNull($geometry->$method_name($argument), 'Failed on '.$method_name);
64 64
               }
65 65
               if ($geometry->geometryType() == 'MultiLineString') {
66
-                $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
66
+                $this->assertNotNull($geometry->$method_name($argument), 'Failed on '.$method_name);
67 67
               }
68 68
               break;
69 69
             default:
70 70
               if ($geometry->geometryType() == 'Point') {
71
-                $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
71
+                $this->assertNotNull($geometry->$method_name($argument), 'Failed on '.$method_name);
72 72
               }
73 73
               if ($geometry->geometryType() == 'LineString') {
74
-                $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
74
+                $this->assertNotNull($geometry->$method_name($argument), 'Failed on '.$method_name);
75 75
               }
76 76
               if ($geometry->geometryType() == 'MultiLineString') {
77
-                $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
77
+                $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
78 78
               }
79 79
           }
80 80
         }
Please login to merge, or discard this patch.
require/libs/geoPHP/tests/tests/aliasesTest.php 2 patches
Indentation   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -9,101 +9,101 @@
 block discarded – undo
9 9
   }
10 10
 
11 11
   function testAliases() {
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
-        $aliases = array(
20
-          array('name' => 'getCentroid'),
21
-          array('name' => 'getArea'),
22
-          array('name' => 'getX'),
23
-          array('name' => 'getY'),
24
-          array('name' => 'getGeos'),
25
-          array('name' => 'getGeomType'),
26
-          array('name' => 'getSRID'),
27
-          array('name' => 'asText'),
28
-          array('name' => 'asBinary'),
29
-        );
19
+		$aliases = array(
20
+		  array('name' => 'getCentroid'),
21
+		  array('name' => 'getArea'),
22
+		  array('name' => 'getX'),
23
+		  array('name' => 'getY'),
24
+		  array('name' => 'getGeos'),
25
+		  array('name' => 'getGeomType'),
26
+		  array('name' => 'getSRID'),
27
+		  array('name' => 'asText'),
28
+		  array('name' => 'asBinary'),
29
+		);
30 30
 
31
-        foreach($aliases as $alias) {
32
-          $argument = NULL;
33
-          $alias_name = $alias['name'];
34
-          if (isset($alias['argument'])) {
35
-            $argument = $alias['argument'];
36
-          }
31
+		foreach($aliases as $alias) {
32
+		  $argument = NULL;
33
+		  $alias_name = $alias['name'];
34
+		  if (isset($alias['argument'])) {
35
+			$argument = $alias['argument'];
36
+		  }
37 37
 
38
-          switch ($alias_name) {
39
-            case 'getSRID':
40
-              if ($geometry->geometryType() == 'Point') {
41
-                $this->assertNotNull($geometry->$alias_name($argument), 'Failed on ' . $alias_name);
42
-              }
43
-              if ($geometry->geometryType() == 'LineString') {
44
-                $this->assertNotNull($geometry->$alias_name($argument), 'Failed on ' . $alias_name);
45
-              }
46
-              if ($geometry->geometryType() == 'MultiLineString') {
47
-                $this->assertNull($geometry->$alias_name($argument), 'Failed on ' . $alias_name);
48
-              }
49
-              break;
50
-            case 'getGeos':
51
-              if ($geometry->geometryType() == 'Point') {
52
-                $this->assertNotNull($geometry->$alias_name($argument), 'Failed on ' . $alias_name);
53
-              }
54
-              if ($geometry->geometryType() == 'LineString') {
55
-                $this->assertNotNull($geometry->$alias_name($argument), 'Failed on ' . $alias_name);
56
-              }
57
-              if ($geometry->geometryType() == 'MultiLineString') {
58
-                $this->assertNotNull($geometry->$alias_name($argument), 'Failed on ' . $alias_name);
59
-              }
60
-              break;
61
-            case 'getX':
62
-            case 'getY':
63
-              if ($geometry->geometryType() == 'Point') {
64
-                $this->assertNotNull($geometry->$alias_name($argument), 'Failed on ' . $alias_name);
65
-              }
66
-              if ($geometry->geometryType() == 'LineString') {
67
-                $this->assertNull($geometry->$alias_name($argument), 'Failed on ' . $alias_name);
68
-              }
69
-              if ($geometry->geometryType() == 'MultiLineString') {
70
-                $this->assertNull($geometry->$alias_name($argument), 'Failed on ' . $alias_name);
71
-              }
72
-              break;
73
-            case 'getArea':
74
-              if ($geometry->geometryType() == 'Point') {
75
-                $this->assertNull($geometry->$alias_name($argument), 'Failed on ' . $alias_name);
76
-              }
77
-              if ($geometry->geometryType() == 'LineString') {
78
-                $this->assertNull($geometry->$alias_name($argument), 'Failed on ' . $alias_name);
79
-              }
80
-              if ($geometry->geometryType() == 'MultiLineString') {
81
-                $this->assertNotNull($geometry->$alias_name($argument), 'Failed on ' . $alias_name);
82
-              }
83
-              break;
84
-            case 'getCentroid':
85
-              if ($geometry->geometryType() == 'Point') {
86
-                $this->assertNotNull($geometry->$alias_name($argument), 'Failed on ' . $alias_name);
87
-              }
88
-              if ($geometry->geometryType() == 'LineString') {
89
-                $this->assertNotNull($geometry->$alias_name($argument), 'Failed on ' . $alias_name);
90
-              }
91
-              if ($geometry->geometryType() == 'MultiLineString') {
92
-                $this->assertNotNull($geometry->$alias_name($argument), 'Failed on ' . $alias_name);
93
-              }
94
-              break;
95
-            case 'asText':
96
-            case 'asBinary':
97
-            case 'getGeomType':
98
-              $this->assertNotNull($geometry->$alias_name($argument), 'Failed on ' . $alias_name);
99
-              break;
100
-            default:
101
-              $this->assertTrue($geometry->$alias_name($argument), 'Failed on ' . $alias_name);
102
-          }
103
-        }
38
+		  switch ($alias_name) {
39
+			case 'getSRID':
40
+			  if ($geometry->geometryType() == 'Point') {
41
+				$this->assertNotNull($geometry->$alias_name($argument), 'Failed on ' . $alias_name);
42
+			  }
43
+			  if ($geometry->geometryType() == 'LineString') {
44
+				$this->assertNotNull($geometry->$alias_name($argument), 'Failed on ' . $alias_name);
45
+			  }
46
+			  if ($geometry->geometryType() == 'MultiLineString') {
47
+				$this->assertNull($geometry->$alias_name($argument), 'Failed on ' . $alias_name);
48
+			  }
49
+			  break;
50
+			case 'getGeos':
51
+			  if ($geometry->geometryType() == 'Point') {
52
+				$this->assertNotNull($geometry->$alias_name($argument), 'Failed on ' . $alias_name);
53
+			  }
54
+			  if ($geometry->geometryType() == 'LineString') {
55
+				$this->assertNotNull($geometry->$alias_name($argument), 'Failed on ' . $alias_name);
56
+			  }
57
+			  if ($geometry->geometryType() == 'MultiLineString') {
58
+				$this->assertNotNull($geometry->$alias_name($argument), 'Failed on ' . $alias_name);
59
+			  }
60
+			  break;
61
+			case 'getX':
62
+			case 'getY':
63
+			  if ($geometry->geometryType() == 'Point') {
64
+				$this->assertNotNull($geometry->$alias_name($argument), 'Failed on ' . $alias_name);
65
+			  }
66
+			  if ($geometry->geometryType() == 'LineString') {
67
+				$this->assertNull($geometry->$alias_name($argument), 'Failed on ' . $alias_name);
68
+			  }
69
+			  if ($geometry->geometryType() == 'MultiLineString') {
70
+				$this->assertNull($geometry->$alias_name($argument), 'Failed on ' . $alias_name);
71
+			  }
72
+			  break;
73
+			case 'getArea':
74
+			  if ($geometry->geometryType() == 'Point') {
75
+				$this->assertNull($geometry->$alias_name($argument), 'Failed on ' . $alias_name);
76
+			  }
77
+			  if ($geometry->geometryType() == 'LineString') {
78
+				$this->assertNull($geometry->$alias_name($argument), 'Failed on ' . $alias_name);
79
+			  }
80
+			  if ($geometry->geometryType() == 'MultiLineString') {
81
+				$this->assertNotNull($geometry->$alias_name($argument), 'Failed on ' . $alias_name);
82
+			  }
83
+			  break;
84
+			case 'getCentroid':
85
+			  if ($geometry->geometryType() == 'Point') {
86
+				$this->assertNotNull($geometry->$alias_name($argument), 'Failed on ' . $alias_name);
87
+			  }
88
+			  if ($geometry->geometryType() == 'LineString') {
89
+				$this->assertNotNull($geometry->$alias_name($argument), 'Failed on ' . $alias_name);
90
+			  }
91
+			  if ($geometry->geometryType() == 'MultiLineString') {
92
+				$this->assertNotNull($geometry->$alias_name($argument), 'Failed on ' . $alias_name);
93
+			  }
94
+			  break;
95
+			case 'asText':
96
+			case 'asBinary':
97
+			case 'getGeomType':
98
+			  $this->assertNotNull($geometry->$alias_name($argument), 'Failed on ' . $alias_name);
99
+			  break;
100
+			default:
101
+			  $this->assertTrue($geometry->$alias_name($argument), 'Failed on ' . $alias_name);
102
+		  }
103
+		}
104 104
 
105
-      }
106
-    }
105
+	  }
106
+	}
107 107
   }
108 108
 
109 109
 }
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 
11 11
   function testAliases() {
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);
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
           array('name' => 'asBinary'),
29 29
         );
30 30
 
31
-        foreach($aliases as $alias) {
31
+        foreach ($aliases as $alias) {
32 32
           $argument = NULL;
33 33
           $alias_name = $alias['name'];
34 34
           if (isset($alias['argument'])) {
@@ -38,67 +38,67 @@  discard block
 block discarded – undo
38 38
           switch ($alias_name) {
39 39
             case 'getSRID':
40 40
               if ($geometry->geometryType() == 'Point') {
41
-                $this->assertNotNull($geometry->$alias_name($argument), 'Failed on ' . $alias_name);
41
+                $this->assertNotNull($geometry->$alias_name($argument), 'Failed on '.$alias_name);
42 42
               }
43 43
               if ($geometry->geometryType() == 'LineString') {
44
-                $this->assertNotNull($geometry->$alias_name($argument), 'Failed on ' . $alias_name);
44
+                $this->assertNotNull($geometry->$alias_name($argument), 'Failed on '.$alias_name);
45 45
               }
46 46
               if ($geometry->geometryType() == 'MultiLineString') {
47
-                $this->assertNull($geometry->$alias_name($argument), 'Failed on ' . $alias_name);
47
+                $this->assertNull($geometry->$alias_name($argument), 'Failed on '.$alias_name);
48 48
               }
49 49
               break;
50 50
             case 'getGeos':
51 51
               if ($geometry->geometryType() == 'Point') {
52
-                $this->assertNotNull($geometry->$alias_name($argument), 'Failed on ' . $alias_name);
52
+                $this->assertNotNull($geometry->$alias_name($argument), 'Failed on '.$alias_name);
53 53
               }
54 54
               if ($geometry->geometryType() == 'LineString') {
55
-                $this->assertNotNull($geometry->$alias_name($argument), 'Failed on ' . $alias_name);
55
+                $this->assertNotNull($geometry->$alias_name($argument), 'Failed on '.$alias_name);
56 56
               }
57 57
               if ($geometry->geometryType() == 'MultiLineString') {
58
-                $this->assertNotNull($geometry->$alias_name($argument), 'Failed on ' . $alias_name);
58
+                $this->assertNotNull($geometry->$alias_name($argument), 'Failed on '.$alias_name);
59 59
               }
60 60
               break;
61 61
             case 'getX':
62 62
             case 'getY':
63 63
               if ($geometry->geometryType() == 'Point') {
64
-                $this->assertNotNull($geometry->$alias_name($argument), 'Failed on ' . $alias_name);
64
+                $this->assertNotNull($geometry->$alias_name($argument), 'Failed on '.$alias_name);
65 65
               }
66 66
               if ($geometry->geometryType() == 'LineString') {
67
-                $this->assertNull($geometry->$alias_name($argument), 'Failed on ' . $alias_name);
67
+                $this->assertNull($geometry->$alias_name($argument), 'Failed on '.$alias_name);
68 68
               }
69 69
               if ($geometry->geometryType() == 'MultiLineString') {
70
-                $this->assertNull($geometry->$alias_name($argument), 'Failed on ' . $alias_name);
70
+                $this->assertNull($geometry->$alias_name($argument), 'Failed on '.$alias_name);
71 71
               }
72 72
               break;
73 73
             case 'getArea':
74 74
               if ($geometry->geometryType() == 'Point') {
75
-                $this->assertNull($geometry->$alias_name($argument), 'Failed on ' . $alias_name);
75
+                $this->assertNull($geometry->$alias_name($argument), 'Failed on '.$alias_name);
76 76
               }
77 77
               if ($geometry->geometryType() == 'LineString') {
78
-                $this->assertNull($geometry->$alias_name($argument), 'Failed on ' . $alias_name);
78
+                $this->assertNull($geometry->$alias_name($argument), 'Failed on '.$alias_name);
79 79
               }
80 80
               if ($geometry->geometryType() == 'MultiLineString') {
81
-                $this->assertNotNull($geometry->$alias_name($argument), 'Failed on ' . $alias_name);
81
+                $this->assertNotNull($geometry->$alias_name($argument), 'Failed on '.$alias_name);
82 82
               }
83 83
               break;
84 84
             case 'getCentroid':
85 85
               if ($geometry->geometryType() == 'Point') {
86
-                $this->assertNotNull($geometry->$alias_name($argument), 'Failed on ' . $alias_name);
86
+                $this->assertNotNull($geometry->$alias_name($argument), 'Failed on '.$alias_name);
87 87
               }
88 88
               if ($geometry->geometryType() == 'LineString') {
89
-                $this->assertNotNull($geometry->$alias_name($argument), 'Failed on ' . $alias_name);
89
+                $this->assertNotNull($geometry->$alias_name($argument), 'Failed on '.$alias_name);
90 90
               }
91 91
               if ($geometry->geometryType() == 'MultiLineString') {
92
-                $this->assertNotNull($geometry->$alias_name($argument), 'Failed on ' . $alias_name);
92
+                $this->assertNotNull($geometry->$alias_name($argument), 'Failed on '.$alias_name);
93 93
               }
94 94
               break;
95 95
             case 'asText':
96 96
             case 'asBinary':
97 97
             case 'getGeomType':
98
-              $this->assertNotNull($geometry->$alias_name($argument), 'Failed on ' . $alias_name);
98
+              $this->assertNotNull($geometry->$alias_name($argument), 'Failed on '.$alias_name);
99 99
               break;
100 100
             default:
101
-              $this->assertTrue($geometry->$alias_name($argument), 'Failed on ' . $alias_name);
101
+              $this->assertTrue($geometry->$alias_name($argument), 'Failed on '.$alias_name);
102 102
           }
103 103
         }
104 104
 
Please login to merge, or discard this patch.
require/libs/geoPHP/tests/tests/adaptersTest.php 3 patches
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -9,56 +9,56 @@
 block discarded – undo
9 9
   }
10 10
 
11 11
   function testAdapters() {
12
-    foreach (scandir('./input') as $file) {
13
-      $parts = explode('.',$file);
14
-      if ($parts[0]) {
15
-        $format = $parts[1];
16
-        $input = file_get_contents('./input/'.$file);
17
-        $geometry = geoPHP::load($input, $format);
12
+	foreach (scandir('./input') as $file) {
13
+	  $parts = explode('.',$file);
14
+	  if ($parts[0]) {
15
+		$format = $parts[1];
16
+		$input = file_get_contents('./input/'.$file);
17
+		$geometry = geoPHP::load($input, $format);
18 18
 
19
-        // Test adapter output and input. Do a round-trip and re-test
20
-        foreach (geoPHP::getAdapterMap() as $adapter_key => $adapter_class) {
21
-          if ($adapter_key != 'google_geocode') { //Don't test google geocoder regularily. Uncomment to test
22
-            $output = $geometry->out($adapter_key);
23
-            $this->assertNotNull($output, "Empty output on "  . $adapter_key);
24
-            if ($output) {
25
-              $adapter_loader = new $adapter_class();
26
-              $test_geom_1 = $adapter_loader->read($output);
27
-              $test_geom_2 = $adapter_loader->read($test_geom_1->out($adapter_key));
28
-              $this->assertEquals($test_geom_1->out('wkt'), $test_geom_2->out('wkt'), "Mismatched adapter output in ".$adapter_class);
29
-            }
30
-          }
31
-        }
19
+		// Test adapter output and input. Do a round-trip and re-test
20
+		foreach (geoPHP::getAdapterMap() as $adapter_key => $adapter_class) {
21
+		  if ($adapter_key != 'google_geocode') { //Don't test google geocoder regularily. Uncomment to test
22
+			$output = $geometry->out($adapter_key);
23
+			$this->assertNotNull($output, "Empty output on "  . $adapter_key);
24
+			if ($output) {
25
+			  $adapter_loader = new $adapter_class();
26
+			  $test_geom_1 = $adapter_loader->read($output);
27
+			  $test_geom_2 = $adapter_loader->read($test_geom_1->out($adapter_key));
28
+			  $this->assertEquals($test_geom_1->out('wkt'), $test_geom_2->out('wkt'), "Mismatched adapter output in ".$adapter_class);
29
+			}
30
+		  }
31
+		}
32 32
 
33
-        // Test to make sure adapter work the same wether GEOS is ON or OFF
34
-        // Cannot test methods if GEOS is not intstalled
35
-        if (!geoPHP::geosInstalled()) return;
33
+		// Test to make sure adapter work the same wether GEOS is ON or OFF
34
+		// Cannot test methods if GEOS is not intstalled
35
+		if (!geoPHP::geosInstalled()) return;
36 36
 
37
-        foreach (geoPHP::getAdapterMap() as $adapter_key => $adapter_class) {
38
-          if ($adapter_key != 'google_geocode') { //Don't test google geocoder regularily. Uncomment to test
39
-            // Turn GEOS on
40
-            geoPHP::geosInstalled(TRUE);
37
+		foreach (geoPHP::getAdapterMap() as $adapter_key => $adapter_class) {
38
+		  if ($adapter_key != 'google_geocode') { //Don't test google geocoder regularily. Uncomment to test
39
+			// Turn GEOS on
40
+			geoPHP::geosInstalled(TRUE);
41 41
 
42
-            $output = $geometry->out($adapter_key);
43
-            if ($output) {
44
-              $adapter_loader = new $adapter_class();
42
+			$output = $geometry->out($adapter_key);
43
+			if ($output) {
44
+			  $adapter_loader = new $adapter_class();
45 45
 
46
-              $test_geom_1 = $adapter_loader->read($output);
46
+			  $test_geom_1 = $adapter_loader->read($output);
47 47
 
48
-              // Turn GEOS off
49
-              geoPHP::geosInstalled(FALSE);
48
+			  // Turn GEOS off
49
+			  geoPHP::geosInstalled(FALSE);
50 50
 
51
-              $test_geom_2 = $adapter_loader->read($output);
51
+			  $test_geom_2 = $adapter_loader->read($output);
52 52
 
53
-              // Turn GEOS back On
54
-              geoPHP::geosInstalled(TRUE);
53
+			  // Turn GEOS back On
54
+			  geoPHP::geosInstalled(TRUE);
55 55
 
56
-              // Check to make sure a both are the same with geos and without
57
-              $this->assertEquals($test_geom_1->out('wkt'), $test_geom_2->out('wkt'), "Mismatched adapter output between GEOS and NORM in ".$adapter_class);
58
-            }
59
-          }
60
-        }
61
-      }
62
-    }
56
+			  // Check to make sure a both are the same with geos and without
57
+			  $this->assertEquals($test_geom_1->out('wkt'), $test_geom_2->out('wkt'), "Mismatched adapter output between GEOS and NORM in ".$adapter_class);
58
+			}
59
+		  }
60
+		}
61
+	  }
62
+	}
63 63
   }
64 64
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 
11 11
   function testAdapters() {
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
         $input = file_get_contents('./input/'.$file);
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
         foreach (geoPHP::getAdapterMap() as $adapter_key => $adapter_class) {
21 21
           if ($adapter_key != 'google_geocode') { //Don't test google geocoder regularily. Uncomment to test
22 22
             $output = $geometry->out($adapter_key);
23
-            $this->assertNotNull($output, "Empty output on "  . $adapter_key);
23
+            $this->assertNotNull($output, "Empty output on ".$adapter_key);
24 24
             if ($output) {
25 25
               $adapter_loader = new $adapter_class();
26 26
               $test_geom_1 = $adapter_loader->read($output);
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -32,7 +32,9 @@
 block discarded – undo
32 32
 
33 33
         // Test to make sure adapter work the same wether GEOS is ON or OFF
34 34
         // Cannot test methods if GEOS is not intstalled
35
-        if (!geoPHP::geosInstalled()) return;
35
+        if (!geoPHP::geosInstalled()) {
36
+        	return;
37
+        }
36 38
 
37 39
         foreach (geoPHP::getAdapterMap() as $adapter_key => $adapter_class) {
38 40
           if ($adapter_key != 'google_geocode') { //Don't test google geocoder regularily. Uncomment to test
Please login to merge, or discard this patch.
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.