Skip to content

Commit 89f11df

Browse files
committed
make geometry objects params more diversified
1 parent 0a1acb4 commit 89f11df

File tree

7 files changed

+151
-151
lines changed

7 files changed

+151
-151
lines changed

tests/Objects/GeometryCollectionTest.php

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ public function it_stores_geometry_collection(): void
2222
'geometry_collection' => new GeometryCollection([
2323
new Polygon([
2424
new LineString([
25-
new Point(0, 0),
26-
new Point(1, 1),
27-
new Point(2, 2),
28-
new Point(3, 3),
29-
new Point(0, 0),
25+
new Point(180, 0),
26+
new Point(179, 1),
27+
new Point(178, 2),
28+
new Point(177, 3),
29+
new Point(180, 0),
3030
]),
3131
]),
32-
new Point(0, 0),
32+
new Point(180, 0),
3333
]),
34-
])->fresh();
34+
]);
3535

3636
$this->assertTrue($testPlace->geometry_collection instanceof GeometryCollection);
3737

@@ -41,21 +41,21 @@ public function it_stores_geometry_collection(): void
4141
$lineStrings = $polygon->getGeometries();
4242
$points = $lineStrings[0]->getGeometries();
4343

44-
$this->assertEquals(0, $points[0]->latitude);
44+
$this->assertEquals(180, $points[0]->latitude);
4545
$this->assertEquals(0, $points[0]->longitude);
46-
$this->assertEquals(1, $points[1]->latitude);
46+
$this->assertEquals(179, $points[1]->latitude);
4747
$this->assertEquals(1, $points[1]->longitude);
48-
$this->assertEquals(2, $points[2]->latitude);
48+
$this->assertEquals(178, $points[2]->latitude);
4949
$this->assertEquals(2, $points[2]->longitude);
50-
$this->assertEquals(3, $points[3]->latitude);
50+
$this->assertEquals(177, $points[3]->latitude);
5151
$this->assertEquals(3, $points[3]->longitude);
52-
$this->assertEquals(0, $points[4]->latitude);
52+
$this->assertEquals(180, $points[4]->latitude);
5353
$this->assertEquals(0, $points[4]->longitude);
5454

5555
/** @var Point $point */
5656
$point = $geometries[1];
5757

58-
$this->assertEquals(0, $point->latitude);
58+
$this->assertEquals(180, $point->latitude);
5959
$this->assertEquals(0, $point->longitude);
6060

6161
$this->assertDatabaseCount($testPlace->getTable(), 1);
@@ -66,8 +66,8 @@ public function it_stores_geometry_collection_from_geo_json(): void
6666
{
6767
/** @var TestPlace $testPlace */
6868
$testPlace = TestPlace::factory()->create([
69-
'geometry_collection' => GeometryCollection::fromJson('{"type":"GeometryCollection","geometries":[{"type":"Polygon","coordinates":[[[0,0],[1,1],[2,2],[3,3],[0,0]]]},{"type":"Point","coordinates":[0,0]}]}'),
70-
])->fresh();
69+
'geometry_collection' => GeometryCollection::fromJson('{"type":"GeometryCollection","geometries":[{"type":"Polygon","coordinates":[[[0,180],[1,179],[2,178],[3,177],[0,180]]]},{"type":"Point","coordinates":[0,180]}]}'),
70+
]);
7171

7272
$this->assertTrue($testPlace->geometry_collection instanceof GeometryCollection);
7373

@@ -77,21 +77,21 @@ public function it_stores_geometry_collection_from_geo_json(): void
7777
$lineStrings = $polygon->getGeometries();
7878
$points = $lineStrings[0]->getGeometries();
7979

80-
$this->assertEquals(0, $points[0]->latitude);
80+
$this->assertEquals(180, $points[0]->latitude);
8181
$this->assertEquals(0, $points[0]->longitude);
82-
$this->assertEquals(1, $points[1]->latitude);
82+
$this->assertEquals(179, $points[1]->latitude);
8383
$this->assertEquals(1, $points[1]->longitude);
84-
$this->assertEquals(2, $points[2]->latitude);
84+
$this->assertEquals(178, $points[2]->latitude);
8585
$this->assertEquals(2, $points[2]->longitude);
86-
$this->assertEquals(3, $points[3]->latitude);
86+
$this->assertEquals(177, $points[3]->latitude);
8787
$this->assertEquals(3, $points[3]->longitude);
88-
$this->assertEquals(0, $points[4]->latitude);
88+
$this->assertEquals(180, $points[4]->latitude);
8989
$this->assertEquals(0, $points[4]->longitude);
9090

9191
/** @var Point $point */
9292
$point = $geometries[1];
9393

94-
$this->assertEquals(0, $point->latitude);
94+
$this->assertEquals(180, $point->latitude);
9595
$this->assertEquals(0, $point->longitude);
9696

9797
$this->assertDatabaseCount($testPlace->getTable(), 1);
@@ -102,8 +102,8 @@ public function it_stores_geometry_collection_from_feature_collection_geo_json()
102102
{
103103
/** @var TestPlace $testPlace */
104104
$testPlace = TestPlace::factory()->create([
105-
'geometry_collection' => GeometryCollection::fromJson('{"type":"FeatureCollection","features":[{"type":"Feature","properties":[],"geometry":{"type":"Polygon","coordinates":[[[0,0],[1,1],[2,2],[3,3],[0,0]]]}},{"type":"Feature","properties":[],"geometry":{"type":"Point","coordinates":[0,0]}}]}'),
106-
])->fresh();
105+
'geometry_collection' => GeometryCollection::fromJson('{"type":"FeatureCollection","features":[{"type":"Feature","properties":[],"geometry":{"type":"Polygon","coordinates":[[[0,180],[1,179],[2,178],[3,177],[0,180]]]}},{"type":"Feature","properties":[],"geometry":{"type":"Point","coordinates":[0,180]}}]}'),
106+
]);
107107

108108
$this->assertTrue($testPlace->geometry_collection instanceof GeometryCollection);
109109

@@ -113,21 +113,21 @@ public function it_stores_geometry_collection_from_feature_collection_geo_json()
113113
$lineStrings = $polygon->getGeometries();
114114
$points = $lineStrings[0]->getGeometries();
115115

116-
$this->assertEquals(0, $points[0]->latitude);
116+
$this->assertEquals(180, $points[0]->latitude);
117117
$this->assertEquals(0, $points[0]->longitude);
118-
$this->assertEquals(1, $points[1]->latitude);
118+
$this->assertEquals(179, $points[1]->latitude);
119119
$this->assertEquals(1, $points[1]->longitude);
120-
$this->assertEquals(2, $points[2]->latitude);
120+
$this->assertEquals(178, $points[2]->latitude);
121121
$this->assertEquals(2, $points[2]->longitude);
122-
$this->assertEquals(3, $points[3]->latitude);
122+
$this->assertEquals(177, $points[3]->latitude);
123123
$this->assertEquals(3, $points[3]->longitude);
124-
$this->assertEquals(0, $points[4]->latitude);
124+
$this->assertEquals(180, $points[4]->latitude);
125125
$this->assertEquals(0, $points[4]->longitude);
126126

127127
/** @var Point $point */
128128
$point = $geometries[1];
129129

130-
$this->assertEquals(0, $point->latitude);
130+
$this->assertEquals(180, $point->latitude);
131131
$this->assertEquals(0, $point->longitude);
132132

133133
$this->assertDatabaseCount($testPlace->getTable(), 1);
@@ -139,18 +139,18 @@ public function it_generates_geometry_collection_geo_json(): void
139139
$geometryCollection = new GeometryCollection([
140140
new Polygon([
141141
new LineString([
142-
new Point(0, 0),
143-
new Point(1, 1),
144-
new Point(2, 2),
145-
new Point(3, 3),
146-
new Point(0, 0),
142+
new Point(180, 0),
143+
new Point(179, 1),
144+
new Point(178, 2),
145+
new Point(177, 3),
146+
new Point(180, 0),
147147
]),
148148
]),
149-
new Point(0, 0),
149+
new Point(180, 0),
150150
]);
151151

152152
$this->assertEquals(
153-
'{"type":"GeometryCollection","geometries":[{"type":"Polygon","coordinates":[[[0,0],[1,1],[2,2],[3,3],[0,0]]]},{"type":"Point","coordinates":[0,0]}]}',
153+
'{"type":"GeometryCollection","geometries":[{"type":"Polygon","coordinates":[[[0,180],[1,179],[2,178],[3,177],[0,180]]]},{"type":"Point","coordinates":[0,180]}]}',
154154
$geometryCollection->toJson()
155155
);
156156
}
@@ -161,18 +161,18 @@ public function it_generates_geometry_collection_feature_collection_json(): void
161161
$geometryCollection = new GeometryCollection([
162162
new Polygon([
163163
new LineString([
164-
new Point(0, 0),
165-
new Point(1, 1),
166-
new Point(2, 2),
167-
new Point(3, 3),
168-
new Point(0, 0),
164+
new Point(180, 0),
165+
new Point(179, 1),
166+
new Point(178, 2),
167+
new Point(177, 3),
168+
new Point(180, 0),
169169
]),
170170
]),
171-
new Point(0, 0),
171+
new Point(180, 0),
172172
]);
173173

174174
$this->assertEquals(
175-
'{"type":"FeatureCollection","features":[{"type":"Feature","properties":[],"geometry":{"type":"Polygon","coordinates":[[[0,0],[1,1],[2,2],[3,3],[0,0]]]}},{"type":"Feature","properties":[],"geometry":{"type":"Point","coordinates":[0,0]}}]}',
175+
'{"type":"FeatureCollection","features":[{"type":"Feature","properties":[],"geometry":{"type":"Polygon","coordinates":[[[0,180],[1,179],[2,178],[3,177],[0,180]]]}},{"type":"Feature","properties":[],"geometry":{"type":"Point","coordinates":[0,180]}}]}',
176176
$geometryCollection->toFeatureCollectionJson()
177177
);
178178
}

tests/Objects/LineStringTest.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@ public function it_stores_line_string(): void
1818
/** @var TestPlace $testPlace */
1919
$testPlace = TestPlace::factory()->create([
2020
'line_string' => new LineString([
21-
new Point(0, 0),
22-
new Point(1, 1),
21+
new Point(180, 0),
22+
new Point(179, 1),
2323
]),
24-
])->fresh();
24+
]);
2525

2626
$this->assertTrue($testPlace->line_string instanceof LineString);
2727

2828
$points = $testPlace->line_string->getGeometries();
2929

30-
$this->assertEquals(0, $points[0]->latitude);
30+
$this->assertEquals(180, $points[0]->latitude);
3131
$this->assertEquals(0, $points[0]->longitude);
32-
$this->assertEquals(1, $points[1]->latitude);
32+
$this->assertEquals(179, $points[1]->latitude);
3333
$this->assertEquals(1, $points[1]->longitude);
3434

3535
$this->assertDatabaseCount($testPlace->getTable(), 1);
@@ -40,16 +40,16 @@ public function it_stores_line_string_from_json(): void
4040
{
4141
/** @var TestPlace $testPlace */
4242
$testPlace = TestPlace::factory()->create([
43-
'line_string' => LineString::fromJson('{"type":"LineString","coordinates":[[0,0],[1,1]]}'),
44-
])->fresh();
43+
'line_string' => LineString::fromJson('{"type":"LineString","coordinates":[[0,180],[1,179]]}'),
44+
]);
4545

4646
$this->assertTrue($testPlace->line_string instanceof LineString);
4747

4848
$points = $testPlace->line_string->getGeometries();
4949

50-
$this->assertEquals(0, $points[0]->latitude);
50+
$this->assertEquals(180, $points[0]->latitude);
5151
$this->assertEquals(0, $points[0]->longitude);
52-
$this->assertEquals(1, $points[1]->latitude);
52+
$this->assertEquals(179, $points[1]->latitude);
5353
$this->assertEquals(1, $points[1]->longitude);
5454

5555
$this->assertDatabaseCount($testPlace->getTable(), 1);
@@ -59,21 +59,21 @@ public function it_stores_line_string_from_json(): void
5959
public function it_generates_line_string_geo_json(): void
6060
{
6161
$lineString = new LineString([
62-
new Point(0, 0),
63-
new Point(1, 1),
62+
new Point(180, 0),
63+
new Point(179, 1),
6464
]);
6565

66-
$this->assertEquals('{"type":"LineString","coordinates":[[0,0],[1,1]]}', $lineString->toJson());
66+
$this->assertEquals('{"type":"LineString","coordinates":[[0,180],[1,179]]}', $lineString->toJson());
6767
}
6868

6969
/** @test */
7070
public function it_generates_line_string_feature_collection_json(): void
7171
{
7272
$lineString = new LineString([
73-
new Point(0, 0),
74-
new Point(1, 1),
73+
new Point(180, 0),
74+
new Point(179, 1),
7575
]);
7676

77-
$this->assertEquals('{"type":"FeatureCollection","features":[{"type":"Feature","properties":[],"geometry":{"type":"LineString","coordinates":[[0,0],[1,1]]}}]}', $lineString->toFeatureCollectionJson());
77+
$this->assertEquals('{"type":"FeatureCollection","features":[{"type":"Feature","properties":[],"geometry":{"type":"LineString","coordinates":[[0,180],[1,179]]}}]}', $lineString->toFeatureCollectionJson());
7878
}
7979
}

tests/Objects/MultiLineStringTest.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,20 @@ public function it_stores_multi_line_string(): void
2020
$testPlace = TestPlace::factory()->create([
2121
'multi_line_string' => new MultiLineString([
2222
new LineString([
23-
new Point(0, 0),
24-
new Point(1, 1),
23+
new Point(180, 0),
24+
new Point(179, 1),
2525
]),
2626
]),
27-
])->fresh();
27+
]);
2828

2929
$this->assertTrue($testPlace->multi_line_string instanceof MultiLineString);
3030

3131
$lineStrings = $testPlace->multi_line_string->getGeometries();
3232
$points = $lineStrings[0]->getGeometries();
3333

34-
$this->assertEquals(0, $points[0]->latitude);
34+
$this->assertEquals(180, $points[0]->latitude);
3535
$this->assertEquals(0, $points[0]->longitude);
36-
$this->assertEquals(1, $points[1]->latitude);
36+
$this->assertEquals(179, $points[1]->latitude);
3737
$this->assertEquals(1, $points[1]->longitude);
3838

3939
$this->assertDatabaseCount($testPlace->getTable(), 1);
@@ -44,17 +44,17 @@ public function it_stores_multi_line_string_from_geo_json(): void
4444
{
4545
/** @var TestPlace $testPlace */
4646
$testPlace = TestPlace::factory()->create([
47-
'multi_line_string' => MultiLineString::fromJson('{"type":"MultiLineString","coordinates":[[[0,0],[1,1]]]}'),
48-
])->fresh();
47+
'multi_line_string' => MultiLineString::fromJson('{"type":"MultiLineString","coordinates":[[[0,180],[1,179]]]}'),
48+
]);
4949

5050
$this->assertTrue($testPlace->multi_line_string instanceof MultiLineString);
5151

5252
$lineStrings = $testPlace->multi_line_string->getGeometries();
5353
$points = $lineStrings[0]->getGeometries();
5454

55-
$this->assertEquals(0, $points[0]->latitude);
55+
$this->assertEquals(180, $points[0]->latitude);
5656
$this->assertEquals(0, $points[0]->longitude);
57-
$this->assertEquals(1, $points[1]->latitude);
57+
$this->assertEquals(179, $points[1]->latitude);
5858
$this->assertEquals(1, $points[1]->longitude);
5959

6060
$this->assertDatabaseCount($testPlace->getTable(), 1);
@@ -65,24 +65,24 @@ public function it_generates_multi_line_string_geo_json(): void
6565
{
6666
$multiLineString = new MultiLineString([
6767
new LineString([
68-
new Point(0, 0),
69-
new Point(1, 1),
68+
new Point(180, 0),
69+
new Point(179, 1),
7070
]),
7171
]);
7272

73-
$this->assertEquals('{"type":"MultiLineString","coordinates":[[[0,0],[1,1]]]}', $multiLineString->toJson());
73+
$this->assertEquals('{"type":"MultiLineString","coordinates":[[[0,180],[1,179]]]}', $multiLineString->toJson());
7474
}
7575

7676
/** @test */
7777
public function it_generates_multi_line_string_feature_collection_json(): void
7878
{
7979
$multiLineString = new MultiLineString([
8080
new LineString([
81-
new Point(0, 0),
82-
new Point(1, 1),
81+
new Point(180, 0),
82+
new Point(179, 1),
8383
]),
8484
]);
8585

86-
$this->assertEquals('{"type":"FeatureCollection","features":[{"type":"Feature","properties":[],"geometry":{"type":"MultiLineString","coordinates":[[[0,0],[1,1]]]}}]}', $multiLineString->toFeatureCollectionJson());
86+
$this->assertEquals('{"type":"FeatureCollection","features":[{"type":"Feature","properties":[],"geometry":{"type":"MultiLineString","coordinates":[[[0,180],[1,179]]]}}]}', $multiLineString->toFeatureCollectionJson());
8787
}
8888
}

tests/Objects/MultiPointTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ public function it_stores_multi_point(): void
1818
/** @var TestPlace $testPlace */
1919
$testPlace = TestPlace::factory()->create([
2020
'multi_point' => new MultiPoint([
21-
new Point(0, 0),
21+
new Point(180, 0),
2222
]),
23-
])->fresh();
23+
]);
2424

2525
$this->assertTrue($testPlace->multi_point instanceof MultiPoint);
2626

2727
$points = $testPlace->multi_point->getGeometries();
2828

29-
$this->assertEquals(0, $points[0]->latitude);
29+
$this->assertEquals(180, $points[0]->latitude);
3030
$this->assertEquals(0, $points[0]->longitude);
3131

3232
$this->assertDatabaseCount($testPlace->getTable(), 1);
@@ -37,14 +37,14 @@ public function it_stores_multi_point_from_json(): void
3737
{
3838
/** @var TestPlace $testPlace */
3939
$testPlace = TestPlace::factory()->create([
40-
'multi_point' => MultiPoint::fromJson('{"type":"MultiPoint","coordinates":[[0,0]]}'),
41-
])->fresh();
40+
'multi_point' => MultiPoint::fromJson('{"type":"MultiPoint","coordinates":[[0,180]]}'),
41+
]);
4242

4343
$this->assertTrue($testPlace->multi_point instanceof MultiPoint);
4444

4545
$points = $testPlace->multi_point->getGeometries();
4646

47-
$this->assertEquals(0, $points[0]->latitude);
47+
$this->assertEquals(180, $points[0]->latitude);
4848
$this->assertEquals(0, $points[0]->longitude);
4949

5050
$this->assertDatabaseCount($testPlace->getTable(), 1);
@@ -54,19 +54,19 @@ public function it_stores_multi_point_from_json(): void
5454
public function it_generates_multi_point_geo_json(): void
5555
{
5656
$multiPoint = new MultiPoint([
57-
new Point(0, 0),
57+
new Point(180, 0),
5858
]);
5959

60-
$this->assertEquals('{"type":"MultiPoint","coordinates":[[0,0]]}', $multiPoint->toJson());
60+
$this->assertEquals('{"type":"MultiPoint","coordinates":[[0,180]]}', $multiPoint->toJson());
6161
}
6262

6363
/** @test */
6464
public function it_generates_multi_point_feature_collection_json(): void
6565
{
6666
$multiPoint = new MultiPoint([
67-
new Point(0, 0),
67+
new Point(180, 0),
6868
]);
6969

70-
$this->assertEquals('{"type":"FeatureCollection","features":[{"type":"Feature","properties":[],"geometry":{"type":"MultiPoint","coordinates":[[0,0]]}}]}', $multiPoint->toFeatureCollectionJson());
70+
$this->assertEquals('{"type":"FeatureCollection","features":[{"type":"Feature","properties":[],"geometry":{"type":"MultiPoint","coordinates":[[0,180]]}}]}', $multiPoint->toFeatureCollectionJson());
7171
}
7272
}

0 commit comments

Comments
 (0)