@dra2020/dra-types 1.8.132 → 1.8.135

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/alldt.d.ts CHANGED
@@ -13,3 +13,4 @@ export * from './reverse';
13
13
  export * from './groups';
14
14
  export * from './datasets';
15
15
  export * from './precincts';
16
+ export * from './cities';
@@ -0,0 +1,22 @@
1
+ export interface Cities {
2
+ id?: string;
3
+ state?: string;
4
+ datasource?: string;
5
+ geoids?: string[];
6
+ name?: string;
7
+ description?: string;
8
+ labels?: string[];
9
+ createdBy?: string;
10
+ createTime?: string;
11
+ modifyTime?: string;
12
+ publishTime?: string;
13
+ deleted?: boolean;
14
+ published?: string;
15
+ official?: boolean;
16
+ supersets?: string[];
17
+ subsets?: string[];
18
+ conflicts?: string[];
19
+ }
20
+ export type CitiesIndex = {
21
+ [id: string]: Cities;
22
+ };
package/dist/dra-types.js CHANGED
@@ -49,6 +49,7 @@ __exportStar(__webpack_require__(/*! ./reverse */ "./lib/reverse.ts"), exports);
49
49
  __exportStar(__webpack_require__(/*! ./groups */ "./lib/groups.ts"), exports);
50
50
  __exportStar(__webpack_require__(/*! ./datasets */ "./lib/datasets.ts"), exports);
51
51
  __exportStar(__webpack_require__(/*! ./precincts */ "./lib/precincts.ts"), exports);
52
+ __exportStar(__webpack_require__(/*! ./cities */ "./lib/cities.ts"), exports);
52
53
 
53
54
 
54
55
  /***/ }),
@@ -97,6 +98,18 @@ exports.BucketMap = {
97
98
  };
98
99
 
99
100
 
101
+ /***/ }),
102
+
103
+ /***/ "./lib/cities.ts":
104
+ /*!***********************!*\
105
+ !*** ./lib/cities.ts ***!
106
+ \***********************/
107
+ /***/ ((__unused_webpack_module, exports) => {
108
+
109
+
110
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
111
+
112
+
100
113
  /***/ }),
101
114
 
102
115
  /***/ "./lib/colormgr.ts":
@@ -276,10 +289,9 @@ function ethnicBackgroundColor(index, pd) {
276
289
  function ToAllEthnicColor(agg, dc, pd) {
277
290
  var _a;
278
291
  // Use VAP/CVAP if it exists
279
- const dataset = dc.primeVDS ? dc.primeVDS : dc.primeDDS;
280
- const did = PF.toDatasetID(dataset);
281
- const builtin = ((_a = dc.dsMeta[did]) === null || _a === void 0 ? void 0 : _a.builtin) || dataset;
282
- return AggregateEthnicColor(PF.ToGetter(agg, dc, did, dataset), pd, builtin.endsWith('NH'));
292
+ const did = dc.primeVDS ? dc.primeVDS : dc.primeDDS;
293
+ const builtin = ((_a = dc.dsMeta[did]) === null || _a === void 0 ? void 0 : _a.builtin) || did;
294
+ return AggregateEthnicColor(PF.ToGetter(agg, dc, did), pd, builtin.endsWith('NH'));
283
295
  }
284
296
  function ToPartisanColorStr(agg, dc, pd) {
285
297
  return ToPartisanColor(agg, dc, partisanStops(exports.PartisanPrecinctStops, pd));
@@ -288,25 +300,8 @@ function ToPartisanDistrictColor(agg, dc, pd) {
288
300
  return ToPartisanColor(agg, dc, partisanDistrictStops(exports.PartisanDistrictStops, pd));
289
301
  }
290
302
  function ToPartisanColor(agg, dc, stops) {
291
- const did = PF.toDatasetID(dc.primeEDS);
292
- if (dc.primeEDS === PF.DS_PVI2020) {
293
- const getter16 = PF.ToGetter(agg, dc, did, PF.DS_PRES2016);
294
- const getter20 = PF.ToGetter(agg, dc, did, PF.DS_PRES2020);
295
- const pviRaw = PF.calcRaw2020Pvi(getter16, getter20);
296
- const color = ColorFromRGBPcts((1 - pviRaw / 100), 0, pviRaw / 100, stops);
297
- //console.log('Pvi (r, d, color): (' + (1 - pviRaw/100) + ', ' + pviRaw/100 + ', ' + color + ')');
298
- return color;
299
- }
300
- else if (dc.primeEDS === PF.DS_PVI2016) {
301
- const getter = PF.ToGetter(agg, dc, did, dc.primeEDS);
302
- const pviRaw = PF.calcRawPvi(getter);
303
- const color = ColorFromRGBPcts((1 - pviRaw / 100), 0, pviRaw / 100, stops);
304
- return color;
305
- }
306
- else {
307
- const getter = PF.ToGetter(agg, dc, did, dc.primeEDS);
308
- return AggregatePartisanColorStr(getter, stops);
309
- }
303
+ const getter = PF.ToGetter(agg, dc, dc.primeEDS);
304
+ return AggregatePartisanColorStr(getter, stops);
310
305
  }
311
306
  function ToPartisanShiftColor(agg, dc, datasets, pd, isDistrict) {
312
307
  if (!datasets || datasets.length < 2)
@@ -327,9 +322,8 @@ function ToEthnicColorStr(agg, dc, pd, detail) {
327
322
  let ethnic = 'Wh';
328
323
  let total = 'Tot';
329
324
  let bInvert = false;
330
- const dataset = dc.primeVDS ? dc.primeVDS : dc.primeDDS;
331
- const did = PF.toDatasetID(dataset);
332
- const builtin = ((_a = dc.dsMeta[did]) === null || _a === void 0 ? void 0 : _a.builtin) || dataset;
325
+ const did = dc.primeVDS ? dc.primeVDS : dc.primeDDS;
326
+ const builtin = ((_a = dc.dsMeta[did]) === null || _a === void 0 ? void 0 : _a.builtin) || did;
333
327
  switch (detail) {
334
328
  case null:
335
329
  case '':
@@ -369,7 +363,7 @@ function ToEthnicColorStr(agg, dc, pd, detail) {
369
363
  break;
370
364
  default: break;
371
365
  }
372
- const getter = PF.ToGetter(agg, dc, did, dataset);
366
+ const getter = PF.ToGetter(agg, dc, did);
373
367
  let den = getter(total);
374
368
  let num = getter(ethnic);
375
369
  if (den === undefined || isNaN(den) || num === undefined || isNaN(num))
@@ -613,7 +607,7 @@ function ToExtendedColor(agg, dc, colorBy) {
613
607
  colors = safeColors('');
614
608
  }
615
609
  let o = {};
616
- let getter = PF.ToGetter(agg, dc, datasetid, datasetid);
610
+ let getter = PF.ToGetter(agg, dc, datasetid);
617
611
  Object.keys(meta.fields).forEach(f => o[f] = getter(f));
618
612
  let formatter = new baseclient_1.Detail.FormatDetail(dscolor.expr);
619
613
  let result = formatter.format(baseclient_1.Detail.FormatDetail.prepare(o));
@@ -621,7 +615,7 @@ function ToExtendedColor(agg, dc, colorBy) {
621
615
  return baseclient_1.Util.execGradient(makeStops(stops, colors), intensity);
622
616
  }
623
617
  else {
624
- let getter = PF.ToGetter(agg, dc, datasetid, datasetid);
618
+ let getter = PF.ToGetter(agg, dc, datasetid);
625
619
  let fields = PF.sortedFieldList(meta);
626
620
  let den = 0;
627
621
  if (meta.fields['Tot'])
@@ -1562,19 +1556,17 @@ exports.fGet = fGet;
1562
1556
  exports.sortedFieldList = sortedFieldList;
1563
1557
  exports.getDatasetField = getDatasetField;
1564
1558
  exports.computeMetaIndex = computeMetaIndex;
1565
- exports.initPackedFields = initPackedFields;
1566
- exports.computePackedFields = computePackedFields;
1567
1559
  exports.computeOnePackedFields = computeOnePackedFields;
1560
+ exports.initPackedFields = initPackedFields;
1568
1561
  exports.clearPackedFields = clearPackedFields;
1569
1562
  exports.hasPackedFields = hasPackedFields;
1570
1563
  exports.setPackedFields = setPackedFields;
1571
1564
  exports.isExtDataset = isExtDataset;
1572
- exports.toDatasetID = toDatasetID;
1565
+ exports.pushExtPackedFields = pushExtPackedFields;
1573
1566
  exports.featurePushExtPackedFields = featurePushExtPackedFields;
1574
1567
  exports.featurePushedExtPackedFields = featurePushedExtPackedFields;
1575
1568
  exports.pushedExtPackedFields = pushedExtPackedFields;
1576
1569
  exports.retrievePackedFields = retrievePackedFields;
1577
- exports.retrievePackedIndex = retrievePackedIndex;
1578
1570
  exports.zeroPackedFields = zeroPackedFields;
1579
1571
  exports.zeroPackedCopy = zeroPackedCopy;
1580
1572
  exports.packedCopy = packedCopy;
@@ -1586,8 +1578,6 @@ exports.getPackedField = getPackedField;
1586
1578
  exports.findPackedField = findPackedField;
1587
1579
  exports.fieldGetterNotLoaded = fieldGetterNotLoaded;
1588
1580
  exports.ToGetter = ToGetter;
1589
- exports.ToGetterPvi16 = ToGetterPvi16;
1590
- exports.ToGetterPvi20 = ToGetterPvi20;
1591
1581
  exports.calcShift = calcShift;
1592
1582
  exports.calcRawPvi = calcRawPvi;
1593
1583
  exports.pviStr = pviStr;
@@ -1632,17 +1622,15 @@ function sortedFieldList(ds) {
1632
1622
  let kv = keys.map(k => { return { k, v: ds.fields[k] }; }).sort((a, b) => { return (a.v.order || 0) - (b.v.order || 0); });
1633
1623
  return kv.map(kv => kv.k);
1634
1624
  }
1635
- function getDatasetField(f, dataset, field) {
1625
+ function getDatasetField(f, did, field) {
1636
1626
  let pf = retrievePackedFields(f);
1637
- let dxGroup = retrievePackedIndex(f);
1638
- let did = toDatasetID(dataset);
1639
- return getPackedField(dxGroup, pf, did, dataset, field);
1627
+ return getPackedField(pf, did, field);
1640
1628
  }
1641
- function computeMetaIndex(datasetid, meta) {
1629
+ function computeMetaIndex(did, meta) {
1642
1630
  if (meta == null)
1643
1631
  return null;
1644
1632
  let offset = 1; // first entry is count of aggregates
1645
- let index = { length: 0, fields: {}, getDatasetField: null };
1633
+ let index = { length: 0, fields: {} };
1646
1634
  Object.keys(meta).forEach((datasetKey) => {
1647
1635
  let dataset = meta[datasetKey];
1648
1636
  let fieldsIndex = {};
@@ -1652,46 +1640,9 @@ function computeMetaIndex(datasetid, meta) {
1652
1640
  index.fields[datasetKey] = fieldsIndex;
1653
1641
  });
1654
1642
  index.length = offset;
1655
- index.getDatasetField = getDatasetField;
1656
1643
  return index;
1657
1644
  }
1658
- let nAlloc = 0;
1659
- function allocPackedFieldsArray(length) {
1660
- let ab = new ArrayBuffer(8 * length);
1661
- let af = new Float64Array(ab);
1662
- nAlloc++;
1663
- //if ((nAlloc % 10000) == 0) console.log(`allocPackedFieldsArray: ${nAlloc} allocs`);
1664
- return af;
1665
- }
1666
- function initPackedFields(f) {
1667
- if (f.properties.packedFields !== undefined)
1668
- throw 'Packed fields already set';
1669
- f.properties.packedIndex = {};
1670
- f.properties.packedFields = {};
1671
- f.properties.getDatasetField = getDatasetField;
1672
- }
1673
- function computePackedFields(f, index) {
1674
- if (f.properties.packedFields)
1675
- return f.properties.packedFields;
1676
- let af = allocPackedFieldsArray(index.length);
1677
- af[0] = 0; // count of number of aggregates
1678
- Object.keys(index.fields).forEach((dataset) => {
1679
- let fields = index.fields[dataset];
1680
- Object.keys(fields).forEach((field) => {
1681
- let n = fGetW(f, dataset, field);
1682
- if (isNaN(n))
1683
- n = 0;
1684
- af[fields[field]] = n;
1685
- });
1686
- });
1687
- f.properties.packedIndex = { ['']: index };
1688
- f.properties.packedFields = { ['']: af }; // cache here
1689
- f.properties.getDatasetField = index.getDatasetField;
1690
- // Major memory savings to delete this after packing
1691
- delete f.properties.datasets;
1692
- return f.properties.packedFields;
1693
- }
1694
- function computeOnePackedFields(f, index, did, datasetKey) {
1645
+ function computeOnePackedFields(f, dsGroup, index, did, datasetKey) {
1695
1646
  let af = allocPackedFieldsArray(index.length);
1696
1647
  af[0] = 0; // count of number of aggregates
1697
1648
  let fields = index.fields[did];
@@ -1701,45 +1652,47 @@ function computeOnePackedFields(f, index, did, datasetKey) {
1701
1652
  n = 0;
1702
1653
  af[fields[field]] = n;
1703
1654
  });
1704
- if (!f.properties.packedIndex)
1705
- initPackedFields(f);
1706
- f.properties.packedIndex[did] = index;
1707
- f.properties.packedFields[did] = af;
1708
- f.properties.getDatasetField = index.getDatasetField;
1655
+ if (!f.properties.packedFields)
1656
+ initPackedFields(f, dsGroup);
1657
+ f.properties.packedFields.data[did] = af;
1709
1658
  return f.properties.packedFields;
1710
1659
  }
1660
+ let nAlloc = 0;
1661
+ function allocPackedFieldsArray(length) {
1662
+ let ab = new ArrayBuffer(8 * length);
1663
+ let af = new Float64Array(ab);
1664
+ nAlloc++;
1665
+ //if ((nAlloc % 10000) == 0) console.log(`allocPackedFieldsArray: ${nAlloc} allocs`);
1666
+ return af;
1667
+ }
1668
+ function initPackedFields(f, dsGroup) {
1669
+ if (f.properties.packedFields !== undefined)
1670
+ throw 'Packed fields already set';
1671
+ f.properties.packedFields = { dsGroup, data: {} };
1672
+ }
1711
1673
  function clearPackedFields(f) {
1712
- delete f.properties.packedIndex;
1713
1674
  delete f.properties.packedFields;
1714
- delete f.properties.getDatasetField;
1715
1675
  }
1716
1676
  function hasPackedFields(f) {
1717
1677
  return f.properties.packedFields !== undefined;
1718
1678
  }
1719
- function setPackedFields(f, pf, fIndex) {
1679
+ function setPackedFields(f, pf) {
1720
1680
  if (f.properties.packedFields !== undefined)
1721
1681
  throw 'Packed fields already set';
1722
- f.properties.packedIndex = fIndex.properties.packedIndex;
1723
1682
  f.properties.packedFields = pf;
1724
- f.properties.getDatasetField = fIndex.properties.getDatasetField;
1725
1683
  }
1726
1684
  const reExtDataset = /^.*\.ds$/;
1727
1685
  function isExtDataset(did) {
1728
1686
  return did && reExtDataset.test(did);
1729
1687
  }
1730
- function toDatasetID(datasetKey) {
1731
- return isExtDataset(datasetKey) ? datasetKey : '';
1732
- }
1733
- function featurePushExtPackedFields(f, datasetid, index, data, card) {
1734
- var _a;
1735
- 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);
1688
+ function pushExtPackedFields(blocks, pf, did, index, data, card) {
1736
1689
  if (!blocks)
1737
1690
  return;
1738
- if (!f.properties.packedFields)
1739
- throw ('pushExtPackedFields: base datasets should be pushed first');
1691
+ if (!pf)
1692
+ throw ('pushExtPackedFields: packed fields should be initialized before push');
1740
1693
  if (card.size != data[0])
1741
1694
  throw ('pushExtPackedFields: packed fields and block cardinality do not match');
1742
- if (f.properties.packedFields[datasetid])
1695
+ if (pf.data[did])
1743
1696
  return; // already pushed
1744
1697
  let nfields = data[1];
1745
1698
  let pfa = allocPackedFieldsArray(nfields + 1); // field count
@@ -1753,25 +1706,29 @@ function featurePushExtPackedFields(f, datasetid, index, data, card) {
1753
1706
  for (let i = 1; i <= nfields; i++)
1754
1707
  pfa[i] += (data[x++] << 0); // left shift by 0 to force unsigned to be interpreted as signed (used by prisoner-adjusted)
1755
1708
  });
1756
- f.properties.packedFields[datasetid] = pfa;
1757
- f.properties.packedIndex[datasetid] = index;
1709
+ pf.data[did] = pfa;
1710
+ }
1711
+ function featurePushExtPackedFields(f, did, index, data, card) {
1712
+ var _a;
1713
+ 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);
1714
+ pushExtPackedFields(blocks, f.properties.packedFields, did, index, data, card);
1758
1715
  }
1759
- function featurePushedExtPackedFields(f, datasetid, card) {
1716
+ function featurePushedExtPackedFields(f, did, card) {
1760
1717
  var _a;
1761
1718
  if (!f)
1762
1719
  return true;
1763
1720
  if (f.features)
1764
- return featurePushedExtPackedFields(f.features[0], datasetid, card);
1721
+ return featurePushedExtPackedFields(f.features[0], did, card);
1765
1722
  if (!((_a = f === null || f === void 0 ? void 0 : f.properties) === null || _a === void 0 ? void 0 : _a.blocks) && !card.has(f.properties.id))
1766
1723
  return true;
1767
1724
  if (!f.properties.packedFields)
1768
1725
  return true;
1769
- return !!f.properties.packedFields[datasetid];
1726
+ return !!f.properties.packedFields.data[did];
1770
1727
  }
1771
1728
  function pushedExtPackedFields(pf, datasetids) {
1772
1729
  if (pf && datasetids)
1773
1730
  for (let i = 0; i < datasetids.length; i++)
1774
- if (!pf[datasetids[i]])
1731
+ if (!pf.data[datasetids[i]])
1775
1732
  return false;
1776
1733
  return !!pf;
1777
1734
  }
@@ -1780,67 +1737,62 @@ function retrievePackedFields(f) {
1780
1737
  throw 'Feature should have pre-computed packed fields';
1781
1738
  return f.properties.packedFields;
1782
1739
  }
1783
- function retrievePackedIndex(f) {
1784
- if (f.properties.packedIndex === undefined)
1785
- throw 'Feature should have pre-computed packed index';
1786
- return f.properties.packedIndex;
1787
- }
1788
- // The first entry in the PackedFields aggregate is the count of items aggregated.
1740
+ // The first entry in the PackedFieldsArray aggregate is the count of items aggregated.
1789
1741
  // Treat a null instance as just a single entry with no aggregates.
1790
1742
  let abZero = new ArrayBuffer(8);
1791
1743
  let afZero = new Float64Array(abZero);
1792
1744
  afZero[0] = 0;
1793
- let pfZero = { ['']: afZero };
1794
- function zeroPackedFields(index) {
1795
- if (index == null)
1745
+ let pfZero = { dsGroup: {}, data: { ['']: afZero } };
1746
+ function zeroPackedFields(dsGroup) {
1747
+ if (dsGroup == null)
1796
1748
  return pfZero;
1797
- let pf = {};
1798
- Object.keys(index).forEach(datasetid => {
1799
- let af = allocPackedFieldsArray(index[datasetid].length);
1749
+ let pf = { dsGroup, data: {} };
1750
+ Object.keys(dsGroup).forEach(did => {
1751
+ let af = allocPackedFieldsArray(dsGroup[did].length);
1800
1752
  for (let i = 0; i < af.length; i++)
1801
1753
  af[i] = 0;
1802
- pf[datasetid] = af;
1754
+ pf.data[did] = af;
1803
1755
  });
1804
1756
  return pf;
1805
1757
  }
1806
1758
  function zeroPackedCopy(pf) {
1807
1759
  if (pf == null)
1808
1760
  return pfZero;
1809
- let copy = {};
1810
- Object.keys(pf).forEach(datasetid => {
1811
- let cf = allocPackedFieldsArray(pf[datasetid].length);
1761
+ let copy = { dsGroup: pf.dsGroup, data: {} };
1762
+ Object.keys(pf.data).forEach(did => {
1763
+ let cf = allocPackedFieldsArray(pf.data[did].length);
1812
1764
  for (let i = 0; i < cf.length; i++)
1813
1765
  cf[i] = 0;
1814
- copy[datasetid] = cf;
1766
+ copy.data[did] = cf;
1815
1767
  });
1816
1768
  return copy;
1817
1769
  }
1818
1770
  function packedCopy(pf) {
1819
1771
  if (pf == null)
1820
1772
  return null;
1821
- let copy = {};
1822
- Object.keys(pf).forEach(datasetid => {
1823
- let af = pf[datasetid];
1773
+ let copy = { dsGroup: pf.dsGroup, data: {} };
1774
+ Object.keys(pf.data).forEach(did => {
1775
+ let af = pf.data[did];
1824
1776
  let cf = allocPackedFieldsArray(af.length);
1825
1777
  for (let i = 0; i < af.length; i++)
1826
1778
  cf[i] = af[i];
1827
- copy[datasetid] = cf;
1779
+ copy.data[did] = cf;
1828
1780
  });
1829
1781
  return copy;
1830
1782
  }
1831
1783
  function aggregatePackedFields(agg, pf) {
1832
1784
  if (agg == null || pf == null)
1833
1785
  return agg;
1834
- Object.keys(pf).forEach(datasetid => {
1835
- let af = agg[datasetid];
1836
- let sf = pf[datasetid];
1786
+ Object.keys(pf.data).forEach(did => {
1787
+ let af = agg.data[did];
1788
+ let sf = pf.data[did];
1837
1789
  if (sf && (!af || sf.length == af.length)) {
1838
1790
  if (!af) {
1839
1791
  af = allocPackedFieldsArray(sf.length);
1840
1792
  af[0] = 0;
1841
1793
  for (let i = 1; i < sf.length; i++)
1842
1794
  af[i] = sf[i];
1843
- agg[datasetid] = af;
1795
+ agg.data[did] = af;
1844
1796
  }
1845
1797
  else {
1846
1798
  let n = af.length;
@@ -1857,15 +1809,15 @@ function aggregateCount(agg) {
1857
1809
  // So we just pick the one that happens to be come up first.
1858
1810
  if (!agg)
1859
1811
  return 0;
1860
- let pfa = baseclient_1.Util.nthProperty(agg);
1812
+ let pfa = baseclient_1.Util.nthProperty(agg.data);
1861
1813
  return pfa ? pfa[0] : 0;
1862
1814
  }
1863
1815
  function decrementPackedFields(agg, pf) {
1864
1816
  if (agg == null || pf == null)
1865
1817
  return agg;
1866
- Object.keys(agg).forEach(datasetid => {
1867
- let af = agg[datasetid];
1868
- let sf = pf[datasetid];
1818
+ Object.keys(agg.data).forEach(did => {
1819
+ let af = agg.data[did];
1820
+ let sf = pf.data[did];
1869
1821
  if (sf && sf.length == af.length) {
1870
1822
  let n = af.length;
1871
1823
  for (let i = 1; i < n; i++)
@@ -1883,57 +1835,23 @@ function diffPackedFields(main, parts) {
1883
1835
  parts.forEach((pf) => decrementPackedFields(main, pf));
1884
1836
  return main;
1885
1837
  }
1886
- function getPackedField(index, pf, datasetid, dataset, field) {
1887
- if (!index || !pf || !index[datasetid] || !pf[datasetid])
1838
+ function getPackedField(pf, did, field) {
1839
+ if (!pf || !pf.dsGroup || !pf.dsGroup[did] || !pf.data[did])
1888
1840
  return 0;
1889
- let fields = index[datasetid].fields[dataset];
1890
- return fields ? (fields[field] !== undefined ? pf[datasetid][fields[field]] : 0) : 0;
1841
+ let fields = pf.dsGroup[did].fields[did];
1842
+ return fields ? (fields[field] !== undefined ? pf.data[did][fields[field]] : 0) : 0;
1891
1843
  }
1892
- function findPackedField(index, pf, datasetid, dataset, field) {
1893
- let fields = index[datasetid].fields[dataset];
1844
+ function findPackedField(pf, did, field) {
1845
+ let fields = pf.dsGroup[did].fields[did];
1894
1846
  return fields ? (fields[field] !== undefined ? fields[field] : -1) : -1;
1895
1847
  }
1896
1848
  function fieldGetterNotLoaded(f) { return undefined; }
1897
- function ToGetter(agg, dc, datasetid, datasetKey) {
1898
- return (field) => { return getPackedField(dc.dsIndex, agg, datasetid, datasetKey, field); };
1899
- }
1900
- function ToGetterPvi16(agg, dc, datasetKey) {
1901
- return (field) => {
1902
- if (field === 'R')
1903
- return Math.round((getPackedField(dc.dsIndex, agg, '', datasetKey, 'R12') + getPackedField(dc.dsIndex, agg, '', datasetKey, 'R16')) / 2);
1904
- if (field === 'D')
1905
- return Math.round((getPackedField(dc.dsIndex, agg, '', datasetKey, 'D12') + getPackedField(dc.dsIndex, agg, '', datasetKey, 'D16')) / 2);
1906
- if (field === 'Tot')
1907
- return Math.round((getPackedField(dc.dsIndex, agg, '', datasetKey, 'R12') + getPackedField(dc.dsIndex, agg, '', datasetKey, 'R16') +
1908
- getPackedField(dc.dsIndex, agg, '', datasetKey, 'D12') + getPackedField(dc.dsIndex, agg, '', datasetKey, 'D16')) / 2);
1909
- return 0;
1910
- };
1849
+ function ToGetter(agg, dc, did) {
1850
+ return (field) => { return getPackedField(agg, did, field); };
1911
1851
  }
1912
- function ToGetterPvi20(agg, dc) {
1913
- return (field) => {
1914
- if (field === 'R')
1915
- return Math.round((getPackedField(dc.dsIndex, agg, '', exports.DS_PRES2016, 'R') + getPackedField(dc.dsIndex, agg, '', exports.DS_PRES2020, 'R')) / 2);
1916
- if (field === 'D')
1917
- return Math.round((getPackedField(dc.dsIndex, agg, '', exports.DS_PRES2016, 'D') + getPackedField(dc.dsIndex, agg, '', exports.DS_PRES2020, 'D')) / 2);
1918
- if (field === 'Tot')
1919
- return Math.round((getPackedField(dc.dsIndex, agg, '', exports.DS_PRES2016, 'R') + getPackedField(dc.dsIndex, agg, '', exports.DS_PRES2020, 'R') +
1920
- getPackedField(dc.dsIndex, agg, '', exports.DS_PRES2016, 'D') + getPackedField(dc.dsIndex, agg, '', exports.DS_PRES2020, 'D')) / 2);
1921
- return 0;
1922
- };
1923
- }
1924
- function calcShift(agg, dc, datasetOld, datasetNew) {
1925
- const didOld = toDatasetID(datasetOld);
1926
- const didNew = toDatasetID(datasetNew);
1927
- const getterOld = datasetOld === exports.DS_PVI2016 ?
1928
- ToGetterPvi16(agg, dc, datasetOld) :
1929
- datasetOld === exports.DS_PVI2020 ?
1930
- ToGetterPvi20(agg, dc) :
1931
- ToGetter(agg, dc, didOld, datasetOld);
1932
- const getterNew = datasetNew === exports.DS_PVI2016 ?
1933
- ToGetterPvi16(agg, dc, datasetNew) :
1934
- datasetNew === exports.DS_PVI2020 ?
1935
- ToGetterPvi20(agg, dc) :
1936
- ToGetter(agg, dc, didNew, datasetNew);
1852
+ function calcShift(agg, dc, didOld, didNew) {
1853
+ const getterOld = ToGetter(agg, dc, didOld);
1854
+ const getterNew = ToGetter(agg, dc, didNew);
1937
1855
  // Calc two-party Swing
1938
1856
  const repOld = getterOld('R');
1939
1857
  const demOld = getterOld('D');
@@ -2354,6 +2272,28 @@ exports.Schemas = {
2354
2272
  { published: 'HASH' },
2355
2273
  ], // sparse
2356
2274
  },
2275
+ 'places': {
2276
+ FileOptions: { map: true },
2277
+ Schema: {
2278
+ id: 'S',
2279
+ state: 'S',
2280
+ datasource: 'S',
2281
+ name: 'S',
2282
+ description: 'S',
2283
+ labels: 'L',
2284
+ createdBy: 'S',
2285
+ createTime: 'S',
2286
+ modifyTime: 'S',
2287
+ deleted: 'BOOL',
2288
+ published: 'S',
2289
+ official: 'BOOL',
2290
+ },
2291
+ KeySchema: { createdBy: 'HASH', id: 'RANGE' },
2292
+ GlobalSecondaryIndexes: [
2293
+ { id: 'HASH' },
2294
+ { published: 'HASH' },
2295
+ ], // sparse
2296
+ },
2357
2297
  };
2358
2298
 
2359
2299
 
@@ -2387,11 +2327,8 @@ function splitToGeoFeature(split, topoPrecinct, mbm) {
2387
2327
  baseclient_1.Util.deepAccum(f.properties.datasets, b.properties.datasets);
2388
2328
  }
2389
2329
  if (b.properties.packedFields) {
2390
- if (!f.properties.packedFields) {
2330
+ if (!f.properties.packedFields)
2391
2331
  f.properties.packedFields = PF.packedCopy(b.properties.packedFields);
2392
- f.properties.packedIndex = b.properties.packedIndex;
2393
- f.properties.getDatasetField = b.properties.getDatasetField;
2394
- }
2395
2332
  else
2396
2333
  PF.aggregatePackedFields(f.properties.packedFields, b.properties.packedFields);
2397
2334
  }