示例#1
0
 public function test_polygon_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));
     $ring1 = LinearRing::from_array($ring1_coords, 444, true);
     $ring2 = LinearRing::from_array($ring2_coords, 444, true);
     $poly = Polygon::from_linear_rings(array($ring1, $ring2), 444, true);
     $this->assertTrue($poly instanceof Polygon);
     $this->assertEquals(2, count($poly->rings));
     $this->assertEquals(5, $poly->rings[0]->points[2]->x);
     $this->assertEquals(5, $poly->rings[0]->points[2]->y);
     $this->assertEquals(2, $poly->rings[0]->points[2]->z);
     $poly = Polygon::from_array(array($ring1_coords, $ring2_coords), 444, true);
     $this->assertTrue($poly instanceof Polygon);
     $this->assertEquals(2, count($poly->rings));
 }
示例#2
0
 public function test_extent()
 {
     $ring1_coords = array(array(0, 1, 0), array(0, 6, 1), array(5, 6, 2), array(5, 1, 1), array(0, 1, 0));
     $ring2_coords = array(array(1, 2, 0), array(1, 4, 1), array(4, 4, 2), array(4, 2, 1), array(1, 2, 0));
     $ring1 = LinearRing::from_array($ring1_coords, 444, true);
     $ring2 = LinearRing::from_array($ring2_coords, 444, true);
     $poly = Polygon::from_linear_rings(array($ring1, $ring2), 444, true);
     $e = $poly->extent();
     $this->assertTrue($e->ll instanceof Point);
     $this->assertTrue($e->ur instanceof Point);
     $this->assertEquals(0, $e->ll->x);
     $this->assertEquals(1, $e->ll->y);
     $this->assertEquals(0, $e->ll->z);
     $this->assertEquals(5, $e->ur->x);
     $this->assertEquals(6, $e->ur->y);
     $this->assertEquals(2, $e->ur->z);
 }