@dra2020/dra-types 1.8.96 → 1.8.98
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 +3 -2
- package/lib/packedfields.ts +12 -31
- package/lib/splittogeofeature.ts +1 -0
- package/package.json +1 -1
package/dist/datasets.d.ts
CHANGED
package/dist/dra-types.js
CHANGED
|
@@ -1377,7 +1377,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
1377
1377
|
|
|
1378
1378
|
|
|
1379
1379
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1380
|
-
exports.pvi2020Str = exports.calcRaw2020Pvi = exports.pviStr = exports.calcRawPvi = exports.calcShift = exports.ToGetterPvi20 = exports.ToGetterPvi16 = exports.ToGetter = exports.fieldGetterNotLoaded = exports.findPackedField = exports.getPackedField = exports.diffPackedFields = exports.decrementPackedFields = exports.aggregateCount = exports.aggregatePackedFields = exports.packedCopy = exports.zeroPackedCopy = exports.zeroPackedFields = exports.retrievePackedFields = exports.pushedExtPackedFields = exports.featurePushedExtPackedFields = exports.featurePushExtPackedFields = exports.isExtDataset = exports.setPackedFields = exports.hasPackedFields = exports.computePackedFields = exports.computeMetaIndex = exports.sortedFieldList = exports.fGet = exports.
|
|
1380
|
+
exports.pvi2020Str = exports.calcRaw2020Pvi = exports.pviStr = exports.calcRawPvi = exports.calcShift = exports.ToGetterPvi20 = exports.ToGetterPvi16 = exports.ToGetter = exports.fieldGetterNotLoaded = exports.findPackedField = exports.getPackedField = exports.diffPackedFields = exports.decrementPackedFields = exports.aggregateCount = exports.aggregatePackedFields = exports.packedCopy = exports.zeroPackedCopy = exports.zeroPackedFields = exports.retrievePackedIndex = exports.retrievePackedFields = exports.pushedExtPackedFields = exports.featurePushedExtPackedFields = exports.featurePushExtPackedFields = exports.isExtDataset = exports.setPackedFields = exports.hasPackedFields = exports.computePackedFields = exports.computeMetaIndex = exports.sortedFieldList = exports.fGet = exports.DS_PRES2016 = exports.DS_PRES2020 = exports.DS_PVI2016 = exports.PVI2020_Title = exports.DS_PVI2020 = exports.DATASET_TYPE_OTHER = exports.DATASET_TYPE_PVI = exports.DATASET_TYPE_ELECTION = exports.DATASET_TYPE_DEMOGRAPHIC = exports.AGG_pvi = exports.AGG_pres2016 = exports.AGG_pres2008 = exports.AGG_DEMOGRAPHIC18 = exports.AGG_DEMOGRAPHIC = void 0;
|
|
1381
1381
|
const baseclient_1 = __webpack_require__(/*! @dra2020/baseclient */ "@dra2020/baseclient");
|
|
1382
1382
|
exports.AGG_DEMOGRAPHIC = 'demographic';
|
|
1383
1383
|
exports.AGG_DEMOGRAPHIC18 = 'demographic18';
|
|
@@ -1393,10 +1393,6 @@ exports.PVI2020_Title = 'PVI 2016/2020';
|
|
|
1393
1393
|
exports.DS_PVI2016 = 'P16GPR';
|
|
1394
1394
|
exports.DS_PRES2020 = 'E20GPR';
|
|
1395
1395
|
exports.DS_PRES2016 = 'E16GPR';
|
|
1396
|
-
function fGetJoined(f) {
|
|
1397
|
-
return (f.properties && f.properties.joined) ? f.properties.joined : undefined;
|
|
1398
|
-
}
|
|
1399
|
-
exports.fGetJoined = fGetJoined;
|
|
1400
1396
|
function fGet(f, p) {
|
|
1401
1397
|
return fGetW(f, null, p);
|
|
1402
1398
|
}
|
|
@@ -1415,25 +1411,6 @@ function fGetW(f, datasetKey, p) {
|
|
|
1415
1411
|
else if (pBackup && f.properties.datasets[datasetKey][pBackup] != null)
|
|
1416
1412
|
return f.properties.datasets[datasetKey][pBackup];
|
|
1417
1413
|
}
|
|
1418
|
-
// Joined property?
|
|
1419
|
-
let a = fGetJoined(f);
|
|
1420
|
-
if (a) {
|
|
1421
|
-
for (let i = 0; i < a.length; i++) {
|
|
1422
|
-
let o = a[i];
|
|
1423
|
-
if (!datasetKey) {
|
|
1424
|
-
if (o[p] !== undefined)
|
|
1425
|
-
return o[p];
|
|
1426
|
-
}
|
|
1427
|
-
else {
|
|
1428
|
-
if (o['datasets'] && o['datasets'][datasetKey] != null) {
|
|
1429
|
-
if (o['datasets'][datasetKey][p] != null)
|
|
1430
|
-
return o['datasets'][datasetKey][p];
|
|
1431
|
-
else if (pBackup && o['datasets'][datasetKey][pBackup] != null)
|
|
1432
|
-
return o['datasets'][datasetKey][pBackup];
|
|
1433
|
-
}
|
|
1434
|
-
}
|
|
1435
|
-
}
|
|
1436
|
-
}
|
|
1437
1414
|
return undefined;
|
|
1438
1415
|
}
|
|
1439
1416
|
function sortedFieldList(ds) {
|
|
@@ -1455,10 +1432,11 @@ function computeMetaIndex(datasetid, meta) {
|
|
|
1455
1432
|
});
|
|
1456
1433
|
index.fields[datasetKey] = fieldsIndex;
|
|
1457
1434
|
});
|
|
1458
|
-
let groupindex = { [datasetid]: index };
|
|
1459
1435
|
index.length = offset;
|
|
1460
1436
|
index.getDatasetField = (f, dataset, field) => {
|
|
1461
1437
|
let pf = retrievePackedFields(f);
|
|
1438
|
+
let groupindex = retrievePackedIndex(f);
|
|
1439
|
+
let datasetid = dataset.length > 20 ? dataset : ''; // hack - extended datasets use 26 char guids, built-in ones are short
|
|
1462
1440
|
return getPackedField(groupindex, pf, datasetid, dataset, field);
|
|
1463
1441
|
};
|
|
1464
1442
|
return index;
|
|
@@ -1486,6 +1464,7 @@ function computePackedFields(f, index) {
|
|
|
1486
1464
|
af[fields[field]] = n;
|
|
1487
1465
|
});
|
|
1488
1466
|
});
|
|
1467
|
+
f.properties.packedIndex = { ['']: index };
|
|
1489
1468
|
f.properties.packedFields = { ['']: af }; // cache here
|
|
1490
1469
|
f.properties.getDatasetField = index.getDatasetField;
|
|
1491
1470
|
// Major memory savings to delete this after packing
|
|
@@ -1500,6 +1479,7 @@ exports.hasPackedFields = hasPackedFields;
|
|
|
1500
1479
|
function setPackedFields(f, pf, fIndex) {
|
|
1501
1480
|
if (f.properties.packedFields !== undefined)
|
|
1502
1481
|
throw 'Packed fields already set';
|
|
1482
|
+
f.properties.packedIndex = fIndex.properties.packedIndex;
|
|
1503
1483
|
f.properties.packedFields = pf;
|
|
1504
1484
|
f.properties.getDatasetField = fIndex.properties.getDatasetField;
|
|
1505
1485
|
}
|
|
@@ -1509,7 +1489,7 @@ function isExtDataset(did) {
|
|
|
1509
1489
|
return did && reExtDataset.test(did);
|
|
1510
1490
|
}
|
|
1511
1491
|
exports.isExtDataset = isExtDataset;
|
|
1512
|
-
function featurePushExtPackedFields(f, datasetid, data, card) {
|
|
1492
|
+
function featurePushExtPackedFields(f, datasetid, index, data, card) {
|
|
1513
1493
|
var _a;
|
|
1514
1494
|
let blocks = ((_a = f === null || f === void 0 ? void 0 : f.properties) === null || _a === void 0 ? void 0 : _a.blocks) || (card.has(f.properties.id) ? [f.properties.id] : null);
|
|
1515
1495
|
if (!blocks)
|
|
@@ -1533,6 +1513,7 @@ function featurePushExtPackedFields(f, datasetid, data, card) {
|
|
|
1533
1513
|
pfa[i] += data[x++];
|
|
1534
1514
|
});
|
|
1535
1515
|
f.properties.packedFields[datasetid] = pfa;
|
|
1516
|
+
f.properties.packedIndex[datasetid] = index;
|
|
1536
1517
|
}
|
|
1537
1518
|
exports.featurePushExtPackedFields = featurePushExtPackedFields;
|
|
1538
1519
|
function featurePushedExtPackedFields(f, datasetid, card) {
|
|
@@ -1562,6 +1543,12 @@ function retrievePackedFields(f) {
|
|
|
1562
1543
|
return f.properties.packedFields;
|
|
1563
1544
|
}
|
|
1564
1545
|
exports.retrievePackedFields = retrievePackedFields;
|
|
1546
|
+
function retrievePackedIndex(f) {
|
|
1547
|
+
if (f.properties.packedIndex === undefined)
|
|
1548
|
+
throw 'Feature should have pre-computed packed index';
|
|
1549
|
+
return f.properties.packedIndex;
|
|
1550
|
+
}
|
|
1551
|
+
exports.retrievePackedIndex = retrievePackedIndex;
|
|
1565
1552
|
// The first entry in the PackedFields aggregate is the count of items aggregated.
|
|
1566
1553
|
// Treat a null instance as just a single entry with no aggregates.
|
|
1567
1554
|
let abZero = new ArrayBuffer(8);
|
|
@@ -2161,6 +2148,7 @@ function splitToGeoFeature(split, topoPrecinct, mbm) {
|
|
|
2161
2148
|
if (b.properties.packedFields) {
|
|
2162
2149
|
if (!f.properties.packedFields) {
|
|
2163
2150
|
f.properties.packedFields = PF.packedCopy(b.properties.packedFields);
|
|
2151
|
+
f.properties.packedIndex = b.properties.packedIndex;
|
|
2164
2152
|
f.properties.getDatasetField = b.properties.getDatasetField;
|
|
2165
2153
|
}
|
|
2166
2154
|
else
|