@@ -192,24 +192,24 @@ public function testDistance()
192
192
$ loc3 ->location = new Point (3 , 3 ); // Distance from loc1: 2.8284271247462
193
193
$ loc3 ->save ();
194
194
195
- $ a = GeometryModel::distance (2 , $ loc1 ->location , ' location ' )->get ();
195
+ $ a = GeometryModel::distance (' location ' , $ loc1 ->location , 2 )->get ();
196
196
$ this ->assertCount (2 , $ a );
197
- $ this ->assertTrue ($ a ->contains ($ loc1 ));
198
- $ this ->assertTrue ($ a ->contains ($ loc2 ));
199
- $ this ->assertFalse ($ a ->contains ($ loc3 ));
197
+ $ this ->assertTrue ($ a ->contains (' location ' , $ loc1-> location ));
198
+ $ this ->assertTrue ($ a ->contains (' location ' , $ loc2-> location ));
199
+ $ this ->assertFalse ($ a ->contains (' location ' , $ loc3-> location ));
200
200
201
201
// Excluding self
202
- $ b = GeometryModel::distance (2 , $ loc1 ->location , ' location ' , true )->get ();
202
+ $ b = GeometryModel::distance (' location ' , $ loc1 ->location , 2 , true )->get ();
203
203
$ this ->assertCount (1 , $ b );
204
- $ this ->assertFalse ($ b ->contains ($ loc1 ));
205
- $ this ->assertTrue ($ b ->contains ($ loc2 ));
206
- $ this ->assertFalse ($ b ->contains ($ loc3 ));
204
+ $ this ->assertFalse ($ b ->contains (' location ' , $ loc1-> location ));
205
+ $ this ->assertTrue ($ b ->contains (' location ' , $ loc2-> location ));
206
+ $ this ->assertFalse ($ b ->contains (' location ' , $ loc3-> location ));
207
207
208
- $ c = GeometryModel::distance (1 , $ loc1 ->location , ' location ' )->get ();
208
+ $ c = GeometryModel::distance (' location ' , $ loc1 ->location , 1 )->get ();
209
209
$ this ->assertCount (1 , $ c );
210
- $ this ->assertTrue ($ c ->contains ($ loc1 ));
211
- $ this ->assertFalse ($ c ->contains ($ loc2 ));
212
- $ this ->assertFalse ($ c ->contains ($ loc3 ));
210
+ $ this ->assertTrue ($ c ->contains (' location ' , $ loc1-> location ));
211
+ $ this ->assertFalse ($ c ->contains (' location ' , $ loc2-> location ));
212
+ $ this ->assertFalse ($ c ->contains (' location ' , $ loc3-> location ));
213
213
}
214
214
215
215
public function testDistanceSphere ()
@@ -226,24 +226,24 @@ public function testDistanceSphere()
226
226
$ loc3 ->location = new Point (40.761434 , -73.977619 ); // Distance from loc1: 870.06424066202
227
227
$ loc3 ->save ();
228
228
229
- $ a = GeometryModel::distanceSphere (200 , $ loc1 ->location , ' location ' )->get ();
229
+ $ a = GeometryModel::distanceSphere (' location ' , $ loc1 ->location , 200 )->get ();
230
230
$ this ->assertCount (2 , $ a );
231
- $ this ->assertTrue ($ a ->contains ($ loc1 ));
232
- $ this ->assertTrue ($ a ->contains ($ loc2 ));
233
- $ this ->assertFalse ($ a ->contains ($ loc3 ));
231
+ $ this ->assertTrue ($ a ->contains (' location ' , $ loc1-> location ));
232
+ $ this ->assertTrue ($ a ->contains (' location ' , $ loc2-> location ));
233
+ $ this ->assertFalse ($ a ->contains (' location ' , $ loc3-> location ));
234
234
235
235
// Excluding self
236
- $ b = GeometryModel::distanceSphere (200 , $ loc1 ->location , ' location ' , true )->get ();
236
+ $ b = GeometryModel::distanceSphere (' location ' , $ loc1 ->location , 200 , true )->get ();
237
237
$ this ->assertCount (1 , $ b );
238
- $ this ->assertFalse ($ b ->contains ($ loc1 ));
239
- $ this ->assertTrue ($ b ->contains ($ loc2 ));
240
- $ this ->assertFalse ($ b ->contains ($ loc3 ));
238
+ $ this ->assertFalse ($ b ->contains (' location ' , $ loc1-> location ));
239
+ $ this ->assertTrue ($ b ->contains (' location ' , $ loc2-> location ));
240
+ $ this ->assertFalse ($ b ->contains (' location ' , $ loc3-> location ));
241
241
242
- $ c = GeometryModel::distanceSphere (44.741406484587 , $ loc1 ->location , ' location ' )->get ();
242
+ $ c = GeometryModel::distanceSphere (' location ' , $ loc1 ->location , 44.741406484587 )->get ();
243
243
$ this ->assertCount (1 , $ c );
244
- $ this ->assertTrue ($ c ->contains ($ loc1 ));
245
- $ this ->assertFalse ($ c ->contains ($ loc2 ));
246
- $ this ->assertFalse ($ c ->contains ($ loc3 ));
244
+ $ this ->assertTrue ($ c ->contains (' location ' , $ loc1-> location ));
245
+ $ this ->assertFalse ($ c ->contains (' location ' , $ loc2-> location ));
246
+ $ this ->assertFalse ($ c ->contains (' location ' , $ loc3-> location ));
247
247
}
248
248
249
249
public function testDistanceValue ()
@@ -256,7 +256,7 @@ public function testDistanceValue()
256
256
$ loc2 ->location = new Point (2 , 2 ); // Distance from loc1: 1.4142135623731
257
257
$ loc2 ->save ();
258
258
259
- $ a = GeometryModel::distanceValue ($ loc1 ->location , ' location ' )->get ();
259
+ $ a = GeometryModel::distanceValue (' location ' , $ loc1 ->location )->get ();
260
260
$ this ->assertCount (2 , $ a );
261
261
$ this ->assertEquals (0 , $ a [0 ]->distance );
262
262
$ this ->assertEquals (1.4142135623 , $ a [1 ]->distance ); // PHP floats' 11th+ digits don't matter
@@ -271,41 +271,41 @@ public function testDistanceSphereValue() {
271
271
$ loc2 ->location = new Point (40.767664 , -73.971271 ); // Distance from loc1: 44.741406484588
272
272
$ loc2 ->save ();
273
273
274
- $ a = GeometryModel::distanceSphereValue ($ loc1 ->location , ' location ' )->get ();
274
+ $ a = GeometryModel::distanceSphereValue (' location ' , $ loc1 ->location )->get ();
275
275
$ this ->assertCount (2 , $ a );
276
276
$ this ->assertEquals (0 , $ a [0 ]->distance );
277
277
$ this ->assertEquals (44.7414064845 , $ a [1 ]->distance ); // PHP floats' 11th+ digits don't matter
278
278
}
279
279
280
- public function testBounding () {
281
- $ point = new Point (0 , 0 );
282
-
283
- $ linestring1 = \Grimzy \LaravelMysqlSpatial \Types \LineString::fromWkt ("LINESTRING(1 1, 2 2) " );
284
- $ linestring2 = \Grimzy \LaravelMysqlSpatial \Types \LineString::fromWkt ("LINESTRING(20 20, 24 24) " );
285
- $ linestring3 = \Grimzy \LaravelMysqlSpatial \Types \LineString::fromWkt ("LINESTRING(0 10, 10 10) " );
286
-
287
- $ geo1 = new GeometryModel ();
288
- $ geo1 ->location = $ point ;
289
- $ geo1 ->line = $ linestring1 ;
290
- $ geo1 ->save ();
291
-
292
- $ geo2 = new GeometryModel ();
293
- $ geo2 ->location = $ point ;
294
- $ geo2 ->line = $ linestring2 ;
295
- $ geo2 ->save ();
296
-
297
- $ geo3 = new GeometryModel ();
298
- $ geo3 ->location = $ point ;
299
- $ geo3 ->line = $ linestring3 ;
300
- $ geo3 ->save ();
301
-
302
- $ polygon = Polygon::fromWKT ("POLYGON((0 10,10 10,10 0,0 0,0 10)) " );
303
-
304
- $ result = GeometryModel::Bounding ($ polygon , 'line ' )->get ();
305
- $ this ->assertCount (2 , $ result );
306
- $ this ->assertTrue ($ result ->contains ($ geo1 ));
307
- $ this ->assertFalse ($ result ->contains ($ geo2 ));
308
- $ this ->assertTrue ($ result ->contains ($ geo3 ));
309
-
310
- }
280
+ // public function testBounding() {
281
+ // $point = new Point(0, 0);
282
+ //
283
+ // $linestring1 = \Grimzy\LaravelMysqlSpatial\Types\LineString::fromWkt("LINESTRING(1 1, 2 2)");
284
+ // $linestring2 = \Grimzy\LaravelMysqlSpatial\Types\LineString::fromWkt("LINESTRING(20 20, 24 24)");
285
+ // $linestring3 = \Grimzy\LaravelMysqlSpatial\Types\LineString::fromWkt("LINESTRING(0 10, 10 10)");
286
+ //
287
+ // $geo1 = new GeometryModel();
288
+ // $geo1->location = $point;
289
+ // $geo1->line = $linestring1;
290
+ // $geo1->save();
291
+ //
292
+ // $geo2 = new GeometryModel();
293
+ // $geo2->location = $point;
294
+ // $geo2->line = $linestring2;
295
+ // $geo2->save();
296
+ //
297
+ // $geo3 = new GeometryModel();
298
+ // $geo3->location = $point;
299
+ // $geo3->line = $linestring3;
300
+ // $geo3->save();
301
+ //
302
+ // $polygon = Polygon::fromWKT("POLYGON((0 10,10 10,10 0,0 0,0 10))");
303
+ //
304
+ // $result = GeometryModel::Bounding($polygon, 'line')->get();
305
+ // $this->assertCount(2, $result);
306
+ // $this->assertTrue($result->contains($geo1));
307
+ // $this->assertFalse($result->contains($geo2));
308
+ // $this->assertTrue($result->contains($geo3));
309
+ //
310
+ // }
311
311
}
0 commit comments