addPoint() public method

public addPoint ( Coordinate $point )
$point Coordinate
Beispiel #1
0
 /**
  * @covers Location\Formatter\Coordinate\DecimalDegrees::format
  */
 public function testFormatDefault()
 {
     $polygon = new Polygon();
     $polygon->addPoint(new Coordinate(10, 20));
     $polygon->addPoint(new Coordinate(20, 40));
     $polygon->addPoint(new Coordinate(30, 40));
     $polygon->addPoint(new Coordinate(30, 20));
     $json = '{ "type" : "Polygon" , "coordinates" : [ [ 20, 10 ], [ 40, 20 ], [ 40, 30 ], [ 20, 30] ] }';
     $this->assertJsonStringEqualsJsonString($json, $this->formatter->format($polygon));
 }
Beispiel #2
0
function createPolygons($kades)
{
    $polygons = array();
    foreach ($kades as $id => $kade) {
        $polygon = new Polygon();
        foreach ($kade as $point) {
            $latitude = $point['latitude'];
            $longitude = $point['longitude'];
            $polygon->addPoint(new Coordinate($latitude, $longitude));
        }
        $polygons[$id] = $polygon;
    }
    return $polygons;
}
Beispiel #3
0
 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);
 }
Beispiel #4
0
 public function testReverseTwiceWorksAsExpected()
 {
     $polygon = new Polygon();
     $polygon->addPoint(new Coordinate(52.5, 13.5));
     $polygon->addPoint(new Coordinate(64.09999999999999, -21.9));
     $polygon->addPoint(new Coordinate(40.7, -74.0));
     $polygon->addPoint(new Coordinate(33.9, -118.4));
     $doubleReversed = $polygon->getReverse()->getReverse();
     $this->assertEquals($polygon, $doubleReversed);
 }