@dra2020/baseclient 1.0.16 → 1.0.17

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.
@@ -54,9 +54,10 @@ export function packCollection(coder: Util.Coder, col: any): ArrayBuffer
54
54
  {
55
55
  // Compute size
56
56
  let pp = PP.featurePack(col) as PP.PolyPack;
57
- let buffer: any = col.features.length ? col.features[0].geometry.packed.buffer : null; // to restore, below
57
+ let f: any = col.features.find((f: any) => { return f.geometry.packed ? f.geometry.packed.buffer : null });
58
+ let buffer: any = f ? f.geometry.packed.buffer : null;
58
59
  let size = 16; // int endiness, offset to coordinates, float endiness
59
- col.features.forEach((f: any) => { delete f.geometry.packed.buffer; }); // reconstructed when unpacking
60
+ col.features.forEach((f: any) => { if (f.geometry.packed) delete f.geometry.packed.buffer; }); // reconstructed when unpacking
60
61
  let j = JSON.stringify(col);
61
62
  size += sizeOfString(coder, j);
62
63
  size += pad(size, 8);
@@ -84,7 +85,7 @@ export function packCollection(coder: Util.Coder, col: any): ArrayBuffer
84
85
  buf64[foff++] = buf[i];
85
86
 
86
87
  // Now restore
87
- col.features.forEach((f: any) => { f.geometry.packed.buffer = buffer; });
88
+ col.features.forEach((f: any) => { if (f.geometry.packed) f.geometry.packed.buffer = buffer; });
88
89
  PP.featureUnpack(col);
89
90
 
90
91
  return ab;
@@ -144,7 +145,7 @@ export function unpackCollection(coder: Util.Coder, ab: ArrayBuffer): any
144
145
  let offset = 16;
145
146
  let j = unpackString(coder, buf8, buf32, offset);
146
147
  col = JSON.parse(j);
147
- col.features.forEach((f: any) => { f.geometry.packed.buffer = buf64 });
148
+ col.features.forEach((f: any) => { if (f.geometry.packed) f.geometry.packed.buffer = buf64 });
148
149
  return col;
149
150
  }
150
151
 
@@ -326,7 +326,7 @@ export function polyUnpack(prepack: any): any
326
326
 
327
327
  export function featurePackSize(f: any): number
328
328
  {
329
- if (f && f.geometry && f.geometry.coordinates)
329
+ if (f && f.geometry && f.geometry.coordinates && f.geometry.type !== 'Point')
330
330
  return polyPackSize(f.geometry.coordinates);
331
331
  return 0;
332
332
  }
@@ -335,7 +335,9 @@ export function featurePack(f: any, prepack?: PolyPack): any
335
335
  {
336
336
  if (f && f.type === 'Feature')
337
337
  {
338
- if (f.geometry && f.geometry.coordinates)
338
+ if (f.geometry && f.geometry.type === 'Point')
339
+ return prepack ? { offset: prepack.offset, length: 0, buffer: prepack.buffer } : { offset: 0, length: 0, buffer: null };
340
+ else if (f.geometry && f.geometry.coordinates)
339
341
  {
340
342
  f.geometry.packed = polyPack(f.geometry.coordinates, prepack);
341
343
  delete f.geometry.coordinates;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dra2020/baseclient",
3
- "version": "1.0.16",
3
+ "version": "1.0.17",
4
4
  "description": "Utility functions for Javascript projects.",
5
5
  "main": "dist/baseclient.js",
6
6
  "types": "./dist/all/all.d.ts",