コード例 #1
0
ファイル: MultiLineStringTest.php プロジェクト: h-sn/geophp
 public function test_multilinestring_ewkt()
 {
     $line1_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));
     $line2_coords = array(array(1, 1, 0, -2), array(1, 4, 1, -3), array(4, 4, 2, -4), array(4, 1, 1, -5), array(1, 1, 0, -2));
     // No Z value
     $ml = MultiLineString::from_array(array($line1_coords, $line2_coords), 444);
     $this->assertEquals('SRID=444;MULTILINESTRING((0 0,0 5,5 5,5 0,0 0),(1 1,1 4,4 4,4 1,1 1))', $ml->to_ewkt());
     // z value
     $ml = MultiLineString::from_array(array($line1_coords, $line2_coords), 444, true);
     $this->assertEquals('SRID=444;MULTILINESTRING((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))', $ml->to_ewkt());
     // m
     $ml = MultiLineString::from_array(array($line1_coords, $line2_coords), 444, false, true);
     $this->assertEquals('SRID=444;MULTILINESTRINGM((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))', $ml->to_ewkt());
     // z + m
     $ml = MultiLineString::from_array(array($line1_coords, $line2_coords), 444, true, true);
     $this->assertEquals('SRID=444;MULTILINESTRING((0 0 0 4,0 5 1 3,5 5 2 2,5 0 1 1,0 0 0 4),(1 1 0 -2,1 4 1 -3,4 4 2 -4,4 1 1 -5,1 1 0 -2))', $ml->to_ewkt());
 }
コード例 #2
0
ファイル: EWKTParser.php プロジェクト: h-sn/geophp
 private function parse_multi_line_string()
 {
     if ($this->tokenizer->get_next_token() != '(') {
         throw new EWKTFormatError('Invalid MULTILINESTRING');
     }
     $token = '';
     $lines = array();
     while ($token != ')') {
         $lines[] = $this->parse_line_string();
         $token = $this->tokenizer->get_next_token();
         // comma
         if ($token === null) {
             throw new EWKTFormatError('Incorrect termination of EWKT string');
         }
     }
     return MultiLineString::from_line_strings($lines, $this->srid, $this->with_z, $this->with_m);
 }