@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.
@@ -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 == 3) coords = [ [ coords ] ];
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' && Util.depthof(f.geometry.coordinates) === 4)
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)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dra2020/baseclient",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "description": "Utility functions for Javascript projects.",
5
5
  "main": "dist/baseclient.js",
6
6
  "types": "./dist/all/all.d.ts",