예제 #1
0
 public function test_multipolygon_ewkt()
 {
     $ring1_coords = array(array(0, 0, 0, 4), array(0, 5, 1, 3), array(5, 5, 2, 2), array(5, 0, 1, 1), array(0, 0, 0, 4));
     $ring2_coords = array(array(1, 1, 0, 4), array(1, 4, 1, 3), array(4, 4, 2, 2), array(4, 1, 1, 1), array(1, 1, 0, 4));
     $ring3_coords = array(array(6, 6, 0, 4), array(6, 10, 1, 3), array(10, 10, 2, 2), array(10, 6, 1, 1), array(6, 6, 0, 4));
     // No Z values
     $mp = MultiPolygon::from_array(array(array($ring1_coords, $ring2_coords), array($ring3_coords)), 444);
     $this->assertEquals('SRID=444;MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0),(1 1,1 4,4 4,4 1,1 1)),((6 6,6 10,10 10,10 6,6 6)))', $mp->to_ewkt());
     // Z value
     $mp = MultiPolygon::from_array(array(array($ring1_coords, $ring2_coords), array($ring3_coords)), 444, true);
     $this->assertEquals('SRID=444;MULTIPOLYGON(((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)),((6 6 0,6 10 1,10 10 2,10 6 1,6 6 0)))', $mp->to_ewkt());
     // M value
     $mp = MultiPolygon::from_array(array(array($ring1_coords, $ring2_coords), array($ring3_coords)), 444, false, true);
     $this->assertEquals('SRID=444;MULTIPOLYGONM(((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)),((6 6 0,6 10 1,10 10 2,10 6 1,6 6 0)))', $mp->to_ewkt());
     // Z+M
     $mp = MultiPolygon::from_array(array(array($ring1_coords, $ring2_coords), array($ring3_coords)), 444, true, true);
     $this->assertEquals('SRID=444;MULTIPOLYGON(((0 0 0 4,0 5 1 3,5 5 2 2,5 0 1 1,0 0 0 4),(1 1 0 4,1 4 1 3,4 4 2 2,4 1 1 1,1 1 0 4)),((6 6 0 4,6 10 1 3,10 10 2 2,10 6 1 1,6 6 0 4)))', $mp->to_ewkt());
 }
예제 #2
0
파일: EWKTParser.php 프로젝트: h-sn/geophp
 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);
 }