Ejemplo n.º 1
0
 public function test_multilinestring_create()
 {
     $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));
     $line1 = LineString::from_array($line1_coords, 444, true);
     $line2 = LineString::from_array($line2_coords, 444, true);
     $ml = MultiLineString::from_line_strings(array($line1, $line2), 444, true);
     $this->assertTrue($ml instanceof MultiLineString);
     $this->assertEquals(2, count($ml->lines));
     $this->assertEquals(5, $ml->lines[0]->points[2]->x);
     $this->assertEquals(5, $ml->lines[0]->points[2]->y);
     $this->assertEquals(2, $ml->lines[0]->points[2]->z);
     $ml = MultiLineString::from_array(array($line1_coords, $line2_coords), 444, true);
     $this->assertTrue($ml instanceof MultiLineString);
     $this->assertEquals(2, count($ml->lines));
 }
Ejemplo n.º 2
0
 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);
 }