Example #1
0
 public function test_linestring_ewkt()
 {
     $coords = array(array(1.1, 2.2, -10, 5), array(3.3, 4.4, 2.55555555, -5), array(0, -0.5, 3.14, 1.111));
     $line = LineString::from_array($coords, 444);
     $this->assertEquals('SRID=444;LINESTRING(1.1 2.2,3.3 4.4,0 -0.5)', $line->to_ewkt());
     $line = LineString::from_array($coords, 444, true);
     $this->assertEquals('SRID=444;LINESTRING(1.1 2.2 -10,3.3 4.4 2.55555555,0 -0.5 3.14)', $line->to_ewkt());
     $this->assertEquals('LINESTRING(1.1 2.2,3.3 4.4,0 -0.5)', $line->to_wkt());
     $line = LineString::from_array($coords, 444, true, true);
     $this->assertEquals('SRID=444;LINESTRING(1.1 2.2 -10 5,3.3 4.4 2.55555555 -5,0 -0.5 3.14 1.111)', $line->to_ewkt());
 }
Example #2
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));
 }