public function test_polygon_ewkt() { $ring1_coords = array(array(0, 0, 0), array(0, 5, 1), array(5, 5, 2), array(5, 0, 1), array(0, 0, 0)); $ring2_coords = array(array(1, 1, 0), array(1, 4, 1), array(4, 4, 2), array(4, 1, 1), array(1, 1, 0)); $poly = Polygon::from_array(array($ring1_coords, $ring2_coords), 444, true); $this->assertEquals('SRID=444;POLYGON((0 0 0,0 5 1,5 5 2,5 0 1,0 0 0),(1 1 0,1 4 1,4 4 2,4 1 1,1 1 0))', $poly->to_ewkt()); $this->assertEquals('POLYGON((0 0,0 5,5 5,5 0,0 0),(1 1,1 4,4 4,4 1,1 1))', $poly->to_wkt()); }
public function test_multipolygon_create() { $ring1_coords = array(array(0, 0, 0), array(0, 5, 1), array(5, 5, 2), array(5, 0, 1), array(0, 0, 0)); $ring2_coords = array(array(1, 1, 0), array(1, 4, 1), array(4, 4, 2), array(4, 1, 1), array(1, 1, 0)); $ring3_coords = array(array(6, 6, 0), array(6, 10, 1), array(10, 10, 2), array(10, 6, 1), array(6, 6, 0)); $poly1 = Polygon::from_array(array($ring1_coords, $ring2_coords), 444, true); $poly2 = Polygon::from_array(array($ring3_coords), 444, true); $mp = MultiPolygon::from_polygons(array($poly1, $poly2), 444, true); $this->assertTrue($mp instanceof MultiPolygon); $this->assertEquals(2, count($mp->polygons)); $this->assertEquals(2, count($mp->polygons[0]->rings)); $this->assertEquals(1, count($mp->polygons[1]->rings)); $this->assertEquals(10, $mp->polygons[1]->rings[0]->points[2]->x); $this->assertEquals(10, $mp->polygons[1]->rings[0]->points[2]->y); $this->assertEquals(2, $mp->polygons[1]->rings[0]->points[2]->z); $mp = MultiPolygon::from_array(array(array($ring1_coords, $ring2_coords), array($ring3_coords)), 444, true); $this->assertTrue($mp instanceof MultiPolygon); $this->assertEquals(2, count($mp->polygons)); }