Esempio n. 1
0
 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));
 }
Esempio n. 2
0
 private function parse_multi_polygon()
 {
     if ($this->tokenizer->get_next_token() != '(') {
         throw new EWKTFormatError('Invalid MULTIPOLYGON');
     }
     $token = '';
     $polys = array();
     while ($token != ')') {
         $polys[] = $this->parse_polygon();
         $token = $this->tokenizer->get_next_token();
         // comma
         if ($token === null) {
             throw new EWKTFormatError('Incorrect termination of EWKT string');
         }
     }
     return MultiPolygon::from_polygons($polys, $this->srid, $this->with_z, $this->with_m);
 }