Skip to content

Commit 057e4cc

Browse files
author
dekichan
committed
Update tests so coordinates of geometries under test don't start with (0, 0).
1 parent 52747a7 commit 057e4cc

7 files changed

+55
-53
lines changed

tests/Geometries/GeometryCollectionTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ protected function setUp()
1515
{
1616
$collection = new LineString(
1717
[
18-
new Point(0, 0),
19-
new Point(0, 1),
2018
new Point(1, 1),
21-
new Point(1, 0),
22-
new Point(0, 0)
19+
new Point(1, 2),
20+
new Point(2, 2),
21+
new Point(2, 1),
22+
new Point(1, 1)
2323
]
2424
);
2525

@@ -45,7 +45,7 @@ public function testFromWKT()
4545
public function testToWKT()
4646
{
4747
$this->assertEquals(
48-
'GEOMETRYCOLLECTION(LINESTRING(0 0,1 0,1 1,0 1,0 0),POINT(200 100))',
48+
'GEOMETRYCOLLECTION(LINESTRING(1 1,2 1,2 2,1 2,1 1),POINT(200 100))',
4949
$this->collection->toWKT()
5050
);
5151
}
@@ -58,7 +58,7 @@ public function testJsonSerialize()
5858
);
5959

6060
$this->assertSame(
61-
'{"type":"GeometryCollection","geometries":[{"type":"LineString","coordinates":[[0,0],[1,0],[1,1],[0,1],[0,0]]},{"type":"Point","coordinates":[200,100]}]}',
61+
'{"type":"GeometryCollection","geometries":[{"type":"LineString","coordinates":[[1,1],[2,1],[2,2],[1,2],[1,1]]},{"type":"Point","coordinates":[200,100]}]}',
6262
json_encode($this->collection->jsonSerialize())
6363
);
6464

tests/Geometries/GeometryTest.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,28 @@ class GeometryTest extends BaseTestCase
1414
public function testGetWKTArgument()
1515
{
1616
$this->assertEquals(
17-
'0 0',
18-
Geometry::getWKTArgument('POINT(0 0)')
17+
'1 1',
18+
Geometry::getWKTArgument('POINT(1 1)')
1919
);
2020
$this->assertEquals(
21-
'0 0,1 1,1 2',
22-
Geometry::getWKTArgument('LINESTRING(0 0,1 1,1 2)')
21+
'1 1,1 2,2 2',
22+
Geometry::getWKTArgument('LINESTRING(1 1,1 2,2 2)')
2323
);
2424
$this->assertEquals(
25-
'(0 0,4 0,4 4,0 4,0 0),(1 1, 2 1, 2 2, 1 2,1 1)',
26-
Geometry::getWKTArgument('POLYGON((0 0,4 0,4 4,0 4,0 0),(1 1, 2 1, 2 2, 1 2,1 1))')
25+
'(1 1,4 1,4 4,1 4,1 1),(1 1, 2 1, 2 2, 1 2,1 1)',
26+
Geometry::getWKTArgument('POLYGON((1 1,4 1,4 4,1 4,1 1),(1 1, 2 1, 2 2, 1 2,1 1))')
2727
);
2828
$this->assertEquals(
29-
'(0 0),(1 2)',
30-
Geometry::getWKTArgument('MULTIPOINT((0 0),(1 2))')
29+
'(1 1),(1 2)',
30+
Geometry::getWKTArgument('MULTIPOINT((1 1),(1 2))')
3131
);
3232
$this->assertEquals(
33-
'(0 0,1 1,1 2),(2 3,3 2,5 4)',
34-
Geometry::getWKTArgument('MULTILINESTRING((0 0,1 1,1 2),(2 3,3 2,5 4))')
33+
'(1 1,1 2,2 2),(2 3,3 2,5 4)',
34+
Geometry::getWKTArgument('MULTILINESTRING((1 1,1 2,2 2),(2 3,3 2,5 4))')
3535
);
3636
$this->assertEquals(
37-
'((0 0,4 0,4 4,0 4,0 0),(1 1,2 1,2 2,1 2,1 1)), ((-1 -1,-1 -2,-2 -2,-2 -1,-1 -1))',
38-
Geometry::getWKTArgument('MULTIPOLYGON(((0 0,4 0,4 4,0 4,0 0),(1 1,2 1,2 2,1 2,1 1)), ((-1 -1,-1 -2,-2 -2,-2 -1,-1 -1)))')
37+
'((1 1,4 1,4 4,1 4,1 1),(1 1,2 1,2 2,1 2,1 1)), ((-1 -1,-1 -2,-2 -2,-2 -1,-1 -1))',
38+
Geometry::getWKTArgument('MULTIPOLYGON(((1 1,4 1,4 4,1 4,1 1),(1 1,2 1,2 2,1 2,1 1)), ((-1 -1,-1 -2,-2 -2,-2 -1,-1 -1)))')
3939
);
4040
$this->assertEquals(
4141
'POINT(2 3),LINESTRING(2 3,3 4)',

tests/Geometries/LineStringTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@ class LineStringTest extends BaseTestCase
99

1010
protected function setUp()
1111
{
12-
$this->points = [new Point(0, 0), new Point(1, 1), new Point(2, 2)];
12+
$this->points = [new Point(1, 1), new Point(2, 2), new Point(3, 3)];
1313
}
1414

1515
public function testToWKT()
1616
{
1717
$linestring = new LineString($this->points);
1818

19-
$this->assertEquals('LINESTRING(0 0,1 1,2 2)', $linestring->toWKT());
19+
$this->assertEquals('LINESTRING(1 1,2 2,3 3)', $linestring->toWKT());
2020
}
2121

2222
public function testFromWKT()
2323
{
24-
$linestring = LineString::fromWkt('LINESTRING(0 0, 1 1, 2 2)');
24+
$linestring = LineString::fromWKT('LINESTRING(1 1, 2 2,3 3)');
2525
$this->assertInstanceOf(LineString::class, $linestring);
2626

2727
$this->assertEquals(3, $linestring->count());
@@ -31,14 +31,14 @@ public function testToString()
3131
{
3232
$linestring = new LineString($this->points);
3333

34-
$this->assertEquals('0 0,1 1,2 2', (string)$linestring);
34+
$this->assertEquals('1 1,2 2,3 3', (string)$linestring);
3535
}
3636

3737
public function testJsonSerialize()
3838
{
3939
$lineString = new LineString($this->points);
4040

4141
$this->assertInstanceOf(\GeoJson\Geometry\LineString::class, $lineString->jsonSerialize());
42-
$this->assertSame('{"type":"LineString","coordinates":[[0,0],[1,1],[2,2]]}', json_encode($lineString));
42+
$this->assertSame('{"type":"LineString","coordinates":[[1,1],[2,2],[3,3]]}', json_encode($lineString));
4343
}
4444
}

tests/Geometries/MultiLineStringTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class MultiLineStringTest extends BaseTestCase
88
{
99
public function testFromWKT()
1010
{
11-
$multilinestring = MultiLineString::fromWKT('MULTILINESTRING((0 0,1 1,1 2),(2 3,3 2,5 4))');
11+
$multilinestring = MultiLineString::fromWKT('MULTILINESTRING((1 1,2 2,2 3),(3 4,4 3,6 5))');
1212
$this->assertInstanceOf(MultiLineString::class, $multilinestring);
1313

1414
$this->assertSame(2, $multilinestring->count());
@@ -18,26 +18,26 @@ public function testToWKT()
1818
{
1919
$collection = new LineString(
2020
[
21-
new Point(0, 0),
22-
new Point(0, 1),
2321
new Point(1, 1),
24-
new Point(1, 0),
25-
new Point(0, 0)
22+
new Point(1, 2),
23+
new Point(2, 2),
24+
new Point(2, 1),
25+
new Point(1, 1)
2626
]
2727
);
2828

2929
$multilinestring = new MultiLineString([$collection]);
3030

31-
$this->assertSame('MULTILINESTRING((0 0,1 0,1 1,0 1,0 0))', $multilinestring->toWKT());
31+
$this->assertSame('MULTILINESTRING((1 1,2 1,2 2,1 2,1 1))', $multilinestring->toWKT());
3232
}
3333

3434
public function testJsonSerialize()
3535
{
36-
$multilinestring = MultiLineString::fromWKT('MULTILINESTRING((0 0,1 1,1 2),(2 3,3 2,5 4))');
36+
$multilinestring = MultiLineString::fromWKT('MULTILINESTRING((1 1,2 2,2 3),(3 4,4 3,6 5))');
3737

3838
$this->assertInstanceOf(\GeoJson\Geometry\MultiLineString::class, $multilinestring->jsonSerialize());
3939
$this->assertSame(
40-
'{"type":"MultiLineString","coordinates":[[[0,0],[1,1],[1,2]],[[2,3],[3,2],[5,4]]]}',
40+
'{"type":"MultiLineString","coordinates":[[[1,1],[2,2],[2,3]],[[3,4],[4,3],[6,5]]]}',
4141
json_encode($multilinestring)
4242
);
4343
}

tests/Geometries/MultiPointTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,28 @@ class MultiPointTest extends BaseTestCase
77
{
88
public function testFromWKT()
99
{
10-
$multipoint = MultiPoint::fromWkt('MULTIPOINT((0 0),(1 0),(1 1))');
10+
$multipoint = MultiPoint::fromWkt('MULTIPOINT((1 1),(2 1),(2 2))');
1111
$this->assertInstanceOf(MultiPoint::class, $multipoint);
1212

1313
$this->assertEquals(3, $multipoint->count());
1414
}
1515

1616
public function testToWKT()
1717
{
18-
$collection = [new Point(0, 0), new Point(0, 1), new Point(1, 1)];
18+
$collection = [new Point(1, 1), new Point(1, 2), new Point(2, 2)];
1919

2020
$multipoint = new MultiPoint($collection);
2121

22-
$this->assertEquals('MULTIPOINT((0 0),(1 0),(1 1))', $multipoint->toWKT());
22+
$this->assertEquals('MULTIPOINT((1 1),(2 1),(2 2))', $multipoint->toWKT());
2323
}
2424

2525
public function testJsonSerialize()
2626
{
27-
$collection = [new Point(0, 0), new Point(0, 1), new Point(1, 1)];
27+
$collection = [new Point(1, 1), new Point(1, 2), new Point(2, 2)];
2828

2929
$multipoint = new MultiPoint($collection);
3030

3131
$this->assertInstanceOf(\GeoJson\Geometry\MultiPoint::class, $multipoint->jsonSerialize());
32-
$this->assertSame('{"type":"MultiPoint","coordinates":[[0,0],[1,0],[1,1]]}', json_encode($multipoint));
32+
$this->assertSame('{"type":"MultiPoint","coordinates":[[1,1],[2,1],[2,2]]}', json_encode($multipoint));
3333
}
3434
}

tests/Geometries/MultiPolygonTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ protected function setUp()
1616
{
1717
$collection1 = new LineString(
1818
[
19-
new Point(0, 0),
20-
new Point(0, 1),
2119
new Point(1, 1),
22-
new Point(1, 0),
23-
new Point(0, 0)
20+
new Point(1, 2),
21+
new Point(2, 2),
22+
new Point(2, 1),
23+
new Point(1, 1)
2424
]
2525
);
2626

@@ -54,19 +54,19 @@ protected function setUp()
5454

5555
public function testFromWKT()
5656
{
57-
$polygon = MultiPolygon::fromWKT(
58-
'MULTIPOLYGON(((0 0,4 0,4 4,0 4,0 0),(1 1,2 1,2 2,1 2,1 1)), ((-1 -1,-1 -2,-2 -2,-2 -1,-1 -1)))'
59-
);
57+
$wkt = 'MULTIPOLYGON(((1 1,2 1,2 2,1 2,1 1),(1 1,2 1,2 2,1 2,1 1)),((-1 -1,-1 -2,-2 -2,-2 -1,-1 -1)))';
58+
$polygon = MultiPolygon::fromWKT($wkt);
59+
6060
$this->assertInstanceOf(MultiPolygon::class, $polygon);
61-
6261
$this->assertEquals(2, $polygon->count());
62+
$this->assertEquals($wkt, $polygon->toWKT());
6363
}
6464

6565

6666
public function testToWKT()
6767
{
6868
$this->assertEquals(
69-
'MULTIPOLYGON(((0 0,1 0,1 1,0 1,0 0),(10 10,20 10,20 20,10 20,10 10)),((100 100,200 100,200 200,100 200,100 100)))',
69+
'MULTIPOLYGON(((1 1,2 1,2 2,1 2,1 1),(10 10,20 10,20 20,10 20,10 10)),((100 100,200 100,200 200,100 200,100 100)))',
7070
$this->multiPolygon->toWKT()
7171
);
7272
}
@@ -93,7 +93,7 @@ public function testJsonSerialize()
9393
{
9494
$this->assertInstanceOf(\GeoJson\Geometry\MultiPolygon::class, $this->multiPolygon->jsonSerialize());
9595
$this->assertSame(
96-
'{"type":"MultiPolygon","coordinates":[[[[0,0],[1,0],[1,1],[0,1],[0,0]],[[10,10],[20,10],[20,20],[10,20],[10,10]]],[[[100,100],[200,100],[200,200],[100,200],[100,100]]]]}',
96+
'{"type":"MultiPolygon","coordinates":[[[[1,1],[2,1],[2,2],[1,2],[1,1]],[[10,10],[20,10],[20,20],[10,20],[10,10]]],[[[100,100],[200,100],[200,200],[100,200],[100,100]]]]}',
9797
json_encode($this->multiPolygon)
9898
);
9999
}

tests/Geometries/PolygonTest.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ protected function setUp()
1212
{
1313
$collection = new LineString(
1414
[
15-
new Point(0, 0),
16-
new Point(0, 1),
1715
new Point(1, 1),
18-
new Point(1, 0),
19-
new Point(0, 0)
16+
new Point(1, 2),
17+
new Point(2, 2),
18+
new Point(2, 1),
19+
new Point(1, 1)
2020
]
2121
);
2222

@@ -26,22 +26,24 @@ protected function setUp()
2626

2727
public function testFromWKT()
2828
{
29-
$polygon = Polygon::fromWKT('POLYGON((0 0,4 0,4 4,0 4,0 0),(1 1, 2 1, 2 2, 1 2,1 1))');
29+
$wkt = 'POLYGON((1 1,5 1,5 5,1 5,1 1),(2 2,3 2,3 3,2 3,2 2))';
30+
$polygon = Polygon::fromWKT($wkt);
3031
$this->assertInstanceOf(Polygon::class, $polygon);
3132

3233
$this->assertEquals(2, $polygon->count());
34+
$this->assertEquals($wkt, $polygon->toWKT());
3335
}
3436

3537
public function testToWKT()
3638
{
37-
$this->assertEquals('POLYGON((0 0,1 0,1 1,0 1,0 0))', $this->polygon->toWKT());
39+
$this->assertEquals('POLYGON((1 1,2 1,2 2,1 2,1 1))', $this->polygon->toWKT());
3840
}
3941

4042
public function testJsonSerialize()
4143
{
4244
$this->assertInstanceOf(\GeoJson\Geometry\Polygon::class, $this->polygon->jsonSerialize());
4345
$this->assertSame(
44-
'{"type":"Polygon","coordinates":[[[0,0],[1,0],[1,1],[0,1],[0,0]]]}',
46+
'{"type":"Polygon","coordinates":[[[1,1],[2,1],[2,2],[1,2],[1,1]]]}',
4547
json_encode($this->polygon)
4648
);
4749

0 commit comments

Comments
 (0)