@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.
- package/dist/baseclient.js +12 -6
- package/dist/baseclient.js.map +1 -1
- package/lib/poly/polybin.ts +5 -4
- package/lib/poly/polypack.ts +4 -2
- package/package.json +1 -1
package/lib/poly/polybin.ts
CHANGED
|
@@ -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
|
|
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
|
|
package/lib/poly/polypack.ts
CHANGED
|
@@ -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.
|
|
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;
|