@dra2020/dra-types 1.8.121 → 1.8.123
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 +42 -8
- package/dist/dra-types.js.map +1 -1
- package/dist/packedfields.d.ts +4 -0
- package/lib/datasets.ts +1 -0
- package/lib/packedfields.ts +47 -7
- package/package.json +2 -2
package/dist/packedfields.d.ts
CHANGED
|
@@ -69,8 +69,12 @@ export type DSLists = {
|
|
|
69
69
|
export type PlanTypePlus = PlanType | '';
|
|
70
70
|
export declare function fGet(f: any, p: string): any;
|
|
71
71
|
export declare function sortedFieldList(ds: DatasetMeta): string[];
|
|
72
|
+
export declare function getDatasetField(f: any, dataset: string, field: string): number;
|
|
72
73
|
export declare function computeMetaIndex(datasetid: string, meta: DatasetsMeta): PackedMetaIndex;
|
|
74
|
+
export declare function initPackedFields(f: any): void;
|
|
73
75
|
export declare function computePackedFields(f: any, index: PackedMetaIndex): PackedFields;
|
|
76
|
+
export declare function computeOnePackedFields(f: any, index: PackedMetaIndex, did: string, datasetKey: string): PackedFields;
|
|
77
|
+
export declare function clearPackedFields(f: any): void;
|
|
74
78
|
export declare function hasPackedFields(f: any): boolean;
|
|
75
79
|
export declare function setPackedFields(f: any, pf: PackedFields, fIndex: any): void;
|
|
76
80
|
export declare function isExtDataset(did: string): boolean;
|
package/lib/datasets.ts
CHANGED
|
@@ -76,6 +76,7 @@ export interface DatasetMeta
|
|
|
76
76
|
colors?: DatasetColors, // Optional colorby expressions
|
|
77
77
|
formats?: DatasetFormats, // Optional format expressions
|
|
78
78
|
displayPercent?: boolean, // True if details should auto include percent
|
|
79
|
+
hideHeading?: boolean, // True if details should hide heading row
|
|
79
80
|
}
|
|
80
81
|
|
|
81
82
|
export type DatasetsMeta = { [dataset: string]: DatasetMeta };
|
package/lib/packedfields.ts
CHANGED
|
@@ -154,6 +154,14 @@ export function sortedFieldList(ds: DatasetMeta): string[]
|
|
|
154
154
|
return kv.map(kv => kv.k);
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
+
export function getDatasetField(f: any, dataset: string, field: string): number
|
|
158
|
+
{
|
|
159
|
+
let pf = retrievePackedFields(f);
|
|
160
|
+
let dxGroup = retrievePackedIndex(f);
|
|
161
|
+
let did = toDatasetID(dataset);
|
|
162
|
+
return getPackedField(dxGroup, pf, did, dataset, field);
|
|
163
|
+
}
|
|
164
|
+
|
|
157
165
|
export function computeMetaIndex(datasetid: string, meta: DatasetsMeta): PackedMetaIndex
|
|
158
166
|
{
|
|
159
167
|
if (meta == null) return null;
|
|
@@ -168,12 +176,7 @@ export function computeMetaIndex(datasetid: string, meta: DatasetsMeta): PackedM
|
|
|
168
176
|
index.fields[datasetKey] = fieldsIndex;
|
|
169
177
|
});
|
|
170
178
|
index.length = offset;
|
|
171
|
-
index.getDatasetField =
|
|
172
|
-
let pf = retrievePackedFields(f);
|
|
173
|
-
let groupindex = retrievePackedIndex(f);
|
|
174
|
-
let datasetid = toDatasetID(dataset);
|
|
175
|
-
return getPackedField(groupindex, pf, datasetid, dataset, field);
|
|
176
|
-
};
|
|
179
|
+
index.getDatasetField = getDatasetField;
|
|
177
180
|
return index;
|
|
178
181
|
}
|
|
179
182
|
|
|
@@ -187,6 +190,15 @@ function allocPackedFieldsArray(length: number): PackedFieldsArray
|
|
|
187
190
|
return af;
|
|
188
191
|
}
|
|
189
192
|
|
|
193
|
+
export function initPackedFields(f: any): void
|
|
194
|
+
{
|
|
195
|
+
if (f.properties.packedFields !== undefined) throw 'Packed fields already set';
|
|
196
|
+
|
|
197
|
+
f.properties.packedIndex = {};
|
|
198
|
+
f.properties.packedFields = {};
|
|
199
|
+
f.properties.getDatasetField = getDatasetField;
|
|
200
|
+
}
|
|
201
|
+
|
|
190
202
|
export function computePackedFields(f: any, index: PackedMetaIndex): PackedFields
|
|
191
203
|
{
|
|
192
204
|
if (f.properties.packedFields) return f.properties.packedFields as PackedFields;
|
|
@@ -211,6 +223,34 @@ export function computePackedFields(f: any, index: PackedMetaIndex): PackedField
|
|
|
211
223
|
return f.properties.packedFields;
|
|
212
224
|
}
|
|
213
225
|
|
|
226
|
+
export function computeOnePackedFields(f: any, index: PackedMetaIndex, did: string, datasetKey: string): PackedFields
|
|
227
|
+
{
|
|
228
|
+
let af = allocPackedFieldsArray(index.length);
|
|
229
|
+
af[0] = 0; // count of number of aggregates
|
|
230
|
+
let fields = index.fields[did];
|
|
231
|
+
Object.keys(fields).forEach((field: string) => {
|
|
232
|
+
let n = fGetW(f, datasetKey, field);
|
|
233
|
+
if (isNaN(n))
|
|
234
|
+
n = 0;
|
|
235
|
+
af[fields[field]] = n;
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
if (! f.properties.packedIndex)
|
|
239
|
+
initPackedFields(f);
|
|
240
|
+
f.properties.packedIndex[did] = index;
|
|
241
|
+
f.properties.packedFields[did] = af;
|
|
242
|
+
f.properties.getDatasetField = index.getDatasetField;
|
|
243
|
+
|
|
244
|
+
return f.properties.packedFields;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export function clearPackedFields(f: any): void
|
|
248
|
+
{
|
|
249
|
+
delete f.properties.packedIndex;
|
|
250
|
+
delete f.properties.packedFields;
|
|
251
|
+
delete f.properties.getDatasetField;
|
|
252
|
+
}
|
|
253
|
+
|
|
214
254
|
export function hasPackedFields(f: any): boolean
|
|
215
255
|
{
|
|
216
256
|
return f.properties.packedFields !== undefined;
|
|
@@ -258,7 +298,7 @@ export function featurePushExtPackedFields(f: any, datasetid: string, index: Pac
|
|
|
258
298
|
throw(`pushExtPackedFields: missing blockid ${blockid} in cardinality set`);
|
|
259
299
|
let x = 2 + (nfields * card.get(blockid));
|
|
260
300
|
for (let i = 1; i <= nfields; i++)
|
|
261
|
-
pfa[i] += data[x++];
|
|
301
|
+
pfa[i] += (data[x++] << 0); // left shift by 0 to force unsigned to be interpreted as signed (used by prisoner-adjusted)
|
|
262
302
|
});
|
|
263
303
|
f.properties.packedFields[datasetid] = pfa;
|
|
264
304
|
f.properties.packedIndex[datasetid] = index;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dra2020/dra-types",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.123",
|
|
4
4
|
"description": "Shared types used between client, server and tools.",
|
|
5
5
|
"main": "dist/dra-types.js",
|
|
6
6
|
"types": "./dist/all.d.ts",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"webpack-cli": "^5.1.4"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@dra2020/baseclient": "^1.0.
|
|
37
|
+
"@dra2020/baseclient": "^1.0.144",
|
|
38
38
|
"geojson": "^0.5.0",
|
|
39
39
|
"object-hash": "^3.0.0"
|
|
40
40
|
}
|