@dra2020/baseclient 1.0.11 → 1.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/baseclient.js +11 -2
- package/dist/baseclient.js.map +1 -1
- package/lib/poly/polypack.ts +12 -2
- package/package.json +1 -1
package/lib/poly/polypack.ts
CHANGED
|
@@ -221,7 +221,8 @@ export function polyPack(coords: any, prepack?: PolyPack): PolyPack
|
|
|
221
221
|
|
|
222
222
|
// Transparently handle polygon or multi-polygon
|
|
223
223
|
let depth = Util.depthof(coords);
|
|
224
|
-
if (depth ==
|
|
224
|
+
if (depth == 2) coords = [ [ [ coords ] ] ];
|
|
225
|
+
else if (depth == 3) coords = [ [ coords ] ];
|
|
225
226
|
else if (depth == 4) coords = [ coords ];
|
|
226
227
|
|
|
227
228
|
let nFloats = polyPackSize(coords);
|
|
@@ -374,9 +375,18 @@ export function featureUnpack(f: any): any
|
|
|
374
375
|
if (f && f.geometry && f.geometry.packed !== undefined)
|
|
375
376
|
{
|
|
376
377
|
f.geometry.coordinates = polyUnpack(f.geometry.packed);
|
|
378
|
+
let depth = Util.depthof(f.geometry.coordinates);
|
|
377
379
|
// Check for oops, optimized away the multipolygon in polyUnpack
|
|
378
|
-
if (f.geometry.type === 'MultiPolygon' &&
|
|
380
|
+
if (f.geometry.type === 'MultiPolygon' && depth === 4)
|
|
379
381
|
f.geometry.coordinates = [ f.geometry.coordinates ];
|
|
382
|
+
else if (f.geometry.type === 'Point' && depth != 2)
|
|
383
|
+
{
|
|
384
|
+
while (depth > 2)
|
|
385
|
+
{
|
|
386
|
+
f.geometry.coordinates = f.geometry.coordinates[0];
|
|
387
|
+
depth = Util.depthof(f.geometry.coordinates);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
380
390
|
delete f.geometry.packed;
|
|
381
391
|
}
|
|
382
392
|
else if (f.type && f.type === 'FeatureCollection' && f.features)
|