|
107 | 107 | expect($geometryCollectionFromJson)->toEqual($geometryCollection);
|
108 | 108 | });
|
109 | 109 |
|
| 110 | +it('creates geometry collection from Array', function (): void { |
| 111 | + $geometryCollection = new GeometryCollection([ |
| 112 | + new Polygon([ |
| 113 | + new LineString([ |
| 114 | + new Point(0, 180), |
| 115 | + new Point(1, 179), |
| 116 | + new Point(2, 178), |
| 117 | + new Point(3, 177), |
| 118 | + new Point(0, 180), |
| 119 | + ]), |
| 120 | + ]), |
| 121 | + new Point(0, 180), |
| 122 | + ]); |
| 123 | + |
| 124 | + $geometryCollectionFromJson = GeometryCollection::fromArray(json_decode('{"type":"GeometryCollection","geometries":[{"type":"Polygon","coordinates":[[[180,0],[179,1],[178,2],[177,3],[180,0]]]},{"type":"Point","coordinates":[180,0]}]}',true)); |
| 125 | + |
| 126 | + expect($geometryCollectionFromJson)->toEqual($geometryCollection); |
| 127 | +}); |
| 128 | + |
| 129 | +it('creates geometry collection with SRID from Array', function (): void { |
| 130 | + $geometryCollection = new GeometryCollection([ |
| 131 | + new Polygon([ |
| 132 | + new LineString([ |
| 133 | + new Point(0, 180), |
| 134 | + new Point(1, 179), |
| 135 | + new Point(2, 178), |
| 136 | + new Point(3, 177), |
| 137 | + new Point(0, 180), |
| 138 | + ]), |
| 139 | + ]), |
| 140 | + new Point(0, 180), |
| 141 | + ], Srid::WGS84->value); |
| 142 | + |
| 143 | + $geometryCollectionFromJson = GeometryCollection::fromArray(json_decode('{"type":"GeometryCollection","geometries":[{"type":"Polygon","coordinates":[[[180,0],[179,1],[178,2],[177,3],[180,0]]]},{"type":"Point","coordinates":[180,0]}]}',true), Srid::WGS84->value); |
| 144 | + |
| 145 | + expect($geometryCollectionFromJson)->toEqual($geometryCollection); |
| 146 | +}); |
| 147 | + |
110 | 148 | it('creates geometry collection from feature collection JSON', function (): void {
|
111 | 149 | $geometryCollection = new GeometryCollection([
|
112 | 150 | new Polygon([
|
|
126 | 164 | expect($geometryCollectionFromFeatureCollectionJson)->toEqual($geometryCollection);
|
127 | 165 | });
|
128 | 166 |
|
| 167 | +it('creates geometry collection from feature collection with SRID from JSON', function (): void { |
| 168 | + $geometryCollection = new GeometryCollection([ |
| 169 | + new Polygon([ |
| 170 | + new LineString([ |
| 171 | + new Point(0, 180), |
| 172 | + new Point(1, 179), |
| 173 | + new Point(2, 178), |
| 174 | + new Point(3, 177), |
| 175 | + new Point(0, 180), |
| 176 | + ]), |
| 177 | + ]), |
| 178 | + new Point(0, 180), |
| 179 | + ], Srid::WGS84); |
| 180 | + |
| 181 | + $geometryCollectionFromFeatureCollectionJson = GeometryCollection::fromJson('{"type":"FeatureCollection","features":[{"type":"Feature","properties":[],"geometry":{"type":"Polygon","coordinates":[[[180,0],[179,1],[178,2],[177,3],[180,0]]]}},{"type":"Feature","properties":[],"geometry":{"type":"Point","coordinates":[180,0]}}]}', Srid::WGS84); |
| 182 | + |
| 183 | + expect($geometryCollectionFromFeatureCollectionJson)->toEqual($geometryCollection); |
| 184 | +}); |
| 185 | + |
| 186 | +it('creates geometry collection from feature collection from Array', function (): void { |
| 187 | + $geometryCollection = new GeometryCollection([ |
| 188 | + new Polygon([ |
| 189 | + new LineString([ |
| 190 | + new Point(0, 180), |
| 191 | + new Point(1, 179), |
| 192 | + new Point(2, 178), |
| 193 | + new Point(3, 177), |
| 194 | + new Point(0, 180), |
| 195 | + ]), |
| 196 | + ]), |
| 197 | + new Point(0, 180), |
| 198 | + ]); |
| 199 | + |
| 200 | + $geometryCollectionFromFeatureCollectionJson = GeometryCollection::fromArray(json_decode('{"type":"FeatureCollection","features":[{"type":"Feature","properties":[],"geometry":{"type":"Polygon","coordinates":[[[180,0],[179,1],[178,2],[177,3],[180,0]]]}},{"type":"Feature","properties":[],"geometry":{"type":"Point","coordinates":[180,0]}}]}',true)); |
| 201 | + |
| 202 | + expect($geometryCollectionFromFeatureCollectionJson)->toEqual($geometryCollection); |
| 203 | +}); |
| 204 | + |
| 205 | +it('creates geometry collection from feature collection with SRID from Array', function (): void { |
| 206 | + $geometryCollection = new GeometryCollection([ |
| 207 | + new Polygon([ |
| 208 | + new LineString([ |
| 209 | + new Point(0, 180), |
| 210 | + new Point(1, 179), |
| 211 | + new Point(2, 178), |
| 212 | + new Point(3, 177), |
| 213 | + new Point(0, 180), |
| 214 | + ]), |
| 215 | + ]), |
| 216 | + new Point(0, 180), |
| 217 | + ], Srid::WGS84); |
| 218 | + |
| 219 | + $geometryCollectionFromFeatureCollectionJson = GeometryCollection::fromArray(json_decode('{"type":"FeatureCollection","features":[{"type":"Feature","properties":[],"geometry":{"type":"Polygon","coordinates":[[[180,0],[179,1],[178,2],[177,3],[180,0]]]}},{"type":"Feature","properties":[],"geometry":{"type":"Point","coordinates":[180,0]}}]}',true), Srid::WGS84); |
| 220 | + |
| 221 | + expect($geometryCollectionFromFeatureCollectionJson)->toEqual($geometryCollection); |
| 222 | +}); |
| 223 | + |
129 | 224 | it('generates geometry collection JSON', function (): void {
|
130 | 225 | $geometryCollection = new GeometryCollection([
|
131 | 226 | new Polygon([
|
|
0 commit comments