/** * Test geolib::expand(). * This test isn't yet working for edge cases, * expanding to the original precision or to the minimum precision. * Perhaps those expansions don't make much sense. * * @dataProvider geohashProvider * @param string $geohash */ public function testCircle($geohash) { $circle = new geohash_circle($geohash); $center = geohash::decode($geohash); $last_radius = 0; // test all precisions up to 0 do { $radius = $circle->max_radius() / EARTH_RADIUS; $circle->expand($geohash, $precision); // the center point should be in the set $this->assertTrue($circle->contains($center)); // the following tests only work for points away from the poles where radiuses expand usefully if ($radius > 0) { $this->assertGreaterThan($last_radius, $radius); // all points box size x 1 distance from the center should be in the set $this->assertTrue($circle->contains(new geopoint(min($center->latitude + $radius, 90), self::normalize_longitude($center->longitude + $radius)))); $this->assertTrue($circle->contains(new geopoint(min($center->latitude + $radius, 90), self::normalize_longitude($center->longitude - $radius)))); $this->assertTrue($circle->contains(new geopoint(max($center->latitude - $radius, -90), self::normalize_longitude($center->longitude + $radius)))); $this->assertTrue($circle->contains(new geopoint(max($center->latitude - $radius, -90), self::normalize_longitude($center->longitude - $radius)))); // at least one point box size x 2 distance from the center should be outside the set /* $this->assertFalse($circle->contains(new geopoint(min($center->latitude + $radius*2, 90), $center->longitude + $radius*2)) && $circle->contains(new geopoint(min($center->latitude + $radius*2, 90), $center->longitude - $radius*2)) && $circle->contains(new geopoint(max($center->latitude - $radius*2, -90), $center->longitude + $radius*2)) && $circle->contains(new geopoint(max($center->latitude - $radius*2, -90), $center->longitude - $radius*2))); */ $last_radius = $radius; } } while ($circle->expand()); }