Skip to content

Commit

Permalink
MDL-56331 tests: increase tolerance of coordinate tests
Browse files Browse the repository at this point in the history
1) It seems the maxmind database is getting relatively frequent updates
which are causing differences in exact coordinates

2) GeoIP location lookups are not an exact science, I tried to pick some
ips which I thought would remain fairly static, but these things are
just guesses.

3) Moving to 2 decimal places should give us good enough results for
this test, according to:
http://gis.stackexchange.com/questions/8650/measuring-accuracy-of-latitude-and-longitude

  "The second decimal place is worth up to 1.1 km: it can separate one
   village from the next."
  "The third decimal place is worth up to 110 m: it can identify a
   large agricultural field or institutional campus."
  • Loading branch information
danpoltawski committed Oct 10, 2016
1 parent d9520bc commit 0b73876
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions iplookup/tests/geoip_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ public function test_ipv4() {

$this->assertEquals('array', gettype($result));
$this->assertEquals('Cambridge', $result['city']);
$this->assertEquals(0.1249, $result['longitude'], '', 0.001);
$this->assertEquals(52.191000000000003, $result['latitude'], '', 0.001);
$this->assertEquals(0.1249, $result['longitude'], 'Coordinates are out of accepted tolerance', 0.01);
$this->assertEquals(52.191000000000003, $result['latitude'], 'Coordinates are out of accepted tolerance', 0.01);
$this->assertNull($result['error']);
$this->assertEquals('array', gettype($result['title']));
$this->assertEquals('Cambridge', $result['title'][0]);
Expand All @@ -100,8 +100,8 @@ public function test_ipv6() {

$this->assertEquals('array', gettype($result));
$this->assertEquals('Lancaster', $result['city']);
$this->assertEquals(-2.79970, $result['longitude'], '', 0.001);
$this->assertEquals(54.04650, $result['latitude'], '', 0.001);
$this->assertEquals(-2.79970, $result['longitude'], 'Coordinates are out of accepted tolerance', 0.01);
$this->assertEquals(54.04650, $result['latitude'], 'Coordinates are out of accepted tolerance', 0.01);
$this->assertNull($result['error']);
$this->assertEquals('array', gettype($result['title']));
$this->assertEquals('Lancaster', $result['title'][0]);
Expand Down

0 comments on commit 0b73876

Please sign in to comment.