@dra2020/dra-types 1.8.95 → 1.8.97
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/datasets.d.ts +1 -0
- package/dist/dra-types.js +14 -26
- package/dist/dra-types.js.map +1 -1
- package/dist/packedfields.d.ts +2 -2
- package/lib/datasets.ts +1 -0
- package/lib/packedfields.ts +12 -31
- package/lib/splittogeofeature.ts +1 -0
- package/package.json +1 -1
package/dist/packedfields.d.ts
CHANGED
|
@@ -69,7 +69,6 @@ export type DSLists = {
|
|
|
69
69
|
election: DSList;
|
|
70
70
|
};
|
|
71
71
|
export type PlanTypePlus = PlanType | '';
|
|
72
|
-
export declare function fGetJoined(f: any): any[];
|
|
73
72
|
export declare function fGet(f: any, p: string): any;
|
|
74
73
|
export declare function sortedFieldList(ds: DatasetMeta): string[];
|
|
75
74
|
export declare function computeMetaIndex(datasetid: string, meta: DatasetsMeta): PackedMetaIndex;
|
|
@@ -79,10 +78,11 @@ export declare function setPackedFields(f: any, pf: PackedFields, fIndex: any):
|
|
|
79
78
|
export declare function isExtDataset(did: string): boolean;
|
|
80
79
|
export type ExtPackedFields = Uint32Array;
|
|
81
80
|
export type ExtBlockCardinality = Map<string, number>;
|
|
82
|
-
export declare function featurePushExtPackedFields(f: any, datasetid: string, data: ExtPackedFields, card: ExtBlockCardinality): void;
|
|
81
|
+
export declare function featurePushExtPackedFields(f: any, datasetid: string, index: PackedMetaIndex, data: ExtPackedFields, card: ExtBlockCardinality): void;
|
|
83
82
|
export declare function featurePushedExtPackedFields(f: any, datasetid: string, card: ExtBlockCardinality): boolean;
|
|
84
83
|
export declare function pushedExtPackedFields(pf: PackedFields, datasetids: string[]): boolean;
|
|
85
84
|
export declare function retrievePackedFields(f: any): PackedFields;
|
|
85
|
+
export declare function retrievePackedIndex(f: any): GroupPackedMetaIndex;
|
|
86
86
|
export declare function zeroPackedFields(index: GroupPackedMetaIndex): PackedFields;
|
|
87
87
|
export declare function zeroPackedCopy(pf: PackedFields): PackedFields;
|
|
88
88
|
export declare function packedCopy(pf: PackedFields): PackedFields;
|
package/lib/datasets.ts
CHANGED
package/lib/packedfields.ts
CHANGED
|
@@ -120,11 +120,6 @@ export type DSLists = {
|
|
|
120
120
|
|
|
121
121
|
export type PlanTypePlus = PlanType | '';
|
|
122
122
|
|
|
123
|
-
export function fGetJoined(f: any): any[]
|
|
124
|
-
{
|
|
125
|
-
return (f.properties && f.properties.joined) ? f.properties.joined : undefined;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
123
|
export function fGet(f: any, p: string): any
|
|
129
124
|
{
|
|
130
125
|
return fGetW(f, null, p);
|
|
@@ -148,30 +143,6 @@ function fGetW(f: any, datasetKey: string, p: string): any
|
|
|
148
143
|
return f.properties.datasets[datasetKey][pBackup];
|
|
149
144
|
}
|
|
150
145
|
|
|
151
|
-
// Joined property?
|
|
152
|
-
let a: any[] = fGetJoined(f);
|
|
153
|
-
if (a)
|
|
154
|
-
{
|
|
155
|
-
for (let i: number = 0; i < a.length; i++)
|
|
156
|
-
{
|
|
157
|
-
let o: any = a[i];
|
|
158
|
-
if (!datasetKey)
|
|
159
|
-
{
|
|
160
|
-
if (o[p] !== undefined)
|
|
161
|
-
return o[p];
|
|
162
|
-
}
|
|
163
|
-
else
|
|
164
|
-
{
|
|
165
|
-
if (o['datasets'] && o['datasets'][datasetKey] != null)
|
|
166
|
-
{
|
|
167
|
-
if (o['datasets'][datasetKey][p] != null)
|
|
168
|
-
return o['datasets'][datasetKey][p];
|
|
169
|
-
else if (pBackup && o['datasets'][datasetKey][pBackup] != null)
|
|
170
|
-
return o['datasets'][datasetKey][pBackup];
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
146
|
return undefined;
|
|
176
147
|
}
|
|
177
148
|
|
|
@@ -195,10 +166,11 @@ export function computeMetaIndex(datasetid: string, meta: DatasetsMeta): PackedM
|
|
|
195
166
|
});
|
|
196
167
|
index.fields[datasetKey] = fieldsIndex;
|
|
197
168
|
});
|
|
198
|
-
let groupindex = { [datasetid]: index };
|
|
199
169
|
index.length = offset;
|
|
200
170
|
index.getDatasetField = (f: any, dataset: string, field: string): number => {
|
|
201
171
|
let pf = retrievePackedFields(f);
|
|
172
|
+
let groupindex = retrievePackedIndex(f);
|
|
173
|
+
let datasetid = dataset.length > 20 ? dataset : ''; // hack - extended datasets use 26 char guids, built-in ones are short
|
|
202
174
|
return getPackedField(groupindex, pf, datasetid, dataset, field);
|
|
203
175
|
};
|
|
204
176
|
return index;
|
|
@@ -229,6 +201,7 @@ export function computePackedFields(f: any, index: PackedMetaIndex): PackedField
|
|
|
229
201
|
af[fields[field]] = n;
|
|
230
202
|
});
|
|
231
203
|
});
|
|
204
|
+
f.properties.packedIndex = { ['']: index };
|
|
232
205
|
f.properties.packedFields = { ['']: af }; // cache here
|
|
233
206
|
f.properties.getDatasetField = index.getDatasetField;
|
|
234
207
|
|
|
@@ -245,6 +218,7 @@ export function hasPackedFields(f: any): boolean
|
|
|
245
218
|
export function setPackedFields(f: any, pf: PackedFields, fIndex: any): void
|
|
246
219
|
{
|
|
247
220
|
if (f.properties.packedFields !== undefined) throw 'Packed fields already set';
|
|
221
|
+
f.properties.packedIndex = fIndex.properties.packedIndex;
|
|
248
222
|
f.properties.packedFields = pf;
|
|
249
223
|
f.properties.getDatasetField = fIndex.properties.getDatasetField
|
|
250
224
|
}
|
|
@@ -258,7 +232,7 @@ export function isExtDataset(did: string): boolean
|
|
|
258
232
|
export type ExtPackedFields = Uint32Array; // [nblocks][nfields][fields]...
|
|
259
233
|
export type ExtBlockCardinality = Map<string, number>;
|
|
260
234
|
|
|
261
|
-
export function featurePushExtPackedFields(f: any, datasetid: string, data: ExtPackedFields, card: ExtBlockCardinality): void
|
|
235
|
+
export function featurePushExtPackedFields(f: any, datasetid: string, index: PackedMetaIndex, data: ExtPackedFields, card: ExtBlockCardinality): void
|
|
262
236
|
{
|
|
263
237
|
let blocks = f?.properties?.blocks || (card.has(f.properties.id) ? [ f.properties.id ] : null);
|
|
264
238
|
if (!blocks)
|
|
@@ -281,6 +255,7 @@ export function featurePushExtPackedFields(f: any, datasetid: string, data: ExtP
|
|
|
281
255
|
pfa[i] += data[x++];
|
|
282
256
|
});
|
|
283
257
|
f.properties.packedFields[datasetid] = pfa;
|
|
258
|
+
f.properties.packedIndex[datasetid] = index;
|
|
284
259
|
}
|
|
285
260
|
|
|
286
261
|
export function featurePushedExtPackedFields(f: any, datasetid: string, card: ExtBlockCardinality): boolean
|
|
@@ -309,6 +284,12 @@ export function retrievePackedFields(f: any): PackedFields
|
|
|
309
284
|
return f.properties.packedFields as PackedFields;
|
|
310
285
|
}
|
|
311
286
|
|
|
287
|
+
export function retrievePackedIndex(f: any): GroupPackedMetaIndex
|
|
288
|
+
{
|
|
289
|
+
if (f.properties.packedIndex === undefined) throw 'Feature should have pre-computed packed index';
|
|
290
|
+
return f.properties.packedIndex as GroupPackedMetaIndex;
|
|
291
|
+
}
|
|
292
|
+
|
|
312
293
|
// The first entry in the PackedFields aggregate is the count of items aggregated.
|
|
313
294
|
// Treat a null instance as just a single entry with no aggregates.
|
|
314
295
|
let abZero = new ArrayBuffer(8);
|
package/lib/splittogeofeature.ts
CHANGED
|
@@ -26,6 +26,7 @@ export function splitToGeoFeature(split: DT.SplitBlock, topoPrecinct: Poly.Topo,
|
|
|
26
26
|
if (! f.properties.packedFields)
|
|
27
27
|
{
|
|
28
28
|
f.properties.packedFields = PF.packedCopy(b.properties.packedFields);
|
|
29
|
+
f.properties.packedIndex = b.properties.packedIndex;
|
|
29
30
|
f.properties.getDatasetField = b.properties.getDatasetField;
|
|
30
31
|
}
|
|
31
32
|
else
|