@dra2020/dra-types 1.8.121 → 1.8.122

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.
@@ -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 };
@@ -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 = (f: any, dataset: string, field: string): number => {
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dra2020/dra-types",
3
- "version": "1.8.121",
3
+ "version": "1.8.122",
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.132",
37
+ "@dra2020/baseclient": "^1.0.144",
38
38
  "geojson": "^0.5.0",
39
39
  "object-hash": "^3.0.0"
40
40
  }