Calculates the polygon perimeter.
public getPerimeter ( Location\Distance\DistanceInterface $calculator ) : float | ||
$calculator | Location\Distance\DistanceInterface | instance of distance calculation class |
return | float |
public function testIfPerimeterCalculationWorksAsExpected() { $polygon = new Polygon(); $polygon->addPoint(new Coordinate(10, 10)); $polygon->addPoint(new Coordinate(10, 20)); $polygon->addPoint(new Coordinate(20, 20)); $polygon->addPoint(new Coordinate(20, 10)); // http://geographiclib.sourceforge.net/cgi-bin/Planimeter?type=polygon&rhumb=geodesic&input=10+10%0D%0A10+20%0D%0A20+20%0D%0A20+10&norm=decdegrees&option=Submit $this->assertEquals(4355689.472548, $polygon->getPerimeter(new Vincenty()), '', 0.01); $polygon = new Polygon(); $polygon->addPoint(new Coordinate(52, 13)); $polygon->addPoint(new Coordinate(53, 13)); $polygon->addPoint(new Coordinate(53, 12)); $polygon->addPoint(new Coordinate(52, 12)); // http://geographiclib.sourceforge.net/cgi-bin/Planimeter?type=polygon&rhumb=geodesic&input=52+13%0D%0A53+13%0D%0A53+12%0D%0A52+12&norm=decdegrees&option=Submit $this->assertEquals(358367.809428, $polygon->getPerimeter(new Vincenty()), '', 0.01); }