@dra2020/district-analytics 2.0.2 → 2.0.3

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.
@@ -1 +1 @@
1
- {"version":3,"sources":["webpack://district-analytics/webpack/universalModuleDefinition","webpack://district-analytics/webpack/bootstrap","webpack://district-analytics/./src/_api.ts","webpack://district-analytics/./src/_data.ts","webpack://district-analytics/./src/analyze.ts","webpack://district-analytics/./src/cohesive.ts","webpack://district-analytics/./src/compact.ts","webpack://district-analytics/./src/equal.ts","webpack://district-analytics/./src/geofeature.ts","webpack://district-analytics/./src/index.ts","webpack://district-analytics/./src/minority.ts","webpack://district-analytics/./src/political.ts","webpack://district-analytics/./src/preprocess.ts","webpack://district-analytics/./src/results.ts","webpack://district-analytics/./src/settings.ts","webpack://district-analytics/./src/types.ts","webpack://district-analytics/./src/utils.ts","webpack://district-analytics/./src/valid.ts","webpack://district-analytics/external \"@dra2020/poly\"","webpack://district-analytics/external \"@dra2020/util\"","webpack://district-analytics/external \"assert\""],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;QCVA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;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mB,IAAI,SAAS,EAAE;wBACpC,SAAS,GAAG,KAAK,CAAC;wBAClB,sCAAsC;wBACtC,MAAM;qBACP;yBACI;wBACH,2EAA2E;wBAC3E,sEAAsE;wBACtE,oEAAoE;wBACpE,0EAA0E;wBAC1E,uEAAuE;wBACvE,IAAI,mBAAmB,IAAI,UAAU,EAAE;4BACrC,oBAAoB,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;yBAC/C;wBAED,IAAI,oBAAoB,CAAC,IAAI,GAAG,CAAC,EAAE;4BACjC,SAAS,GAAG,KAAK,CAAC;4BAClB,sCAAsC;4BACtC,MAAM;yBACP;qBACF;iBACF;aACF;YACD,kEAAkE;YAClE,eAAe;YACf,IAAI,CAAC,SAAS,EAAE;gBACd,MAAM;aACP;SACF;KAEF;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AApED,gCAoEC;;;;;;;;;;;;;;;;;;;;;;;AC/QD,0C;;;;;;;;;;;ACAA,0C;;;;;;;;;;;ACAA,mC","file":"district-analytics.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"district-analytics\"] = factory();\n\telse\n\t\troot[\"district-analytics\"] = factory();\n})(global, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./src/index.ts\");\n","//\n// THE NODE PACKAGE API\n//\n\nimport { doPreprocessData } from './preprocess'\nimport { doAnalyzePlan, doAnalyzeDistricts } from './analyze'\nimport {\n doConfigureScales, doAnalyzePostProcessing\n} from './results'\nimport {\n PlanAnalytics, DistrictStatistics,\n preparePlanAnalytics, prepareDistrictStatistics\n} from './results'\n\nimport * as D from './_data';\nimport * as T from './types'\nimport * as U from './utils';\nimport * as S from './settings';\n\nexport class AnalyticsSession {\n title: string;\n legislativeDistricts: boolean;\n config: T.Dict = {};\n\n bOneTimeProcessingDone = false;\n bPlanAnalyzed = false;\n bPostProcessingDone = false;\n testScales = {} as T.TestScales;\n tests = {} as T.TestEntries;\n\n state: D.State;\n counties: D.Counties;\n graph: D.Graph;\n features: D.Features;\n plan: D.Plan;\n districts: D.Districts;\n\n constructor(SessionRequest: T.SessionRequest) {\n this.title = SessionRequest['title'];\n this.legislativeDistricts = SessionRequest['legislativeDistricts'];\n this.config = this.processConfig(SessionRequest['config'])\n\n this.state = new D.State(this, SessionRequest['stateXX'], SessionRequest['nDistricts']);\n this.counties = new D.Counties(this, SessionRequest['counties']);\n this.graph = new D.Graph(this, SessionRequest['graph']);\n this.features = new D.Features(this, SessionRequest['data'], this.config['datasets']);\n this.plan = new D.Plan(this, SessionRequest['plan']);\n this.districts = new D.Districts(this, SessionRequest['districtShapes']);\n\n // NOTE: I've pulled these out of the individual analytics to here. Eventually,\n // we could want them to passed into an analytics session as data, along with\n // everything else. For now, this keeps branching out of the main code.\n doConfigureScales(this);\n }\n processConfig(config: T.Dict): T.Dict {\n // NOTE - Session settings are required:\n // - Analytics suites can be defaulted to all with [], but\n // - Dataset keys must be explicitly specified with 'dataset'\n\n // TODO - DASHBOARD: Remove this mechanism. Always run everything.\n let defaultSuites = [T.Suite.Legal, T.Suite.Fair, T.Suite.Best];\n\n // If the config passed in has no suites = [], use the default suites\n if (U.isArrayEmpty(config['suites'])) {\n config['suites'] = defaultSuites;\n }\n\n // Default the Census & redistricting cycle to 2010\n if (!(U.keyExists('cycle', config))) config['cycle'] = 2010;\n\n return config;\n }\n\n // Using the the data in the analytics session, calculate all the\n // analytics & validations, saving/updating the individual test results.\n analyzePlan(bLog: boolean = false): boolean {\n try {\n doPreprocessData(this, bLog);\n doAnalyzeDistricts(this, bLog);\n doAnalyzePlan(this, bLog);\n doAnalyzePostProcessing(this, bLog);\n }\n catch {\n console.log(\"Exception caught by analyzePlan()\");\n return false;\n }\n\n return true;\n }\n\n // NOTE - This assumes that analyzePlan() has been run!\n getPlanAnalytics(bLog: boolean = false): PlanAnalytics {\n return preparePlanAnalytics(this, bLog);\n }\n // NOTE - This assumes that analyzePlan() has been run!\n getDistrictStatistics(bLog: boolean = false): DistrictStatistics {\n return prepareDistrictStatistics(this, bLog);\n }\n // NOTE - This assumes that analyzePlan() has been run!\n getDiscontiguousDistrictFeatures(bLog: boolean = false): T.GeoFeatureCollection {\n // Get the (possibly empty) list of discontiguous district IDs\n let contiguousTest = this.getTest(T.Test.Contiguous) as T.TestEntry;\n let discontiguousDistrictIDs: number[] = contiguousTest['details']['discontiguousDistricts'] || [];\n\n // Convert them into a (possibly empty) list of features\n let discontiguousDistrictFeatures: T.GeoFeatureCollection = { type: 'FeatureCollection', features: [] };\n if (!(U.isArrayEmpty(discontiguousDistrictIDs))) {\n for (let id of discontiguousDistrictIDs) {\n let poly = this.districts.getDistrictShapeByID(id);\n\n if (poly) discontiguousDistrictFeatures.features.push(poly);\n }\n }\n\n return discontiguousDistrictFeatures;\n }\n\n\n // HELPERS USED INTERNALLY\n\n // Get an individual test, so you can drive UI with the results.\n getTest(testID: T.Test): T.TestEntry {\n // Get the existing test entries\n // T.Test is a numeric enum, so convert the string keys to numbers\n let testValues = U.getNumericObjectKeys(this.tests);\n\n // If there's no entry for this test, create & initialize one\n if (!(testValues.includes(testID))) {\n this.tests[testID] = {} as T.TestEntry;\n this.tests[testID]['score'] = undefined;\n this.tests[testID]['details'] = {};\n }\n\n // Return a pointer to the the test entry for this test\n return this.tests[testID];\n }\n\n // NOTE - Not sure why this has to be up here.\n populationDeviationThreshold(): number {\n return 1 - this.testScales[T.Test.PopulationDeviation]['scale'][0];\n }\n}\n\n","//\n// DATA ABSTRACTION LAYER\n//\n\nimport * as T from './types'\nimport * as U from './utils';\nimport * as S from './settings';\n\nimport { AnalyticsSession } from './_api';\nimport { isConnected, isEmbedded } from './valid';\nimport { extractDistrictProperties } from './compact';\nimport { fptpWin } from './political'\n\n\n// DISTRICT STATISTICS\n\n// Indexes for statistics fields in Districts\n// NOTE - Not a const, so the number can be determined dynamically\nexport enum DistrictField {\n TotalPop, // Display\n PopDevPct, // Display\n bEqualPop, // Display\n bNotEmpty, // Display\n bContiguous, // Display\n bNotEmbedded, // Display\n CountySplits,\n DemVotes,\n RepVotes,\n TwoPartyVote, // Two-party total ()= Dem + Rep) not all votes!\n DemPct, // Display (also the \"VPI,\" by convention\")\n RepPct, // Display\n DemSeat,\n TotalVAP, // VAP or CVAP ...\n MinorityPop, // Derived\n WhitePop,\n BlackPop,\n HispanicPop,\n PacificPop,\n AsianPop,\n NativePop,\n WhitePct, // Display\n MinorityPct, // Display\n BlackPct, // Display\n HispanicPct, // Display\n PacificPct, // Display\n AsianPct, // Display\n NativePct // Display\n\n // 1 - MORE ...\n}\n\nexport class Districts {\n _session: AnalyticsSession;\n\n _shapes: T.GeoFeatureCollection;\n _geoProperties = {} as T.DistrictProperties;\n\n statistics: any[][];\n\n constructor(s: AnalyticsSession, ds: T.GeoFeatureCollection) {\n this._session = s;\n\n this._shapes = ds;\n this.statistics = this.initStatistics();\n }\n getDistrictShapeByID(id: number): T.GeoFeature | undefined {\n // NOTE - Find the district shape by ID (not index)\n // return this._shapes.features[id]; \n for (let f of this._shapes.features) {\n if (f.properties && (f.properties.id == id)) {\n return f;\n }\n }\n return undefined;\n }\n getGeoProperties(i: number): any {\n // Make sure the district shape exists & has geo properties\n if (i in this._geoProperties) return this._geoProperties[i];\n else return null;\n }\n setGeoProperties(i: number, p: T.DistrictShapeProperties): void { this._geoProperties[i] = p; }\n\n numberOfColumns(): number { return U.countEnumValues(DistrictField); }\n // +1 for dummy unassigned 0 \"district\" and +1 for N+1 summary \"district\" for\n // state-level values. Real districts are 1–N.\n numberOfRows(): number { return this._session.state.nDistricts + 2; }\n numberOfWorkingDistricts(): number { return this._session.state.nDistricts + 1; }\n\n // This is the core statistics 2D matrix:\n // Fields on the outside, districts on the inside\n initStatistics(): any[][] {\n let nRows = this.numberOfRows();\n let nCols = this.numberOfColumns();\n\n let outer = U.initArray(nCols, undefined);\n\n for (let i = 0; i < nCols; i++) {\n outer[i] = U.initArray(nRows, null);\n }\n\n return outer;\n }\n\n // This is the workhorse computational routine!\n //\n // TODO - OPTIMIZE for getting multiple properties from the same feature?\n // TODO - OPTIMIZE by only re-calc'ing districts that have changed?\n // In this case, special attention to getting county-splits right.\n // TODO - OPTIMIZE by async'ing this?\n // TODO - Is there a way to do this programmatically off data? Does it matter?\n recalcStatistics(bLog: boolean = false): void {\n // Compute these once per recalc cycle\n let targetSize = this._session.state.totalPop / this._session.state.nDistricts;\n let deviationThreshold = this._session.populationDeviationThreshold();\n let planByDistrict = this._session.plan.byDistrictID();\n let plan = this._session.plan;\n let graph = this._session.graph;\n\n // NOTE - SPLITTING\n // Add an extra 0th virtual county bucket for county-district splitting analysis \n let nCountyBuckets = this._session.counties.nCounties + 1;\n\n // INITIALIZE STATE VALUES THAT WILL BE ACCUMULATED\n\n let stateTPVote = 0;\n let stateDemVote = 0;\n let stateRepVote = 0;\n\n let stateVAPPop = 0;\n let stateWhitePop = 0;\n let stateMinorityPop = 0;\n let stateBlackPop = 0;\n let stateHispanicPop = 0;\n let statePacificPop = 0;\n let stateAsianPop = 0;\n let stateNativePop = 0;\n\n // NOTE - These plan-level booleans are set in their respective analytics:\n // - Equal population (bEqualPop)\n // - Complete (bNotEmpty)\n // - Contiguous (bContiguous)\n // - Free of holes (bNotEmbedded)\n\n // 2 - MORE ...\n\n // Loop over the districts (including the dummy unassigned one)\n for (let i = 0; i < this.numberOfWorkingDistricts(); i++) {\n\n // INITIALIZE DISTRICT VALUES THAT WILL BE ACCUMULATED (VS. DERIVED)\n\n let featurePop: number;\n let totalPop: number = 0;\n\n // NOTE - SPLITTING\n let countySplits: number[] = U.initArray(nCountyBuckets, 0);\n\n let demVotes: number = 0;\n let repVotes: number = 0;\n\n let totalVAP: number = 0;\n let whitePop: number = 0;\n let blackPop: number = 0;\n let hispanicPop: number = 0;\n let pacificPop: number = 0;\n let asianPop: number = 0;\n let nativePop: number = 0;\n\n // NOTE - Only report explicitly found validity issues\n let bNotEmpty = false;\n let bContiguous = true;\n let bNotEmbedded = true;\n let bEqualPop = true;\n\n // 3 - MORE ...\n\n // HACK - Because \"this\" gets ghosted inside the forEach loop below\n let outerThis = this;\n\n // Get the geoIDs assigned to the district\n // Guard against empty districts\n let geoIDs = this._session.plan.geoIDsForDistrictID(i);\n if (geoIDs && (geoIDs.size > 0)) {\n bNotEmpty = true;\n\n // ... loop over the geoIDs creating district-by-district statistics \n geoIDs.forEach(function (geoID: string): void {\n // Skip water-only features\n if (!(U.isWaterOnly(geoID))) {\n // Map from geoID to feature index\n let featureID = outerThis._session.features.featureID(geoID);\n let f: T.GeoFeature = outerThis._session.features.featureByIndex(featureID);\n\n if (f == undefined) {\n console.log(\"Skipping undefined feature in district statistics: GEOID =\", geoID, \"Feature ID =\", featureID);\n }\n else {\n // ACCUMULATE VALUES\n\n // Total population of each feature\n // NOTE - This result is used more than once\n featurePop = outerThis._session.features.fieldForFeature(f, Dataset.CENSUS, FeatureField.TotalPop);\n\n // Total district population\n totalPop += featurePop;\n\n // NOTE - SPLITTING\n // Total population by counties w/in a district,\n // except the dummy unassigned district 0\n if (i > 0) countySplits[outerThis.getCountyIndex(geoID)] += featurePop;\n\n // Democratic and Republican vote totals\n demVotes += outerThis._session.features.fieldForFeature(f, Dataset.ELECTION, FeatureField.DemVotes);\n repVotes += outerThis._session.features.fieldForFeature(f, Dataset.ELECTION, FeatureField.RepVotes);\n\n // Voting-age demographic breakdowns (or citizen voting-age)\n totalVAP += outerThis._session.features.fieldForFeature(f, Dataset.VAP, FeatureField.TotalPop);\n whitePop += outerThis._session.features.fieldForFeature(f, Dataset.VAP, FeatureField.WhitePop);\n blackPop += outerThis._session.features.fieldForFeature(f, Dataset.VAP, FeatureField.BlackPop);\n hispanicPop += outerThis._session.features.fieldForFeature(f, Dataset.VAP, FeatureField.HispanicPop);\n pacificPop += outerThis._session.features.fieldForFeature(f, Dataset.VAP, FeatureField.PacificPop);\n asianPop += outerThis._session.features.fieldForFeature(f, Dataset.VAP, FeatureField.AsianPop);\n nativePop += outerThis._session.features.fieldForFeature(f, Dataset.VAP, FeatureField.NativePop);\n\n // 4 - MORE ...\n }\n }\n else console.log(\"Skipping water-only feature in district statistics:\", geoID);\n });\n\n // COMPUTE DERIVED VALUES\n\n // Population deviation % and equal population (boolean) by district.\n // Don't set the values for the dummy unassigned district.\n let popDevPct = null;\n if (i > 0) {\n popDevPct = (totalPop - targetSize) / targetSize;\n bEqualPop = (popDevPct <= deviationThreshold);\n }\n\n // Total two-party (not total total!) votes, Democratic and Republican vote\n // shares, and Democratic first-past-the-post win (= 1) or loss (= 0).\n let totVotes: number;\n let demPct: number = 0;\n let repPct: number = 0;\n let DemSeat: number = 0;\n\n totVotes = demVotes + repVotes;\n if (totVotes > 0) {\n demPct = demVotes / totVotes;\n repPct = repVotes / totVotes;\n DemSeat = fptpWin(demPct);\n }\n\n // Total minority VAP\n let minorityPop = totalVAP - whitePop;\n\n // Voting-age demographic proportions (or citizen voting-age)\n let whitePct: number = 0;\n let minorityPct: number = 0;\n let blackPct: number = 0;\n let hispanicPct: number = 0;\n let pacificPct: number = 0;\n let asianPct: number = 0;\n let nativePct: number = 0;\n\n if (totalVAP > 0) {\n whitePct = whitePop / totalVAP;\n minorityPct = minorityPop / totalVAP;\n blackPct = blackPop / totalVAP;\n hispanicPct = hispanicPop / totalVAP;\n pacificPct = pacificPop / totalVAP;\n asianPct = asianPop / totalVAP;\n nativePct = nativePop / totalVAP;\n }\n\n // 5 - MORE ...\n\n // COMPUTE DISTRICT-LEVEL VALUES\n\n // Validations\n\n // Leave the default values for the dummy unassigned district,\n // and districts that are empty.\n if ((i > 0) && bNotEmpty) {\n bContiguous = isConnected(geoIDs, graph);\n bNotEmbedded = (!isEmbedded(i, planByDistrict[i], plan, graph));\n }\n\n // 6 - MORE ...\n\n { // UPDATE THE DISTRICT STATISTICS\n\n // NOTE - These are set below for both non-empty & empty districts:\n // this.statistics[DistrictField.bNotEmpty][i] = bNotEmpty;\n // this.statistics[DistrictField.bContiguous][i] = bContiguous;\n // this.statistics[DistrictField.bNotEmbedded][i] = bNotEmbedded;\n // this.statistics[DistrictField.TotalPop][i] = totalPop;\n // this.statistics[DistrictField.bEqualPop][i] = bEqualPop;\n this.statistics[DistrictField.PopDevPct][i] = popDevPct;\n\n this.statistics[DistrictField.DemVotes][i] = demVotes;\n this.statistics[DistrictField.RepVotes][i] = repVotes;\n this.statistics[DistrictField.TwoPartyVote][i] = totVotes;\n this.statistics[DistrictField.DemPct][i] = demPct;\n this.statistics[DistrictField.RepPct][i] = repPct;\n this.statistics[DistrictField.DemSeat][i] = DemSeat;\n\n this.statistics[DistrictField.WhitePop][i] = whitePop;\n this.statistics[DistrictField.MinorityPop][i] = minorityPop;\n this.statistics[DistrictField.BlackPop][i] = blackPop;\n this.statistics[DistrictField.HispanicPop][i] = hispanicPop;\n this.statistics[DistrictField.PacificPop][i] = pacificPop;\n this.statistics[DistrictField.AsianPop][i] = asianPop;\n this.statistics[DistrictField.NativePop][i] = nativePop;\n\n this.statistics[DistrictField.TotalVAP][i] = totalVAP;\n this.statistics[DistrictField.WhitePct][i] = whitePct;\n this.statistics[DistrictField.MinorityPct][i] = minorityPct;\n this.statistics[DistrictField.BlackPct][i] = blackPct;\n this.statistics[DistrictField.HispanicPct][i] = hispanicPct;\n this.statistics[DistrictField.PacificPct][i] = pacificPct;\n this.statistics[DistrictField.AsianPct][i] = asianPct;\n this.statistics[DistrictField.NativePct][i] = nativePct;\n }\n\n // 7 - MORE ...\n\n { // ACCUMULATE STATE STATISTICS FROM DISTRICT TOTALS\n stateTPVote += totVotes;\n stateDemVote += demVotes;\n stateRepVote += repVotes;\n\n stateVAPPop += totalVAP;\n stateWhitePop += whitePop;\n stateMinorityPop += minorityPop\n stateBlackPop += blackPop;\n stateHispanicPop += hispanicPop;\n statePacificPop += pacificPop;\n stateAsianPop += asianPop;\n stateNativePop += nativePop;\n }\n }\n else { // If a district is empty, zero these results (vs. null)\n this.statistics[DistrictField.PopDevPct][i] = 0.0;\n\n this.statistics[DistrictField.DemVotes][i] = 0;\n this.statistics[DistrictField.RepVotes][i] = 0;\n this.statistics[DistrictField.TwoPartyVote][i] = 0;\n this.statistics[DistrictField.DemPct][i] = 0;\n this.statistics[DistrictField.RepPct][i] = 0;\n this.statistics[DistrictField.DemSeat][i] = 0;\n\n this.statistics[DistrictField.WhitePop][i] = 0;\n this.statistics[DistrictField.MinorityPop][i] = 0;\n this.statistics[DistrictField.BlackPop][i] = 0;\n this.statistics[DistrictField.HispanicPop][i] = 0;\n this.statistics[DistrictField.PacificPop][i] = 0;\n this.statistics[DistrictField.AsianPop][i] = 0;\n this.statistics[DistrictField.NativePop][i] = 0;\n\n this.statistics[DistrictField.TotalVAP][i] = 0;\n this.statistics[DistrictField.WhitePct][i] = 0;\n this.statistics[DistrictField.MinorityPct][i] = 0;\n this.statistics[DistrictField.BlackPct][i] = 0;\n this.statistics[DistrictField.HispanicPct][i] = 0;\n this.statistics[DistrictField.PacificPct][i] = 0;\n this.statistics[DistrictField.AsianPct][i] = 0;\n this.statistics[DistrictField.NativePct][i] = 0;\n }\n\n { // UPDATE THESE DISTRICT STATISTICS, EVEN WHEN THEY ARE EMPTY\n this.statistics[DistrictField.TotalPop][i] = totalPop;\n\n this.statistics[DistrictField.bNotEmpty][i] = bNotEmpty;\n this.statistics[DistrictField.bContiguous][i] = bContiguous;\n this.statistics[DistrictField.bNotEmbedded][i] = bNotEmbedded;\n this.statistics[DistrictField.bEqualPop][i] = bEqualPop;\n\n this.statistics[DistrictField.CountySplits][i] = countySplits;\n }\n }\n\n // UPDATE STATE STATISTICS\n let summaryRow = this.numberOfRows() - 1;\n\n if (stateTPVote > 0) {\n this.statistics[DistrictField.DemPct][summaryRow] = stateDemVote / stateTPVote;\n this.statistics[DistrictField.RepPct][summaryRow] = stateRepVote / stateTPVote;\n }\n\n if (stateVAPPop > 0) {\n this.statistics[DistrictField.WhitePct][summaryRow] = stateWhitePop / stateVAPPop;\n this.statistics[DistrictField.MinorityPct][summaryRow] = stateMinorityPop / stateVAPPop;\n this.statistics[DistrictField.BlackPct][summaryRow] = stateBlackPop / stateVAPPop;\n this.statistics[DistrictField.HispanicPct][summaryRow] = stateHispanicPop / stateVAPPop;\n this.statistics[DistrictField.PacificPct][summaryRow] = statePacificPop / stateVAPPop;\n this.statistics[DistrictField.AsianPct][summaryRow] = stateAsianPop / stateVAPPop;\n this.statistics[DistrictField.NativePct][summaryRow] = stateNativePop / stateVAPPop;\n }\n }\n // NOTE - I did not roll these into district statistics, because creating the\n // district shapes themselves is the big district-by-district activity, these\n // calc's already work, and I'm not going to expose these values. Wrapping\n // the underlying function and exposing it here to illustrate the parallelism\n // with recalcStatistics(). These are called in tandem by doAnalyzeDistricts().\n extractDistrictShapeProperties(bLog: boolean = false): void {\n extractDistrictProperties(this._session, bLog)\n }\n getCountyIndex(geoID: string): number {\n let countyGeoID = U.parseGeoID(geoID)['county'] as string;\n let countyFIPS = U.getFIPSFromCountyGeoID(countyGeoID);\n let countyIndex = this._session.counties.indexFromFIPS(countyFIPS);\n\n return countyIndex;\n }\n}\n\n\n// CLASSES, ETC. FOR FEATURE & COUNTY DATA\n\n// Types of datasets by feature\nexport const enum Dataset {\n SHAPES = \"SHAPES\",\n CENSUS = \"CENSUS\",\n VAP = \"VAP\",\n ELECTION = \"ELECTION\"\n}\n\nexport type DatasetKeys = {\n SHAPES: string; // A shapefile\n CENSUS: string; // A total population Census dataset\n VAP: string; // A voting age (or citizen voting age) dataset\n ELECTION: string; // An election dataset\n}\n\n// Identifiers of fields for each feature in the datasets\nexport const enum FeatureField {\n TotalPop = \"Tot\",\n WhitePop = \"Wh\",\n BlackPop = \"BlC\",\n HispanicPop = \"His\",\n AsianPop = \"AsnC\",\n PacificPop = \"PacC\",\n NativePop = \"NatC\",\n DemVotes = \"D\",\n RepVotes = \"R\",\n TotalVotes = \"Tot\"\n}\n\n// Wrap data by feature, to abstract the specifics of the internal structure\nexport class Features {\n _session: AnalyticsSession;\n\n _data: T.GeoFeatureCollection;\n _keys: DatasetKeys;\n\n _featureIDs = {} as T.FeaturesByGeoID;\n\n constructor(s: AnalyticsSession, data: T.GeoFeatureCollection, keys: DatasetKeys) {\n this._session = s;\n\n this._data = data;\n this._keys = keys;\n }\n nFeatures(): number { return this._data.features.length; }\n featureByIndex(i: number): T.GeoFeature { return this._data.features[i]; }\n geoIDForFeature(f: any): string {\n // GEOIDs will be one of these properties\n let value = f.properties['GEOID10'] || f.properties['GEOID20'] || f.properties['GEOID'];\n return value;\n }\n fieldForFeature(f: any, dt: Dataset, fk: string): any {\n let dk: string = this._keys[dt];\n\n return _getFeatures(f, dk, fk);\n }\n resetDataset(d: Dataset, k: string): void {\n this._keys[d] = k;\n // TODO - RECALC: Does anything need to be recalc'd now when a dataset is changed?\n }\n mapGeoIDsToFeatureIDs(): void {\n for (let i: number = 0; i < this._session.features.nFeatures(); i++) {\n let f: T.GeoFeature = this._session.features.featureByIndex(i);\n let geoID: string = this._session.features.geoIDForFeature(f);\n\n this._featureIDs[geoID] = i;\n }\n }\n featureID(i: string): number { return this._featureIDs[i]; }\n}\n\n// NOTE - This accessor is cloned from fGetW() in dra-client/restrict.ts\n// f is a direct GeoJSON feature\n// p is a geoID\nfunction _getFeatures(f: any, datasetKey: string, p: string): any {\n // Echo parameters for debugging\n // console.log(\"f =\", f, \"k = \", datasetKey, \"p =\", p);\n\n // Shim to load sample data2.json from disk for command-line scaffolding\n if (f.properties && f.properties['datasets']) {\n return f.properties['datasets'][datasetKey][p];\n }\n\n // NOTE - The fGetW() code from dra-client below here ...\n\n // Direct property?\n if (f.properties && f.properties[p] !== undefined)\n return f.properties[p];\n\n // Joined property?\n let a: any[] = _fGetJoined(f);\n if (a) {\n for (let i: number = 0; i < a.length; i++) {\n let o: any = a[i];\n if (!datasetKey) {\n if (o[p] !== undefined)\n return o[p];\n }\n else {\n if (o['datasets'] && o['datasets'][datasetKey]) {\n let v = (o['datasets'][datasetKey][p]);\n if ((!(v == null)) && (!(v == undefined)))\n return o['datasets'][datasetKey][p];\n }\n }\n }\n }\n console.log(`${p} value undefined for ${f.properties['GEOID10']}!`);\n\n return undefined;\n}\n\nfunction _fGetJoined(f: any): any[] {\n return (f.properties && f.properties.joined) ? f.properties.joined : undefined;\n}\n\n// Wrap data by county, to abstract the specifics of the internal structure\nexport class Counties {\n _session: AnalyticsSession;\n\n _data: T.GeoFeatureCollection;\n _countyNameLookup: T.FIPSCodeToCountyNameMap = {};\n\n nCounties: number;\n index = {} as T.FIPSToOrdinalMap;\n totalPopulation: number[] = [];\n\n constructor(s: AnalyticsSession, data: T.GeoFeatureCollection) {\n this._session = s;\n\n this._data = data;\n this.nCounties = this._data.features.length;\n }\n countyByIndex(i: number): T.GeoFeature { return this._data.features[i]; }\n propertyForCounty(f: any, pk: string): any { return f.properties[pk]; }\n mapFIPSToName(fips: string, name: string): void { this._countyNameLookup[fips] = name; }\n nameFromFIPS(fips: string): string { return this._countyNameLookup[fips]; }\n indexFromFIPS(fips: string): number { return this.index[fips]; }\n}\n\n// CLASSES TO ORGANIZE AND/OR ABSTRACT OTHER DATA\n\nexport class State {\n _session: AnalyticsSession;\n\n xx: string;\n nDistricts: number;\n totalPop = 0;\n tooBigFIPS = [] as string[];\n tooBigName = [] as string[];\n expectedSplits = 0;\n expectedAffected = 0;\n\n constructor(s: AnalyticsSession, xx: string, n: number) {\n this._session = s;\n\n this.xx = xx;\n this.nDistricts = n;\n }\n}\n\nexport class Plan {\n _session: AnalyticsSession;\n\n // TODO - RECALC: Do these need to be updated, when the plan changes?\n _planByGeoID: T.PlanByGeoID;\n _planByDistrictID: T.PlanByDistrictID;\n\n districtIDs: number[];\n\n constructor(s: AnalyticsSession, p: T.PlanByGeoID) {\n this._session = s;\n\n\n this._planByGeoID = p;\n this._planByDistrictID = {} as T.PlanByDistrictID;\n\n this.districtIDs = []; // Set when the plan in inverted\n }\n // NOTE - DON'T remove water-only features from the plan, as they may be required\n // for contiguity. Just skip them in aggregating district statistics.\n // removeWaterOnlyFeatures(plan: T.PlanByGeoID): T.PlanByGeoID {\n // let newPlan = {} as T.PlanByGeoID;\n\n // for (let geoID in plan) {\n // // Remove water-only features\n // if (!(U.isWaterOnly(geoID))) {\n // newPlan[geoID] = plan[geoID];\n // }\n // else {\n // console.log(\"Removing water-only feature\", geoID);\n // }\n // }\n\n // return newPlan;\n // }\n invertPlan(): void {\n // NOTE - UNASSIGNED\n this._planByDistrictID = invertPlan(this._planByGeoID, this._session);\n this.districtIDs = U.getNumericObjectKeys(this._planByDistrictID);\n }\n initializeDistrict(i: number): void { this._planByDistrictID[i] = new Set(); }\n\n byGeoID(): T.PlanByGeoID { return this._planByGeoID; }\n byDistrictID(): T.PlanByDistrictID { return this._planByDistrictID; }\n districtForGeoID(i: string): number { return this._planByGeoID[i]; }\n geoIDsForDistrictID(i: number): Set<string> { return this._planByDistrictID[i]; }\n}\n\n// Invert a feature assignment structure to sets of ids by district\nexport function invertPlan(plan: T.PlanByGeoID, s?: AnalyticsSession): T.PlanByDistrictID {\n let invertedPlan = {} as T.PlanByDistrictID;\n\n // Add a dummy 'unassigned' district\n invertedPlan[S.NOT_ASSIGNED] = new Set();\n\n // NOTE - UNASSIGNED\n // The feature assignments coming from DRA do not include unassigned ones.\n // - In the DRA-calling context, there's an analytics session with a reference\n // to the features. Loop over all the features to find the unassigned ones,\n // and add them to the dummy unassigned district explicitly.\n // - In the CLI-calling context, there's no session (yet) but the plan is complete.\n if (!(s == undefined)) {\n for (let i: number = 0; i < s.features.nFeatures(); i++) {\n let f: T.GeoFeature = s.features.featureByIndex(i);\n let geoID: string = s.features.geoIDForFeature(f);\n\n // If the feature is NOT explicitly assigned to a district, add the geoID\n // to the dummy unassigned district 0.\n if (!(U.keyExists(geoID, plan))) invertedPlan[S.NOT_ASSIGNED].add(geoID);\n\n // NOTE - NOT skipping WATER-ONLY features here, because we're\n // not skipping them below when they are explicitly assigned in plans. Should\n // we skip them in both places?\n }\n }\n\n for (let geoID in plan) {\n let districtID = plan[geoID];\n\n // Make sure the set for the districtID exists\n if (!(U.objectContains(invertedPlan, districtID))) {\n invertedPlan[districtID] = new Set();\n }\n\n // Add the geoID to the districtID's set\n invertedPlan[districtID].add(geoID);\n\n if (U.isWaterOnly(geoID)) console.log(\"Water-only feature still in plan!\", geoID);\n }\n\n return invertedPlan;\n}\n\nexport class Graph {\n _session: AnalyticsSession;\n\n _graph: T.ContiguityGraph;\n\n constructor(s: AnalyticsSession, graph: T.ContiguityGraph) {\n this._session = s;\n\n this._graph = graph;\n }\n peerNeighbors(node: string): string[] {\n // Get the neighboring geoIDs connected to a geoID\n // Ignore the lengths of the shared borders (the values), for now\n\n // Protect against getting a GEOID that's not in the graph\n if (U.keyExists(node, this._graph)) {\n // NOTE - CONTIGUITY GRAPHS\n // Handle both unweighted & weighted neighbors\n let n = this._graph[node];\n let l = (n instanceof Array) ? n : U.getObjectKeys(n);\n\n return l;\n\n // return U.getObjectKeys(this._graph[node]);\n }\n else return [];\n\n // return U.getObjectKeys(this._graph[node]);\n }\n}\n\n\n","//\n// ANALYZE A PLAN\n//\n\nimport * as T from './types'\nimport * as U from './utils';\nimport * as S from './settings';\n\nimport { AnalyticsSession } from './_api';\n\nimport { doIsComplete, doIsContiguous, doIsFreeOfHoles } from './valid'\nimport { doPopulationDeviation, doHasEqualPopulations } from './equal';\nimport { doReock, doPolsbyPopper } from './compact';\nimport {\n doFindCountiesSplitUnexpectedly, doFindSplitVTDs,\n doCountySplitting, doDistrictSplitting\n} from './cohesive';\nimport {\n doSeatsBias, doVotesBias,\n doResponsiveness, doResponsiveDistricts, doEfficiencyGap\n} from './political';\nimport { doMajorityMinorityDistricts } from './minority'\n\n// Compile district-level info for plan/map-level analytics\nexport function doAnalyzeDistricts(s: AnalyticsSession, bLog: boolean = false): void {\n s.districts.recalcStatistics(bLog);\n s.districts.extractDistrictShapeProperties(bLog);\n}\n\n// Calculate the analytics & validations and cache the results\n// NOTE - doAnalyzePlan() depends on doAnalyzeDistricts() having run first.\n// NOTE - I could make this table-driven, but I'm thinking that the explicit\n// calls might make chunking for aync easier.\nexport function doAnalyzePlan(s: AnalyticsSession, bLog: boolean = false): void {\n // TODO - Remove this mechanism. Always run all tests\n // Get the requested suites, and only execute those tests\n let requestedSuites = s.config['suites'];\n\n // Tests in the \"Legal\" suite, i.e., pass/ fail constraints\n if (requestedSuites.includes(T.Suite.Legal)) {\n s.tests[T.Test.Complete] = doIsComplete(s, bLog);\n\n s.tests[T.Test.Contiguous] = doIsContiguous(s, bLog);\n\n s.tests[T.Test.FreeOfHoles] = doIsFreeOfHoles(s, bLog);\n\n s.tests[T.Test.PopulationDeviation] = doPopulationDeviation(s, bLog);\n\n // NOTE - I can't check whether a population deviation is legal or not, until\n // the raw % is normalized. A zero (0) would mean \"too much\" / \"not legal,\" for\n // the given type of district (CD vs. LD). The EqualPopulation test is derived\n // from PopulationDeviation, as part of scorecard or test log preparation.\n\n // Create an empty test entry here though ...\n s.tests[T.Test.EqualPopulation] = s.getTest(T.Test.EqualPopulation) as T.TestEntry;\n }\n\n // Tests in the \"Fair\" suite\n if (requestedSuites.includes(T.Suite.Fair)) {\n s.tests[T.Test.SeatsBias] = doSeatsBias(s, bLog);\n\n s.tests[T.Test.VotesBias] = doVotesBias(s, bLog);\n\n s.tests[T.Test.Responsiveness] = doResponsiveness(s, bLog);\n\n s.tests[T.Test.ResponsiveDistricts] = doResponsiveDistricts(s, bLog);\n\n s.tests[T.Test.EfficiencyGap] = doEfficiencyGap(s, bLog);\n\n s.tests[T.Test.MajorityMinorityDistricts] = doMajorityMinorityDistricts(s, bLog);\n }\n\n // Tests in the \"Best\" suite, i.e., criteria for better/worse\n if (requestedSuites.includes(T.Suite.Best)) {\n s.tests[T.Test.Reock] = doReock(s, bLog);\n s.tests[T.Test.PolsbyPopper] = doPolsbyPopper(s, bLog);\n\n s.tests[T.Test.UnexpectedCountySplits] = doFindCountiesSplitUnexpectedly(s, bLog);\n s.tests[T.Test.VTDSplits] = doFindSplitVTDs(s, bLog);\n s.tests[T.Test.CountySplitting] = doCountySplitting(s, bLog);\n s.tests[T.Test.DistrictSplitting] = doDistrictSplitting(s, bLog);\n }\n\n // Enable a Test Log and Scorecard to be generated\n s.bPlanAnalyzed = true;\n s.bPostProcessingDone = false;\n}\n\n// Derive secondary analytics that are based on primary tests.\n// This concept allows Population Deviation to be a primary numeric test and\n// Equal Population to be secondary pass/fail validation.\n//\n// NOTE - Should this be conditionalized on the test suites requested? \n// Those are encapsulated in reports.ts right now, so not doing that.\nexport function doDeriveSecondaryTests(s: AnalyticsSession, bLog: boolean = false): void {\n s.tests[T.Test.EqualPopulation] = doHasEqualPopulations(s, bLog);\n}\n","//\n// SPLITTING of counties & districts\n//\n\nimport * as T from './types'\nimport * as U from './utils';\nimport * as S from './settings';\n\nimport * as D from './_data'\nimport { AnalyticsSession } from './_api';\n\n\n// CALCULATE ENHANCED SQRT ENTROPY METRIC\n\nexport function doCountySplitting(s: AnalyticsSession, bLog: boolean = false): T.TestEntry {\n let test = s.getTest(T.Test.CountySplitting) as T.TestEntry;\n\n let CxD = s.districts.statistics[D.DistrictField.CountySplits].slice(0, -1);\n let countyTotals = s.counties.totalPopulation;\n let districtTotals = s.districts.statistics[D.DistrictField.TotalPop].slice(0, -1);\n\n let f = calcCountyFractions(CxD, countyTotals);\n let w = calcCountyWeights(countyTotals);\n\n let SqEnt_DC = countySplitting(f, w, bLog);\n\n let CxDreducedC = U.deepCopy(CxD);\n reduceCSplits(CxDreducedC, districtTotals);\n\n let fReduced = calcCountyFractions(CxDreducedC, countyTotals);\n let wReduced = calcCountyWeights(countyTotals);\n\n let SqEnt_DCreduced = countySplitting(fReduced, wReduced, bLog);\n\n test['score'] = SqEnt_DCreduced;\n test['details']['SqEnt_DC'] = SqEnt_DC;\n\n return test;\n}\n\nexport function doDistrictSplitting(s: AnalyticsSession, bLog: boolean = false): T.TestEntry {\n let test = s.getTest(T.Test.DistrictSplitting) as T.TestEntry;\n\n let CxD = s.districts.statistics[D.DistrictField.CountySplits].slice(0, -1);\n let countyTotals = s.counties.totalPopulation;\n let districtTotals = s.districts.statistics[D.DistrictField.TotalPop].slice(0, -1);\n\n let g = calcDistrictFractions(CxD, districtTotals);\n let x = calcDistrictWeights(districtTotals);\n\n let SqEnt_CD = districtSplitting(g, x, bLog);\n\n let CxDreducedD = U.deepCopy(CxD);\n reduceDSplits(CxDreducedD, countyTotals);\n\n let gReduced = calcDistrictFractions(CxDreducedD, districtTotals);\n let xReduced = calcDistrictWeights(districtTotals);\n\n let SqEnt_CDreduced = districtSplitting(gReduced, xReduced, bLog);\n\n test['score'] = SqEnt_CDreduced;\n test['details']['SqEnt_CD'] = SqEnt_CD;\n\n return test;\n}\n\n\n// HELPERS\n\n// Loop over all the county-district combos, skipping the virtual district 0 \n// and virtual county 0.\n//\n// NOTE - The county-district splits and the county & district totals may all,\n// in general, be fractional/decimal numbers as opposed to integers, due to\n// dissaggregation & re-aggregation. Hence, comparisons need to approximate\n// equality.\n\n// Consolidate districts (rows) consisting of just one county (column)\n// UP into the dummy district (0).\nfunction reduceCSplits(CxDreducedC: number[][], districtTotals: number[]): void {\n let nD = CxDreducedC.length;\n let nC = CxDreducedC[0].length;\n\n for (let j = 1; j < nC; j++) {\n for (let i = 1; i < nD; i++) {\n let split_total = CxDreducedC[i][j];\n\n if (split_total > 0) {\n if (areRoughlyEqual(split_total, districtTotals[i])) {\n CxDreducedC[0][j] += split_total;\n CxDreducedC[i][j] = 0;\n }\n }\n }\n }\n}\n\n// Consolidate whole counties (columns) in a district (row) LEFT into the\n// dummy county (0).\nfunction reduceDSplits(CxDreducedD: number[][], countyTotals: number[]): void {\n let nD = CxDreducedD.length;\n let nC = CxDreducedD[0].length;\n\n for (let i = 1; i < nD; i++) {\n for (let j = 1; j < nC; j++) {\n let split_total = CxDreducedD[i][j];\n\n if (split_total > 0) {\n if (areRoughlyEqual(split_total, countyTotals[j])) {\n CxDreducedD[i][0] += split_total;\n CxDreducedD[i][j] = 0;\n }\n }\n }\n }\n}\n\nfunction calcCountyWeights(countyTotals: number[]): number[] {\n let nC: number = countyTotals.length;\n let cTotal: number = U.sumArray(countyTotals);\n\n let w: number[] = U.initArray(nC, 0.0);\n\n for (let j = 0; j < nC; j++) {\n w[j] = countyTotals[j] / cTotal;\n }\n\n return w;\n}\n\nfunction calcDistrictWeights(districtTotals: number[]): number[] {\n let nD = districtTotals.length;\n let dTotal: number = U.sumArray(districtTotals);\n\n let x: number[] = U.initArray(nD, 0.0);\n\n for (let i = 0; i < nD; i++) {\n x[i] = districtTotals[i] / dTotal;\n }\n\n return x;\n}\n\nfunction calcCountyFractions(CxDreducedD: number[][], countyTotals: number[]): number[][] {\n let nD = CxDreducedD.length;\n let nC = CxDreducedD[0].length;\n\n let f: number[][] = new Array(nD).fill(0.0).map(() => new Array(nC).fill(0.0));\n\n for (let j = 0; j < nC; j++) {\n for (let i = 0; i < nD; i++) {\n if (countyTotals[j] > 0) {\n f[i][j] = CxDreducedD[i][j] / countyTotals[j];\n }\n else {\n f[i][j] = 0.0;\n }\n }\n }\n\n return f;\n}\n\nfunction calcDistrictFractions(CxDreducedC: number[][], districtTotals: number[]): number[][] {\n let nD = CxDreducedC.length;\n let nC = CxDreducedC[0].length;\n\n let g: number[][] = new Array(nD).fill(0.0).map(() => new Array(nC).fill(0.0));\n\n for (let j = 0; j < nC; j++) {\n for (let i = 0; i < nD; i++) {\n if (districtTotals[i] > 0) {\n g[i][j] = CxDreducedC[i][j] / districtTotals[i];\n }\n else {\n g[i][j] = 0.0;\n }\n }\n }\n\n return g;\n}\n\n// Deal with decimal census \"counts\" due to disagg/re-agg\nfunction areRoughlyEqual(x: number, y: number): boolean {\n let delta = Math.abs(x - y);\n let result = (delta < S.EQUAL_TOLERANCE) ? true : false;\n\n return result;\n}\n\n// For all districts in a county, sum the split score.\nfunction countySplitScore(j: number, f: number[][], numD: number, bLog: boolean = false): number {\n let e = 0.0;\n\n for (let i = 0; i < numD; i++) {\n e += Math.sqrt(f[i][j]);\n }\n\n return e;\n}\n\n// For all counties, sum the weighted county splits.\nfunction countySplitting(f: number[][], w: number[], bLog: boolean = false): number {\n let numC = f[0].length;\n let numD = f.length;\n\n let e = 0.0;\n\n for (let j = 0; j < numC; j++) {\n let splitScore = countySplitScore(j, f, numD, bLog);\n e += w[j] * splitScore;\n\n if (bLog) console.log(\"County splitting =\", j, w[j], splitScore, e);\n }\n\n return U.trim(e, 3);\n}\n\n// For all counties in a district, sum the split score.\nfunction districtSplitScore(i: number, g: number[][], numC: number, bLog: boolean = false): number {\n let e = 0.0;\n\n for (let j = 0; j < numC; j++) {\n e += Math.sqrt(g[i][j]);\n }\n\n return e;\n}\n\n// For all districts, sum the weighted district splits.\nfunction districtSplitting(g: number[][], x: number[], bLog: boolean = false): number {\n let numC = g[0].length;\n let numD = g.length;\n\n let e = 0.0;\n\n for (let i = 0; i < numD; i++) {\n let splitScore = districtSplitScore(i, g, numC, bLog);\n e += x[i] * splitScore;\n\n if (bLog) console.log(\"District split score =\", i, x[i], splitScore, e);\n }\n\n return U.trim(e, 3);\n}\n\n\n// ANALYZE SIMPLE COUNTY & VTD SPLITTING\n\n/*\n \nSample results for NC 2016 dongressional plan\n________________________________________________________________________________\n \nState: NC\nCensus: 2010\nTotal population: 9,535,483\nNumber of districts: 13\nTarget district size: 733,499\nNumber of counties: 100\n \nEqual Population: 11.24% deviation\nCompactness: None\nProportionality: 27.67% gap\nCohesiveness: 11 unexpected splits, affecting 27.14% of the total population\n \nThese counties are split unexpectedly:\n \n • Bladen\n • Buncombe\n • Catawba\n • Cumberland\n • Durham\n • Guilford\n • Iredell\n • Johnston\n • Pitt\n • Rowan\n • Wilson\n \n*/\n\nexport function doFindCountiesSplitUnexpectedly(s: AnalyticsSession, bLog: boolean = false): T.TestEntry {\n let test = s.getTest(T.Test.UnexpectedCountySplits) as T.TestEntry;\n\n // THE THREE VALUES TO DETERMINE FOR A PLAN\n let unexpectedSplits: number = 0;\n let unexpectedAffected: number = 0;\n let countiesSplitUnexpectedly = [];\n\n // FIRST, ANALYZE THE COUNTY SPLITTING FOR THE PLAN\n\n // Get the county-district pivot (\"splits\")\n let countiesByDistrict = s.districts.statistics[D.DistrictField.CountySplits];\n // countiesByDistrict = countiesByDistrict.slice(1, -1);\n\n // Find the single-county districts, i.e., districts NOT split across counties.\n // Ignore the dummy unassigned 0 and N+1 summary \"districts.\"\n let singleCountyDistricts = [];\n for (let d = 1; d <= s.state.nDistricts; d++) {\n // See if there's only one county partition\n let nCountiesInDistrict = 0;\n for (let c = 0; c < s.counties.nCounties; c++) {\n // Guard against empty district\n if (countiesByDistrict[d]) {\n if (countiesByDistrict[d][c] > 0) {\n nCountiesInDistrict += 1;\n if (nCountiesInDistrict > 1) {\n break;\n }\n }\n }\n }\n // If so, save the district\n if (nCountiesInDistrict == 1) {\n singleCountyDistricts.push(d);\n }\n }\n\n // Process the splits/partitions in the plan:\n // - Count the total # of partitions,\n // - Find the counties split across districts, and\n // - Accumulate the number people affected (except when single-county districts)\n let nPartitionsOverall: number = 0;\n let splitCounties = new Set(); // The counties that are split across districts\n let totalAffected: number = 0; // The total population affected by those splits\n\n for (let c = 0; c < s.counties.nCounties; c++) {\n let nCountyParts = 0;\n let subtotal = 0;\n\n for (let d = 1; d <= s.state.nDistricts; d++) {\n // Guard against empty district\n if (countiesByDistrict[d]) {\n if (countiesByDistrict[d][c] > 0) {\n nPartitionsOverall += 1;\n nCountyParts += 1;\n if (!(U.arrayContains(singleCountyDistricts, d))) {\n subtotal += countiesByDistrict[d][c];\n }\n }\n }\n }\n if (nCountyParts > 1) {\n splitCounties.add(c);\n totalAffected += subtotal;\n }\n }\n\n // Convert county ordinals to FIPS codes\n let splitCountiesFIPS = U.getSelectObjectKeys(s.counties.index, [...splitCounties]);\n\n // THEN TAKE ACCOUNT OF THE COUNTY SPLITTING THAT IS EXPECTED (REQUIRED)\n\n // Compute the total number of splits this way, in case any counties are split\n // more than once. I.e., it's not just len(all_counties_split).\n let nSplits = nPartitionsOverall - s.counties.nCounties;\n\n // Determine the number of *unexpected* splits. NOTE: Prevent negative numbers,\n // in case you have a plan the *doesn't* split counties that would have to be\n // split due to their size.\n unexpectedSplits = Math.max(0, nSplits - s.state.expectedSplits);\n\n // Subtract off the total population that *has* to be affected by splits,\n // because their counties are too big. NOTE: Again, prevent negative numbers, \n // in case you have a plan the *doesn't* split counties that would have to be\n // split due to their size.\n unexpectedAffected = U.trim(Math.max(0, totalAffected - s.state.expectedAffected) / s.state.totalPop);\n\n // Find the counties that are split *unexpectedly*. From all the counties that\n // are split, remove those that *have* to be split, because they are bigger than\n // a district.\n let countiesSplitUnexpectedlyFIPS = [];\n for (let fips of splitCountiesFIPS) {\n if (!(U.arrayContains(s.state.tooBigFIPS, fips))) {\n countiesSplitUnexpectedlyFIPS.push(fips);\n }\n }\n\n // ... and convert the FIPS codes to county names.\n for (let fips of countiesSplitUnexpectedlyFIPS) {\n countiesSplitUnexpectedly.push(s.counties.nameFromFIPS(fips));\n }\n countiesSplitUnexpectedly = countiesSplitUnexpectedly.sort();\n\n test['score'] = U.trim(unexpectedAffected);\n test['details']['unexpectedSplits'] = unexpectedSplits;\n test['details']['countiesSplitUnexpectedly'] = countiesSplitUnexpectedly;\n\n return test;\n}\n\nexport function doFindSplitVTDs(s: AnalyticsSession, bLog: boolean = false): T.TestEntry {\n let test = s.getTest(T.Test.VTDSplits) as T.TestEntry;\n\n let splitVTDs: string[] = [];\n\n // TODO - SPLITTING: Flesh this out, using Terry's virtual VTD's ...\n\n test['score'] = splitVTDs.length;\n test['details']['splitVTDs'] = splitVTDs;\n\n return test;\n}\n\n","//\n// COMPACT\n//\n\nimport * as Poly from '@dra2020/poly';\n\nimport { gfArea, gfPerimeter, gfDiameter } from './geofeature';\n\nimport * as T from './types';\nimport * as U from './utils';\nimport * as S from './settings';\n\nimport { AnalyticsSession } from './_api';\n\n// Measures of compactness compare district shapes to various ideally compact\n// benchmarks, such as circles. All else equal, more compact districts are better.\n// \n// There are four popular measures of compactness. They either focus on how\n// dispersed or how indented a shapes are.\n//\n// These first two measures are the most important:\n// \n// Reock is the primary measure of the dispersion of district shapes, calculated\n// as “the area of the district to the area of the minimum spanning circle that\n// can enclose the district.”\n//\n// R = A / A(Minimum Bounding Circle)\n// R = A / (π * (D / 2)^2)\n//\n// R = 4A / πD^2\n//\n// where A is the area of the district and D is the diameter of the minimum\n// bounding circle.\n//\n// Polsby-Popper is the primary measure of the indendentation of district shapes,\n// calculated as the “the ratio of the area of the district to the area of a circle\n// whose circumference is equal to the perimeter of the district.”\n//\n// PP = A / A(C)\n//\n// where C is that circle. In other words:\n//\n// P = 2πRc and A(C) = π(P / 2π)^2\n//\n// where P is the perimeter of the district and Rc is the radius of the circle.\n//\n// Hence, the measure simplifies to:\n//\n// PP = 4π * (A / P^2)\n// \n// I propose that we use these two, normalize them, and weight equally to determine\n// our compactness value.\n// \n// These second two measures may be used to complement the primary ones above:\n// \n// Convex Hull is a secondary measure of the dispersion of district shapes, calculated\n// as “the ratio of the district area to the area of the minimum convex bounding\n// polygon (also known as a convex hull) enclosing the district.”\n//\n// CH = A / A(Convex Hull)\n// \n// where a convex hull is the minimum perimeter that encloses all points in a shape,\n// basically the shortest unstretched rubber band that fits around the shape.\n//\n// Schwartzberg is a secondary measure of the degree of indentation of district\n// shapes, calculated as “the ratio of the perimeter of the district to the circumference\n// of a circle whose area is equal to the area of the district.”\n//\n// S = 1 / (P / C)\n//\n// where P is the perimeter of the district and C is the circumference of the circle.\n// The radius of the circle is:\n//\n// Rc = SQRT(A / π)\n//\n// So, the circumference of the circle is:\n//\n// C = 2πRc or C = 2π * SQRT(A / π)\n//\n// Hence:\n//\n// S = 1 (P / 2π * SQRT(A / π))\n//\n// S = (2π * SQRT(A / π)) / P\n//\n// All these measures produce values between 0 and 1, with 0 being the least compact\n// and 1 being the most compact. Sometimes these values are multiplied by 100 to\n// give values between 0 and 100.\n// \n// For each measure, the compactness of a set of Congressional districts is the\n// average of that measure for all the districts.\n//\n\n// Calculate Reock compactness:\n// reock = (4 * a) / (math.pi * d**2)\n// NOTE - Depends on extractDistrictProperties running first\nexport function doReock(s: AnalyticsSession, bLog: boolean = false): T.TestEntry {\n let test = s.getTest(T.Test.Reock) as T.TestEntry;\n\n // Calculate Reock scores by district\n let scores: number[] = [];\n\n for (let districtID = 1; districtID <= s.state.nDistricts; districtID++) {\n let districtProps = s.districts.getGeoProperties(districtID);\n // Guard against no shape and no properties\n if (districtProps) {\n let a = districtProps[T.DistrictShapeProperty.Area];\n let d = districtProps[T.DistrictShapeProperty.Diameter];\n\n let reock = (4 * a) / (Math.PI * d ** 2);\n\n // Save each district score\n scores.push(reock);\n\n // Echo the results by district\n if (bLog) console.log(\"Reock for district\", districtID, \"=\", reock);\n }\n }\n\n // Populate the test entry ... for the shapes that exist!\n let averageReock = U.avgArray(scores);\n\n test['score'] = U.trim(averageReock);\n test['details'] = {}; // TODO - Any details?\n\n return test;\n}\n\n// Calculate Polsby-Popper compactness measures:\n// polsby_popper = (4 * math.pi) * (a / p**2)\n// NOTE - Depends on extractDistrictProperties running first\nexport function doPolsbyPopper(s: AnalyticsSession, bLog: boolean = false): T.TestEntry {\n let test = s.getTest(T.Test.PolsbyPopper) as T.TestEntry;\n\n // Calculate Polsby-Popper scores by district\n let scores: number[] = [];\n\n for (let districtID = 1; districtID <= s.state.nDistricts; districtID++) {\n let districtProps = s.districts.getGeoProperties(districtID);\n // Guard against no shape and no properties\n if (districtProps) {\n let a = districtProps[T.DistrictShapeProperty.Area];\n let p = districtProps[T.DistrictShapeProperty.Perimeter];\n\n let polsbyPopper = (4 * Math.PI) * (a / p ** 2);\n\n // Save each district score\n scores.push(polsbyPopper);\n\n // Echo the results by district\n if (bLog) console.log(\"Polsby-Popper for district\", districtID, \"=\", polsbyPopper);\n }\n }\n\n // Populate the test entry ... for the shapes that exist!\n let averagePolsbyPopper = U.avgArray(scores);\n\n test['score'] = U.trim(averagePolsbyPopper);\n test['details'] = {}; // TODO - Any details?\n\n return test;\n}\n\n\n// HELPER TO EXTRACT PROPERTIES OF DISTRICT SHAPES\n\nexport function extractDistrictProperties(s: AnalyticsSession, bLog: boolean = false): void {\n // NOTE - I am assuming that district IDs are integers 1–N\n for (let i = 1; i <= s.state.nDistricts; i++) {\n let poly = s.districts.getDistrictShapeByID(i);\n\n // Guard against no shape for empty districts AND null shapes\n let polyOptions = { noLatitudeCorrection: true }\n let bNull = (!Poly.polyNormalize(poly, polyOptions));\n\n if (poly && (!bNull)) {\n // TODO - OPTIMIZE: Bundle these calls?\n let area: number = gfArea(poly);\n let perimeter: number = gfPerimeter(poly);\n let diameter: number = gfDiameter(poly);\n\n let props: T.DistrictShapeProperties = [0, 0, 0]; // TODO - TERRY?!?\n props[T.DistrictShapeProperty.Area] = area;\n props[T.DistrictShapeProperty.Diameter] = diameter;\n props[T.DistrictShapeProperty.Perimeter] = perimeter;\n\n s.districts.setGeoProperties(i, props);\n\n if (bLog) console.log(\"District\", i, \"A =\", area, \"P =\", perimeter, \"D =\", diameter);\n }\n }\n}\n\n\n// SAVE THESE NOTES, IN CASE WE NEED TO REWORK HOW WE PERFORM THESE CALCS.\n// THEY REFLECT HOW I DID THEM IN PYTHON.\n//\n// THE COMPACTNESS ANALYTICS NEED THE FOLLOWING DATA,\n// IN ADDITION TO THE MAP (IDEALLY, GEO_IDS INDEXED BY DISTRICT_ID)\n//\n// Shapes by geo_id\n//\n// If we need/want to speed compactness calculations up, we'll need\n// to calculate the perimeters and diameters (and areas) of districts implicitly,\n// which will require identifying district boundaries initially and updating\n// them incrementally as districts are (re)assigned.\n//\n// A district's boundary info is the set/list of features that constitute the\n// district's border along with each boundary feature's neighbors. Hence, this\n// requires a contiguity graph with the lengths of shared edges between features\n// precomputed.\n//\n// NOTE - I can write up (if not implement) the logic for determining what shapes\n// constitute a district's boundary. There are a few nuances.\n//\n// If we have to optimize like this when we generalize to mixed maps, the\n// determination of \"neighbors in the map\" and the length of shared borders\n// (for determining a district perimeters) becomes more complicated and dynamic.\n//\n// NOTE - Again, I can write up (if not implement) the logic for both of these.\n// They are a bit tricky and require special preprocessing of the summary level\n// hierarchy (which I also have a script for that we can repurpose).\n","//\n// EQUAL POPULATION\n//\n\nimport * as T from './types'\nimport * as U from './utils';\nimport * as S from './settings';\n\nimport * as D from './_data'\nimport { AnalyticsSession } from './_api';\n\n\nexport function doPopulationDeviation(s: AnalyticsSession, bLog: boolean = false): T.TestEntry {\n let test = s.getTest(T.Test.PopulationDeviation) as T.TestEntry;\n\n // Compute the min, max, and average district populations,\n // excluding the dummy 'unassigned' 0 and N+1 summary \"districts.\"\n let totPopByDistrict = s.districts.statistics[D.DistrictField.TotalPop];\n totPopByDistrict = totPopByDistrict.slice(1, -1);\n\n let min = U.minArray(totPopByDistrict);\n let max = U.maxArray(totPopByDistrict);\n let total = U.sumArray(totPopByDistrict);\n\n // Calculate the raw population deviation.\n // The target size is the average population.\n let avg = total / s.state.nDistricts;\n let popDev = (max - min) / avg;\n\n // Round the raw value to the desired level of precision\n popDev = U.trim(popDev);\n\n // Populate the test entry\n test['score'] = popDev;\n test['details'] = { 'maxDeviation': max - min };\n\n // Populate the N+1 summary \"district\" in district.statistics\n let totalPop = s.districts.statistics[D.DistrictField.TotalPop];\n let popDevPct = s.districts.statistics[D.DistrictField.PopDevPct];\n let summaryRow = s.districts.numberOfRows() - 1;\n\n totalPop[summaryRow] = avg; // aka \"target size\"\n popDevPct[summaryRow] = popDev;\n\n return test;\n}\n\n// NOTE - This validity check is *derived* and depends on population deviation %\n// being computed (above) and normalized in test log & scorecard generation.\nexport function doHasEqualPopulations(s: AnalyticsSession, bLog: boolean = false): T.TestEntry {\n let test = s.getTest(T.Test.EqualPopulation) as T.TestEntry;\n\n // Get the normalized population deviation %\n let popDevTest = s.getTest(T.Test.PopulationDeviation);\n let popDevPct = popDevTest['score'] as number;\n let popDevNormalized: number = popDevTest['normalizedScore'] as number;\n\n // Populate the test entry\n if (popDevNormalized > 0) {\n test['score'] = true;\n }\n else {\n test['score'] = false;\n }\n test['details']['deviation'] = popDevPct;\n test['details']['thresholds'] = popDevTest['details']['scale'];\n\n // Populate the N+1 summary \"district\" in district.statistics\n let bEqualPop = s.districts.statistics[D.DistrictField.bEqualPop];\n let summaryRow = s.districts.numberOfRows() - 1;\n\n bEqualPop[summaryRow] = test['score'];\n\n return test;\n}\n","//\n// GEO-FEATURES UTILITIES\n//\n\nimport * as Poly from '@dra2020/poly';\n\nimport * as T from './types'\nimport * as U from './utils';\nimport * as S from './settings';\n\n\n// CARTESIAN SHIMS OVER 'POLY' FUNCTIONS\n\n// TODO - POLY: Confirm Cartesian calculations\nexport function gfArea(poly: any): number {\n let area: number = _polygonArea(poly);\n\n return area;\n}\n\n// Algorithm for the area of a simple/single planar polygon:\n// https://algorithmtutor.com/Computational-Geometry/Area-of-a-polygon-given-a-set-of-points/\n// https://mathopenref.com/coordpolygonarea2.html\n//\n// function polygonArea(X, Y, numPoints) \n// { \n// area = 0; // Accumulates area in the loop\n// j = numPoints-1; // The last vertex is the 'previous' one to the first\n\n// for (i=0; i<numPoints; i++)\n// { area = area + (X[j]+X[i]) * (Y[j]-Y[i]); \n// j = i; //j is previous vertex to i\n// }\n// return area/2;\n// }\n\n// Reimplemented to use polygons vs. X & Y vectors\nfunction _polygonSimpleArea(p: any): number {\n let area = 0; // Accumulates area in the loop\n let n = p.length;\n let j = n - 1; // The last vertex is the 'previous' one to the first\n\n for (let i = 0; i < n; i++) {\n area = area + (p[j][0] + p[i][0]) * (p[j][1] - p[i][1]);\n // area = area + (X[j] + X[i]) * (Y[j] - Y[i]);\n j = i; // j is previous vertex to i\n }\n return Math.abs(area / 2);\n}\n\n// Generalizes the above for MultiPolygons -- cloned from polyArea() in 'poly'\nfunction _polygonArea(poly: any): number {\n let polyOptions = { noLatitudeCorrection: true } // NO-OP?\n poly = Poly.polyNormalize(poly, polyOptions); // TODO - POLY: Discuss w/ Terry\n\n let a: number = 0;\n\n // A MultiPolygon is a set of polygons\n for (let i: number = 0; poly && i < poly.length; i++) {\n // A single polygon is an exterior ring with interior holes. Holes are subtracted.\n let p = poly[i];\n for (let j: number = 0; j < p.length; j++) {\n let sp = p[j];\n a += _polygonSimpleArea(sp) * (j == 0 ? 1 : -1);\n }\n }\n\n return a;\n}\n\n// TODO - POLY: Confirm Cartesian calculations w/ Terry\n// The perimeter calculation already just computes cartesian distance if you\n// pass in the noLatitudeCorrection flag. You would need to divide by \n// Poly.EARTH_RADIUS to go from the returned units of meters to Lat/Lon “units”.\n\nexport function gfPerimeter(poly: any): number {\n let perimeter: number = _polygonPerimeter(poly);\n\n return perimeter;\n}\n\n// TODO - POLY: Confirm Cartesian calculations w/ Terry\n// Cloned from polyPerimeter() in 'poly' and revised to use Cartesian distance\n// NOTE: No conversion of degrees to radians!\nfunction _polygonPerimeter(poly: any): number {\n let polyOptions = { noLatitudeCorrection: true } // Cartesian distance\n poly = Poly.polyNormalize(poly, polyOptions);\n\n let perimeter: number = 0;\n for (let i: number = 0; poly && i < poly.length; i++) {\n // Ignore holes so only look at first polyline\n let p: any = poly[i][0];\n for (let j: number = 0; j < p.length - 1; j++)\n perimeter += _distance(p[j][0], p[j][1], p[j + 1][0], p[j + 1][1]);\n\n if (p.length > 2 && (p[0][0] != p[p.length - 1][0] || p[0][1] != p[p.length - 1][1]))\n perimeter += _distance(p[0][0], p[0][1], p[p.length - 1][0], p[p.length - 1][1]);\n }\n\n return perimeter;\n}\n\nfunction _distance(x1: number, y1: number, x2: number, y2: number): number {\n let dLat = y2 - y1;\n let dLon = x2 - x1;\n let d: number;\n\n d = Math.sqrt((dLat * dLat) + (dLon * dLon));\n\n return d;\n}\n\n// TODO - POLY: Confirm Cartesian calculations w/ Terry\n// As I mentioned, the polyCircle code was already just treating the coordinate\n// system as Cartesian. I then did polyFromCircle to convert it to a polygon that\n// then could be passed to polyArea in order to take into account the projection.\n// If instead, you compute area directly from the circle as PI R squared, then\n// you should have your cartesian circular area.\n\nexport function gfDiameter(poly: any): number {\n let polyOptions = { noLatitudeCorrection: true } // NO-OP\n\n let circle = Poly.polyToCircle(poly, polyOptions) as Poly.Circle;\n let diameter: number = circle.r * 2;\n\n return diameter;\n}\n","//\n// THE DISTRICT-ANALYTICS NODE PACKAGE API\n//\n\nexport * from './_api';\nexport * from './_data';\nexport * from './results';\nexport * from './types';\n","//\n// PROTECTS MINORITIES\n//\n\nimport * as T from './types'\nimport * as U from './utils';\nimport * as S from './settings';\n\nimport { AnalyticsSession } from './_api';\n\nimport demographicDefs from '../static/demographic-defns.json';\nimport majorityMinority from '../static/majority-minority.json';\nimport stateContacts from '../static/state-contacts.json';\nimport vraSection5 from '../static/vra5-preclearance.json';\n\nexport function doMajorityMinorityDistricts(s: AnalyticsSession, bLog: boolean = false): T.TestEntry {\n let test = s.getTest(T.Test.MajorityMinorityDistricts) as T.TestEntry;\n\n if (bLog) console.log(\"TODO - Calculating # of majority-minority districts ...\");\n\n return test;\n}\n\n\n// Sources for majority-minority info:\n// - https://en.wikipedia.org/wiki/List_of_majority-minority_United_States_congressional_districts\n// TODO - 2020: Update/revise this, when the update comes out in September:\n// - http://www.ncsl.org/Portals/1/Documents/Redistricting/Redistricting_2010.pdf\n","//\n// FAIR/PROPORTIONAL\n//\n\nimport { strict as assert } from 'assert';\n\nimport * as T from './types'\nimport * as U from './utils';\nimport * as S from './settings';\n\nimport * as D from './_data'\nimport { AnalyticsSession } from './_api';\n\n// Partisan analytics need the following data:\n//\n// An \"election model\" by geo_id, where each item has 4 pieces of data:\n//\n// { geo_id, Democratic votes, Republican votes, Total votes }\n//\n// NOTE: D + R <= Total, because there could be third-party or write-in votes.\n//\n// An election model can simply represent one election, e.g., President 2012,\n// or combine multiple elections in some fashion. An election model is used to\n// computer a single index of the likely partisan weight / lean / preference\n// for the districts in a plan. An election model and the associated index go\n// hand in hand. So much so that the index frequently stands in as the name for\n// both, e.g., Cook's PVI is one example, Nagle's 7s, Hofeller's Formula, NDRC's\n// DPI.\n//\n// I'm labelling this general concept a \"Voter Preference Index (VPI),\" a\n// conscious +1 letter play on Cook's \"PVI\" acronymn.\n\n\n// MEASURING BIAS & RESPONSIVENESS (NAGLE'S METHOD)\n\nexport function doSeatsBias(s: AnalyticsSession, bLog: boolean = false): T.TestEntry {\n let test = s.getTest(T.Test.SeatsBias) as T.TestEntry;\n\n if (bLog) console.log(\"TODO - Calculating seats bias ...\");\n\n return test;\n}\n\nexport function doVotesBias(s: AnalyticsSession, bLog: boolean = false): T.TestEntry {\n let test = s.getTest(T.Test.VotesBias) as T.TestEntry;\n\n if (bLog) console.log(\"TODO - Calculating votes bias ...\");\n\n return test;\n}\n\nexport function doResponsiveness(s: AnalyticsSession, bLog: boolean = false): T.TestEntry {\n let test = s.getTest(T.Test.Responsiveness) as T.TestEntry;\n\n if (bLog) console.log(\"TODO - Calculating responsiveness ...\");\n\n return test;\n}\n\nexport function doResponsiveDistricts(s: AnalyticsSession, bLog: boolean = false): T.TestEntry {\n let test = s.getTest(T.Test.ResponsiveDistricts) as T.TestEntry;\n\n if (bLog) console.log(\"TODO - Calculating # of responsive districts ...\");\n\n return test;\n}\n\n\n// OTHER MEASURES OF PARTISAN BIAS\n\n// TODO - PARTISAN: This formula might need to be inverted for D vs. R +/-\n// TODO - Normalize the results.\nexport function doEfficiencyGap(s: AnalyticsSession, bLog: boolean = false): T.TestEntry {\n if (bLog) console.log(\"TODO - Calculating the efficiency gap ...\");\n\n let test = s.getTest(T.Test.EfficiencyGap) as T.TestEntry;\n\n // Get partisan statistics by districts.\n // Use Democratic votes, seats, and shares by convention.\n let DVotes = s.districts.statistics[D.DistrictField.DemVotes];\n let DSeats = s.districts.statistics[D.DistrictField.DemSeat];\n let TPVotes = s.districts.statistics[D.DistrictField.TwoPartyVote];\n\n // Exclude the dummy unassigned '0' and N+1 summary \"districts\"\n DVotes = DVotes.slice(1, -1);\n DSeats = DSeats.slice(1, -1);\n TPVotes = TPVotes.slice(1, -1);\n\n // Calculate D vote share & D seat share\n let DVoteShare = U.sumArray(DVotes) / U.sumArray(TPVotes);\n let DSeatShare = U.sumArray(DSeats) / s.state.nDistricts;\n\n // Finally, calculate the Efficiency Gap\n let efficiencyGap = (DSeatShare - 0.5) - (2.0 * (DVoteShare - 0.5));\n\n // Round the raw value to the desired level of precision\n efficiencyGap = U.trim(efficiencyGap);\n\n // Populate the test entry\n test['score'] = efficiencyGap;\n // test['normalizedScore'] = 0; /* TODO - Normalize the raw score */\n test['details'] = {}; /* TODO - Add details, if any */\n\n return test;\n}\n\n\n// HELPERS\n\nexport function fptpWin(demPct: number): number {\n // Vote shares should be fractions in the range [0.0 – 1.0]\n assert((demPct <= 1.0) && (demPct >= 0.));\n\n return ((demPct > 0.5) ? 1 : 0);\n}\n","//\n// PREPROCESS DATA\n//\n\nimport * as T from './types'\nimport * as U from './utils';\nimport * as S from './settings';\n\nimport * as D from './_data'\nimport { AnalyticsSession } from './_api';\n\n\n// NOTE - Do preprocessing separately, so the constructor returns quickly.\nexport function doPreprocessData(s: AnalyticsSession, bLog: boolean = false): void {\n // If necessary, do one-time preprocessing\n if (!s.bOneTimeProcessingDone) {\n doPreprocessCountyFeatures(s, bLog);\n doPreprocessCensus(s, bLog);\n doPreprocessElection(s, bLog);\n s.bOneTimeProcessingDone = true;\n }\n\n // NOTE - UNASSIGNED: Made both the planByGeoID & DistrictID are right\n // Invert the plan by district ID\n s.plan.invertPlan();\n\n // Create a map of geoIDs to feature IDs\n s.features.mapGeoIDsToFeatureIDs();\n}\n\n// CREATE A FIPS CODE TO COUNTY NAME LOOKUP\n\nfunction doPreprocessCountyFeatures(s: AnalyticsSession, bLog: boolean = false): void {\n for (let i: number = 0; i < s.counties.nCounties; i++) {\n\n let county = s.counties.countyByIndex(i);\n\n let fips = s.counties.propertyForCounty(county, 'COUNTYFP');\n let name = s.counties.propertyForCounty(county, 'NAME');\n\n s.counties.mapFIPSToName(fips, name);\n }\n}\n\n\n// ANALYZE THE CENSUS BY COUNTY\n\nfunction doPreprocessCensus(s: AnalyticsSession, bLog: boolean = false): void {\n // The county-splitting analytic needs the following info, using NC as an example:\n // '_stateTotal' = The total state population, e.g., 9,535,483 for NC's 2010 Census\n // 'totalByCounty' = The total population by county FIPS code\n\n // SUM TOTAL POPULATION BY COUNTY\n\n let totalByCounty: T.GeoIDTotal = {};\n\n // NOTE - This works w/o GEOIDs, because you're looping over all features.\n for (let i: number = 0; i < s.features.nFeatures(); i++) {\n let f: T.GeoFeature = s.features.featureByIndex(i);\n let geoID: string = s.features.geoIDForFeature(f);\n // Skip water-only features\n if (!(U.isWaterOnly(geoID))) {\n let value: number = s.features.fieldForFeature(f, D.Dataset.CENSUS, D.FeatureField.TotalPop);\n\n // Sum total population across the state\n s.state.totalPop += value;\n\n // Get the county FIPS code for the feature\n let county = U.parseGeoID(geoID)['county'] as string;\n let countyFIPS = U.getFIPSFromCountyGeoID(county);\n // If a subtotal for the county doesn't exist, initialize one\n if (!(U.keyExists(countyFIPS, totalByCounty))) {\n totalByCounty[countyFIPS] = 0;\n }\n // Sum total population by county\n totalByCounty[countyFIPS] += value;\n }\n // else {\n // console.log(\"Skipping water-only feature in Census preprocessing:\", geoID);\n // }\n }\n // NOTE - The above could be replaced, if I got totals on county.geojson.\n\n\n // CREATE A FIPS CODE-ORDINAL MAP\n\n // Get the county FIPS codes\n let fipsCodes = U.getObjectKeys(totalByCounty);\n // Sort the results\n fipsCodes = fipsCodes.sort();\n\n // NOTE - SPLITTING\n // Add a dummy county, for county-district splitting analysis\n fipsCodes.unshift('000');\n\n // Create the ID-ordinal map\n for (let i in fipsCodes) {\n s.counties.index[fipsCodes[i]] = Number(i);\n }\n\n\n // MAKE AN ARRAY OF TOTAL POPULATIONS BY COUNTY INDEX\n\n // Add an extra 0th virtual county bucket for county-district splitting analysis \n let nCountyBuckets = s.counties.nCounties + 1;\n let countyTotals: number[] = U.initArray(nCountyBuckets, 0);\n\n for (let fipsCode in totalByCounty) {\n let i = s.counties.indexFromFIPS(fipsCode);\n\n countyTotals[i] = totalByCounty[fipsCode];\n }\n\n s.counties.totalPopulation = countyTotals;\n\n\n // ANALYZE THE COUNTIES\n\n // 'target_size': 733499, # calc as total / districts\n let targetSize = Math.round(s.state.totalPop / s.state.nDistricts);\n\n // Find counties that are bigger than the target district size.\n // 'too_big' = The counties that are bigger than a district, e.g., ['Mecklenburg', 'Wake']\n // 'too_big_fips' = Their FIPS codes, e.g., ['119', '183']\n // 'expected_splits' = The # of counties that are bigger than a single district, e.g., 2\n // 'expected_affected' = The # of people whose district must be split, e.g., 353,623\n\n let tooBigFIPS = [];\n let tooBigName = [];\n let expectedSplits = 0;\n let expectedAffected = 0;\n\n // Loop over the counties\n for (let county in fipsCodes) {\n let fipsCode = fipsCodes[county];\n\n // NOTE - SPLITTING\n // Skip the dummy county\n if (fipsCode == '000') continue;\n\n let countyAffected = 0;\n\n // Find the number of required splits, assuming target district size.\n let rawQuotient = totalByCounty[fipsCode] / (targetSize + 1);\n let remainder = rawQuotient % 1;\n let quotient = rawQuotient - remainder;\n let countySplits = quotient;\n\n if (countySplits > 0) {\n countyAffected = totalByCounty[fipsCode] % targetSize;\n tooBigFIPS.push(fipsCode);\n tooBigName.push(s.counties.nameFromFIPS(fipsCode));\n }\n\n expectedSplits += countySplits;\n expectedAffected += countyAffected;\n }\n\n s.state.tooBigFIPS = tooBigFIPS;\n s.state.tooBigName = tooBigName;\n s.state.expectedSplits = expectedSplits;\n s.state.expectedAffected = expectedAffected;\n}\n\n\n// PREPROCESS ELECTION RESULTS\n\nfunction doPreprocessElection(s: AnalyticsSession, bLog: boolean = false): void {\n if (bLog) console.log(\"TODO - Preprocessing election data ...\");\n}\n\n","//\n// TEMPLATES FOR UNFORMATTED ANALYTICS RESULTS\n// \n\nimport * as T from './types'\nimport * as U from './utils';\nimport * as S from './settings';\n\nimport * as D from './_data'\nimport { AnalyticsSession } from './_api';\nimport { doDeriveSecondaryTests } from './analyze';\n\nimport allStateReqs from '../static/state-reqs.json';\nimport stateNames from '../static/state-names.json';\n\n// PLAN ANALYTICS\n\nexport type RequirementsCategory = {\n score: T.TriState;\n metrics: {\n complete: T.TriState;\n contiguous: T.TriState;\n freeOfHoles: T.TriState;\n equalPopulation: T.TriState;\n };\n details: {\n unassignedFeatures: string[]; // A possibly empty list of GEOIDs\n emptyDistricts: number[]; // A possibly empty list of district IDs\n discontiguousDistricts: number[]; // Ditto\n embeddedDistricts: number[]; // Ditto\n populationDeviation: number; // A fraction [0.0 – 1.0] to represent as a %\n deviationThreshold: number; // A fraction [0.0 – 1.0] to represent as a % \n };\n datasets: T.Datasets;\n resources: {\n stateReqs: string;\n };\n};\n\nexport type CompactnessCategory = {\n score: number; // An integer score [0–100]\n metrics: {\n reock: number; // A decimal number [0.0–1.0]\n polsby: number; // A decimal number [0.0–1.0]\n };\n details: {\n // None at this time\n };\n datasets: T.Datasets;\n resources: {\n // None at this time\n };\n};\n\nexport type SplittingCategory = {\n score: number; // An integer score [0–100]\n metrics: {\n sqEnt_DCreduced: number, // A decimal number [1.0 – < 2.0]\n sqEnt_CDreduced: number // A decimal number [1.0 – < 2.0]\n };\n details: {\n countiesSplitUnexpectedly: string[], // A possibly empty list of county names\n unexpectedAffected: number, // A fraction [0.0 – 1.0] to represent as a %\n nSplitVTDs: number, // An integer, possibly 0\n splitVTDs: string[] // A possibly empty list of GEOIDs\n };\n datasets: T.Datasets;\n resources: {\n // None at this time\n };\n};\n\n// TODO - PARTISAN: This category is still under development.\n// We haven't settled on metrics yet. This is just an example.\nexport type PartisanCategory = {\n score: number; // An integer score [0–100]\n metrics: {\n partisanBias: 0.15, // TBD\n responsiveness: 2.0 // TBD\n };\n details: {\n // TODO - Need to flesh this out\n };\n datasets: T.Datasets;\n resources: {\n planScore?: string;\n };\n};\n\n// TODO - MINORITY: This category is still under development.\n// We haven't settled on metrics yet. This is just a (likely) example.\nexport type MinorityCategory = {\n score: null; // Explicitly NOT scored\n metrics: {\n nBlack37to50: number, // Integer >= 0; two-digit maximum\n nBlackMajority: number, // Ditto\n nHispanic37to50: number, // Ditto\n nHispanicMajority: number, // Ditto\n nPacific37to50: number, // Ditto\n nPacificMajority: number, // Ditto\n nAsian37to50: number, // Ditto\n nAsianMajority: number, // Ditto\n nNative37to50: number, // Ditto\n nNativeMajority: number, // Ditto\n nMinority37to50: number, // Ditto\n nMinorityMajority: number, // Ditto\n\n averageDVoteShare: number // A fraction [0.0 – 1.0] to represent as a %\n };\n details: {\n vap: true, // true = using VAP data; false = CVAP data\n comboCategories: true // true = using combo fields; false = mutually exclusive\n };\n datasets: T.Datasets;\n resources: {\n // TODO - Add these ...\n };\n};\n\nexport type PlanAnalytics = {\n requirements: RequirementsCategory;\n compactness: CompactnessCategory;\n // TODO - Don't show these categories yet\n splitting: SplittingCategory;\n partisan: PartisanCategory;\n minority: MinorityCategory;\n}\n\n\n// Example\n\nlet sampleRequirements: RequirementsCategory = {\n score: T.TriState.Red,\n metrics: {\n complete: T.TriState.Green,\n contiguous: T.TriState.Red,\n freeOfHoles: T.TriState.Yellow,\n equalPopulation: T.TriState.Red\n },\n details: {\n unassignedFeatures: [],\n emptyDistricts: [],\n discontiguousDistricts: [2],\n embeddedDistricts: [],\n populationDeviation: 0.6748,\n deviationThreshold: 0.75 / 100\n },\n datasets: {\n census: \"2010 Census Total Population\"\n },\n resources: {\n stateReqs: \"https://www.brennancenter.org/sites/default/files/publications/2019_06_50States_FINALsinglepages_20.pdf\"\n }\n}\n\nlet sampleCompactness: CompactnessCategory = {\n score: 60,\n metrics: {\n reock: 0.3773,\n polsby: 0.3815\n },\n details: {},\n datasets: {\n shapes: \"2010 VTD shapes\"\n },\n resources: {}\n}\n\nlet sampleSplitting: SplittingCategory = {\n score: 73,\n metrics: {\n sqEnt_DCreduced: 1.531,\n sqEnt_CDreduced: 1.760\n },\n details: {\n countiesSplitUnexpectedly: [\n \"Bladen\", \"Buncombe\", \"Catawba\", \"Cumberland\", \"Durham\", \"Guilford\", \"Iredell\", \"Johnston\", \"Pitt\", \"Rowan\", \"Wilson\"\n ],\n unexpectedAffected: 0.3096,\n nSplitVTDs: 12,\n splitVTDs: [\"VTD-01\", \"VTD-02\", \"VTD-03\", \"VTD-04\", \"VTD-05\", \"VTD-06\", \"VTD-07\", \"VTD-08\", \"VTD-09\", \"VTD-10\", \"VTD-11\", \"VTD-12\"]\n },\n datasets: {},\n resources: {}\n}\n\n// TODO - PARTISAN: This category is still being fleshed out.\nlet samplePartisan: PartisanCategory = {\n score: 100,\n metrics: {\n partisanBias: 0.15,\n responsiveness: 2.0\n },\n details: {},\n datasets: {\n election: \"2016 Presidential, US Senate, Governor, and AG election results\"\n },\n resources: {\n planScore: \"https://planscore.org/plan.html?20180219T202039.596761160Z\"\n }\n}\n\n// TODO - MINORITY: This category is still being fleshed out.\nlet sampleMinority: MinorityCategory = {\n score: null,\n metrics: {\n nBlack37to50: 1,\n nBlackMajority: 12,\n nHispanic37to50: 0,\n nHispanicMajority: 0,\n nPacific37to50: 0,\n nPacificMajority: 0,\n nAsian37to50: 0,\n nAsianMajority: 0,\n nNative37to50: 0,\n nNativeMajority: 0,\n nMinority37to50: 0,\n nMinorityMajority: 0,\n\n averageDVoteShare: 0.90\n },\n details: {\n vap: true,\n comboCategories: true\n },\n datasets: {\n vap: \"2010 Voting Age Population\"\n },\n resources: {}\n}\n\nexport const samplePlanAnalytics: PlanAnalytics = {\n requirements: sampleRequirements,\n compactness: sampleCompactness,\n // TODO - Don't show these categories yet\n splitting: sampleSplitting,\n partisan: samplePartisan,\n minority: sampleMinority\n}\n\nexport function preparePlanAnalytics(s: AnalyticsSession, bLog: boolean = false): PlanAnalytics {\n if (!(s.bPostProcessingDone)) {\n doAnalyzePostProcessing(s);\n }\n\n // REQUIREMENTS CATEGORY\n let paRequirements: RequirementsCategory;\n\n {\n let completeTest = s.getTest(T.Test.Complete) as T.TestEntry;\n let contiguousTest = s.getTest(T.Test.Contiguous) as T.TestEntry;\n let freeOfHolesTest = s.getTest(T.Test.FreeOfHoles) as T.TestEntry;\n let equalPopulationTest = s.getTest(T.Test.EqualPopulation) as T.TestEntry;\n\n // Combine individual checks into an overall score\n\n // TODO - DASHBOARD: Until we add three-state support top to bottom in\n // requirements/validations, map booleans to tri-states here.\n let completeMetric = U.mapBooleanToTriState(completeTest['score'] as boolean);\n let contiguousMetric = U.mapBooleanToTriState(contiguousTest['score'] as boolean);\n let freeOfHolesMetric = U.mapBooleanToTriState(freeOfHolesTest['score'] as boolean);\n let equalPopulationMetric = U.mapBooleanToTriState(equalPopulationTest['score'] as boolean);\n\n let reqScore: T.TriState = T.TriState.Green;\n let checks = [completeMetric, contiguousMetric, freeOfHolesMetric, equalPopulationMetric];\n if (checks.includes(T.TriState.Yellow)) reqScore = T.TriState.Yellow;\n if (checks.includes(T.TriState.Red)) reqScore = T.TriState.Red;\n\n // Get values to support details entries\n let unassignedFeaturesDetail = U.deepCopy(completeTest['details']['unassignedFeatures']) || [];\n let emptyDistrictsDetail = U.deepCopy(completeTest['details']['emptyDistricts']) || [];\n let discontiguousDistrictsDetail = U.deepCopy(contiguousTest['details']['discontiguousDistricts']) || [];\n let embeddedDistrictsDetail = U.deepCopy(freeOfHolesTest['details']['embeddedDistricts']) || [];\n\n let populationDeviationDetail = U.deepCopy(equalPopulationTest['details']['deviation']);\n let deviationThresholdDetail = U.trim(s.populationDeviationThreshold());\n\n let xx: string = s.state.xx;\n // TODO - JSON: Is there a better / easier way to work with the variable?\n let stateReqsDict: T.Dict = allStateReqs;\n let reqLinkToStateReqs: string = stateReqsDict[xx];\n\n // Populate the category\n paRequirements = {\n score: reqScore,\n metrics: {\n complete: completeMetric,\n contiguous: contiguousMetric,\n freeOfHoles: freeOfHolesMetric,\n equalPopulation: equalPopulationMetric\n },\n details: {\n unassignedFeatures: unassignedFeaturesDetail,\n emptyDistricts: emptyDistrictsDetail,\n discontiguousDistricts: discontiguousDistrictsDetail,\n embeddedDistricts: embeddedDistrictsDetail,\n populationDeviation: populationDeviationDetail,\n deviationThreshold: deviationThresholdDetail\n },\n datasets: {\n census: U.deepCopy(s.config['descriptions']['CENSUS']),\n },\n resources: {\n stateReqs: reqLinkToStateReqs\n }\n }\n }\n\n // COMPACTNESS CATEGORY\n let paCompactness: CompactnessCategory;\n {\n let reockWeight = 0.5;\n let polsbyWeight = 1.0 - reockWeight;\n\n let reockTest = s.getTest(T.Test.Reock) as T.TestEntry;\n let polsbyTest = s.getTest(T.Test.PolsbyPopper) as T.TestEntry;\n\n let normalizedReock = reockTest['normalizedScore'] as number;\n let normalizedPolsby = reockTest['normalizedScore'] as number;\n let compactnessScore = U.trim((reockWeight * normalizedReock) + (polsbyWeight * normalizedPolsby), 0);\n\n let reockMetric = U.deepCopy(reockTest['score'] as number);\n let polsbyMetric = U.deepCopy(polsbyTest['score'] as number);\n\n // Populate the category\n paCompactness = {\n score: compactnessScore,\n metrics: {\n reock: reockMetric,\n polsby: polsbyMetric\n },\n details: {\n // None at this time\n },\n datasets: {\n // NOTE - DATASETS\n shapes: U.deepCopy(s.config['descriptions']['SHAPES'])\n // shapes: \"2010 VTD shapes\"\n },\n resources: {\n // None at this time\n }\n }\n }\n\n // SPLITTING CATEGORY\n\n let paSplitting: SplittingCategory\n\n {\n let unexpectedCountySplittingTest = s.getTest(T.Test.UnexpectedCountySplits) as T.TestEntry;\n let VTDSplitsTest = s.getTest(T.Test.VTDSplits) as T.TestEntry;\n let countySplittingTest = s.getTest(T.Test.CountySplitting) as T.TestEntry;\n let districtSplittingTest = s.getTest(T.Test.DistrictSplitting) as T.TestEntry;\n\n let unexpectedAffectedMetric = U.deepCopy(unexpectedCountySplittingTest['score']);\n let countiesSplitUnexpectedlyDetail = U.deepCopy(unexpectedCountySplittingTest['details']['countiesSplitUnexpectedly']);\n\n let nVTDSplitsMetric = U.deepCopy(VTDSplitsTest['score']);\n let splitVTDsDetail = U.deepCopy(VTDSplitsTest['details']['splitVTDs']);\n\n let SqEnt_DCreducedMetric = U.deepCopy(countySplittingTest['score']);\n let SqEnt_CDreducedMetric = U.deepCopy(districtSplittingTest['score']);\n\n let countySplittingNormalized = countySplittingTest['normalizedScore'] as number;\n let districtSplittingNormalized = districtSplittingTest['normalizedScore'] as number;\n let splittingScore = U.trim((S.COUNTY_SPLITTING_WEIGHT * countySplittingNormalized) +\n + (S.DISTRICT_SPLITTING_WEIGHT * districtSplittingNormalized), 0);\n\n paSplitting = {\n score: splittingScore,\n metrics: {\n sqEnt_DCreduced: SqEnt_DCreducedMetric,\n sqEnt_CDreduced: SqEnt_CDreducedMetric\n // NOTE - The un-reduced raw values\n // sqEnt_DC : SqEnt_DCMetric,\n // sqEnt_CD : SqEnt_CDMetric\n },\n details: {\n countiesSplitUnexpectedly: countiesSplitUnexpectedlyDetail,\n unexpectedAffected: unexpectedAffectedMetric,\n nSplitVTDs: nVTDSplitsMetric,\n splitVTDs: splitVTDsDetail\n },\n datasets: {\n // None at this time\n },\n resources: {\n // None at this time\n }\n }\n }\n\n // PARTISAN CATEGORY\n //\n // TODO - PARTISAN: This category is still being fleshed out. Just an example below.\n let paPartisan: PartisanCategory;\n\n {\n paPartisan = {\n score: 100,\n metrics: {\n partisanBias: 0.15,\n responsiveness: 2.0\n },\n details: {},\n datasets: {\n election: \"2016 Presidential, US Senate, Governor, and AG election results\"\n },\n resources: {\n planScore: \"https://planscore.org/plan.html?20180219T202039.596761160Z\"\n }\n }\n }\n\n // MINORITY CATEGORY\n //\n // TODO - MINORITY: This category is still being fleshed out. Just an example below.\n let paMinority: MinorityCategory;\n\n {\n paMinority = {\n score: null,\n metrics: {\n nBlack37to50: 1,\n nBlackMajority: 12,\n nHispanic37to50: 0,\n nHispanicMajority: 0,\n nPacific37to50: 0,\n nPacificMajority: 0,\n nAsian37to50: 0,\n nAsianMajority: 0,\n nNative37to50: 0,\n nNativeMajority: 0,\n nMinority37to50: 0,\n nMinorityMajority: 0,\n\n averageDVoteShare: 0.90\n },\n details: {\n vap: true,\n comboCategories: true\n },\n datasets: {\n vap: \"2010 Voting Age Population\"\n },\n resources: {}\n }\n }\n\n // PLAN ANALYTICS\n let pa: PlanAnalytics = {\n requirements: paRequirements,\n compactness: paCompactness,\n // TODO - Not implemented yet\n splitting: paSplitting,\n partisan: paPartisan,\n minority: paMinority\n }\n\n return pa;\n}\n\n\n// DISTRICT STATISTICS\n\n// Indexes for the fields in the rows of the DistrictStatistics table\nexport const enum DistrictColumn { // Column headers:\n DistrictID, // 'ID'\n TotalPop, // 'Total'\n PopDevPct, // 'Δ%'\n bEqualPop, // Don't display. Use this to conditionally color PopDevPct.\n bNotEmpty, // Don't display. TotalPop = 0 shows empty districts.\n bContiguous, // Some TBD glyph suggesting contiguity\n bNotEmbedded, // Some TBD glyph suggesting embedded\n DemPct, // 'Dem'\n RepPct, // 'Rep'\n WhitePct, // 'White'\n MinorityPct, // 'Minority'\n BlackPct, // 'Black'\n HispanicPct, // 'Hispanic'\n PacificPct, // 'Pacific'\n AsianPct, // 'Asian'\n NativePct // 'Native\n}\n\nexport type DistrictRow = [\n number, // DistrictID\n number, // TotalPop\n number, // PopDevPct\n T.TriState | null, // bEqualPop\n T.TriState | null, // bNotEmpty\n T.TriState | null, // bContiguous\n T.TriState | null, // bNotEmbedded\n number, // DemPct\n number, // RepPct\n number, // WhitePct\n number, // MinorityPct\n number, // BlackPct\n number, // HispanicPct\n number, // PacificPct\n number, // AsianPct\n number // NativePct\n];\n\nexport type DistrictStatistics = {\n table: DistrictRow[];\n details: {}; // None at this time\n datasets: T.Datasets;\n resources: {}; // None at this time\n}\n\n// Example\n\nexport const sampleDistrictStatistics: DistrictStatistics = {\n table: [\n // District 0 is the dummy unassigned district\n [0, 0, 0, null, null, null, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n [1, 653133, -0.0950, T.TriState.Green, T.TriState.Red, T.TriState.Green, T.TriState.Green, 0.4177, 0.5823, 0.8631, 0.1369, 0.0734, 0.0360, 0.0009, 0.0235, 0.0064],\n [2, 620961, -0.1396, T.TriState.Green, T.TriState.Red, T.TriState.Red, T.TriState.Green, 0.8820, 0.1180, 0.3129, 0.6871, 0.6169, 0.0391, 0.0013, 0.0310, 0.0099],\n [3, 971777, 0.3465, T.TriState.Green, T.TriState.Red, T.TriState.Green, T.TriState.Green, 0.7261, 0.2739, 0.5174, 0.4826, 0.1745, 0.1572, 0.0020, 0.1531, 0.0090],\n [4, 863420, 0.1964, T.TriState.Green, T.TriState.Red, T.TriState.Green, T.TriState.Green, 0.8957, 0.1043, 0.1734, 0.8266, 0.6489, 0.1348, 0.0020, 0.0496, 0.0127],\n [5, 805029, 0.1155, T.TriState.Green, T.TriState.Red, T.TriState.Green, T.TriState.Yellow, 0.5743, 0.4257, 0.6587, 0.3413, 0.2494, 0.0363, 0.0012, 0.0536, 0.0081],\n [6, 824741, 0.1428, T.TriState.Green, T.TriState.Red, T.TriState.Green, T.TriState.Red, 0.5341, 0.4659, 0.7045, 0.2955, 0.1619, 0.0526, 0.0018, 0.0782, 0.0090],\n [7, 549714, -0.2383, T.TriState.Green, T.TriState.Green, T.TriState.Green, T.TriState.Green, 0.5025, 0.4975, 0.6906, 0.3094, 0.2468, 0.0319, 0.0013, 0.0258, 0.0111],\n [8, 484777, -0.3283, T.TriState.Green, T.TriState.Green, T.TriState.Green, T.TriState.Green, 0.4105, 0.5895, 0.8370, 0.1630, 0.1074, 0.0316, 0.0013, 0.0197, 0.0077],\n // District N+1 is the dummy state-summary district\n [9, 721694, 0.6748, T.TriState.Green, T.TriState.Red, T.TriState.Red, T.TriState.Red, 0.6293, 0.3707, 0.5722, 0.4278, 0.2925, 0.0729, 0.0015, 0.0618, 0.0093]\n ],\n details: {},\n datasets: {\n shapes: \"2010 VTD shapes\",\n census: \"2010 Census Total Population\",\n vap: \"2010 Voting Age Population\",\n election: \"2016 Presidential, US Senate, Governor, and AG election results\"\n },\n resources: {}\n}\n\n// Create a DistrictStatistics instance, deep copying the underlying values.\nexport function prepareDistrictStatistics(s: AnalyticsSession, bLog: boolean = false): DistrictStatistics {\n if (!(s.bPostProcessingDone)) {\n doAnalyzePostProcessing(s);\n }\n\n let dsTable: DistrictRow[] = [];\n for (let i = 0; i < s.districts.numberOfRows(); i++) {\n let rawRow = [\n i,\n s.districts.statistics[D.DistrictField.TotalPop][i],\n s.districts.statistics[D.DistrictField.PopDevPct][i],\n s.districts.statistics[D.DistrictField.bEqualPop][i],\n s.districts.statistics[D.DistrictField.bNotEmpty][i],\n s.districts.statistics[D.DistrictField.bContiguous][i],\n s.districts.statistics[D.DistrictField.bNotEmbedded][i],\n s.districts.statistics[D.DistrictField.DemPct][i],\n s.districts.statistics[D.DistrictField.RepPct][i],\n s.districts.statistics[D.DistrictField.WhitePct][i],\n s.districts.statistics[D.DistrictField.MinorityPct][i],\n s.districts.statistics[D.DistrictField.BlackPct][i],\n s.districts.statistics[D.DistrictField.HispanicPct][i],\n s.districts.statistics[D.DistrictField.PacificPct][i],\n s.districts.statistics[D.DistrictField.AsianPct][i],\n s.districts.statistics[D.DistrictField.NativePct][i]\n ];\n\n // TODO - DASHBOARD: Until we add three-state support top to bottom in\n // requirements/validations, map booleans to tri-states here.\n rawRow[DistrictColumn.bEqualPop] = U.mapBooleanToTriState(rawRow[DistrictColumn.bEqualPop]);\n rawRow[DistrictColumn.bNotEmpty] = U.mapBooleanToTriState(rawRow[DistrictColumn.bNotEmpty]);\n rawRow[DistrictColumn.bContiguous] = U.mapBooleanToTriState(rawRow[DistrictColumn.bContiguous]);\n rawRow[DistrictColumn.bNotEmbedded] = U.mapBooleanToTriState(rawRow[DistrictColumn.bNotEmbedded]);\n\n let readyRow: DistrictRow = U.deepCopy(rawRow);\n dsTable.push(readyRow);\n }\n\n let dsDetails = {\n // None at this time\n };\n\n let dsDatasets: T.Datasets = {\n shapes: \"2010 VTD shapes\",\n census: U.deepCopy(s.config['descriptions']['CENSUS']),\n vap: U.deepCopy(s.config['descriptions']['VAP']),\n election: U.deepCopy(s.config['descriptions']['ELECTION'])\n }\n\n let dsResources = {\n // None at this time\n };\n\n let ds: DistrictStatistics = {\n table: dsTable,\n details: dsDetails,\n datasets: dsDatasets,\n resources: dsResources\n };\n\n return ds;\n}\n\n\n// META-DATA FOR TESTS/ANALYTICS\n// \n// NOTE - This structure is a vestige of having created a metadata-driven\n// scorecard w/in district-analytics at first. It works for creating the\n// unstyled results structures, so it isn't a high priority to rationalize.\n\nenum TestType {\n PassFail,\n Percentage,\n Number\n}\n\nconst completeDefn: T.Dict = {\n ID: T.Test.Complete,\n name: \"Complete\",\n normalize: false,\n externalType: TestType.PassFail,\n suites: [T.Suite.Legal]\n};\n\nconst contiguousDefn: T.Dict = {\n ID: T.Test.Contiguous,\n name: \"Contiguous\",\n normalize: false,\n externalType: TestType.PassFail,\n suites: [T.Suite.Legal]\n};\n\nconst freeOfHolesDefn: T.Dict = {\n ID: T.Test.FreeOfHoles,\n name: \"Free of Holes\",\n normalize: false,\n externalType: TestType.PassFail,\n suites: [T.Suite.Legal]\n};\n\nconst equalPopulationDefn: T.Dict = {\n ID: T.Test.EqualPopulation,\n name: \"Equal Population\",\n normalize: false,\n externalType: TestType.PassFail,\n suites: [T.Suite.Legal]\n};\n\nconst populationDeviationDefn: T.Dict = {\n ID: T.Test.PopulationDeviation,\n name: \"Population Deviation\",\n normalize: true,\n externalType: TestType.Percentage,\n suites: [T.Suite.Legal, T.Suite.Best] // Both so EqualPopulation can be assessed\n};\n\nconst reockDefn: T.Dict = {\n ID: T.Test.Reock,\n name: \"Reock\",\n normalize: true,\n externalType: TestType.Number,\n suites: [T.Suite.Best]\n};\n\nconst polsbyPopperDefn: T.Dict = {\n ID: T.Test.PolsbyPopper,\n name: \"Polsby-Popper\",\n normalize: true,\n externalType: TestType.Number,\n suites: [T.Suite.Best]\n};\n\n// NOTE - SPLITTING\nconst unexpectedCountySplitsDefn: T.Dict = {\n ID: T.Test.UnexpectedCountySplits,\n name: \"Unexpected County Splits\",\n normalize: false,\n externalType: TestType.Percentage,\n suites: [T.Suite.Best]\n};\n\n// NOTE - SPLITTING\nconst VTDSplitsDefn: T.Dict = {\n ID: T.Test.VTDSplits,\n name: \"VTD Splits\",\n normalize: false,\n externalType: TestType.Number,\n suites: [T.Suite.Best]\n};\n\n// NOTE - SPLITTING\nconst countySplittingDefn: T.Dict = {\n ID: T.Test.CountySplitting,\n name: \"County Splitting\",\n normalize: true,\n externalType: TestType.Number,\n suites: [T.Suite.Best]\n};\n\n// NOTE - SPLITTING\nconst districtSplittingDefn: T.Dict = {\n ID: T.Test.DistrictSplitting,\n name: \"District Splitting\",\n normalize: true,\n externalType: TestType.Number,\n suites: [T.Suite.Best]\n};\n\nconst efficiencyGapDefn: T.Dict = {\n ID: T.Test.EfficiencyGap,\n name: \"Efficiency Gap\",\n normalize: false, // TODO - Normalize this!\n externalType: TestType.Percentage,\n suites: [T.Suite.Fair]\n};\n\n// A structure to hold test definitions\ntype TestDefns = {\n [category: number]: any;\n}\n\n// All the tests that have been defined (can be reported on)\nconst testDefns = {\n [T.Test.Complete]: completeDefn,\n [T.Test.Contiguous]: contiguousDefn,\n [T.Test.FreeOfHoles]: freeOfHolesDefn,\n [T.Test.EqualPopulation]: equalPopulationDefn,\n [T.Test.PopulationDeviation]: populationDeviationDefn,\n [T.Test.Reock]: reockDefn,\n [T.Test.PolsbyPopper]: polsbyPopperDefn,\n // NOTE - SPLITTING\n [T.Test.UnexpectedCountySplits]: unexpectedCountySplitsDefn,\n [T.Test.VTDSplits]: VTDSplitsDefn,\n [T.Test.CountySplitting]: countySplittingDefn,\n [T.Test.DistrictSplitting]: districtSplittingDefn,\n\n // TODO - More tests ...\n\n [T.Test.EfficiencyGap]: efficiencyGapDefn\n} as TestDefns;\n\n\n// NORMALIZE RAW ANALYTICS\n// Raw numeric analytics, such as population deviation, compactness, etc. are\n// normalized as part of creating a scorecard, so the code to normalize results\n// is encapsulated here.\n\n// Configure scale parameters for normalizing each raw test result\n// This needs to be separate from the scorecard configuration info above,\n// because some scales need access to the analytics session object.\nexport function doConfigureScales(s: AnalyticsSession): void {\n // Scale defn for PopulationDeviation\n const CDLimit = 0.75 / 100; // Deviation threshold for CD's\n const LDLimit = 10.00 / 100; // Deviation threshold for LD's\n\n const CDGoodEnough = 0.20 / 100;\n const LDGoodEnough = (CDGoodEnough / CDLimit) * LDLimit;\n const popDevScale = (s.legislativeDistricts) ? [1.0 - LDLimit, 1.0 - LDGoodEnough] : [1.0 - CDLimit, 1.0 - CDGoodEnough];\n // const scale = [1.0 - CDLimit, 1.0 - CDGoodEnough];\n\n s.testScales[T.Test.PopulationDeviation] = { scale: popDevScale, bInvertRaw: true };\n\n s.testScales[T.Test.Reock] = { scale: [0.25, 0.50] };\n s.testScales[T.Test.PolsbyPopper] = { scale: [0.10, 0.50] };\n\n const nDistricts = s.state.nDistricts;\n const nCounties = s.counties.nCounties;\n\n // NOTE - SPLITTING: Experiment w/ this multiplier. Only allowing the expected\n // number of county splits seems too stringent, empirically. \n const allowableCountySplitsMultiplier = 1.5;\n const nAllowableSplits = Math.min(allowableCountySplitsMultiplier * (nDistricts - 1));\n const countySplittingThreshold = ((nAllowableSplits * 1.71) + ((nCounties - nAllowableSplits) * 1.0)) / nCounties;\n const countySplittingScale = [1.0, countySplittingThreshold];\n s.testScales[T.Test.CountySplitting] = { scale: countySplittingScale, bInvertScaled: true };\n\n const districtSplittingThreshold = 1.5;\n const districtSplittingScale = [1.0, districtSplittingThreshold];\n s.testScales[T.Test.DistrictSplitting] = { scale: districtSplittingScale, bInvertScaled: true };\n\n // TODO - More analytics ...\n}\n\n// Postprocess analytics - Normalize numeric results and derive secondary tests.\n// Do this after analytics have been run and before preparing a test log or scorecard. \nexport function doAnalyzePostProcessing(s: AnalyticsSession, bLog: boolean = false): void {\n // Normalize the raw scores for all the numerics tests\n let testResults = U.getNumericObjectKeys(testDefns);\n\n for (let testID of testResults) {\n if (testDefns[testID]['normalize']) {\n let testResult = s.getTest(testID) as T.TestEntry;\n\n let rawScore = testResult['score'] as number;\n let normalizedScore: number;\n\n normalizedScore = U.normalize(rawScore, s.testScales[testID]);\n testResult['normalizedScore'] = normalizedScore;\n\n // Add the scale used to normalize the raw score to the details\n testResult['details']['scale'] = s.testScales[testID].scale;\n }\n }\n\n // Derive secondary tests\n doDeriveSecondaryTests(s, bLog);\n\n // Toggle the semaphore, so postprocessing isn't for both the testlog & scorecard\n s.bPostProcessingDone = true;\n}\n\n","//\n// GLOBAL CONSTANTS\n//\n\n// Keep four decimal places for fractions [0–1], i.e.,\n// keep two decimal places for %'s [0–100].\nexport const PRECISION: number = 4;\n\n// Normalized scores [0-100]\nexport const NORMALIZED_RANGE: number = 100;\n\n// The dummy district ID for features not assigned districts yet\nexport const NOT_ASSIGNED: number = 0;\n\n// TODO - DASHBOARD: Discuss w/ Dave\n// # of items to report as problematic (e.g., features, districts, etc.)\nexport const NUMBER_OF_ITEMS_TO_REPORT: number = 10;\n\n// The virtual geoID for \"neighbors\" in other states\nexport const OUT_OF_STATE: string = \"OUT_OF_STATE\";\n\n// \"Roughly equal\" = average census block size / 2\nconst AVERAGE_BLOCK_SIZE = 30;\nexport const EQUAL_TOLERANCE: number = AVERAGE_BLOCK_SIZE / 2;\n\n// County & district splitting weights\nexport const COUNTY_SPLITTING_WEIGHT = 0.8;\nexport const DISTRICT_SPLITTING_WEIGHT = 1.0 - COUNTY_SPLITTING_WEIGHT;\n","//\n// TYPE DEFINITIONS\n//\n\nimport * as geojson from 'geojson';\n\n// CONFIGURATION TYPES\n\n// Sets of analytics, to enable them to be turned on/off by the host.\nexport const enum Suite {\n Legal,\n Fair,\n Best\n} // as in \"best fair map\"\n\n// INPUT DATA TYPES\n\n// The SessionRequest specifies an analytics session\nexport type SessionRequest = {\n title: string;\n stateXX: string;\n nDistricts: number;\n legislativeDistricts: boolean;\n plan: PlanByGeoID;\n data: GeoFeatureCollection;\n districtShapes: GeoFeatureCollection;\n districtProperties: DistrictProperties;\n graph: ContiguityGraph;\n counties: GeoFeatureCollection;\n config: {}\n}\n\n// A Plan is a dict of geoID-districtID pairs indexed by geoID\nexport type PlanByGeoID = {\n [geoID: string]: number;\n}\n\n// A inverted Plan is a dict of districtID's with associated sets of geoID's\nexport type PlanByDistrictID = {\n // TODO - TERRY, why does this constructor need a <T> type specification?\n [districtID: number]: Set<string>;\n}\n\n// A map of geoIDs to feature IDs\nexport type FeaturesByGeoID = {\n [geoID: string]: number;\n}\n\n// The FIPS-codes-to-county-name map for a state\nexport type FIPSCodeToCountyNameMap = {\n [FIPSCode: string]: string;\n}\n\n// The FIPS to array ordinal map \nexport type FIPSToOrdinalMap = {\n [FIPSCode: string]: number;\n}\n\n// Shapes - following the declarations in dra-client/redistrictdata.ts\nexport type GeoFeature = geojson.Feature;\nexport type GeoFeatureArray = GeoFeature[];\nexport type GeoFeatureCollection = geojson.FeatureCollection;\nexport interface GeoFeatureMap {\n [geoID: string]: GeoFeature;\n}\n\n\n// NOTE - CONTIGUITY GRAPHS\n\n// Contiguity graph -- For each geoID, there's either:\n// a) a (new) unweighted list of neighbors; or\n// b) an (old) dictionary of neighbors, where the value for each\n// neighbor geoID key is the the length of the shared border.\nexport type ContiguityGraph = {\n [geoID: string]: UnweightedNeighbors | WeightedNeighbors;\n}\n\nexport type WeightedNeighbors = {\n [geoID: string]: number;\n}\n\nexport type UnweightedNeighbors = string[];\n\n\n// An election (model) captures three actual or composite vote totals:\n// DEM votes, REP votes, and TOTal votes, where DEM + REP <= TOT, because\n// of third-party candidates and write-in votes. IOW, the two-party vote is\n// DEM + REP.\nexport type VoteTriple = [number, number, number];\n\n// An index for accessing a vote triple\nexport const enum VoteType {\n Democratic,\n Republican,\n Total\n}\n\n// CONFIGURATION TYPES\n\n// Scale config values for an individual test\nexport type TestScale = {\n scale: Array<number>,\n bInvertRaw?: boolean,\n bInvertScaled?: boolean\n}\n\n// The scales for all the analytics & validations\n// Presently assigned as part of session initialization\n// Use the Tests enum below as the test index\nexport type TestScales = {\n [test: number]: TestScale;\n}\n\n\n// RETURN TYPES\n\nexport type TestEntry = {\n score?: number | boolean; // Specific to the test\n details: Dict; // Additional details\n normalizedScore?: number; // Normalized to [0–100] for graded tests\n}\n\n// District WIP captures a district-level result, indexed by districtID\nexport type DistrictWIP = {\n [districtID: number]: any;\n}\n\n// TODO - Revise this ...\n// Analytics & validations\nexport const enum Test {\n Complete,\n Contiguous,\n FreeOfHoles,\n EqualPopulation, // This is the legal/not legal assessment of the population \n PopulationDeviation, // deviation % (when legal, less is still better).\n Reock,\n PolsbyPopper,\n UnexpectedCountySplits,\n CountySplitting,\n DistrictSplitting,\n VTDSplits,\n\n // TODO - PARTISAN\n SeatsBias,\n VotesBias,\n Responsiveness,\n ResponsiveDistricts,\n EfficiencyGap,\n\n // TODO - MINORITY\n MajorityMinorityDistricts\n}\n\n// The analytics & validation entries for a plan\n// Use the Tests enum above as the test index\nexport type TestEntries = {\n [test: number]: TestEntry;\n}\n\n// DistrictProperties holds properties of district shapes, indexed by districtID\nexport type DistrictProperties = {\n [districtID: number]: any;\n}\n\n// For compactness calculations, we need 3 properties of each district shape:\nexport type DistrictShapeProperties = [number, number, number];\n\n// An index for accessing properties extracted from a district shape\nexport const enum DistrictShapeProperty {\n Area,\n Diameter,\n Perimeter\n}\n\n// HELPER TYPES\n\nexport type GeoIDParts = {\n state?: string;\n county?: string;\n tract?: string;\n bg?: string;\n block?: string;\n}\n\nexport type GeoIDTotal = {\n [geoID: string]: number;\n}\n\n// GENERIC TYPES\n\nexport type Dict = { [key: string]: any };\n\n\n// TYPES FOR RESULTS\n\nexport const enum TriState { // Sample interpretations:\n Green, // OK, Pass, Yes\n Yellow, // Warning, Maybe\n Red // Not OK, Fail, No\n}\n// NOTE - I'm using Green / Yellow / Red here, because the connotations are so\n// clear. But colors are just one way you might choose to render these 3 states.\n// Could be Check (Green), X (Red), or Warning symbol (Yellow) or combinations\n// of visual indicators. Some examples as comments below.\n\n// For associating datasets with notes in a category\nexport type Datasets = {\n shapes?: string; // A shapefile\n census?: string; // A total population Census dataset\n vap?: string; // A voting age (or citizen voting age) dataset\n election?: string; // An election dataset\n}\n\n\n// END\n","//\n// UTILITIES\n//\n\nimport * as T from './types'\nimport * as S from './settings';\n\n// PLAN HELPERS\n\n// Is a \"neighbor\" in state?\nexport function isInState(geoID: string): boolean {\n return geoID != S.OUT_OF_STATE;\n}\n\n// Is a \"neighbor\" out of state?\nexport function isOutOfState(geoID: string): boolean {\n return geoID == S.OUT_OF_STATE;\n}\n\n// NOTE - UNASSIGNED\n// Get the districtID to which a geoID is assigned\nexport function getDistrict(plan: T.PlanByGeoID, geoID: string): number | undefined {\n // All geoIDs in a state *should be* assigned to a district (including the\n // dummy \"unassigned\" district), but \"water-only\" features are sometimes missing\n // from a map. This is also a guard against a bug in which a geoID has no district.\n if (keyExists(geoID, plan)) {\n return plan[geoID];\n }\n else {\n return undefined;\n }\n}\n\n\n// WORKING WITH GEOIDS\n\nexport function parseGeoID(geoID: string): T.GeoIDParts {\n let parts: T.GeoIDParts = {};\n\n parts['state'] = geoID.substring(0, 2);\n parts['county'] = geoID.substring(0, 5);\n\n let l: number = geoID.length;\n\n if (l >= 11) {\n parts['tract'] = geoID.substring(0, 11);\n }\n\n if (l >= 12) {\n parts['bg'] = geoID.substring(0, 12);\n }\n\n if (l == 15) {\n parts['block'] = geoID;\n }\n\n return parts;\n}\n\nexport function getFIPSFromCountyGeoID(geoID: string): string {\n return geoID.substring(2, 5);\n}\n\nexport function isWaterOnly(geoID: string): boolean {\n let waterOnlySignature = 'ZZZZZZ';\n\n if (geoID.indexOf(waterOnlySignature) >= 0) return true;\n else return false;\n}\n\n// NORMALIZING RESULTS\n\nexport function normalize(rawScore: number, testScale: T.TestScale): number {\n let rangeMin: number = testScale.scale[0];\n let rangeMax: number = testScale.scale[1];\n\n // Invert the raw value if necessary to make bigger = better\n // TODO - This works for Population Deviation, because the max is 1.0.\n // Generalize this???\n if (testScale.bInvertRaw) {\n rawScore = 1.0 - rawScore;\n }\n\n // Coerce the value to be w/in the given range\n let coercedValue = Math.min(Math.max(rawScore, rangeMin), rangeMax);\n\n // Scale the bounded value w/in the range [0 - (rangeMax - rangeMin)]\n let scaledValue = (coercedValue - rangeMin) / (rangeMax - rangeMin);\n\n // NOTE - SPLITTING\n // Invert the scaled value if necessary to make bigger = better\n if (testScale.bInvertScaled) {\n scaledValue = 1.0 - scaledValue;\n }\n\n // Finally, make the range [0-100]\n return Math.round(scaledValue * S.NORMALIZED_RANGE);\n}\n\n// Round a fractional number [0-1] to the desired level of PRECISION.\nexport function trim(fullFraction: number, digits: number | undefined = undefined): number {\n if (digits == 0) {\n return Math.round(fullFraction);\n }\n else {\n let shiftPlaces = 10 ** (digits || S.PRECISION);\n\n return Math.round(fullFraction * shiftPlaces) / shiftPlaces;\n }\n}\n\n// ARRAY HELPERS\n\nexport function sumArray(arr: number[]): number {\n return arr.reduce((a, b) => a + b, 0);\n}\n\nexport function avgArray(arr: number[]): number {\n return (arr.reduce((a, b) => a + b, 0)) / arr.length;\n}\n\nexport function minArray(arr: number[]): number {\n return Math.min(...arr);\n}\n\nexport function maxArray(arr: number[]): number {\n return Math.max(...arr);\n}\n\nexport function initArray(n: number, value: any): any[] {\n return Array.from(Array(n), () => value);\n}\n\nexport function andArray(arr: boolean[]): boolean {\n return arr.reduce(function (a, b) { return a && b; }, true);\n}\n\n// WORKING WITH OBJECT KEYS/PROPERTIES\n\n// TODO - TERRY, is this copesetic?\n// TODO - Handle integer keys?\n// Does an object have a key/property?\nexport function keyExists(k: string, o: object): boolean {\n return k in o;\n}\n\n// TODO - TERRY, can these three be combined into a generic isEmpty() check?\n// Does an object (dict) have any keys/properties?\nexport function isObjectEmpty(o: object): boolean {\n return Object.keys(o).length === 0\n}\n// Does a Set have any members?\nexport function isSetEmpty(s: any): boolean {\n return s.size === 0\n}\n// Does an array hold any items?\nexport function isArrayEmpty(a: any[]): boolean {\n if (a === undefined || a.length == 0) {\n // array empty or does not exist\n return true;\n }\n else {\n return false;\n }\n}\n\n// Get the keys for an object\nexport function getObjectKeys(o: object): string[] {\n return Object.keys(o);\n}\n\n// TODO - Convert getNumericObjectKeys() idiom to for..of where possible\nexport function getNumericObjectKeys(o: object): number[] {\n return Object.keys(o).map(Number);\n}\n\nexport function getSelectObjectKeys(o: T.Dict, v: any[]): string[] {\n let selectKeys: string[] = [];\n\n Object.keys(o).forEach(key => {\n if (arrayContains(v, o[key])) {\n selectKeys.push(key);\n }\n });\n\n return selectKeys;\n}\n\nexport function arrayContains(a: any[], item: any): boolean {\n return a.some(x => x === item);\n}\n\nexport function objectContains(o: object, key: any): boolean {\n return (key in o);\n}\n\n\n// ENUM HELPERS\n\n// Source: https://stackoverflow.com/questions/38034673/determine-the-number-of-enum-elements-typescript\nexport function countEnumValues(enumName: any): number {\n let count = 0\n for (let item in enumName) {\n if (isNaN(Number(item))) count++\n }\n return count\n}\n\n// COPYING - Copied from dra-client/util.ts\n\nexport function shallowCopy(src: any): any {\n if (Array.isArray(src))\n return src.slice();\n else if (typeof src === 'object') {\n let dst: any = {};\n for (var p in src) if (src.hasOwnProperty(p))\n dst[p] = src[p];\n return dst;\n }\n else\n return src;\n}\n\nexport function deepCopy(src: any): any {\n if (Array.isArray(src)) {\n let dst: any[] = [];\n\n for (let i: number = 0; i < src.length; i++)\n dst.push(deepCopy(src[i]));\n return dst;\n }\n else if (typeof src === 'object') {\n let dst: any = {};\n for (var p in src) if (src.hasOwnProperty(p))\n dst[p] = deepCopy(src[p]);\n return dst;\n }\n else\n return src;\n}\n\n\n// TODO - TRI-STATES: Map booleans to tri-states.\nexport function mapBooleanToTriState(bool: boolean): T.TriState {\n return (bool) ? T.TriState.Green : T.TriState.Red;\n}\n\n// TODO - TERRY: What is this the simple explanation of what this thing is doing?\nexport { depthof } from '@dra2020/util';\n","//\n// MAP/PLAN VALIDATIONS\n//\n\nimport * as T from './types'\nimport * as U from './utils';\nimport * as S from './settings';\n\nimport * as D from './_data'\nimport { AnalyticsSession } from './_api';\n\n//\n// COMPLETE - Are all geo's assigned to a district, and do all districts have\n// at least one geo assigned to them?\n//\n\nexport function doIsComplete(s: AnalyticsSession, bLog: boolean = false): T.TestEntry {\n let test = s.getTest(T.Test.Complete) as T.TestEntry;\n\n // Get the by-district results, including the dummy unassigned district,\n // but ignoring the N+1 summary district\n let bNotEmptyByDistrict = s.districts.statistics[D.DistrictField.bNotEmpty];\n bNotEmptyByDistrict = bNotEmptyByDistrict.slice(0, -1);\n\n // Are all features assigned to districts?\n // Check the dummy district that holds any unassigned features.\n let unassignedFeatures: string[] = [];\n let bAllAssigned = (!bNotEmptyByDistrict[S.NOT_ASSIGNED]);\n\n if (!bAllAssigned) {\n let unassignedDistrict = s.plan.geoIDsForDistrictID(S.NOT_ASSIGNED);\n unassignedFeatures = Array.from(unassignedDistrict);\n unassignedFeatures = unassignedFeatures.slice(0, S.NUMBER_OF_ITEMS_TO_REPORT);\n }\n\n // Do all real districts have at least one feature assigned to them?\n let emptyDistricts: number[] = [];\n let bNoneEmpty = true;\n bNotEmptyByDistrict = bNotEmptyByDistrict.slice(1);\n\n let districtID = 1;\n bNotEmptyByDistrict.forEach(function (bNotEmpty: boolean): void {\n if (!bNotEmpty) {\n bNoneEmpty = false;\n emptyDistricts.push(districtID);\n }\n districtID += 1;\n });\n\n // Case 1 - One or more districts are missing:\n // The # of enumerated districts minus the dummy NOT_ASSIGNED one should\n // equal the number apportioned districts. This guards against a district\n // not being included in a map that is imported.\n //\n // NOTE - I'm no longer checking for this, but DRA should!\n\n // Case 2 - Or a district is explicitly named but empty:\n // Note, this can happen if a district is created, and then all features\n // are removed from it (in DRA).\n\n // Populate the test entry\n test['score'] = bAllAssigned && bNoneEmpty;\n if (!bAllAssigned) {\n test['details']['unassignedFeatures'] = unassignedFeatures;\n }\n\n if (!bNoneEmpty) {\n test['details']['emptyDistricts'] = emptyDistricts;\n }\n\n // Populate the N+1 summary \"district\" in district.statistics\n let bNotEmpty = s.districts.statistics[D.DistrictField.bNotEmpty];\n let summaryRow = s.districts.numberOfRows() - 1;\n\n bNotEmpty[summaryRow] = test['score'];\n\n return test;\n}\n\n//\n// CONTIGUOUS - Is each district in a plan fully connected?\n//\n// NOTE - To check \"operational contiguity,\" we need to use a graph, i.e.,\n// we can't rely on just the geometric contiguity of shapes in a shapefile.\n//\n// To test this, load the NC 2010 map 'SAMPLE-BG-map-discontiguous.csv'.\n//\n\nexport function doIsContiguous(s: AnalyticsSession, bLog: boolean = false): T.TestEntry {\n let test = s.getTest(T.Test.Contiguous) as T.TestEntry;\n\n // Get the contiguity of each district. Ignore dummy unassigned district\n // and the N+1 summary district.\n let bContiguousByDistrict = s.districts.statistics[D.DistrictField.bContiguous];\n bContiguousByDistrict = bContiguousByDistrict.slice(1, -1);\n\n // If any real districts aren't contiguous, mark the plan as not contiguous\n let bMapContiguous = U.andArray(bContiguousByDistrict);\n\n // If the map is not contiguous, log the offending districts.\n let discontiguousDistricts: number[] = [];\n let districtID = 1;\n bContiguousByDistrict.forEach(function (bDistrictContiguous: boolean): void {\n if (!bDistrictContiguous) discontiguousDistricts.push(districtID);\n districtID += 1;\n });\n\n // Populate the test entry\n test['score'] = bMapContiguous;\n if (!bMapContiguous) {\n test['details'] = { 'discontiguousDistricts': discontiguousDistricts };\n }\n\n // Populate the N+1 summary \"district\" in district.statistics\n let bContiguous = s.districts.statistics[D.DistrictField.bContiguous];\n let summaryRow = s.districts.numberOfRows() - 1;\n\n bContiguous[summaryRow] = test['score'];\n\n return test;\n}\n\n// Are the features in a district fully connected?\nexport function isConnected(districtGeos: Set<string>, graph: D.Graph): boolean {\n // TODO - TERRY, why does this constructor need a <T> type specification?\n let visited = new Set<string>();\n let toProcess: string[] = [];\n\n // Start processing with the first geoID in the district\n let iter = districtGeos.values();\n toProcess.push(iter.next().value);\n\n // While there are geoIDs in the district that haven't been processed\n while (toProcess.length > 0) {\n // Grab a geoID and process it\n let node = toProcess.pop() as string;\n visited.add(node);\n\n // Get its actual, in-state neighbors\n let actualNeighbors = graph.peerNeighbors(node).filter(x => U.isInState(x));\n\n // Add neighbors to visit, if they're in the same district Y haven't already been visited\n let neighborsToVisit = actualNeighbors.filter(x => districtGeos.has(x) && (!visited.has(x)));\n // TODO - TERRY, is this the quickest/best way to do this?\n toProcess.push(...neighborsToVisit);\n }\n\n // Stop when you've visited all the geoIDs in the district\n return visited.size == districtGeos.size;\n}\n\n\n//\n// FREE OF HOLES - Are any districts fully embedded w/in another district?\n//\n// A district is NOT a \"donut hole\" district:\n// - If any neighbor is 'OUT_OF_STATE'; or\n// - If there are 2 or more neighboring districts.\n//\n// To test this, load the NC 2010 map 'SAMPLE-BG-map-hole.csv'. District 1,\n// Buncombe County (37021), is a donut hole w/in District 3.\n//\n// TODO - OPTIMIZE: This to take advantage of district boundary info, if/when\n// we cache one to optimize compactness.\n//\n\nexport function doIsFreeOfHoles(s: AnalyticsSession, bLog: boolean = false): T.TestEntry {\n let test = s.getTest(T.Test.FreeOfHoles) as T.TestEntry;\n\n // Initialize values\n let bFreeOfHoles = true;\n let embeddedDistricts: number[] = [];\n\n // Get the embeddedness of each district. Ignore dummy unassigned district\n // and the N+1 summary district.\n let bNotEmbeddedByDistrict = s.districts.statistics[D.DistrictField.bNotEmbedded];\n bNotEmbeddedByDistrict = bNotEmbeddedByDistrict.slice(1, -1);\n\n let districtID = 1;\n bNotEmbeddedByDistrict.forEach(function (bDistrictNotEmbedded: boolean): void {\n if (!bDistrictNotEmbedded) {\n embeddedDistricts.push(districtID);\n bFreeOfHoles = false;\n }\n districtID += 1;\n });\n\n // Populate the test entry\n test['score'] = bFreeOfHoles;\n if (!bFreeOfHoles) {\n test['details'] = { 'embeddedDistricts': embeddedDistricts };\n }\n\n // Populate the N+1 summary \"district\" in district.statistics\n let bNotEmbedded = s.districts.statistics[D.DistrictField.bNotEmbedded];\n let summaryRow = s.districts.numberOfRows() - 1;\n\n bNotEmbedded[summaryRow] = test['score'];\n\n return test;\n}\n\n// Test whether one district is embedded w/in any other.\nexport function isEmbedded(districtID: number, geoIDs: Set<string>, plan: D.Plan, graph: D.Graph): boolean {\n // NOTE - \"features\" here = \"geoIDs.\" These aren't \"features\" proper, just\n // identifier strings.\n let features = geoIDs;\n let planByGeo = plan.byGeoID();\n\n // Assume the district is embedded\n let bEmbedded = true;\n // Keep track of the neighoring districts\n let neighboringDistricts = new Set();\n\n // TODO - OPTIMIZE: Use just the boundary features, when available\n // Get the features for the real district\n let featuresToCheck = Array.from(features);\n\n // If the district has features, check whether it is embedded\n if (!(U.isArrayEmpty(featuresToCheck))) {\n // For each feature that needs to be checked (see above)\n for (let feature of featuresToCheck) {\n // Get its neighbors (including the virtual \"out of state\" ones)\n let neighbors = graph.peerNeighbors(feature);\n\n for (let neighbor of neighbors) {\n if (U.isOutOfState(neighbor)) {\n bEmbedded = false;\n // No need to check any more neighbors\n break;\n }\n else {\n let neighboringDistrict = U.getDistrict(planByGeo, neighbor);\n\n // Assume that a missing district assignment (= None) means that the\n // feature is \"water-only\" AND part of the state border (vs. internal)\n // and, therefore, not in the plan/map.\n\n if (neighboringDistrict == undefined) {\n bEmbedded = false;\n // No need to check any more neighbors\n break;\n }\n else {\n // TODO - OPTIMIZE: Since we're checking *all* features in a district right\n // now, not just boundary features and neighbors in other districts,\n // prune out the current district. If/when we optimize compactness\n // to cache district boundaries (as before in my Python implementation),\n // we won't have to guard adding \"neighboring\" districts in this way.\n if (neighboringDistrict != districtID) {\n neighboringDistricts.add(neighboringDistrict);\n }\n\n if (neighboringDistricts.size > 1) {\n bEmbedded = false;\n // No need to check any more neighbors\n break;\n }\n }\n }\n }\n // If a district is not embedded, there's no need to check anymore\n // border geos.\n if (!bEmbedded) {\n break;\n }\n }\n\n }\n\n return bEmbedded;\n}\n\n","module.exports = require(\"@dra2020/poly\");","module.exports = require(\"@dra2020/util\");","module.exports = require(\"assert\");"],"sourceRoot":""}
1
+ {"version":3,"sources":["webpack://district-analytics/webpack/universalModuleDefinition","webpack://district-analytics/webpack/bootstrap","webpack://district-analytics/./src/_api.ts","webpack://district-analytics/./src/_data.ts","webpack://district-analytics/./src/analyze.ts","webpack://district-analytics/./src/cohesive.ts","webpack://district-analytics/./src/compact.ts","webpack://district-analytics/./src/equal.ts","webpack://district-analytics/./src/geofeature.ts","webpack://district-analytics/./src/index.ts","webpack://district-analytics/./src/minority.ts","webpack://district-analytics/./src/political.ts","webpack://district-analytics/./src/preprocess.ts","webpack://district-analytics/./src/results.ts","webpack://district-analytics/./src/settings.ts","webpack://district-analytics/./src/types.ts","webpack://district-analytics/./src/utils.ts","webpack://district-analytics/./src/valid.ts","webpack://district-analytics/external \"@dra2020/poly\"","webpack://district-analytics/external \"@dra2020/util\"","webpack://district-analytics/external \"assert\""],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;QCVA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;;;;;;;;AClFA,EAAE;AACF,uBAAuB;AACvB,EAAE;;;;;;;;;AAEF,oFAA+C;AAC/C,2EAA6D;AAC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B,sCAAsC;wBACtC,MAAM;qBACP;yBACI;wBACH,2EAA2E;wBAC3E,sEAAsE;wBACtE,oEAAoE;wBACpE,0EAA0E;wBAC1E,uEAAuE;wBACvE,IAAI,mBAAmB,IAAI,UAAU,EAAE;4BACrC,oBAAoB,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;yBAC/C;wBAED,IAAI,oBAAoB,CAAC,IAAI,GAAG,CAAC,EAAE;4BACjC,SAAS,GAAG,KAAK,CAAC;4BAClB,sCAAsC;4BACtC,MAAM;yBACP;qBACF;iBACF;aACF;YACD,kEAAkE;YAClE,eAAe;YACf,IAAI,CAAC,SAAS,EAAE;gBACd,MAAM;aACP;SACF;KAEF;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AApED,gCAoEC;;;;;;;;;;;;;;;;;;;;;;;AC/QD,0C;;;;;;;;;;;ACAA,0C;;;;;;;;;;;ACAA,mC","file":"district-analytics.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"district-analytics\"] = factory();\n\telse\n\t\troot[\"district-analytics\"] = factory();\n})(global, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./src/index.ts\");\n","//\n// THE NODE PACKAGE API\n//\n\nimport { doPreprocessData } from './preprocess'\nimport { doAnalyzePlan, doAnalyzeDistricts } from './analyze'\nimport {\n doConfigureScales, doAnalyzePostProcessing\n} from './results'\nimport {\n PlanAnalytics, DistrictStatistics,\n preparePlanAnalytics, prepareDistrictStatistics\n} from './results'\n\nimport * as D from './_data';\nimport * as T from './types'\nimport * as U from './utils';\nimport * as S from './settings';\n\nexport class AnalyticsSession {\n title: string;\n legislativeDistricts: boolean;\n config: T.Dict = {};\n\n bOneTimeProcessingDone = false;\n bPlanAnalyzed = false;\n bPostProcessingDone = false;\n testScales = {} as T.TestScales;\n tests = {} as T.TestEntries;\n\n state: D.State;\n counties: D.Counties;\n graph: D.Graph;\n features: D.Features;\n plan: D.Plan;\n districts: D.Districts;\n\n constructor(SessionRequest: T.SessionRequest) {\n this.title = SessionRequest['title'];\n this.legislativeDistricts = SessionRequest['legislativeDistricts'];\n this.config = this.processConfig(SessionRequest['config'])\n\n this.state = new D.State(this, SessionRequest['stateXX'], SessionRequest['nDistricts']);\n this.counties = new D.Counties(this, SessionRequest['counties']);\n this.graph = new D.Graph(this, SessionRequest['graph']);\n this.features = new D.Features(this, SessionRequest['data'], this.config['datasets']);\n this.plan = new D.Plan(this, SessionRequest['plan']);\n this.districts = new D.Districts(this, SessionRequest['districtShapes']);\n\n // NOTE: I've pulled these out of the individual analytics to here. Eventually,\n // we could want them to passed into an analytics session as data, along with\n // everything else. For now, this keeps branching out of the main code.\n doConfigureScales(this);\n }\n processConfig(config: T.Dict): T.Dict {\n // NOTE - Session settings are required:\n // - Analytics suites can be defaulted to all with [], but\n // - Dataset keys must be explicitly specified with 'dataset'\n\n // TODO - DASHBOARD: Remove this mechanism. Always run everything.\n let defaultSuites = [T.Suite.Legal, T.Suite.Fair, T.Suite.Best];\n\n // If the config passed in has no suites = [], use the default suites\n if (U.isArrayEmpty(config['suites'])) {\n config['suites'] = defaultSuites;\n }\n\n // Default the Census & redistricting cycle to 2010\n if (!(U.keyExists('cycle', config))) config['cycle'] = 2010;\n\n return config;\n }\n\n // Using the the data in the analytics session, calculate all the\n // analytics & validations, saving/updating the individual test results.\n analyzePlan(bLog: boolean = false): boolean {\n try {\n doPreprocessData(this, bLog);\n doAnalyzeDistricts(this, bLog);\n doAnalyzePlan(this, bLog);\n doAnalyzePostProcessing(this, bLog);\n }\n catch {\n console.log(\"Exception caught by analyzePlan()\");\n return false;\n }\n\n return true;\n }\n\n // NOTE - This assumes that analyzePlan() has been run!\n getPlanAnalytics(bLog: boolean = false): PlanAnalytics {\n return preparePlanAnalytics(this, bLog);\n }\n // NOTE - This assumes that analyzePlan() has been run!\n getDistrictStatistics(bLog: boolean = false): DistrictStatistics {\n return prepareDistrictStatistics(this, bLog);\n }\n // NOTE - This assumes that analyzePlan() has been run!\n getDiscontiguousDistrictFeatures(bLog: boolean = false): T.GeoFeatureCollection {\n // Get the (possibly empty) list of discontiguous district IDs\n let contiguousTest = this.getTest(T.Test.Contiguous) as T.TestEntry;\n let discontiguousDistrictIDs: number[] = contiguousTest['details']['discontiguousDistricts'] || [];\n\n // Convert them into a (possibly empty) list of features\n let discontiguousDistrictFeatures: T.GeoFeatureCollection = { type: 'FeatureCollection', features: [] };\n if (!(U.isArrayEmpty(discontiguousDistrictIDs))) {\n for (let id of discontiguousDistrictIDs) {\n let poly = this.districts.getDistrictShapeByID(id);\n\n if (poly) discontiguousDistrictFeatures.features.push(poly);\n }\n }\n\n return discontiguousDistrictFeatures;\n }\n\n\n // HELPERS USED INTERNALLY\n\n // Get an individual test, so you can drive UI with the results.\n getTest(testID: T.Test): T.TestEntry {\n // Get the existing test entries\n // T.Test is a numeric enum, so convert the string keys to numbers\n let testValues = U.getNumericObjectKeys(this.tests);\n\n // If there's no entry for this test, create & initialize one\n if (!(testValues.includes(testID))) {\n this.tests[testID] = {} as T.TestEntry;\n this.tests[testID]['score'] = undefined;\n this.tests[testID]['details'] = {};\n }\n\n // Return a pointer to the the test entry for this test\n return this.tests[testID];\n }\n\n // NOTE - Not sure why this has to be up here.\n populationDeviationThreshold(): number {\n return 1 - this.testScales[T.Test.PopulationDeviation]['scale'][0];\n }\n}\n\n","//\n// DATA ABSTRACTION LAYER\n//\n\nimport * as T from './types'\nimport * as U from './utils';\nimport * as S from './settings';\n\nimport { AnalyticsSession } from './_api';\nimport { isConnected, isEmbedded } from './valid';\nimport { extractDistrictProperties } from './compact';\nimport { fptpWin } from './political'\n\n\n// DISTRICT STATISTICS\n\n// Indexes for statistics fields in Districts\n// NOTE - Not a const, so the number can be determined dynamically\nexport enum DistrictField {\n TotalPop, // Display\n PopDevPct, // Display\n bEqualPop, // Display\n bNotEmpty, // Display\n bContiguous, // Display\n bNotEmbedded, // Display\n CountySplits,\n DemVotes,\n RepVotes,\n TwoPartyVote, // Two-party total ()= Dem + Rep) not all votes!\n DemPct, // Display (also the \"VPI,\" by convention\")\n RepPct, // Display\n DemSeat,\n TotalVAP, // VAP or CVAP ...\n MinorityPop, // Derived\n WhitePop,\n BlackPop,\n HispanicPop,\n PacificPop,\n AsianPop,\n NativePop,\n WhitePct, // Display\n MinorityPct, // Display\n BlackPct, // Display\n HispanicPct, // Display\n PacificPct, // Display\n AsianPct, // Display\n NativePct // Display\n\n // 1 - MORE ...\n}\n\nexport class Districts {\n _session: AnalyticsSession;\n\n _shapes: T.GeoFeatureCollection;\n _geoProperties = {} as T.DistrictProperties;\n\n statistics: any[][];\n\n constructor(s: AnalyticsSession, ds: T.GeoFeatureCollection) {\n this._session = s;\n\n this._shapes = ds;\n this.statistics = this.initStatistics();\n }\n getDistrictShapeByID(id: number): T.GeoFeature | undefined {\n // NOTE - Find the district shape by ID (not index)\n // return this._shapes.features[id]; \n for (let f of this._shapes.features) {\n if (f.properties && (f.properties.id == id)) {\n return f;\n }\n }\n return undefined;\n }\n getGeoProperties(i: number): any {\n // Make sure the district shape exists & has geo properties\n if (i in this._geoProperties) return this._geoProperties[i];\n else return null;\n }\n setGeoProperties(i: number, p: T.DistrictShapeProperties): void { this._geoProperties[i] = p; }\n\n numberOfColumns(): number { return U.countEnumValues(DistrictField); }\n // +1 for dummy unassigned 0 \"district\" and +1 for N+1 summary \"district\" for\n // state-level values. Real districts are 1–N.\n numberOfRows(): number { return this._session.state.nDistricts + 2; }\n numberOfWorkingDistricts(): number { return this._session.state.nDistricts + 1; }\n\n // This is the core statistics 2D matrix:\n // Fields on the outside, districts on the inside\n initStatistics(): any[][] {\n let nRows = this.numberOfRows();\n let nCols = this.numberOfColumns();\n\n let outer = U.initArray(nCols, undefined);\n\n for (let i = 0; i < nCols; i++) {\n outer[i] = U.initArray(nRows, null);\n }\n\n return outer;\n }\n\n // This is the workhorse computational routine!\n //\n // TODO - OPTIMIZE for getting multiple properties from the same feature?\n // TODO - OPTIMIZE by only re-calc'ing districts that have changed?\n // In this case, special attention to getting county-splits right.\n // TODO - OPTIMIZE by async'ing this?\n // TODO - Is there a way to do this programmatically off data? Does it matter?\n recalcStatistics(bLog: boolean = false): void {\n // Compute these once per recalc cycle\n let targetSize = this._session.state.totalPop / this._session.state.nDistricts;\n let deviationThreshold = this._session.populationDeviationThreshold();\n let planByDistrict = this._session.plan.byDistrictID();\n let plan = this._session.plan;\n let graph = this._session.graph;\n\n // NOTE - SPLITTING\n // Add an extra 0th virtual county bucket for county-district splitting analysis \n let nCountyBuckets = this._session.counties.nCounties + 1;\n\n // INITIALIZE STATE VALUES THAT WILL BE ACCUMULATED\n\n let stateTPVote = 0;\n let stateDemVote = 0;\n let stateRepVote = 0;\n\n let stateVAPPop = 0;\n let stateWhitePop = 0;\n let stateMinorityPop = 0;\n let stateBlackPop = 0;\n let stateHispanicPop = 0;\n let statePacificPop = 0;\n let stateAsianPop = 0;\n let stateNativePop = 0;\n\n // NOTE - These plan-level booleans are set in their respective analytics:\n // - Equal population (bEqualPop)\n // - Complete (bNotEmpty)\n // - Contiguous (bContiguous)\n // - Free of holes (bNotEmbedded)\n\n // 2 - MORE ...\n\n // Loop over the districts (including the dummy unassigned one)\n for (let i = 0; i < this.numberOfWorkingDistricts(); i++) {\n\n // INITIALIZE DISTRICT VALUES THAT WILL BE ACCUMULATED (VS. DERIVED)\n\n let featurePop: number;\n let totalPop: number = 0;\n\n // NOTE - SPLITTING\n let countySplits: number[] = U.initArray(nCountyBuckets, 0);\n\n let demVotes: number = 0;\n let repVotes: number = 0;\n\n let totalVAP: number = 0;\n let whitePop: number = 0;\n let blackPop: number = 0;\n let hispanicPop: number = 0;\n let pacificPop: number = 0;\n let asianPop: number = 0;\n let nativePop: number = 0;\n\n // NOTE - Only report explicitly found validity issues\n let bNotEmpty = false;\n let bContiguous = true;\n let bNotEmbedded = true;\n let bEqualPop = true;\n\n // 3 - MORE ...\n\n // HACK - Because \"this\" gets ghosted inside the forEach loop below\n let outerThis = this;\n\n // Get the geoIDs assigned to the district\n // Guard against empty districts\n let geoIDs = this._session.plan.geoIDsForDistrictID(i);\n if (geoIDs && (geoIDs.size > 0)) {\n bNotEmpty = true;\n\n // ... loop over the geoIDs creating district-by-district statistics \n geoIDs.forEach(function (geoID: string): void {\n // Skip water-only features\n if (!(U.isWaterOnly(geoID))) {\n // Map from geoID to feature index\n let featureID = outerThis._session.features.featureID(geoID);\n let f: T.GeoFeature = outerThis._session.features.featureByIndex(featureID);\n\n if (f == undefined) {\n console.log(\"Skipping undefined feature in district statistics: GEOID =\", geoID, \"Feature ID =\", featureID);\n }\n else {\n // ACCUMULATE VALUES\n\n // Total population of each feature\n // NOTE - This result is used more than once\n featurePop = outerThis._session.features.fieldForFeature(f, Dataset.CENSUS, FeatureField.TotalPop);\n\n // Total district population\n totalPop += featurePop;\n\n // NOTE - SPLITTING\n // Total population by counties w/in a district,\n // except the dummy unassigned district 0\n if (i > 0) countySplits[outerThis.getCountyIndex(geoID)] += featurePop;\n\n // Democratic and Republican vote totals\n demVotes += outerThis._session.features.fieldForFeature(f, Dataset.ELECTION, FeatureField.DemVotes);\n repVotes += outerThis._session.features.fieldForFeature(f, Dataset.ELECTION, FeatureField.RepVotes);\n\n // Voting-age demographic breakdowns (or citizen voting-age)\n totalVAP += outerThis._session.features.fieldForFeature(f, Dataset.VAP, FeatureField.TotalPop);\n whitePop += outerThis._session.features.fieldForFeature(f, Dataset.VAP, FeatureField.WhitePop);\n blackPop += outerThis._session.features.fieldForFeature(f, Dataset.VAP, FeatureField.BlackPop);\n hispanicPop += outerThis._session.features.fieldForFeature(f, Dataset.VAP, FeatureField.HispanicPop);\n pacificPop += outerThis._session.features.fieldForFeature(f, Dataset.VAP, FeatureField.PacificPop);\n asianPop += outerThis._session.features.fieldForFeature(f, Dataset.VAP, FeatureField.AsianPop);\n nativePop += outerThis._session.features.fieldForFeature(f, Dataset.VAP, FeatureField.NativePop);\n\n // 4 - MORE ...\n }\n }\n else console.log(\"Skipping water-only feature in district statistics:\", geoID);\n });\n\n // COMPUTE DERIVED VALUES\n\n // Population deviation % and equal population (boolean) by district.\n // Default the value for the dummy unassigned district to 0%.\n let popDevPct = 0 / targetSize;\n if (i > 0) {\n popDevPct = (totalPop - targetSize) / targetSize;\n bEqualPop = (popDevPct <= deviationThreshold);\n }\n\n // Total two-party (not total total!) votes, Democratic and Republican vote\n // shares, and Democratic first-past-the-post win (= 1) or loss (= 0).\n let totVotes: number;\n let demPct: number = 0;\n let repPct: number = 0;\n let DemSeat: number = 0;\n\n totVotes = demVotes + repVotes;\n if (totVotes > 0) {\n demPct = demVotes / totVotes;\n repPct = repVotes / totVotes;\n DemSeat = fptpWin(demPct);\n }\n\n // Total minority VAP\n let minorityPop = totalVAP - whitePop;\n\n // Voting-age demographic proportions (or citizen voting-age)\n let whitePct: number = 0;\n let minorityPct: number = 0;\n let blackPct: number = 0;\n let hispanicPct: number = 0;\n let pacificPct: number = 0;\n let asianPct: number = 0;\n let nativePct: number = 0;\n\n if (totalVAP > 0) {\n whitePct = whitePop / totalVAP;\n minorityPct = minorityPop / totalVAP;\n blackPct = blackPop / totalVAP;\n hispanicPct = hispanicPop / totalVAP;\n pacificPct = pacificPop / totalVAP;\n asianPct = asianPop / totalVAP;\n nativePct = nativePop / totalVAP;\n }\n\n // 5 - MORE ...\n\n // COMPUTE DISTRICT-LEVEL VALUES\n\n // Validations\n\n // Leave the default values for the dummy unassigned district,\n // and districts that are empty.\n if ((i > 0) && bNotEmpty) {\n bContiguous = isConnected(geoIDs, graph);\n bNotEmbedded = (!isEmbedded(i, planByDistrict[i], plan, graph));\n }\n\n // 6 - MORE ...\n\n { // UPDATE THE DISTRICT STATISTICS\n\n // NOTE - These are set below for both non-empty & empty districts:\n // this.statistics[DistrictField.bNotEmpty][i] = bNotEmpty;\n // this.statistics[DistrictField.bContiguous][i] = bContiguous;\n // this.statistics[DistrictField.bNotEmbedded][i] = bNotEmbedded;\n // this.statistics[DistrictField.TotalPop][i] = totalPop;\n // this.statistics[DistrictField.bEqualPop][i] = bEqualPop;\n this.statistics[DistrictField.PopDevPct][i] = popDevPct;\n\n this.statistics[DistrictField.DemVotes][i] = demVotes;\n this.statistics[DistrictField.RepVotes][i] = repVotes;\n this.statistics[DistrictField.TwoPartyVote][i] = totVotes;\n this.statistics[DistrictField.DemPct][i] = demPct;\n this.statistics[DistrictField.RepPct][i] = repPct;\n this.statistics[DistrictField.DemSeat][i] = DemSeat;\n\n this.statistics[DistrictField.WhitePop][i] = whitePop;\n this.statistics[DistrictField.MinorityPop][i] = minorityPop;\n this.statistics[DistrictField.BlackPop][i] = blackPop;\n this.statistics[DistrictField.HispanicPop][i] = hispanicPop;\n this.statistics[DistrictField.PacificPop][i] = pacificPop;\n this.statistics[DistrictField.AsianPop][i] = asianPop;\n this.statistics[DistrictField.NativePop][i] = nativePop;\n\n this.statistics[DistrictField.TotalVAP][i] = totalVAP;\n this.statistics[DistrictField.WhitePct][i] = whitePct;\n this.statistics[DistrictField.MinorityPct][i] = minorityPct;\n this.statistics[DistrictField.BlackPct][i] = blackPct;\n this.statistics[DistrictField.HispanicPct][i] = hispanicPct;\n this.statistics[DistrictField.PacificPct][i] = pacificPct;\n this.statistics[DistrictField.AsianPct][i] = asianPct;\n this.statistics[DistrictField.NativePct][i] = nativePct;\n }\n\n // 7 - MORE ...\n\n { // ACCUMULATE STATE STATISTICS FROM DISTRICT TOTALS\n stateTPVote += totVotes;\n stateDemVote += demVotes;\n stateRepVote += repVotes;\n\n stateVAPPop += totalVAP;\n stateWhitePop += whitePop;\n stateMinorityPop += minorityPop\n stateBlackPop += blackPop;\n stateHispanicPop += hispanicPop;\n statePacificPop += pacificPop;\n stateAsianPop += asianPop;\n stateNativePop += nativePop;\n }\n }\n else { // If a district is empty, zero these results (vs. null)\n this.statistics[DistrictField.PopDevPct][i] = 0.0;\n\n this.statistics[DistrictField.DemVotes][i] = 0;\n this.statistics[DistrictField.RepVotes][i] = 0;\n this.statistics[DistrictField.TwoPartyVote][i] = 0;\n this.statistics[DistrictField.DemPct][i] = 0;\n this.statistics[DistrictField.RepPct][i] = 0;\n this.statistics[DistrictField.DemSeat][i] = 0;\n\n this.statistics[DistrictField.WhitePop][i] = 0;\n this.statistics[DistrictField.MinorityPop][i] = 0;\n this.statistics[DistrictField.BlackPop][i] = 0;\n this.statistics[DistrictField.HispanicPop][i] = 0;\n this.statistics[DistrictField.PacificPop][i] = 0;\n this.statistics[DistrictField.AsianPop][i] = 0;\n this.statistics[DistrictField.NativePop][i] = 0;\n\n this.statistics[DistrictField.TotalVAP][i] = 0;\n this.statistics[DistrictField.WhitePct][i] = 0;\n this.statistics[DistrictField.MinorityPct][i] = 0;\n this.statistics[DistrictField.BlackPct][i] = 0;\n this.statistics[DistrictField.HispanicPct][i] = 0;\n this.statistics[DistrictField.PacificPct][i] = 0;\n this.statistics[DistrictField.AsianPct][i] = 0;\n this.statistics[DistrictField.NativePct][i] = 0;\n }\n\n { // UPDATE THESE DISTRICT STATISTICS, EVEN WHEN THEY ARE EMPTY\n this.statistics[DistrictField.TotalPop][i] = totalPop;\n\n this.statistics[DistrictField.bNotEmpty][i] = bNotEmpty;\n this.statistics[DistrictField.bContiguous][i] = bContiguous;\n this.statistics[DistrictField.bNotEmbedded][i] = bNotEmbedded;\n this.statistics[DistrictField.bEqualPop][i] = bEqualPop;\n\n this.statistics[DistrictField.CountySplits][i] = countySplits;\n }\n }\n\n // UPDATE STATE STATISTICS\n let summaryRow = this.numberOfRows() - 1;\n\n if (stateTPVote > 0) {\n this.statistics[DistrictField.DemPct][summaryRow] = stateDemVote / stateTPVote;\n this.statistics[DistrictField.RepPct][summaryRow] = stateRepVote / stateTPVote;\n }\n\n if (stateVAPPop > 0) {\n this.statistics[DistrictField.WhitePct][summaryRow] = stateWhitePop / stateVAPPop;\n this.statistics[DistrictField.MinorityPct][summaryRow] = stateMinorityPop / stateVAPPop;\n this.statistics[DistrictField.BlackPct][summaryRow] = stateBlackPop / stateVAPPop;\n this.statistics[DistrictField.HispanicPct][summaryRow] = stateHispanicPop / stateVAPPop;\n this.statistics[DistrictField.PacificPct][summaryRow] = statePacificPop / stateVAPPop;\n this.statistics[DistrictField.AsianPct][summaryRow] = stateAsianPop / stateVAPPop;\n this.statistics[DistrictField.NativePct][summaryRow] = stateNativePop / stateVAPPop;\n }\n }\n // NOTE - I did not roll these into district statistics, because creating the\n // district shapes themselves is the big district-by-district activity, these\n // calc's already work, and I'm not going to expose these values. Wrapping\n // the underlying function and exposing it here to illustrate the parallelism\n // with recalcStatistics(). These are called in tandem by doAnalyzeDistricts().\n extractDistrictShapeProperties(bLog: boolean = false): void {\n extractDistrictProperties(this._session, bLog)\n }\n getCountyIndex(geoID: string): number {\n let countyGeoID = U.parseGeoID(geoID)['county'] as string;\n let countyFIPS = U.getFIPSFromCountyGeoID(countyGeoID);\n let countyIndex = this._session.counties.indexFromFIPS(countyFIPS);\n\n return countyIndex;\n }\n}\n\n\n// CLASSES, ETC. FOR FEATURE & COUNTY DATA\n\n// Types of datasets by feature\nexport const enum Dataset {\n SHAPES = \"SHAPES\",\n CENSUS = \"CENSUS\",\n VAP = \"VAP\",\n ELECTION = \"ELECTION\"\n}\n\nexport type DatasetKeys = {\n SHAPES: string; // A shapefile\n CENSUS: string; // A total population Census dataset\n VAP: string; // A voting age (or citizen voting age) dataset\n ELECTION: string; // An election dataset\n}\n\n// Identifiers of fields for each feature in the datasets\nexport const enum FeatureField {\n TotalPop = \"Tot\",\n WhitePop = \"Wh\",\n BlackPop = \"BlC\",\n HispanicPop = \"His\",\n AsianPop = \"AsnC\",\n PacificPop = \"PacC\",\n NativePop = \"NatC\",\n DemVotes = \"D\",\n RepVotes = \"R\",\n TotalVotes = \"Tot\"\n}\n\n// Wrap data by feature, to abstract the specifics of the internal structure\nexport class Features {\n _session: AnalyticsSession;\n\n _data: T.GeoFeatureCollection;\n _keys: DatasetKeys;\n\n _featureIDs = {} as T.FeaturesByGeoID;\n\n constructor(s: AnalyticsSession, data: T.GeoFeatureCollection, keys: DatasetKeys) {\n this._session = s;\n\n this._data = data;\n this._keys = keys;\n }\n nFeatures(): number { return this._data.features.length; }\n featureByIndex(i: number): T.GeoFeature { return this._data.features[i]; }\n geoIDForFeature(f: any): string {\n // GEOIDs will be one of these properties\n let value = f.properties['GEOID10'] || f.properties['GEOID20'] || f.properties['GEOID'];\n return value;\n }\n fieldForFeature(f: any, dt: Dataset, fk: string): any {\n let dk: string = this._keys[dt];\n\n return _getFeatures(f, dk, fk);\n }\n resetDataset(d: Dataset, k: string): void {\n this._keys[d] = k;\n // TODO - RECALC: Does anything need to be recalc'd now when a dataset is changed?\n }\n mapGeoIDsToFeatureIDs(): void {\n for (let i: number = 0; i < this._session.features.nFeatures(); i++) {\n let f: T.GeoFeature = this._session.features.featureByIndex(i);\n let geoID: string = this._session.features.geoIDForFeature(f);\n\n this._featureIDs[geoID] = i;\n }\n }\n featureID(i: string): number { return this._featureIDs[i]; }\n}\n\n// NOTE - This accessor is cloned from fGetW() in dra-client/restrict.ts\n// f is a direct GeoJSON feature\n// p is a geoID\nfunction _getFeatures(f: any, datasetKey: string, p: string): any {\n // Echo parameters for debugging\n // console.log(\"f =\", f, \"k = \", datasetKey, \"p =\", p);\n\n // Shim to load sample data2.json from disk for command-line scaffolding\n if (f.properties && f.properties['datasets']) {\n return f.properties['datasets'][datasetKey][p];\n }\n\n // NOTE - The fGetW() code from dra-client below here ...\n\n // Direct property?\n if (f.properties && f.properties[p] !== undefined)\n return f.properties[p];\n\n // Joined property?\n let a: any[] = _fGetJoined(f);\n if (a) {\n for (let i: number = 0; i < a.length; i++) {\n let o: any = a[i];\n if (!datasetKey) {\n if (o[p] !== undefined)\n return o[p];\n }\n else {\n if (o['datasets'] && o['datasets'][datasetKey]) {\n let v = (o['datasets'][datasetKey][p]);\n if ((!(v == null)) && (!(v == undefined)))\n return o['datasets'][datasetKey][p];\n }\n }\n }\n }\n console.log(`${p} value undefined for ${f.properties['GEOID10']}!`);\n\n return undefined;\n}\n\nfunction _fGetJoined(f: any): any[] {\n return (f.properties && f.properties.joined) ? f.properties.joined : undefined;\n}\n\n// Wrap data by county, to abstract the specifics of the internal structure\nexport class Counties {\n _session: AnalyticsSession;\n\n _data: T.GeoFeatureCollection;\n _countyNameLookup: T.FIPSCodeToCountyNameMap = {};\n\n nCounties: number;\n index = {} as T.FIPSToOrdinalMap;\n totalPopulation: number[] = [];\n\n constructor(s: AnalyticsSession, data: T.GeoFeatureCollection) {\n this._session = s;\n\n this._data = data;\n this.nCounties = this._data.features.length;\n }\n countyByIndex(i: number): T.GeoFeature { return this._data.features[i]; }\n propertyForCounty(f: any, pk: string): any { return f.properties[pk]; }\n mapFIPSToName(fips: string, name: string): void { this._countyNameLookup[fips] = name; }\n nameFromFIPS(fips: string): string { return this._countyNameLookup[fips]; }\n indexFromFIPS(fips: string): number { return this.index[fips]; }\n}\n\n// CLASSES TO ORGANIZE AND/OR ABSTRACT OTHER DATA\n\nexport class State {\n _session: AnalyticsSession;\n\n xx: string;\n nDistricts: number;\n totalPop = 0;\n tooBigFIPS = [] as string[];\n tooBigName = [] as string[];\n expectedSplits = 0;\n expectedAffected = 0;\n\n constructor(s: AnalyticsSession, xx: string, n: number) {\n this._session = s;\n\n this.xx = xx;\n this.nDistricts = n;\n }\n}\n\nexport class Plan {\n _session: AnalyticsSession;\n\n // TODO - RECALC: Do these need to be updated, when the plan changes?\n _planByGeoID: T.PlanByGeoID;\n _planByDistrictID: T.PlanByDistrictID;\n\n districtIDs: number[];\n\n constructor(s: AnalyticsSession, p: T.PlanByGeoID) {\n this._session = s;\n\n\n this._planByGeoID = p;\n this._planByDistrictID = {} as T.PlanByDistrictID;\n\n this.districtIDs = []; // Set when the plan in inverted\n }\n // NOTE - DON'T remove water-only features from the plan, as they may be required\n // for contiguity. Just skip them in aggregating district statistics.\n // removeWaterOnlyFeatures(plan: T.PlanByGeoID): T.PlanByGeoID {\n // let newPlan = {} as T.PlanByGeoID;\n\n // for (let geoID in plan) {\n // // Remove water-only features\n // if (!(U.isWaterOnly(geoID))) {\n // newPlan[geoID] = plan[geoID];\n // }\n // else {\n // console.log(\"Removing water-only feature\", geoID);\n // }\n // }\n\n // return newPlan;\n // }\n invertPlan(): void {\n // NOTE - UNASSIGNED\n this._planByDistrictID = invertPlan(this._planByGeoID, this._session);\n this.districtIDs = U.getNumericObjectKeys(this._planByDistrictID);\n }\n initializeDistrict(i: number): void { this._planByDistrictID[i] = new Set(); }\n\n byGeoID(): T.PlanByGeoID { return this._planByGeoID; }\n byDistrictID(): T.PlanByDistrictID { return this._planByDistrictID; }\n districtForGeoID(i: string): number { return this._planByGeoID[i]; }\n geoIDsForDistrictID(i: number): Set<string> { return this._planByDistrictID[i]; }\n}\n\n// Invert a feature assignment structure to sets of ids by district\nexport function invertPlan(plan: T.PlanByGeoID, s?: AnalyticsSession): T.PlanByDistrictID {\n let invertedPlan = {} as T.PlanByDistrictID;\n\n // Add a dummy 'unassigned' district\n invertedPlan[S.NOT_ASSIGNED] = new Set();\n\n // NOTE - UNASSIGNED\n // The feature assignments coming from DRA do not include unassigned ones.\n // - In the DRA-calling context, there's an analytics session with a reference\n // to the features. Loop over all the features to find the unassigned ones,\n // and add them to the dummy unassigned district explicitly.\n // - In the CLI-calling context, there's no session (yet) but the plan is complete.\n if (!(s == undefined)) {\n for (let i: number = 0; i < s.features.nFeatures(); i++) {\n let f: T.GeoFeature = s.features.featureByIndex(i);\n let geoID: string = s.features.geoIDForFeature(f);\n\n // If the feature is NOT explicitly assigned to a district, add the geoID\n // to the dummy unassigned district 0.\n if (!(U.keyExists(geoID, plan))) invertedPlan[S.NOT_ASSIGNED].add(geoID);\n\n // NOTE - NOT skipping WATER-ONLY features here, because we're\n // not skipping them below when they are explicitly assigned in plans. Should\n // we skip them in both places?\n }\n }\n\n for (let geoID in plan) {\n let districtID = plan[geoID];\n\n // Make sure the set for the districtID exists\n if (!(U.objectContains(invertedPlan, districtID))) {\n invertedPlan[districtID] = new Set();\n }\n\n // Add the geoID to the districtID's set\n invertedPlan[districtID].add(geoID);\n\n if (U.isWaterOnly(geoID)) console.log(\"Water-only feature still in plan!\", geoID);\n }\n\n return invertedPlan;\n}\n\nexport class Graph {\n _session: AnalyticsSession;\n\n _graph: T.ContiguityGraph;\n\n constructor(s: AnalyticsSession, graph: T.ContiguityGraph) {\n this._session = s;\n\n this._graph = graph;\n }\n peerNeighbors(node: string): string[] {\n // Get the neighboring geoIDs connected to a geoID\n // Ignore the lengths of the shared borders (the values), for now\n\n // Protect against getting a GEOID that's not in the graph\n if (U.keyExists(node, this._graph)) {\n // NOTE - CONTIGUITY GRAPHS\n // Handle both unweighted & weighted neighbors\n let n = this._graph[node];\n let l = (n instanceof Array) ? n : U.getObjectKeys(n);\n\n return l;\n\n // return U.getObjectKeys(this._graph[node]);\n }\n else return [];\n\n // return U.getObjectKeys(this._graph[node]);\n }\n}\n\n\n","//\n// ANALYZE A PLAN\n//\n\nimport * as T from './types'\nimport * as U from './utils';\nimport * as S from './settings';\n\nimport { AnalyticsSession } from './_api';\n\nimport { doIsComplete, doIsContiguous, doIsFreeOfHoles } from './valid'\nimport { doPopulationDeviation, doHasEqualPopulations } from './equal';\nimport { doReock, doPolsbyPopper } from './compact';\nimport {\n doFindCountiesSplitUnexpectedly, doFindSplitVTDs,\n doCountySplitting, doDistrictSplitting\n} from './cohesive';\nimport {\n doSeatsBias, doVotesBias,\n doResponsiveness, doResponsiveDistricts, doEfficiencyGap\n} from './political';\nimport { doMajorityMinorityDistricts } from './minority'\n\n// Compile district-level info for plan/map-level analytics\nexport function doAnalyzeDistricts(s: AnalyticsSession, bLog: boolean = false): void {\n s.districts.recalcStatistics(bLog);\n s.districts.extractDistrictShapeProperties(bLog);\n}\n\n// Calculate the analytics & validations and cache the results\n// NOTE - doAnalyzePlan() depends on doAnalyzeDistricts() having run first.\n// NOTE - I could make this table-driven, but I'm thinking that the explicit\n// calls might make chunking for aync easier.\nexport function doAnalyzePlan(s: AnalyticsSession, bLog: boolean = false): void {\n // TODO - Remove this mechanism. Always run all tests\n // Get the requested suites, and only execute those tests\n let requestedSuites = s.config['suites'];\n\n // Tests in the \"Legal\" suite, i.e., pass/ fail constraints\n if (requestedSuites.includes(T.Suite.Legal)) {\n s.tests[T.Test.Complete] = doIsComplete(s, bLog);\n\n s.tests[T.Test.Contiguous] = doIsContiguous(s, bLog);\n\n s.tests[T.Test.FreeOfHoles] = doIsFreeOfHoles(s, bLog);\n\n s.tests[T.Test.PopulationDeviation] = doPopulationDeviation(s, bLog);\n\n // NOTE - I can't check whether a population deviation is legal or not, until\n // the raw % is normalized. A zero (0) would mean \"too much\" / \"not legal,\" for\n // the given type of district (CD vs. LD). The EqualPopulation test is derived\n // from PopulationDeviation, as part of scorecard or test log preparation.\n\n // Create an empty test entry here though ...\n s.tests[T.Test.EqualPopulation] = s.getTest(T.Test.EqualPopulation) as T.TestEntry;\n }\n\n // Tests in the \"Fair\" suite\n if (requestedSuites.includes(T.Suite.Fair)) {\n s.tests[T.Test.SeatsBias] = doSeatsBias(s, bLog);\n\n s.tests[T.Test.VotesBias] = doVotesBias(s, bLog);\n\n s.tests[T.Test.Responsiveness] = doResponsiveness(s, bLog);\n\n s.tests[T.Test.ResponsiveDistricts] = doResponsiveDistricts(s, bLog);\n\n s.tests[T.Test.EfficiencyGap] = doEfficiencyGap(s, bLog);\n\n s.tests[T.Test.MajorityMinorityDistricts] = doMajorityMinorityDistricts(s, bLog);\n }\n\n // Tests in the \"Best\" suite, i.e., criteria for better/worse\n if (requestedSuites.includes(T.Suite.Best)) {\n s.tests[T.Test.Reock] = doReock(s, bLog);\n s.tests[T.Test.PolsbyPopper] = doPolsbyPopper(s, bLog);\n\n s.tests[T.Test.UnexpectedCountySplits] = doFindCountiesSplitUnexpectedly(s, bLog);\n s.tests[T.Test.VTDSplits] = doFindSplitVTDs(s, bLog);\n s.tests[T.Test.CountySplitting] = doCountySplitting(s, bLog);\n s.tests[T.Test.DistrictSplitting] = doDistrictSplitting(s, bLog);\n }\n\n // Enable a Test Log and Scorecard to be generated\n s.bPlanAnalyzed = true;\n s.bPostProcessingDone = false;\n}\n\n// Derive secondary analytics that are based on primary tests.\n// This concept allows Population Deviation to be a primary numeric test and\n// Equal Population to be secondary pass/fail validation.\n//\n// NOTE - Should this be conditionalized on the test suites requested? \n// Those are encapsulated in reports.ts right now, so not doing that.\nexport function doDeriveSecondaryTests(s: AnalyticsSession, bLog: boolean = false): void {\n s.tests[T.Test.EqualPopulation] = doHasEqualPopulations(s, bLog);\n}\n","//\n// SPLITTING of counties & districts\n//\n\nimport * as T from './types'\nimport * as U from './utils';\nimport * as S from './settings';\n\nimport * as D from './_data'\nimport { AnalyticsSession } from './_api';\n\n\n// CALCULATE ENHANCED SQRT ENTROPY METRIC\n\nexport function doCountySplitting(s: AnalyticsSession, bLog: boolean = false): T.TestEntry {\n let test = s.getTest(T.Test.CountySplitting) as T.TestEntry;\n\n let CxD = s.districts.statistics[D.DistrictField.CountySplits].slice(0, -1);\n let countyTotals = s.counties.totalPopulation;\n let districtTotals = s.districts.statistics[D.DistrictField.TotalPop].slice(0, -1);\n\n let f = calcCountyFractions(CxD, countyTotals);\n let w = calcCountyWeights(countyTotals);\n\n let SqEnt_DC = countySplitting(f, w, bLog);\n\n let CxDreducedC = U.deepCopy(CxD);\n reduceCSplits(CxDreducedC, districtTotals);\n\n let fReduced = calcCountyFractions(CxDreducedC, countyTotals);\n let wReduced = calcCountyWeights(countyTotals);\n\n let SqEnt_DCreduced = countySplitting(fReduced, wReduced, bLog);\n\n test['score'] = SqEnt_DCreduced;\n test['details']['SqEnt_DC'] = SqEnt_DC;\n\n return test;\n}\n\nexport function doDistrictSplitting(s: AnalyticsSession, bLog: boolean = false): T.TestEntry {\n let test = s.getTest(T.Test.DistrictSplitting) as T.TestEntry;\n\n let CxD = s.districts.statistics[D.DistrictField.CountySplits].slice(0, -1);\n let countyTotals = s.counties.totalPopulation;\n let districtTotals = s.districts.statistics[D.DistrictField.TotalPop].slice(0, -1);\n\n let g = calcDistrictFractions(CxD, districtTotals);\n let x = calcDistrictWeights(districtTotals);\n\n let SqEnt_CD = districtSplitting(g, x, bLog);\n\n let CxDreducedD = U.deepCopy(CxD);\n reduceDSplits(CxDreducedD, countyTotals);\n\n let gReduced = calcDistrictFractions(CxDreducedD, districtTotals);\n let xReduced = calcDistrictWeights(districtTotals);\n\n let SqEnt_CDreduced = districtSplitting(gReduced, xReduced, bLog);\n\n test['score'] = SqEnt_CDreduced;\n test['details']['SqEnt_CD'] = SqEnt_CD;\n\n return test;\n}\n\n\n// HELPERS\n\n// Loop over all the county-district combos, skipping the virtual district 0 \n// and virtual county 0.\n//\n// NOTE - The county-district splits and the county & district totals may all,\n// in general, be fractional/decimal numbers as opposed to integers, due to\n// dissaggregation & re-aggregation. Hence, comparisons need to approximate\n// equality.\n\n// Consolidate districts (rows) consisting of just one county (column)\n// UP into the dummy district (0).\nfunction reduceCSplits(CxDreducedC: number[][], districtTotals: number[]): void {\n let nD = CxDreducedC.length;\n let nC = CxDreducedC[0].length;\n\n for (let j = 1; j < nC; j++) {\n for (let i = 1; i < nD; i++) {\n let split_total = CxDreducedC[i][j];\n\n if (split_total > 0) {\n if (areRoughlyEqual(split_total, districtTotals[i])) {\n CxDreducedC[0][j] += split_total;\n CxDreducedC[i][j] = 0;\n }\n }\n }\n }\n}\n\n// Consolidate whole counties (columns) in a district (row) LEFT into the\n// dummy county (0).\nfunction reduceDSplits(CxDreducedD: number[][], countyTotals: number[]): void {\n let nD = CxDreducedD.length;\n let nC = CxDreducedD[0].length;\n\n for (let i = 1; i < nD; i++) {\n for (let j = 1; j < nC; j++) {\n let split_total = CxDreducedD[i][j];\n\n if (split_total > 0) {\n if (areRoughlyEqual(split_total, countyTotals[j])) {\n CxDreducedD[i][0] += split_total;\n CxDreducedD[i][j] = 0;\n }\n }\n }\n }\n}\n\nfunction calcCountyWeights(countyTotals: number[]): number[] {\n let nC: number = countyTotals.length;\n let cTotal: number = U.sumArray(countyTotals);\n\n let w: number[] = U.initArray(nC, 0.0);\n\n for (let j = 0; j < nC; j++) {\n w[j] = countyTotals[j] / cTotal;\n }\n\n return w;\n}\n\nfunction calcDistrictWeights(districtTotals: number[]): number[] {\n let nD = districtTotals.length;\n let dTotal: number = U.sumArray(districtTotals);\n\n let x: number[] = U.initArray(nD, 0.0);\n\n for (let i = 0; i < nD; i++) {\n x[i] = districtTotals[i] / dTotal;\n }\n\n return x;\n}\n\nfunction calcCountyFractions(CxDreducedD: number[][], countyTotals: number[]): number[][] {\n let nD = CxDreducedD.length;\n let nC = CxDreducedD[0].length;\n\n let f: number[][] = new Array(nD).fill(0.0).map(() => new Array(nC).fill(0.0));\n\n for (let j = 0; j < nC; j++) {\n for (let i = 0; i < nD; i++) {\n if (countyTotals[j] > 0) {\n f[i][j] = CxDreducedD[i][j] / countyTotals[j];\n }\n else {\n f[i][j] = 0.0;\n }\n }\n }\n\n return f;\n}\n\nfunction calcDistrictFractions(CxDreducedC: number[][], districtTotals: number[]): number[][] {\n let nD = CxDreducedC.length;\n let nC = CxDreducedC[0].length;\n\n let g: number[][] = new Array(nD).fill(0.0).map(() => new Array(nC).fill(0.0));\n\n for (let j = 0; j < nC; j++) {\n for (let i = 0; i < nD; i++) {\n if (districtTotals[i] > 0) {\n g[i][j] = CxDreducedC[i][j] / districtTotals[i];\n }\n else {\n g[i][j] = 0.0;\n }\n }\n }\n\n return g;\n}\n\n// Deal with decimal census \"counts\" due to disagg/re-agg\nfunction areRoughlyEqual(x: number, y: number): boolean {\n let delta = Math.abs(x - y);\n let result = (delta < S.EQUAL_TOLERANCE) ? true : false;\n\n return result;\n}\n\n// For all districts in a county, sum the split score.\nfunction countySplitScore(j: number, f: number[][], numD: number, bLog: boolean = false): number {\n let e = 0.0;\n\n for (let i = 0; i < numD; i++) {\n e += Math.sqrt(f[i][j]);\n }\n\n return e;\n}\n\n// For all counties, sum the weighted county splits.\nfunction countySplitting(f: number[][], w: number[], bLog: boolean = false): number {\n let numC = f[0].length;\n let numD = f.length;\n\n let e = 0.0;\n\n for (let j = 0; j < numC; j++) {\n let splitScore = countySplitScore(j, f, numD, bLog);\n e += w[j] * splitScore;\n\n if (bLog) console.log(\"County splitting =\", j, w[j], splitScore, e);\n }\n\n return U.trim(e, 3);\n}\n\n// For all counties in a district, sum the split score.\nfunction districtSplitScore(i: number, g: number[][], numC: number, bLog: boolean = false): number {\n let e = 0.0;\n\n for (let j = 0; j < numC; j++) {\n e += Math.sqrt(g[i][j]);\n }\n\n return e;\n}\n\n// For all districts, sum the weighted district splits.\nfunction districtSplitting(g: number[][], x: number[], bLog: boolean = false): number {\n let numC = g[0].length;\n let numD = g.length;\n\n let e = 0.0;\n\n for (let i = 0; i < numD; i++) {\n let splitScore = districtSplitScore(i, g, numC, bLog);\n e += x[i] * splitScore;\n\n if (bLog) console.log(\"District split score =\", i, x[i], splitScore, e);\n }\n\n return U.trim(e, 3);\n}\n\n\n// ANALYZE SIMPLE COUNTY & VTD SPLITTING\n\n/*\n \nSample results for NC 2016 dongressional plan\n________________________________________________________________________________\n \nState: NC\nCensus: 2010\nTotal population: 9,535,483\nNumber of districts: 13\nTarget district size: 733,499\nNumber of counties: 100\n \nEqual Population: 11.24% deviation\nCompactness: None\nProportionality: 27.67% gap\nCohesiveness: 11 unexpected splits, affecting 27.14% of the total population\n \nThese counties are split unexpectedly:\n \n • Bladen\n • Buncombe\n • Catawba\n • Cumberland\n • Durham\n • Guilford\n • Iredell\n • Johnston\n • Pitt\n • Rowan\n • Wilson\n \n*/\n\nexport function doFindCountiesSplitUnexpectedly(s: AnalyticsSession, bLog: boolean = false): T.TestEntry {\n let test = s.getTest(T.Test.UnexpectedCountySplits) as T.TestEntry;\n\n // THE THREE VALUES TO DETERMINE FOR A PLAN\n let unexpectedSplits: number = 0;\n let unexpectedAffected: number = 0;\n let countiesSplitUnexpectedly = [];\n\n // FIRST, ANALYZE THE COUNTY SPLITTING FOR THE PLAN\n\n // Get the county-district pivot (\"splits\")\n let countiesByDistrict = s.districts.statistics[D.DistrictField.CountySplits];\n // countiesByDistrict = countiesByDistrict.slice(1, -1);\n\n // Find the single-county districts, i.e., districts NOT split across counties.\n // Ignore the dummy unassigned 0 and N+1 summary \"districts.\"\n let singleCountyDistricts = [];\n for (let d = 1; d <= s.state.nDistricts; d++) {\n // See if there's only one county partition\n let nCountiesInDistrict = 0;\n for (let c = 0; c < s.counties.nCounties; c++) {\n // Guard against empty district\n if (countiesByDistrict[d]) {\n if (countiesByDistrict[d][c] > 0) {\n nCountiesInDistrict += 1;\n if (nCountiesInDistrict > 1) {\n break;\n }\n }\n }\n }\n // If so, save the district\n if (nCountiesInDistrict == 1) {\n singleCountyDistricts.push(d);\n }\n }\n\n // Process the splits/partitions in the plan:\n // - Count the total # of partitions,\n // - Find the counties split across districts, and\n // - Accumulate the number people affected (except when single-county districts)\n let nPartitionsOverall: number = 0;\n let splitCounties = new Set(); // The counties that are split across districts\n let totalAffected: number = 0; // The total population affected by those splits\n\n for (let c = 0; c < s.counties.nCounties; c++) {\n let nCountyParts = 0;\n let subtotal = 0;\n\n for (let d = 1; d <= s.state.nDistricts; d++) {\n // Guard against empty district\n if (countiesByDistrict[d]) {\n if (countiesByDistrict[d][c] > 0) {\n nPartitionsOverall += 1;\n nCountyParts += 1;\n if (!(U.arrayContains(singleCountyDistricts, d))) {\n subtotal += countiesByDistrict[d][c];\n }\n }\n }\n }\n if (nCountyParts > 1) {\n splitCounties.add(c);\n totalAffected += subtotal;\n }\n }\n\n // Convert county ordinals to FIPS codes\n let splitCountiesFIPS = U.getSelectObjectKeys(s.counties.index, [...splitCounties]);\n\n // THEN TAKE ACCOUNT OF THE COUNTY SPLITTING THAT IS EXPECTED (REQUIRED)\n\n // Compute the total number of splits this way, in case any counties are split\n // more than once. I.e., it's not just len(all_counties_split).\n let nSplits = nPartitionsOverall - s.counties.nCounties;\n\n // Determine the number of *unexpected* splits. NOTE: Prevent negative numbers,\n // in case you have a plan the *doesn't* split counties that would have to be\n // split due to their size.\n unexpectedSplits = Math.max(0, nSplits - s.state.expectedSplits);\n\n // Subtract off the total population that *has* to be affected by splits,\n // because their counties are too big. NOTE: Again, prevent negative numbers, \n // in case you have a plan the *doesn't* split counties that would have to be\n // split due to their size.\n unexpectedAffected = U.trim(Math.max(0, totalAffected - s.state.expectedAffected) / s.state.totalPop);\n\n // Find the counties that are split *unexpectedly*. From all the counties that\n // are split, remove those that *have* to be split, because they are bigger than\n // a district.\n let countiesSplitUnexpectedlyFIPS = [];\n for (let fips of splitCountiesFIPS) {\n if (!(U.arrayContains(s.state.tooBigFIPS, fips))) {\n countiesSplitUnexpectedlyFIPS.push(fips);\n }\n }\n\n // ... and convert the FIPS codes to county names.\n for (let fips of countiesSplitUnexpectedlyFIPS) {\n countiesSplitUnexpectedly.push(s.counties.nameFromFIPS(fips));\n }\n countiesSplitUnexpectedly = countiesSplitUnexpectedly.sort();\n\n test['score'] = U.trim(unexpectedAffected);\n test['details']['unexpectedSplits'] = unexpectedSplits;\n test['details']['countiesSplitUnexpectedly'] = countiesSplitUnexpectedly;\n\n return test;\n}\n\nexport function doFindSplitVTDs(s: AnalyticsSession, bLog: boolean = false): T.TestEntry {\n let test = s.getTest(T.Test.VTDSplits) as T.TestEntry;\n\n let splitVTDs: string[] = [];\n\n // TODO - SPLITTING: Flesh this out, using Terry's virtual VTD's ...\n\n test['score'] = splitVTDs.length;\n test['details']['splitVTDs'] = splitVTDs;\n\n return test;\n}\n\n","//\n// COMPACT\n//\n\nimport * as Poly from '@dra2020/poly';\n\nimport { gfArea, gfPerimeter, gfDiameter } from './geofeature';\n\nimport * as T from './types';\nimport * as U from './utils';\nimport * as S from './settings';\n\nimport { AnalyticsSession } from './_api';\n\n// Measures of compactness compare district shapes to various ideally compact\n// benchmarks, such as circles. All else equal, more compact districts are better.\n// \n// There are four popular measures of compactness. They either focus on how\n// dispersed or how indented a shapes are.\n//\n// These first two measures are the most important:\n// \n// Reock is the primary measure of the dispersion of district shapes, calculated\n// as “the area of the district to the area of the minimum spanning circle that\n// can enclose the district.”\n//\n// R = A / A(Minimum Bounding Circle)\n// R = A / (π * (D / 2)^2)\n//\n// R = 4A / πD^2\n//\n// where A is the area of the district and D is the diameter of the minimum\n// bounding circle.\n//\n// Polsby-Popper is the primary measure of the indendentation of district shapes,\n// calculated as the “the ratio of the area of the district to the area of a circle\n// whose circumference is equal to the perimeter of the district.”\n//\n// PP = A / A(C)\n//\n// where C is that circle. In other words:\n//\n// P = 2πRc and A(C) = π(P / 2π)^2\n//\n// where P is the perimeter of the district and Rc is the radius of the circle.\n//\n// Hence, the measure simplifies to:\n//\n// PP = 4π * (A / P^2)\n// \n// I propose that we use these two, normalize them, and weight equally to determine\n// our compactness value.\n// \n// These second two measures may be used to complement the primary ones above:\n// \n// Convex Hull is a secondary measure of the dispersion of district shapes, calculated\n// as “the ratio of the district area to the area of the minimum convex bounding\n// polygon (also known as a convex hull) enclosing the district.”\n//\n// CH = A / A(Convex Hull)\n// \n// where a convex hull is the minimum perimeter that encloses all points in a shape,\n// basically the shortest unstretched rubber band that fits around the shape.\n//\n// Schwartzberg is a secondary measure of the degree of indentation of district\n// shapes, calculated as “the ratio of the perimeter of the district to the circumference\n// of a circle whose area is equal to the area of the district.”\n//\n// S = 1 / (P / C)\n//\n// where P is the perimeter of the district and C is the circumference of the circle.\n// The radius of the circle is:\n//\n// Rc = SQRT(A / π)\n//\n// So, the circumference of the circle is:\n//\n// C = 2πRc or C = 2π * SQRT(A / π)\n//\n// Hence:\n//\n// S = 1 (P / 2π * SQRT(A / π))\n//\n// S = (2π * SQRT(A / π)) / P\n//\n// All these measures produce values between 0 and 1, with 0 being the least compact\n// and 1 being the most compact. Sometimes these values are multiplied by 100 to\n// give values between 0 and 100.\n// \n// For each measure, the compactness of a set of Congressional districts is the\n// average of that measure for all the districts.\n//\n\n// Calculate Reock compactness:\n// reock = (4 * a) / (math.pi * d**2)\n// NOTE - Depends on extractDistrictProperties running first\nexport function doReock(s: AnalyticsSession, bLog: boolean = false): T.TestEntry {\n let test = s.getTest(T.Test.Reock) as T.TestEntry;\n\n // Calculate Reock scores by district\n let scores: number[] = [];\n\n for (let districtID = 1; districtID <= s.state.nDistricts; districtID++) {\n let districtProps = s.districts.getGeoProperties(districtID);\n // Guard against no shape and no properties\n if (districtProps) {\n let a = districtProps[T.DistrictShapeProperty.Area];\n let d = districtProps[T.DistrictShapeProperty.Diameter];\n\n let reock = (4 * a) / (Math.PI * d ** 2);\n\n // Save each district score\n scores.push(reock);\n\n // Echo the results by district\n if (bLog) console.log(\"Reock for district\", districtID, \"=\", reock);\n }\n }\n\n // Populate the test entry ... for the shapes that exist!\n let averageReock = U.avgArray(scores);\n\n test['score'] = U.trim(averageReock);\n test['details'] = {}; // TODO - Any details?\n\n return test;\n}\n\n// Calculate Polsby-Popper compactness measures:\n// polsby_popper = (4 * math.pi) * (a / p**2)\n// NOTE - Depends on extractDistrictProperties running first\nexport function doPolsbyPopper(s: AnalyticsSession, bLog: boolean = false): T.TestEntry {\n let test = s.getTest(T.Test.PolsbyPopper) as T.TestEntry;\n\n // Calculate Polsby-Popper scores by district\n let scores: number[] = [];\n\n for (let districtID = 1; districtID <= s.state.nDistricts; districtID++) {\n let districtProps = s.districts.getGeoProperties(districtID);\n // Guard against no shape and no properties\n if (districtProps) {\n let a = districtProps[T.DistrictShapeProperty.Area];\n let p = districtProps[T.DistrictShapeProperty.Perimeter];\n\n let polsbyPopper = (4 * Math.PI) * (a / p ** 2);\n\n // Save each district score\n scores.push(polsbyPopper);\n\n // Echo the results by district\n if (bLog) console.log(\"Polsby-Popper for district\", districtID, \"=\", polsbyPopper);\n }\n }\n\n // Populate the test entry ... for the shapes that exist!\n let averagePolsbyPopper = U.avgArray(scores);\n\n test['score'] = U.trim(averagePolsbyPopper);\n test['details'] = {}; // TODO - Any details?\n\n return test;\n}\n\n\n// HELPER TO EXTRACT PROPERTIES OF DISTRICT SHAPES\n\nexport function extractDistrictProperties(s: AnalyticsSession, bLog: boolean = false): void {\n // NOTE - I am assuming that district IDs are integers 1–N\n for (let i = 1; i <= s.state.nDistricts; i++) {\n let poly = s.districts.getDistrictShapeByID(i);\n\n // Guard against no shape for empty districts AND null shapes\n let polyOptions = { noLatitudeCorrection: true }\n let bNull = (!Poly.polyNormalize(poly, polyOptions));\n\n if (poly && (!bNull)) {\n // TODO - OPTIMIZE: Bundle these calls?\n let area: number = gfArea(poly);\n let perimeter: number = gfPerimeter(poly);\n let diameter: number = gfDiameter(poly);\n\n let props: T.DistrictShapeProperties = [0, 0, 0]; // TODO - TERRY?!?\n props[T.DistrictShapeProperty.Area] = area;\n props[T.DistrictShapeProperty.Diameter] = diameter;\n props[T.DistrictShapeProperty.Perimeter] = perimeter;\n\n s.districts.setGeoProperties(i, props);\n\n if (bLog) console.log(\"District\", i, \"A =\", area, \"P =\", perimeter, \"D =\", diameter);\n }\n }\n}\n\n\n// SAVE THESE NOTES, IN CASE WE NEED TO REWORK HOW WE PERFORM THESE CALCS.\n// THEY REFLECT HOW I DID THEM IN PYTHON.\n//\n// THE COMPACTNESS ANALYTICS NEED THE FOLLOWING DATA,\n// IN ADDITION TO THE MAP (IDEALLY, GEO_IDS INDEXED BY DISTRICT_ID)\n//\n// Shapes by geo_id\n//\n// If we need/want to speed compactness calculations up, we'll need\n// to calculate the perimeters and diameters (and areas) of districts implicitly,\n// which will require identifying district boundaries initially and updating\n// them incrementally as districts are (re)assigned.\n//\n// A district's boundary info is the set/list of features that constitute the\n// district's border along with each boundary feature's neighbors. Hence, this\n// requires a contiguity graph with the lengths of shared edges between features\n// precomputed.\n//\n// NOTE - I can write up (if not implement) the logic for determining what shapes\n// constitute a district's boundary. There are a few nuances.\n//\n// If we have to optimize like this when we generalize to mixed maps, the\n// determination of \"neighbors in the map\" and the length of shared borders\n// (for determining a district perimeters) becomes more complicated and dynamic.\n//\n// NOTE - Again, I can write up (if not implement) the logic for both of these.\n// They are a bit tricky and require special preprocessing of the summary level\n// hierarchy (which I also have a script for that we can repurpose).\n","//\n// EQUAL POPULATION\n//\n\nimport * as T from './types'\nimport * as U from './utils';\nimport * as S from './settings';\n\nimport * as D from './_data'\nimport { AnalyticsSession } from './_api';\n\n\nexport function doPopulationDeviation(s: AnalyticsSession, bLog: boolean = false): T.TestEntry {\n let test = s.getTest(T.Test.PopulationDeviation) as T.TestEntry;\n\n // Compute the min, max, and average district populations,\n // excluding the dummy 'unassigned' 0 and N+1 summary \"districts.\"\n let totPopByDistrict = s.districts.statistics[D.DistrictField.TotalPop];\n totPopByDistrict = totPopByDistrict.slice(1, -1);\n\n let min = U.minArray(totPopByDistrict);\n let max = U.maxArray(totPopByDistrict);\n let total = U.sumArray(totPopByDistrict);\n\n // Calculate the raw population deviation.\n // The target size is the average population.\n let avg = total / s.state.nDistricts;\n let popDev = (max - min) / avg;\n\n // Round the raw value to the desired level of precision\n popDev = U.trim(popDev);\n\n // Populate the test entry\n test['score'] = popDev;\n test['details'] = { 'maxDeviation': max - min };\n\n // Populate the N+1 summary \"district\" in district.statistics\n let totalPop = s.districts.statistics[D.DistrictField.TotalPop];\n let popDevPct = s.districts.statistics[D.DistrictField.PopDevPct];\n let summaryRow = s.districts.numberOfRows() - 1;\n\n totalPop[summaryRow] = avg; // aka \"target size\"\n popDevPct[summaryRow] = popDev;\n\n return test;\n}\n\n// NOTE - This validity check is *derived* and depends on population deviation %\n// being computed (above) and normalized in test log & scorecard generation.\nexport function doHasEqualPopulations(s: AnalyticsSession, bLog: boolean = false): T.TestEntry {\n let test = s.getTest(T.Test.EqualPopulation) as T.TestEntry;\n\n // Get the normalized population deviation %\n let popDevTest = s.getTest(T.Test.PopulationDeviation);\n let popDevPct = popDevTest['score'] as number;\n let popDevNormalized: number = popDevTest['normalizedScore'] as number;\n\n // Populate the test entry\n if (popDevNormalized > 0) {\n test['score'] = true;\n }\n else {\n test['score'] = false;\n }\n test['details']['deviation'] = popDevPct;\n test['details']['thresholds'] = popDevTest['details']['scale'];\n\n // Populate the N+1 summary \"district\" in district.statistics\n let bEqualPop = s.districts.statistics[D.DistrictField.bEqualPop];\n let summaryRow = s.districts.numberOfRows() - 1;\n\n bEqualPop[summaryRow] = test['score'];\n\n return test;\n}\n","//\n// GEO-FEATURES UTILITIES\n//\n\nimport * as Poly from '@dra2020/poly';\n\nimport * as T from './types'\nimport * as U from './utils';\nimport * as S from './settings';\n\n\n// CARTESIAN SHIMS OVER 'POLY' FUNCTIONS\n\n// TODO - POLY: Confirm Cartesian calculations\nexport function gfArea(poly: any): number {\n let area: number = _polygonArea(poly);\n\n return area;\n}\n\n// Algorithm for the area of a simple/single planar polygon:\n// https://algorithmtutor.com/Computational-Geometry/Area-of-a-polygon-given-a-set-of-points/\n// https://mathopenref.com/coordpolygonarea2.html\n//\n// function polygonArea(X, Y, numPoints) \n// { \n// area = 0; // Accumulates area in the loop\n// j = numPoints-1; // The last vertex is the 'previous' one to the first\n\n// for (i=0; i<numPoints; i++)\n// { area = area + (X[j]+X[i]) * (Y[j]-Y[i]); \n// j = i; //j is previous vertex to i\n// }\n// return area/2;\n// }\n\n// Reimplemented to use polygons vs. X & Y vectors\nfunction _polygonSimpleArea(p: any): number {\n let area = 0; // Accumulates area in the loop\n let n = p.length;\n let j = n - 1; // The last vertex is the 'previous' one to the first\n\n for (let i = 0; i < n; i++) {\n area = area + (p[j][0] + p[i][0]) * (p[j][1] - p[i][1]);\n // area = area + (X[j] + X[i]) * (Y[j] - Y[i]);\n j = i; // j is previous vertex to i\n }\n return Math.abs(area / 2);\n}\n\n// Generalizes the above for MultiPolygons -- cloned from polyArea() in 'poly'\nfunction _polygonArea(poly: any): number {\n let polyOptions = { noLatitudeCorrection: true } // NO-OP?\n poly = Poly.polyNormalize(poly, polyOptions); // TODO - POLY: Discuss w/ Terry\n\n let a: number = 0;\n\n // A MultiPolygon is a set of polygons\n for (let i: number = 0; poly && i < poly.length; i++) {\n // A single polygon is an exterior ring with interior holes. Holes are subtracted.\n let p = poly[i];\n for (let j: number = 0; j < p.length; j++) {\n let sp = p[j];\n a += _polygonSimpleArea(sp) * (j == 0 ? 1 : -1);\n }\n }\n\n return a;\n}\n\n// TODO - POLY: Confirm Cartesian calculations w/ Terry\n// The perimeter calculation already just computes cartesian distance if you\n// pass in the noLatitudeCorrection flag. You would need to divide by \n// Poly.EARTH_RADIUS to go from the returned units of meters to Lat/Lon “units”.\n\nexport function gfPerimeter(poly: any): number {\n let perimeter: number = _polygonPerimeter(poly);\n\n return perimeter;\n}\n\n// TODO - POLY: Confirm Cartesian calculations w/ Terry\n// Cloned from polyPerimeter() in 'poly' and revised to use Cartesian distance\n// NOTE: No conversion of degrees to radians!\nfunction _polygonPerimeter(poly: any): number {\n let polyOptions = { noLatitudeCorrection: true } // Cartesian distance\n poly = Poly.polyNormalize(poly, polyOptions);\n\n let perimeter: number = 0;\n for (let i: number = 0; poly && i < poly.length; i++) {\n // Ignore holes so only look at first polyline\n let p: any = poly[i][0];\n for (let j: number = 0; j < p.length - 1; j++)\n perimeter += _distance(p[j][0], p[j][1], p[j + 1][0], p[j + 1][1]);\n\n if (p.length > 2 && (p[0][0] != p[p.length - 1][0] || p[0][1] != p[p.length - 1][1]))\n perimeter += _distance(p[0][0], p[0][1], p[p.length - 1][0], p[p.length - 1][1]);\n }\n\n return perimeter;\n}\n\nfunction _distance(x1: number, y1: number, x2: number, y2: number): number {\n let dLat = y2 - y1;\n let dLon = x2 - x1;\n let d: number;\n\n d = Math.sqrt((dLat * dLat) + (dLon * dLon));\n\n return d;\n}\n\n// TODO - POLY: Confirm Cartesian calculations w/ Terry\n// As I mentioned, the polyCircle code was already just treating the coordinate\n// system as Cartesian. I then did polyFromCircle to convert it to a polygon that\n// then could be passed to polyArea in order to take into account the projection.\n// If instead, you compute area directly from the circle as PI R squared, then\n// you should have your cartesian circular area.\n\nexport function gfDiameter(poly: any): number {\n let polyOptions = { noLatitudeCorrection: true } // NO-OP\n\n let circle = Poly.polyToCircle(poly, polyOptions) as Poly.Circle;\n let diameter: number = circle.r * 2;\n\n return diameter;\n}\n","//\n// THE DISTRICT-ANALYTICS NODE PACKAGE API\n//\n\nexport * from './_api';\nexport * from './_data';\nexport * from './results';\nexport * from './types';\n","//\n// PROTECTS MINORITIES\n//\n\nimport * as T from './types'\nimport * as U from './utils';\nimport * as S from './settings';\n\nimport { AnalyticsSession } from './_api';\n\nimport demographicDefs from '../static/demographic-defns.json';\nimport majorityMinority from '../static/majority-minority.json';\nimport stateContacts from '../static/state-contacts.json';\nimport vraSection5 from '../static/vra5-preclearance.json';\n\nexport function doMajorityMinorityDistricts(s: AnalyticsSession, bLog: boolean = false): T.TestEntry {\n let test = s.getTest(T.Test.MajorityMinorityDistricts) as T.TestEntry;\n\n if (bLog) console.log(\"TODO - Calculating # of majority-minority districts ...\");\n\n return test;\n}\n\n\n// Sources for majority-minority info:\n// - https://en.wikipedia.org/wiki/List_of_majority-minority_United_States_congressional_districts\n// TODO - 2020: Update/revise this, when the update comes out in September:\n// - http://www.ncsl.org/Portals/1/Documents/Redistricting/Redistricting_2010.pdf\n","//\n// FAIR/PROPORTIONAL\n//\n\nimport { strict as assert } from 'assert';\n\nimport * as T from './types'\nimport * as U from './utils';\nimport * as S from './settings';\n\nimport * as D from './_data'\nimport { AnalyticsSession } from './_api';\n\n// Partisan analytics need the following data:\n//\n// An \"election model\" by geo_id, where each item has 4 pieces of data:\n//\n// { geo_id, Democratic votes, Republican votes, Total votes }\n//\n// NOTE: D + R <= Total, because there could be third-party or write-in votes.\n//\n// An election model can simply represent one election, e.g., President 2012,\n// or combine multiple elections in some fashion. An election model is used to\n// computer a single index of the likely partisan weight / lean / preference\n// for the districts in a plan. An election model and the associated index go\n// hand in hand. So much so that the index frequently stands in as the name for\n// both, e.g., Cook's PVI is one example, Nagle's 7s, Hofeller's Formula, NDRC's\n// DPI.\n//\n// I'm labelling this general concept a \"Voter Preference Index (VPI),\" a\n// conscious +1 letter play on Cook's \"PVI\" acronymn.\n\n\n// MEASURING BIAS & RESPONSIVENESS (NAGLE'S METHOD)\n\nexport function doSeatsBias(s: AnalyticsSession, bLog: boolean = false): T.TestEntry {\n let test = s.getTest(T.Test.SeatsBias) as T.TestEntry;\n\n if (bLog) console.log(\"TODO - Calculating seats bias ...\");\n\n return test;\n}\n\nexport function doVotesBias(s: AnalyticsSession, bLog: boolean = false): T.TestEntry {\n let test = s.getTest(T.Test.VotesBias) as T.TestEntry;\n\n if (bLog) console.log(\"TODO - Calculating votes bias ...\");\n\n return test;\n}\n\nexport function doResponsiveness(s: AnalyticsSession, bLog: boolean = false): T.TestEntry {\n let test = s.getTest(T.Test.Responsiveness) as T.TestEntry;\n\n if (bLog) console.log(\"TODO - Calculating responsiveness ...\");\n\n return test;\n}\n\nexport function doResponsiveDistricts(s: AnalyticsSession, bLog: boolean = false): T.TestEntry {\n let test = s.getTest(T.Test.ResponsiveDistricts) as T.TestEntry;\n\n if (bLog) console.log(\"TODO - Calculating # of responsive districts ...\");\n\n return test;\n}\n\n\n// OTHER MEASURES OF PARTISAN BIAS\n\n// TODO - PARTISAN: This formula might need to be inverted for D vs. R +/-\n// TODO - Normalize the results.\nexport function doEfficiencyGap(s: AnalyticsSession, bLog: boolean = false): T.TestEntry {\n if (bLog) console.log(\"TODO - Calculating the efficiency gap ...\");\n\n let test = s.getTest(T.Test.EfficiencyGap) as T.TestEntry;\n\n // Get partisan statistics by districts.\n // Use Democratic votes, seats, and shares by convention.\n let DVotes = s.districts.statistics[D.DistrictField.DemVotes];\n let DSeats = s.districts.statistics[D.DistrictField.DemSeat];\n let TPVotes = s.districts.statistics[D.DistrictField.TwoPartyVote];\n\n // Exclude the dummy unassigned '0' and N+1 summary \"districts\"\n DVotes = DVotes.slice(1, -1);\n DSeats = DSeats.slice(1, -1);\n TPVotes = TPVotes.slice(1, -1);\n\n // Calculate D vote share & D seat share\n let DVoteShare = U.sumArray(DVotes) / U.sumArray(TPVotes);\n let DSeatShare = U.sumArray(DSeats) / s.state.nDistricts;\n\n // Finally, calculate the Efficiency Gap\n let efficiencyGap = (DSeatShare - 0.5) - (2.0 * (DVoteShare - 0.5));\n\n // Round the raw value to the desired level of precision\n efficiencyGap = U.trim(efficiencyGap);\n\n // Populate the test entry\n test['score'] = efficiencyGap;\n // test['normalizedScore'] = 0; /* TODO - Normalize the raw score */\n test['details'] = {}; /* TODO - Add details, if any */\n\n return test;\n}\n\n\n// HELPERS\n\nexport function fptpWin(demPct: number): number {\n // Vote shares should be fractions in the range [0.0 – 1.0]\n assert((demPct <= 1.0) && (demPct >= 0.));\n\n return ((demPct > 0.5) ? 1 : 0);\n}\n","//\n// PREPROCESS DATA\n//\n\nimport * as T from './types'\nimport * as U from './utils';\nimport * as S from './settings';\n\nimport * as D from './_data'\nimport { AnalyticsSession } from './_api';\n\n\n// NOTE - Do preprocessing separately, so the constructor returns quickly.\nexport function doPreprocessData(s: AnalyticsSession, bLog: boolean = false): void {\n // If necessary, do one-time preprocessing\n if (!s.bOneTimeProcessingDone) {\n doPreprocessCountyFeatures(s, bLog);\n doPreprocessCensus(s, bLog);\n doPreprocessElection(s, bLog);\n s.bOneTimeProcessingDone = true;\n }\n\n // NOTE - UNASSIGNED: Made both the planByGeoID & DistrictID are right\n // Invert the plan by district ID\n s.plan.invertPlan();\n\n // Create a map of geoIDs to feature IDs\n s.features.mapGeoIDsToFeatureIDs();\n}\n\n// CREATE A FIPS CODE TO COUNTY NAME LOOKUP\n\nfunction doPreprocessCountyFeatures(s: AnalyticsSession, bLog: boolean = false): void {\n for (let i: number = 0; i < s.counties.nCounties; i++) {\n\n let county = s.counties.countyByIndex(i);\n\n let fips = s.counties.propertyForCounty(county, 'COUNTYFP');\n let name = s.counties.propertyForCounty(county, 'NAME');\n\n s.counties.mapFIPSToName(fips, name);\n }\n}\n\n\n// ANALYZE THE CENSUS BY COUNTY\n\nfunction doPreprocessCensus(s: AnalyticsSession, bLog: boolean = false): void {\n // The county-splitting analytic needs the following info, using NC as an example:\n // '_stateTotal' = The total state population, e.g., 9,535,483 for NC's 2010 Census\n // 'totalByCounty' = The total population by county FIPS code\n\n // SUM TOTAL POPULATION BY COUNTY\n\n let totalByCounty: T.GeoIDTotal = {};\n\n // NOTE - This works w/o GEOIDs, because you're looping over all features.\n for (let i: number = 0; i < s.features.nFeatures(); i++) {\n let f: T.GeoFeature = s.features.featureByIndex(i);\n let geoID: string = s.features.geoIDForFeature(f);\n // Skip water-only features\n if (!(U.isWaterOnly(geoID))) {\n let value: number = s.features.fieldForFeature(f, D.Dataset.CENSUS, D.FeatureField.TotalPop);\n\n // Sum total population across the state\n s.state.totalPop += value;\n\n // Get the county FIPS code for the feature\n let county = U.parseGeoID(geoID)['county'] as string;\n let countyFIPS = U.getFIPSFromCountyGeoID(county);\n // If a subtotal for the county doesn't exist, initialize one\n if (!(U.keyExists(countyFIPS, totalByCounty))) {\n totalByCounty[countyFIPS] = 0;\n }\n // Sum total population by county\n totalByCounty[countyFIPS] += value;\n }\n // else {\n // console.log(\"Skipping water-only feature in Census preprocessing:\", geoID);\n // }\n }\n // NOTE - The above could be replaced, if I got totals on county.geojson.\n\n\n // CREATE A FIPS CODE-ORDINAL MAP\n\n // Get the county FIPS codes\n let fipsCodes = U.getObjectKeys(totalByCounty);\n // Sort the results\n fipsCodes = fipsCodes.sort();\n\n // NOTE - SPLITTING\n // Add a dummy county, for county-district splitting analysis\n fipsCodes.unshift('000');\n\n // Create the ID-ordinal map\n for (let i in fipsCodes) {\n s.counties.index[fipsCodes[i]] = Number(i);\n }\n\n\n // MAKE AN ARRAY OF TOTAL POPULATIONS BY COUNTY INDEX\n\n // Add an extra 0th virtual county bucket for county-district splitting analysis \n let nCountyBuckets = s.counties.nCounties + 1;\n let countyTotals: number[] = U.initArray(nCountyBuckets, 0);\n\n for (let fipsCode in totalByCounty) {\n let i = s.counties.indexFromFIPS(fipsCode);\n\n countyTotals[i] = totalByCounty[fipsCode];\n }\n\n s.counties.totalPopulation = countyTotals;\n\n\n // ANALYZE THE COUNTIES\n\n // 'target_size': 733499, # calc as total / districts\n let targetSize = Math.round(s.state.totalPop / s.state.nDistricts);\n\n // Find counties that are bigger than the target district size.\n // 'too_big' = The counties that are bigger than a district, e.g., ['Mecklenburg', 'Wake']\n // 'too_big_fips' = Their FIPS codes, e.g., ['119', '183']\n // 'expected_splits' = The # of counties that are bigger than a single district, e.g., 2\n // 'expected_affected' = The # of people whose district must be split, e.g., 353,623\n\n let tooBigFIPS = [];\n let tooBigName = [];\n let expectedSplits = 0;\n let expectedAffected = 0;\n\n // Loop over the counties\n for (let county in fipsCodes) {\n let fipsCode = fipsCodes[county];\n\n // NOTE - SPLITTING\n // Skip the dummy county\n if (fipsCode == '000') continue;\n\n let countyAffected = 0;\n\n // Find the number of required splits, assuming target district size.\n let rawQuotient = totalByCounty[fipsCode] / (targetSize + 1);\n let remainder = rawQuotient % 1;\n let quotient = rawQuotient - remainder;\n let countySplits = quotient;\n\n if (countySplits > 0) {\n countyAffected = totalByCounty[fipsCode] % targetSize;\n tooBigFIPS.push(fipsCode);\n tooBigName.push(s.counties.nameFromFIPS(fipsCode));\n }\n\n expectedSplits += countySplits;\n expectedAffected += countyAffected;\n }\n\n s.state.tooBigFIPS = tooBigFIPS;\n s.state.tooBigName = tooBigName;\n s.state.expectedSplits = expectedSplits;\n s.state.expectedAffected = expectedAffected;\n}\n\n\n// PREPROCESS ELECTION RESULTS\n\nfunction doPreprocessElection(s: AnalyticsSession, bLog: boolean = false): void {\n if (bLog) console.log(\"TODO - Preprocessing election data ...\");\n}\n\n","//\n// TEMPLATES FOR UNFORMATTED ANALYTICS RESULTS\n// \n\nimport * as T from './types'\nimport * as U from './utils';\nimport * as S from './settings';\n\nimport * as D from './_data'\nimport { AnalyticsSession } from './_api';\nimport { doDeriveSecondaryTests } from './analyze';\n\nimport allStateReqs from '../static/state-reqs.json';\nimport stateNames from '../static/state-names.json';\n\n// PLAN ANALYTICS\n\nexport type RequirementsCategory = {\n score: T.TriState;\n metrics: {\n complete: T.TriState;\n contiguous: T.TriState;\n freeOfHoles: T.TriState;\n equalPopulation: T.TriState;\n };\n details: {\n unassignedFeatures: string[]; // A possibly empty list of GEOIDs\n emptyDistricts: number[]; // A possibly empty list of district IDs\n discontiguousDistricts: number[]; // Ditto\n embeddedDistricts: number[]; // Ditto\n populationDeviation: number; // A fraction [0.0 – 1.0] to represent as a %\n deviationThreshold: number; // A fraction [0.0 – 1.0] to represent as a % \n };\n datasets: T.Datasets;\n resources: {\n stateReqs: string;\n };\n};\n\nexport type CompactnessCategory = {\n score: number; // An integer score [0–100]\n metrics: {\n reock: number; // A decimal number [0.0–1.0]\n polsby: number; // A decimal number [0.0–1.0]\n };\n details: {\n // None at this time\n };\n datasets: T.Datasets;\n resources: {\n // None at this time\n };\n};\n\nexport type SplittingCategory = {\n score: number; // An integer score [0–100]\n metrics: {\n sqEnt_DCreduced: number, // A decimal number [1.0 – < 2.0]\n sqEnt_CDreduced: number // A decimal number [1.0 – < 2.0]\n };\n details: {\n countiesSplitUnexpectedly: string[], // A possibly empty list of county names\n unexpectedAffected: number, // A fraction [0.0 – 1.0] to represent as a %\n nSplitVTDs: number, // An integer, possibly 0\n splitVTDs: string[] // A possibly empty list of GEOIDs\n };\n datasets: T.Datasets;\n resources: {\n // None at this time\n };\n};\n\n// TODO - PARTISAN: This category is still under development.\n// We haven't settled on metrics yet. This is just an example.\nexport type PartisanCategory = {\n score: number; // An integer score [0–100]\n metrics: {\n partisanBias: 0.15, // TBD\n responsiveness: 2.0 // TBD\n };\n details: {\n // TODO - Need to flesh this out\n };\n datasets: T.Datasets;\n resources: {\n planScore?: string;\n };\n};\n\n// TODO - MINORITY: This category is still under development.\n// We haven't settled on metrics yet. This is just a (likely) example.\nexport type MinorityCategory = {\n score: null; // Explicitly NOT scored\n metrics: {\n nBlack37to50: number, // Integer >= 0; two-digit maximum\n nBlackMajority: number, // Ditto\n nHispanic37to50: number, // Ditto\n nHispanicMajority: number, // Ditto\n nPacific37to50: number, // Ditto\n nPacificMajority: number, // Ditto\n nAsian37to50: number, // Ditto\n nAsianMajority: number, // Ditto\n nNative37to50: number, // Ditto\n nNativeMajority: number, // Ditto\n nMinority37to50: number, // Ditto\n nMinorityMajority: number, // Ditto\n\n averageDVoteShare: number // A fraction [0.0 – 1.0] to represent as a %\n };\n details: {\n vap: true, // true = using VAP data; false = CVAP data\n comboCategories: true // true = using combo fields; false = mutually exclusive\n };\n datasets: T.Datasets;\n resources: {\n // TODO - Add these ...\n };\n};\n\nexport type PlanAnalytics = {\n requirements: RequirementsCategory;\n compactness: CompactnessCategory;\n // TODO - Don't show these categories yet\n splitting: SplittingCategory;\n partisan: PartisanCategory;\n minority: MinorityCategory;\n}\n\n\n// Example\n\nlet sampleRequirements: RequirementsCategory = {\n score: T.TriState.Red,\n metrics: {\n complete: T.TriState.Green,\n contiguous: T.TriState.Red,\n freeOfHoles: T.TriState.Yellow,\n equalPopulation: T.TriState.Red\n },\n details: {\n unassignedFeatures: [],\n emptyDistricts: [],\n discontiguousDistricts: [2],\n embeddedDistricts: [],\n populationDeviation: 0.6748,\n deviationThreshold: 0.75 / 100\n },\n datasets: {\n census: \"2010 Census Total Population\"\n },\n resources: {\n stateReqs: \"https://www.brennancenter.org/sites/default/files/publications/2019_06_50States_FINALsinglepages_20.pdf\"\n }\n}\n\nlet sampleCompactness: CompactnessCategory = {\n score: 60,\n metrics: {\n reock: 0.3773,\n polsby: 0.3815\n },\n details: {},\n datasets: {\n shapes: \"2010 VTD shapes\"\n },\n resources: {}\n}\n\nlet sampleSplitting: SplittingCategory = {\n score: 73,\n metrics: {\n sqEnt_DCreduced: 1.531,\n sqEnt_CDreduced: 1.760\n },\n details: {\n countiesSplitUnexpectedly: [\n \"Bladen\", \"Buncombe\", \"Catawba\", \"Cumberland\", \"Durham\", \"Guilford\", \"Iredell\", \"Johnston\", \"Pitt\", \"Rowan\", \"Wilson\"\n ],\n unexpectedAffected: 0.3096,\n nSplitVTDs: 12,\n splitVTDs: [\"VTD-01\", \"VTD-02\", \"VTD-03\", \"VTD-04\", \"VTD-05\", \"VTD-06\", \"VTD-07\", \"VTD-08\", \"VTD-09\", \"VTD-10\", \"VTD-11\", \"VTD-12\"]\n },\n datasets: {},\n resources: {}\n}\n\n// TODO - PARTISAN: This category is still being fleshed out.\nlet samplePartisan: PartisanCategory = {\n score: 100,\n metrics: {\n partisanBias: 0.15,\n responsiveness: 2.0\n },\n details: {},\n datasets: {\n election: \"2016 Presidential, US Senate, Governor, and AG election results\"\n },\n resources: {\n planScore: \"https://planscore.org/plan.html?20180219T202039.596761160Z\"\n }\n}\n\n// TODO - MINORITY: This category is still being fleshed out.\nlet sampleMinority: MinorityCategory = {\n score: null,\n metrics: {\n nBlack37to50: 1,\n nBlackMajority: 12,\n nHispanic37to50: 0,\n nHispanicMajority: 0,\n nPacific37to50: 0,\n nPacificMajority: 0,\n nAsian37to50: 0,\n nAsianMajority: 0,\n nNative37to50: 0,\n nNativeMajority: 0,\n nMinority37to50: 0,\n nMinorityMajority: 0,\n\n averageDVoteShare: 0.90\n },\n details: {\n vap: true,\n comboCategories: true\n },\n datasets: {\n vap: \"2010 Voting Age Population\"\n },\n resources: {}\n}\n\nexport const samplePlanAnalytics: PlanAnalytics = {\n requirements: sampleRequirements,\n compactness: sampleCompactness,\n // TODO - Don't show these categories yet\n splitting: sampleSplitting,\n partisan: samplePartisan,\n minority: sampleMinority\n}\n\nexport function preparePlanAnalytics(s: AnalyticsSession, bLog: boolean = false): PlanAnalytics {\n if (!(s.bPostProcessingDone)) {\n doAnalyzePostProcessing(s);\n }\n\n // REQUIREMENTS CATEGORY\n let paRequirements: RequirementsCategory;\n\n {\n let completeTest = s.getTest(T.Test.Complete) as T.TestEntry;\n let contiguousTest = s.getTest(T.Test.Contiguous) as T.TestEntry;\n let freeOfHolesTest = s.getTest(T.Test.FreeOfHoles) as T.TestEntry;\n let equalPopulationTest = s.getTest(T.Test.EqualPopulation) as T.TestEntry;\n\n // Combine individual checks into an overall score\n\n // TODO - DASHBOARD: Until we add three-state support top to bottom in\n // requirements/validations, map booleans to tri-states here.\n let completeMetric = U.mapBooleanToTriState(completeTest['score'] as boolean);\n let contiguousMetric = U.mapBooleanToTriState(contiguousTest['score'] as boolean);\n let freeOfHolesMetric = U.mapBooleanToTriState(freeOfHolesTest['score'] as boolean);\n let equalPopulationMetric = U.mapBooleanToTriState(equalPopulationTest['score'] as boolean);\n\n let reqScore: T.TriState = T.TriState.Green;\n let checks = [completeMetric, contiguousMetric, freeOfHolesMetric, equalPopulationMetric];\n if (checks.includes(T.TriState.Yellow)) reqScore = T.TriState.Yellow;\n if (checks.includes(T.TriState.Red)) reqScore = T.TriState.Red;\n\n // Get values to support details entries\n let unassignedFeaturesDetail = U.deepCopy(completeTest['details']['unassignedFeatures']) || [];\n let emptyDistrictsDetail = U.deepCopy(completeTest['details']['emptyDistricts']) || [];\n let discontiguousDistrictsDetail = U.deepCopy(contiguousTest['details']['discontiguousDistricts']) || [];\n let embeddedDistrictsDetail = U.deepCopy(freeOfHolesTest['details']['embeddedDistricts']) || [];\n\n let populationDeviationDetail = U.deepCopy(equalPopulationTest['details']['deviation']);\n let deviationThresholdDetail = U.trim(s.populationDeviationThreshold());\n\n let xx: string = s.state.xx;\n // TODO - JSON: Is there a better / easier way to work with the variable?\n let stateReqsDict: T.Dict = allStateReqs;\n let reqLinkToStateReqs: string = stateReqsDict[xx];\n\n // Populate the category\n paRequirements = {\n score: reqScore,\n metrics: {\n complete: completeMetric,\n contiguous: contiguousMetric,\n freeOfHoles: freeOfHolesMetric,\n equalPopulation: equalPopulationMetric\n },\n details: {\n unassignedFeatures: unassignedFeaturesDetail,\n emptyDistricts: emptyDistrictsDetail,\n discontiguousDistricts: discontiguousDistrictsDetail,\n embeddedDistricts: embeddedDistrictsDetail,\n populationDeviation: populationDeviationDetail,\n deviationThreshold: deviationThresholdDetail\n },\n datasets: {\n census: U.deepCopy(s.config['descriptions']['CENSUS']),\n },\n resources: {\n stateReqs: reqLinkToStateReqs\n }\n }\n }\n\n // COMPACTNESS CATEGORY\n let paCompactness: CompactnessCategory;\n {\n let reockWeight = 0.5;\n let polsbyWeight = 1.0 - reockWeight;\n\n let reockTest = s.getTest(T.Test.Reock) as T.TestEntry;\n let polsbyTest = s.getTest(T.Test.PolsbyPopper) as T.TestEntry;\n\n let normalizedReock = reockTest['normalizedScore'] as number;\n let normalizedPolsby = reockTest['normalizedScore'] as number;\n let compactnessScore = U.trim((reockWeight * normalizedReock) + (polsbyWeight * normalizedPolsby), 0);\n\n let reockMetric = U.deepCopy(reockTest['score'] as number);\n let polsbyMetric = U.deepCopy(polsbyTest['score'] as number);\n\n // Populate the category\n paCompactness = {\n score: compactnessScore,\n metrics: {\n reock: reockMetric,\n polsby: polsbyMetric\n },\n details: {\n // None at this time\n },\n datasets: {\n // NOTE - DATASETS\n shapes: U.deepCopy(s.config['descriptions']['SHAPES'])\n // shapes: \"2010 VTD shapes\"\n },\n resources: {\n // None at this time\n }\n }\n }\n\n // SPLITTING CATEGORY\n\n let paSplitting: SplittingCategory\n\n {\n let unexpectedCountySplittingTest = s.getTest(T.Test.UnexpectedCountySplits) as T.TestEntry;\n let VTDSplitsTest = s.getTest(T.Test.VTDSplits) as T.TestEntry;\n let countySplittingTest = s.getTest(T.Test.CountySplitting) as T.TestEntry;\n let districtSplittingTest = s.getTest(T.Test.DistrictSplitting) as T.TestEntry;\n\n let unexpectedAffectedMetric = U.deepCopy(unexpectedCountySplittingTest['score']);\n let countiesSplitUnexpectedlyDetail = U.deepCopy(unexpectedCountySplittingTest['details']['countiesSplitUnexpectedly']);\n\n let nVTDSplitsMetric = U.deepCopy(VTDSplitsTest['score']);\n let splitVTDsDetail = U.deepCopy(VTDSplitsTest['details']['splitVTDs']);\n\n let SqEnt_DCreducedMetric = U.deepCopy(countySplittingTest['score']);\n let SqEnt_CDreducedMetric = U.deepCopy(districtSplittingTest['score']);\n\n let countySplittingNormalized = countySplittingTest['normalizedScore'] as number;\n let districtSplittingNormalized = districtSplittingTest['normalizedScore'] as number;\n let splittingScore = U.trim((S.COUNTY_SPLITTING_WEIGHT * countySplittingNormalized) +\n + (S.DISTRICT_SPLITTING_WEIGHT * districtSplittingNormalized), 0);\n\n paSplitting = {\n score: splittingScore,\n metrics: {\n sqEnt_DCreduced: SqEnt_DCreducedMetric,\n sqEnt_CDreduced: SqEnt_CDreducedMetric\n // NOTE - The un-reduced raw values\n // sqEnt_DC : SqEnt_DCMetric,\n // sqEnt_CD : SqEnt_CDMetric\n },\n details: {\n countiesSplitUnexpectedly: countiesSplitUnexpectedlyDetail,\n unexpectedAffected: unexpectedAffectedMetric,\n nSplitVTDs: nVTDSplitsMetric,\n splitVTDs: splitVTDsDetail\n },\n datasets: {\n // None at this time\n },\n resources: {\n // None at this time\n }\n }\n }\n\n // PARTISAN CATEGORY\n //\n // TODO - PARTISAN: This category is still being fleshed out. Just an example below.\n let paPartisan: PartisanCategory;\n\n {\n paPartisan = {\n score: 100,\n metrics: {\n partisanBias: 0.15,\n responsiveness: 2.0\n },\n details: {},\n datasets: {\n election: \"2016 Presidential, US Senate, Governor, and AG election results\"\n },\n resources: {\n planScore: \"https://planscore.org/plan.html?20180219T202039.596761160Z\"\n }\n }\n }\n\n // MINORITY CATEGORY\n //\n // TODO - MINORITY: This category is still being fleshed out. Just an example below.\n let paMinority: MinorityCategory;\n\n {\n paMinority = {\n score: null,\n metrics: {\n nBlack37to50: 1,\n nBlackMajority: 12,\n nHispanic37to50: 0,\n nHispanicMajority: 0,\n nPacific37to50: 0,\n nPacificMajority: 0,\n nAsian37to50: 0,\n nAsianMajority: 0,\n nNative37to50: 0,\n nNativeMajority: 0,\n nMinority37to50: 0,\n nMinorityMajority: 0,\n\n averageDVoteShare: 0.90\n },\n details: {\n vap: true,\n comboCategories: true\n },\n datasets: {\n vap: \"2010 Voting Age Population\"\n },\n resources: {}\n }\n }\n\n // PLAN ANALYTICS\n let pa: PlanAnalytics = {\n requirements: paRequirements,\n compactness: paCompactness,\n // TODO - Not implemented yet\n splitting: paSplitting,\n partisan: paPartisan,\n minority: paMinority\n }\n\n return pa;\n}\n\n\n// DISTRICT STATISTICS\n\n// Indexes for the fields in the rows of the DistrictStatistics table\nexport const enum DistrictColumn { // Column headers:\n DistrictID, // 'ID'\n TotalPop, // 'Total'\n PopDevPct, // 'Δ%'\n bEqualPop, // Don't display. Use this to conditionally color PopDevPct.\n bNotEmpty, // Don't display. TotalPop = 0 shows empty districts.\n bContiguous, // Some TBD glyph suggesting contiguity\n bNotEmbedded, // Some TBD glyph suggesting embedded\n DemPct, // 'Dem'\n RepPct, // 'Rep'\n WhitePct, // 'White'\n MinorityPct, // 'Minority'\n BlackPct, // 'Black'\n HispanicPct, // 'Hispanic'\n PacificPct, // 'Pacific'\n AsianPct, // 'Asian'\n NativePct // 'Native\n}\n\nexport type DistrictRow = [\n number, // DistrictID\n number, // TotalPop\n number, // PopDevPct\n T.TriState | null, // bEqualPop\n T.TriState | null, // bNotEmpty\n T.TriState | null, // bContiguous\n T.TriState | null, // bNotEmbedded\n number, // DemPct\n number, // RepPct\n number, // WhitePct\n number, // MinorityPct\n number, // BlackPct\n number, // HispanicPct\n number, // PacificPct\n number, // AsianPct\n number // NativePct\n];\n\nexport type DistrictStatistics = {\n table: DistrictRow[];\n details: {}; // None at this time\n datasets: T.Datasets;\n resources: {}; // None at this time\n}\n\n// Example\n\nexport const sampleDistrictStatistics: DistrictStatistics = {\n table: [\n // District 0 is the dummy unassigned district\n [0, 0, 0, null, null, null, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n [1, 653133, -0.0950, T.TriState.Green, T.TriState.Red, T.TriState.Green, T.TriState.Green, 0.4177, 0.5823, 0.8631, 0.1369, 0.0734, 0.0360, 0.0009, 0.0235, 0.0064],\n [2, 620961, -0.1396, T.TriState.Green, T.TriState.Red, T.TriState.Red, T.TriState.Green, 0.8820, 0.1180, 0.3129, 0.6871, 0.6169, 0.0391, 0.0013, 0.0310, 0.0099],\n [3, 971777, 0.3465, T.TriState.Green, T.TriState.Red, T.TriState.Green, T.TriState.Green, 0.7261, 0.2739, 0.5174, 0.4826, 0.1745, 0.1572, 0.0020, 0.1531, 0.0090],\n [4, 863420, 0.1964, T.TriState.Green, T.TriState.Red, T.TriState.Green, T.TriState.Green, 0.8957, 0.1043, 0.1734, 0.8266, 0.6489, 0.1348, 0.0020, 0.0496, 0.0127],\n [5, 805029, 0.1155, T.TriState.Green, T.TriState.Red, T.TriState.Green, T.TriState.Yellow, 0.5743, 0.4257, 0.6587, 0.3413, 0.2494, 0.0363, 0.0012, 0.0536, 0.0081],\n [6, 824741, 0.1428, T.TriState.Green, T.TriState.Red, T.TriState.Green, T.TriState.Red, 0.5341, 0.4659, 0.7045, 0.2955, 0.1619, 0.0526, 0.0018, 0.0782, 0.0090],\n [7, 549714, -0.2383, T.TriState.Green, T.TriState.Green, T.TriState.Green, T.TriState.Green, 0.5025, 0.4975, 0.6906, 0.3094, 0.2468, 0.0319, 0.0013, 0.0258, 0.0111],\n [8, 484777, -0.3283, T.TriState.Green, T.TriState.Green, T.TriState.Green, T.TriState.Green, 0.4105, 0.5895, 0.8370, 0.1630, 0.1074, 0.0316, 0.0013, 0.0197, 0.0077],\n // District N+1 is the dummy state-summary district\n [9, 721694, 0.6748, T.TriState.Green, T.TriState.Red, T.TriState.Red, T.TriState.Red, 0.6293, 0.3707, 0.5722, 0.4278, 0.2925, 0.0729, 0.0015, 0.0618, 0.0093]\n ],\n details: {},\n datasets: {\n shapes: \"2010 VTD shapes\",\n census: \"2010 Census Total Population\",\n vap: \"2010 Voting Age Population\",\n election: \"2016 Presidential, US Senate, Governor, and AG election results\"\n },\n resources: {}\n}\n\n// Create a DistrictStatistics instance, deep copying the underlying values.\nexport function prepareDistrictStatistics(s: AnalyticsSession, bLog: boolean = false): DistrictStatistics {\n if (!(s.bPostProcessingDone)) {\n doAnalyzePostProcessing(s);\n }\n\n let dsTable: DistrictRow[] = [];\n for (let i = 0; i < s.districts.numberOfRows(); i++) {\n let rawRow = [\n i,\n s.districts.statistics[D.DistrictField.TotalPop][i],\n s.districts.statistics[D.DistrictField.PopDevPct][i],\n s.districts.statistics[D.DistrictField.bEqualPop][i],\n s.districts.statistics[D.DistrictField.bNotEmpty][i],\n s.districts.statistics[D.DistrictField.bContiguous][i],\n s.districts.statistics[D.DistrictField.bNotEmbedded][i],\n s.districts.statistics[D.DistrictField.DemPct][i],\n s.districts.statistics[D.DistrictField.RepPct][i],\n s.districts.statistics[D.DistrictField.WhitePct][i],\n s.districts.statistics[D.DistrictField.MinorityPct][i],\n s.districts.statistics[D.DistrictField.BlackPct][i],\n s.districts.statistics[D.DistrictField.HispanicPct][i],\n s.districts.statistics[D.DistrictField.PacificPct][i],\n s.districts.statistics[D.DistrictField.AsianPct][i],\n s.districts.statistics[D.DistrictField.NativePct][i]\n ];\n\n // TODO - DASHBOARD: Until we add three-state support top to bottom in\n // requirements/validations, map booleans to tri-states here.\n rawRow[DistrictColumn.bEqualPop] = U.mapBooleanToTriState(rawRow[DistrictColumn.bEqualPop]);\n rawRow[DistrictColumn.bNotEmpty] = U.mapBooleanToTriState(rawRow[DistrictColumn.bNotEmpty]);\n rawRow[DistrictColumn.bContiguous] = U.mapBooleanToTriState(rawRow[DistrictColumn.bContiguous]);\n rawRow[DistrictColumn.bNotEmbedded] = U.mapBooleanToTriState(rawRow[DistrictColumn.bNotEmbedded]);\n\n let readyRow: DistrictRow = U.deepCopy(rawRow);\n dsTable.push(readyRow);\n }\n\n let dsDetails = {\n // None at this time\n };\n\n let dsDatasets: T.Datasets = {\n shapes: \"2010 VTD shapes\",\n census: U.deepCopy(s.config['descriptions']['CENSUS']),\n vap: U.deepCopy(s.config['descriptions']['VAP']),\n election: U.deepCopy(s.config['descriptions']['ELECTION'])\n }\n\n let dsResources = {\n // None at this time\n };\n\n let ds: DistrictStatistics = {\n table: dsTable,\n details: dsDetails,\n datasets: dsDatasets,\n resources: dsResources\n };\n\n return ds;\n}\n\n\n// META-DATA FOR TESTS/ANALYTICS\n// \n// NOTE - This structure is a vestige of having created a metadata-driven\n// scorecard w/in district-analytics at first. It works for creating the\n// unstyled results structures, so it isn't a high priority to rationalize.\n\nenum TestType {\n PassFail,\n Percentage,\n Number\n}\n\nconst completeDefn: T.Dict = {\n ID: T.Test.Complete,\n name: \"Complete\",\n normalize: false,\n externalType: TestType.PassFail,\n suites: [T.Suite.Legal]\n};\n\nconst contiguousDefn: T.Dict = {\n ID: T.Test.Contiguous,\n name: \"Contiguous\",\n normalize: false,\n externalType: TestType.PassFail,\n suites: [T.Suite.Legal]\n};\n\nconst freeOfHolesDefn: T.Dict = {\n ID: T.Test.FreeOfHoles,\n name: \"Free of Holes\",\n normalize: false,\n externalType: TestType.PassFail,\n suites: [T.Suite.Legal]\n};\n\nconst equalPopulationDefn: T.Dict = {\n ID: T.Test.EqualPopulation,\n name: \"Equal Population\",\n normalize: false,\n externalType: TestType.PassFail,\n suites: [T.Suite.Legal]\n};\n\nconst populationDeviationDefn: T.Dict = {\n ID: T.Test.PopulationDeviation,\n name: \"Population Deviation\",\n normalize: true,\n externalType: TestType.Percentage,\n suites: [T.Suite.Legal, T.Suite.Best] // Both so EqualPopulation can be assessed\n};\n\nconst reockDefn: T.Dict = {\n ID: T.Test.Reock,\n name: \"Reock\",\n normalize: true,\n externalType: TestType.Number,\n suites: [T.Suite.Best]\n};\n\nconst polsbyPopperDefn: T.Dict = {\n ID: T.Test.PolsbyPopper,\n name: \"Polsby-Popper\",\n normalize: true,\n externalType: TestType.Number,\n suites: [T.Suite.Best]\n};\n\n// NOTE - SPLITTING\nconst unexpectedCountySplitsDefn: T.Dict = {\n ID: T.Test.UnexpectedCountySplits,\n name: \"Unexpected County Splits\",\n normalize: false,\n externalType: TestType.Percentage,\n suites: [T.Suite.Best]\n};\n\n// NOTE - SPLITTING\nconst VTDSplitsDefn: T.Dict = {\n ID: T.Test.VTDSplits,\n name: \"VTD Splits\",\n normalize: false,\n externalType: TestType.Number,\n suites: [T.Suite.Best]\n};\n\n// NOTE - SPLITTING\nconst countySplittingDefn: T.Dict = {\n ID: T.Test.CountySplitting,\n name: \"County Splitting\",\n normalize: true,\n externalType: TestType.Number,\n suites: [T.Suite.Best]\n};\n\n// NOTE - SPLITTING\nconst districtSplittingDefn: T.Dict = {\n ID: T.Test.DistrictSplitting,\n name: \"District Splitting\",\n normalize: true,\n externalType: TestType.Number,\n suites: [T.Suite.Best]\n};\n\nconst efficiencyGapDefn: T.Dict = {\n ID: T.Test.EfficiencyGap,\n name: \"Efficiency Gap\",\n normalize: false, // TODO - Normalize this!\n externalType: TestType.Percentage,\n suites: [T.Suite.Fair]\n};\n\n// A structure to hold test definitions\ntype TestDefns = {\n [category: number]: any;\n}\n\n// All the tests that have been defined (can be reported on)\nconst testDefns = {\n [T.Test.Complete]: completeDefn,\n [T.Test.Contiguous]: contiguousDefn,\n [T.Test.FreeOfHoles]: freeOfHolesDefn,\n [T.Test.EqualPopulation]: equalPopulationDefn,\n [T.Test.PopulationDeviation]: populationDeviationDefn,\n [T.Test.Reock]: reockDefn,\n [T.Test.PolsbyPopper]: polsbyPopperDefn,\n // NOTE - SPLITTING\n [T.Test.UnexpectedCountySplits]: unexpectedCountySplitsDefn,\n [T.Test.VTDSplits]: VTDSplitsDefn,\n [T.Test.CountySplitting]: countySplittingDefn,\n [T.Test.DistrictSplitting]: districtSplittingDefn,\n\n // TODO - More tests ...\n\n [T.Test.EfficiencyGap]: efficiencyGapDefn\n} as TestDefns;\n\n\n// NORMALIZE RAW ANALYTICS\n// Raw numeric analytics, such as population deviation, compactness, etc. are\n// normalized as part of creating a scorecard, so the code to normalize results\n// is encapsulated here.\n\n// Configure scale parameters for normalizing each raw test result.\n// Scales consist of a minimum & a maximum *raw* value. If the values get\n// inverted (to make bigger better), these will switch.\n// This process needs to be separate from the test configuration info above,\n// because some scales need access to the analytics session object.\nexport function doConfigureScales(s: AnalyticsSession): void {\n // Scale defn for PopulationDeviation\n const CDLimit = 0.75 / 100; // Deviation threshold for CD's\n const LDLimit = 10.00 / 100; // Deviation threshold for LD's\n\n const CDGoodEnough = 0.20 / 100;\n const LDGoodEnough = (CDGoodEnough / CDLimit) * LDLimit;\n const popDevScale = (s.legislativeDistricts) ? [1.0 - LDLimit, 1.0 - LDGoodEnough] : [1.0 - CDLimit, 1.0 - CDGoodEnough];\n // const scale = [1.0 - CDLimit, 1.0 - CDGoodEnough];\n\n s.testScales[T.Test.PopulationDeviation] = { scale: popDevScale, bInvertRaw: true };\n\n s.testScales[T.Test.Reock] = { scale: [0.25, 0.50] };\n s.testScales[T.Test.PolsbyPopper] = { scale: [0.10, 0.50] };\n\n const nDistricts = s.state.nDistricts;\n const nCounties = s.counties.nCounties;\n\n // NOTE - SPLITTING: Experiment w/ this multiplier. Only allowing the expected\n // number of county splits seems too stringent, empirically. \n const allowableCountySplitsMultiplier = 1.5;\n const nAllowableSplits = Math.min(allowableCountySplitsMultiplier * (nDistricts - 1));\n const countySplittingThreshold = ((nAllowableSplits * 1.71) + ((nCounties - nAllowableSplits) * 1.0)) / nCounties;\n const countySplittingScale = [1.0, countySplittingThreshold];\n s.testScales[T.Test.CountySplitting] = { scale: countySplittingScale, bInvertScaled: true };\n\n const districtSplittingThreshold = 1.5;\n const districtSplittingScale = [1.0, districtSplittingThreshold];\n s.testScales[T.Test.DistrictSplitting] = { scale: districtSplittingScale, bInvertScaled: true };\n\n // TODO - More analytics ...\n}\n\n// Postprocess analytics - Normalize numeric results and derive secondary tests.\n// Do this after analytics have been run and before preparing a test log or scorecard. \nexport function doAnalyzePostProcessing(s: AnalyticsSession, bLog: boolean = false): void {\n // Normalize the raw scores for all the numerics tests\n let testResults = U.getNumericObjectKeys(testDefns);\n\n for (let testID of testResults) {\n if (testDefns[testID]['normalize']) {\n let testResult = s.getTest(testID) as T.TestEntry;\n\n let rawScore = testResult['score'] as number;\n let normalizedScore: number;\n\n normalizedScore = U.normalize(rawScore, s.testScales[testID]);\n testResult['normalizedScore'] = normalizedScore;\n\n // Add the scale used to normalize the raw score to the details\n testResult['details']['scale'] = s.testScales[testID].scale;\n }\n }\n\n // Derive secondary tests\n doDeriveSecondaryTests(s, bLog);\n\n // Toggle the semaphore, so postprocessing isn't for both the testlog & scorecard\n s.bPostProcessingDone = true;\n}\n\n","//\n// GLOBAL CONSTANTS\n//\n\n// Keep four decimal places for fractions [0–1], i.e.,\n// keep two decimal places for %'s [0–100].\nexport const PRECISION: number = 4;\n\n// Normalized scores [0-100]\nexport const NORMALIZED_RANGE: number = 100;\n\n// The dummy district ID for features not assigned districts yet\nexport const NOT_ASSIGNED: number = 0;\n\n// TODO - DASHBOARD: Discuss w/ Dave\n// # of items to report as problematic (e.g., features, districts, etc.)\nexport const NUMBER_OF_ITEMS_TO_REPORT: number = 10;\n\n// The virtual geoID for \"neighbors\" in other states\nexport const OUT_OF_STATE: string = \"OUT_OF_STATE\";\n\n// \"Roughly equal\" = average census block size / 2\nconst AVERAGE_BLOCK_SIZE = 30;\nexport const EQUAL_TOLERANCE: number = AVERAGE_BLOCK_SIZE / 2;\n\n// County & district splitting weights\nexport const COUNTY_SPLITTING_WEIGHT = 0.8;\nexport const DISTRICT_SPLITTING_WEIGHT = 1.0 - COUNTY_SPLITTING_WEIGHT;\n","//\n// TYPE DEFINITIONS\n//\n\nimport * as geojson from 'geojson';\n\n// CONFIGURATION TYPES\n\n// Sets of analytics, to enable them to be turned on/off by the host.\nexport const enum Suite {\n Legal,\n Fair,\n Best\n} // as in \"best fair map\"\n\n// INPUT DATA TYPES\n\n// The SessionRequest specifies an analytics session\nexport type SessionRequest = {\n title: string;\n stateXX: string;\n nDistricts: number;\n legislativeDistricts: boolean;\n plan: PlanByGeoID;\n data: GeoFeatureCollection;\n districtShapes: GeoFeatureCollection;\n districtProperties: DistrictProperties;\n graph: ContiguityGraph;\n counties: GeoFeatureCollection;\n config: {}\n}\n\n// A Plan is a dict of geoID-districtID pairs indexed by geoID\nexport type PlanByGeoID = {\n [geoID: string]: number;\n}\n\n// A inverted Plan is a dict of districtID's with associated sets of geoID's\nexport type PlanByDistrictID = {\n // TODO - TERRY, why does this constructor need a <T> type specification?\n [districtID: number]: Set<string>;\n}\n\n// A map of geoIDs to feature IDs\nexport type FeaturesByGeoID = {\n [geoID: string]: number;\n}\n\n// The FIPS-codes-to-county-name map for a state\nexport type FIPSCodeToCountyNameMap = {\n [FIPSCode: string]: string;\n}\n\n// The FIPS to array ordinal map \nexport type FIPSToOrdinalMap = {\n [FIPSCode: string]: number;\n}\n\n// Shapes - following the declarations in dra-client/redistrictdata.ts\nexport type GeoFeature = geojson.Feature;\nexport type GeoFeatureArray = GeoFeature[];\nexport type GeoFeatureCollection = geojson.FeatureCollection;\nexport interface GeoFeatureMap {\n [geoID: string]: GeoFeature;\n}\n\n\n// NOTE - CONTIGUITY GRAPHS\n\n// Contiguity graph -- For each geoID, there's either:\n// a) a (new) unweighted list of neighbors; or\n// b) an (old) dictionary of neighbors, where the value for each\n// neighbor geoID key is the the length of the shared border.\nexport type ContiguityGraph = {\n [geoID: string]: UnweightedNeighbors | WeightedNeighbors;\n}\n\nexport type WeightedNeighbors = {\n [geoID: string]: number;\n}\n\nexport type UnweightedNeighbors = string[];\n\n\n// An election (model) captures three actual or composite vote totals:\n// DEM votes, REP votes, and TOTal votes, where DEM + REP <= TOT, because\n// of third-party candidates and write-in votes. IOW, the two-party vote is\n// DEM + REP.\nexport type VoteTriple = [number, number, number];\n\n// An index for accessing a vote triple\nexport const enum VoteType {\n Democratic,\n Republican,\n Total\n}\n\n// CONFIGURATION TYPES\n\n// Scale config values for an individual test\nexport type TestScale = {\n scale: Array<number>,\n bInvertRaw?: boolean,\n bInvertScaled?: boolean\n}\n\n// The scales for all the analytics & validations\n// Presently assigned as part of session initialization\n// Use the Tests enum below as the test index\nexport type TestScales = {\n [test: number]: TestScale;\n}\n\n\n// RETURN TYPES\n\nexport type TestEntry = {\n score?: number | boolean; // Specific to the test\n details: Dict; // Additional details\n normalizedScore?: number; // Normalized to [0–100] for graded tests\n}\n\n// District WIP captures a district-level result, indexed by districtID\nexport type DistrictWIP = {\n [districtID: number]: any;\n}\n\n// TODO - Revise this ...\n// Analytics & validations\nexport const enum Test {\n Complete,\n Contiguous,\n FreeOfHoles,\n EqualPopulation, // This is the legal/not legal assessment of the population \n PopulationDeviation, // deviation % (when legal, less is still better).\n Reock,\n PolsbyPopper,\n UnexpectedCountySplits,\n CountySplitting,\n DistrictSplitting,\n VTDSplits,\n\n // TODO - PARTISAN\n SeatsBias,\n VotesBias,\n Responsiveness,\n ResponsiveDistricts,\n EfficiencyGap,\n\n // TODO - MINORITY\n MajorityMinorityDistricts\n}\n\n// The analytics & validation entries for a plan\n// Use the Tests enum above as the test index\nexport type TestEntries = {\n [test: number]: TestEntry;\n}\n\n// DistrictProperties holds properties of district shapes, indexed by districtID\nexport type DistrictProperties = {\n [districtID: number]: any;\n}\n\n// For compactness calculations, we need 3 properties of each district shape:\nexport type DistrictShapeProperties = [number, number, number];\n\n// An index for accessing properties extracted from a district shape\nexport const enum DistrictShapeProperty {\n Area,\n Diameter,\n Perimeter\n}\n\n// HELPER TYPES\n\nexport type GeoIDParts = {\n state?: string;\n county?: string;\n tract?: string;\n bg?: string;\n block?: string;\n}\n\nexport type GeoIDTotal = {\n [geoID: string]: number;\n}\n\n// GENERIC TYPES\n\nexport type Dict = { [key: string]: any };\n\n\n// TYPES FOR RESULTS\n\nexport const enum TriState { // Sample interpretations:\n Green, // OK, Pass, Yes\n Yellow, // Warning, Maybe\n Red // Not OK, Fail, No\n}\n// NOTE - I'm using Green / Yellow / Red here, because the connotations are so\n// clear. But colors are just one way you might choose to render these 3 states.\n// Could be Check (Green), X (Red), or Warning symbol (Yellow) or combinations\n// of visual indicators. Some examples as comments below.\n\n// For associating datasets with notes in a category\nexport type Datasets = {\n shapes?: string; // A shapefile\n census?: string; // A total population Census dataset\n vap?: string; // A voting age (or citizen voting age) dataset\n election?: string; // An election dataset\n}\n\n\n// END\n","//\n// UTILITIES\n//\n\nimport * as T from './types'\nimport * as S from './settings';\n\n// PLAN HELPERS\n\n// Is a \"neighbor\" in state?\nexport function isInState(geoID: string): boolean {\n return geoID != S.OUT_OF_STATE;\n}\n\n// Is a \"neighbor\" out of state?\nexport function isOutOfState(geoID: string): boolean {\n return geoID == S.OUT_OF_STATE;\n}\n\n// NOTE - UNASSIGNED\n// Get the districtID to which a geoID is assigned\nexport function getDistrict(plan: T.PlanByGeoID, geoID: string): number | undefined {\n // All geoIDs in a state *should be* assigned to a district (including the\n // dummy \"unassigned\" district), but \"water-only\" features are sometimes missing\n // from a map. This is also a guard against a bug in which a geoID has no district.\n if (keyExists(geoID, plan)) {\n return plan[geoID];\n }\n else {\n return undefined;\n }\n}\n\n\n// WORKING WITH GEOIDS\n\nexport function parseGeoID(geoID: string): T.GeoIDParts {\n let parts: T.GeoIDParts = {};\n\n parts['state'] = geoID.substring(0, 2);\n parts['county'] = geoID.substring(0, 5);\n\n let l: number = geoID.length;\n\n if (l >= 11) {\n parts['tract'] = geoID.substring(0, 11);\n }\n\n if (l >= 12) {\n parts['bg'] = geoID.substring(0, 12);\n }\n\n if (l == 15) {\n parts['block'] = geoID;\n }\n\n return parts;\n}\n\nexport function getFIPSFromCountyGeoID(geoID: string): string {\n return geoID.substring(2, 5);\n}\n\nexport function isWaterOnly(geoID: string): boolean {\n let waterOnlySignature = 'ZZZZZZ';\n\n if (geoID.indexOf(waterOnlySignature) >= 0) return true;\n else return false;\n}\n\n// NORMALIZING RESULTS\n\nexport function normalize(rawScore: number, testScale: T.TestScale): number {\n let rangeMin: number = testScale.scale[0];\n let rangeMax: number = testScale.scale[1];\n\n // Invert the raw value if necessary to make bigger = better\n // TODO - This works for Population Deviation, because the max is 1.0.\n // Generalize this???\n if (testScale.bInvertRaw) {\n rawScore = 1.0 - rawScore;\n }\n\n // Coerce the value to be w/in the given range\n let coercedValue = Math.min(Math.max(rawScore, rangeMin), rangeMax);\n\n // Scale the bounded value w/in the range [0 - (rangeMax - rangeMin)]\n let scaledValue = (coercedValue - rangeMin) / (rangeMax - rangeMin);\n\n // NOTE - SPLITTING\n // Invert the scaled value if necessary to make bigger = better\n if (testScale.bInvertScaled) {\n scaledValue = 1.0 - scaledValue;\n }\n\n // Finally, make the range [0-100]\n return Math.round(scaledValue * S.NORMALIZED_RANGE);\n}\n\n// Round a fractional number [0-1] to the desired level of PRECISION.\nexport function trim(fullFraction: number, digits: number | undefined = undefined): number {\n if (digits == 0) {\n return Math.round(fullFraction);\n }\n else {\n let shiftPlaces = 10 ** (digits || S.PRECISION);\n\n return Math.round(fullFraction * shiftPlaces) / shiftPlaces;\n }\n}\n\n// ARRAY HELPERS\n\nexport function sumArray(arr: number[]): number {\n return arr.reduce((a, b) => a + b, 0);\n}\n\nexport function avgArray(arr: number[]): number {\n return (arr.reduce((a, b) => a + b, 0)) / arr.length;\n}\n\nexport function minArray(arr: number[]): number {\n return Math.min(...arr);\n}\n\nexport function maxArray(arr: number[]): number {\n return Math.max(...arr);\n}\n\nexport function initArray(n: number, value: any): any[] {\n return Array.from(Array(n), () => value);\n}\n\nexport function andArray(arr: boolean[]): boolean {\n return arr.reduce(function (a, b) { return a && b; }, true);\n}\n\n// WORKING WITH OBJECT KEYS/PROPERTIES\n\n// TODO - TERRY, is this copesetic?\n// TODO - Handle integer keys?\n// Does an object have a key/property?\nexport function keyExists(k: string, o: object): boolean {\n return k in o;\n}\n\n// TODO - TERRY, can these three be combined into a generic isEmpty() check?\n// Does an object (dict) have any keys/properties?\nexport function isObjectEmpty(o: object): boolean {\n return Object.keys(o).length === 0\n}\n// Does a Set have any members?\nexport function isSetEmpty(s: any): boolean {\n return s.size === 0\n}\n// Does an array hold any items?\nexport function isArrayEmpty(a: any[]): boolean {\n if (a === undefined || a.length == 0) {\n // array empty or does not exist\n return true;\n }\n else {\n return false;\n }\n}\n\n// Get the keys for an object\nexport function getObjectKeys(o: object): string[] {\n return Object.keys(o);\n}\n\n// TODO - Convert getNumericObjectKeys() idiom to for..of where possible\nexport function getNumericObjectKeys(o: object): number[] {\n return Object.keys(o).map(Number);\n}\n\nexport function getSelectObjectKeys(o: T.Dict, v: any[]): string[] {\n let selectKeys: string[] = [];\n\n Object.keys(o).forEach(key => {\n if (arrayContains(v, o[key])) {\n selectKeys.push(key);\n }\n });\n\n return selectKeys;\n}\n\nexport function arrayContains(a: any[], item: any): boolean {\n return a.some(x => x === item);\n}\n\nexport function objectContains(o: object, key: any): boolean {\n return (key in o);\n}\n\n\n// ENUM HELPERS\n\n// Source: https://stackoverflow.com/questions/38034673/determine-the-number-of-enum-elements-typescript\nexport function countEnumValues(enumName: any): number {\n let count = 0\n for (let item in enumName) {\n if (isNaN(Number(item))) count++\n }\n return count\n}\n\n// COPYING - Copied from dra-client/util.ts\n\nexport function shallowCopy(src: any): any {\n if (Array.isArray(src))\n return src.slice();\n else if (typeof src === 'object') {\n let dst: any = {};\n for (var p in src) if (src.hasOwnProperty(p))\n dst[p] = src[p];\n return dst;\n }\n else\n return src;\n}\n\nexport function deepCopy(src: any): any {\n if (Array.isArray(src)) {\n let dst: any[] = [];\n\n for (let i: number = 0; i < src.length; i++)\n dst.push(deepCopy(src[i]));\n return dst;\n }\n else if (typeof src === 'object') {\n let dst: any = {};\n for (var p in src) if (src.hasOwnProperty(p))\n dst[p] = deepCopy(src[p]);\n return dst;\n }\n else\n return src;\n}\n\n\n// TODO - TRI-STATES: Map booleans to tri-states.\nexport function mapBooleanToTriState(bool: boolean): T.TriState {\n return (bool) ? T.TriState.Green : T.TriState.Red;\n}\n\n// TODO - TERRY: What is this the simple explanation of what this thing is doing?\nexport { depthof } from '@dra2020/util';\n","//\n// MAP/PLAN VALIDATIONS\n//\n\nimport * as T from './types'\nimport * as U from './utils';\nimport * as S from './settings';\n\nimport * as D from './_data'\nimport { AnalyticsSession } from './_api';\n\n//\n// COMPLETE - Are all geo's assigned to a district, and do all districts have\n// at least one geo assigned to them?\n//\n\nexport function doIsComplete(s: AnalyticsSession, bLog: boolean = false): T.TestEntry {\n let test = s.getTest(T.Test.Complete) as T.TestEntry;\n\n // Get the by-district results, including the dummy unassigned district,\n // but ignoring the N+1 summary district\n let bNotEmptyByDistrict = s.districts.statistics[D.DistrictField.bNotEmpty];\n bNotEmptyByDistrict = bNotEmptyByDistrict.slice(0, -1);\n\n // Are all features assigned to districts?\n // Check the dummy district that holds any unassigned features.\n let unassignedFeatures: string[] = [];\n let bAllAssigned = (!bNotEmptyByDistrict[S.NOT_ASSIGNED]);\n\n if (!bAllAssigned) {\n let unassignedDistrict = s.plan.geoIDsForDistrictID(S.NOT_ASSIGNED);\n unassignedFeatures = Array.from(unassignedDistrict);\n unassignedFeatures = unassignedFeatures.slice(0, S.NUMBER_OF_ITEMS_TO_REPORT);\n }\n\n // Do all real districts have at least one feature assigned to them?\n let emptyDistricts: number[] = [];\n let bNoneEmpty = true;\n bNotEmptyByDistrict = bNotEmptyByDistrict.slice(1);\n\n let districtID = 1;\n bNotEmptyByDistrict.forEach(function (bNotEmpty: boolean): void {\n if (!bNotEmpty) {\n bNoneEmpty = false;\n emptyDistricts.push(districtID);\n }\n districtID += 1;\n });\n\n // Case 1 - One or more districts are missing:\n // The # of enumerated districts minus the dummy NOT_ASSIGNED one should\n // equal the number apportioned districts. This guards against a district\n // not being included in a map that is imported.\n //\n // NOTE - I'm no longer checking for this, but DRA should!\n\n // Case 2 - Or a district is explicitly named but empty:\n // Note, this can happen if a district is created, and then all features\n // are removed from it (in DRA).\n\n // Populate the test entry\n test['score'] = bAllAssigned && bNoneEmpty;\n if (!bAllAssigned) {\n test['details']['unassignedFeatures'] = unassignedFeatures;\n }\n\n if (!bNoneEmpty) {\n test['details']['emptyDistricts'] = emptyDistricts;\n }\n\n // Populate the N+1 summary \"district\" in district.statistics\n let bNotEmpty = s.districts.statistics[D.DistrictField.bNotEmpty];\n let summaryRow = s.districts.numberOfRows() - 1;\n\n bNotEmpty[summaryRow] = test['score'];\n\n return test;\n}\n\n//\n// CONTIGUOUS - Is each district in a plan fully connected?\n//\n// NOTE - To check \"operational contiguity,\" we need to use a graph, i.e.,\n// we can't rely on just the geometric contiguity of shapes in a shapefile.\n//\n// To test this, load the NC 2010 map 'SAMPLE-BG-map-discontiguous.csv'.\n//\n\nexport function doIsContiguous(s: AnalyticsSession, bLog: boolean = false): T.TestEntry {\n let test = s.getTest(T.Test.Contiguous) as T.TestEntry;\n\n // Get the contiguity of each district. Ignore dummy unassigned district\n // and the N+1 summary district.\n let bContiguousByDistrict = s.districts.statistics[D.DistrictField.bContiguous];\n bContiguousByDistrict = bContiguousByDistrict.slice(1, -1);\n\n // If any real districts aren't contiguous, mark the plan as not contiguous\n let bMapContiguous = U.andArray(bContiguousByDistrict);\n\n // If the map is not contiguous, log the offending districts.\n let discontiguousDistricts: number[] = [];\n let districtID = 1;\n bContiguousByDistrict.forEach(function (bDistrictContiguous: boolean): void {\n if (!bDistrictContiguous) discontiguousDistricts.push(districtID);\n districtID += 1;\n });\n\n // Populate the test entry\n test['score'] = bMapContiguous;\n if (!bMapContiguous) {\n test['details'] = { 'discontiguousDistricts': discontiguousDistricts };\n }\n\n // Populate the N+1 summary \"district\" in district.statistics\n let bContiguous = s.districts.statistics[D.DistrictField.bContiguous];\n let summaryRow = s.districts.numberOfRows() - 1;\n\n bContiguous[summaryRow] = test['score'];\n\n return test;\n}\n\n// Are the features in a district fully connected?\nexport function isConnected(districtGeos: Set<string>, graph: D.Graph): boolean {\n // TODO - TERRY, why does this constructor need a <T> type specification?\n let visited = new Set<string>();\n let toProcess: string[] = [];\n\n // Start processing with the first geoID in the district\n let iter = districtGeos.values();\n toProcess.push(iter.next().value);\n\n // While there are geoIDs in the district that haven't been processed\n while (toProcess.length > 0) {\n // Grab a geoID and process it\n let node = toProcess.pop() as string;\n visited.add(node);\n\n // Get its actual, in-state neighbors\n let actualNeighbors = graph.peerNeighbors(node).filter(x => U.isInState(x));\n\n // Add neighbors to visit, if they're in the same district Y haven't already been visited\n let neighborsToVisit = actualNeighbors.filter(x => districtGeos.has(x) && (!visited.has(x)));\n // TODO - TERRY, is this the quickest/best way to do this?\n toProcess.push(...neighborsToVisit);\n }\n\n // Stop when you've visited all the geoIDs in the district\n return visited.size == districtGeos.size;\n}\n\n\n//\n// FREE OF HOLES - Are any districts fully embedded w/in another district?\n//\n// A district is NOT a \"donut hole\" district:\n// - If any neighbor is 'OUT_OF_STATE'; or\n// - If there are 2 or more neighboring districts.\n//\n// To test this, load the NC 2010 map 'SAMPLE-BG-map-hole.csv'. District 1,\n// Buncombe County (37021), is a donut hole w/in District 3.\n//\n// TODO - OPTIMIZE: This to take advantage of district boundary info, if/when\n// we cache one to optimize compactness.\n//\n\nexport function doIsFreeOfHoles(s: AnalyticsSession, bLog: boolean = false): T.TestEntry {\n let test = s.getTest(T.Test.FreeOfHoles) as T.TestEntry;\n\n // Initialize values\n let bFreeOfHoles = true;\n let embeddedDistricts: number[] = [];\n\n // Get the embeddedness of each district. Ignore dummy unassigned district\n // and the N+1 summary district.\n let bNotEmbeddedByDistrict = s.districts.statistics[D.DistrictField.bNotEmbedded];\n bNotEmbeddedByDistrict = bNotEmbeddedByDistrict.slice(1, -1);\n\n let districtID = 1;\n bNotEmbeddedByDistrict.forEach(function (bDistrictNotEmbedded: boolean): void {\n if (!bDistrictNotEmbedded) {\n embeddedDistricts.push(districtID);\n bFreeOfHoles = false;\n }\n districtID += 1;\n });\n\n // Populate the test entry\n test['score'] = bFreeOfHoles;\n if (!bFreeOfHoles) {\n test['details'] = { 'embeddedDistricts': embeddedDistricts };\n }\n\n // Populate the N+1 summary \"district\" in district.statistics\n let bNotEmbedded = s.districts.statistics[D.DistrictField.bNotEmbedded];\n let summaryRow = s.districts.numberOfRows() - 1;\n\n bNotEmbedded[summaryRow] = test['score'];\n\n return test;\n}\n\n// Test whether one district is embedded w/in any other.\nexport function isEmbedded(districtID: number, geoIDs: Set<string>, plan: D.Plan, graph: D.Graph): boolean {\n // NOTE - \"features\" here = \"geoIDs.\" These aren't \"features\" proper, just\n // identifier strings.\n let features = geoIDs;\n let planByGeo = plan.byGeoID();\n\n // Assume the district is embedded\n let bEmbedded = true;\n // Keep track of the neighoring districts\n let neighboringDistricts = new Set();\n\n // TODO - OPTIMIZE: Use just the boundary features, when available\n // Get the features for the real district\n let featuresToCheck = Array.from(features);\n\n // If the district has features, check whether it is embedded\n if (!(U.isArrayEmpty(featuresToCheck))) {\n // For each feature that needs to be checked (see above)\n for (let feature of featuresToCheck) {\n // Get its neighbors (including the virtual \"out of state\" ones)\n let neighbors = graph.peerNeighbors(feature);\n\n for (let neighbor of neighbors) {\n if (U.isOutOfState(neighbor)) {\n bEmbedded = false;\n // No need to check any more neighbors\n break;\n }\n else {\n let neighboringDistrict = U.getDistrict(planByGeo, neighbor);\n\n // Assume that a missing district assignment (= None) means that the\n // feature is \"water-only\" AND part of the state border (vs. internal)\n // and, therefore, not in the plan/map.\n\n if (neighboringDistrict == undefined) {\n bEmbedded = false;\n // No need to check any more neighbors\n break;\n }\n else {\n // TODO - OPTIMIZE: Since we're checking *all* features in a district right\n // now, not just boundary features and neighbors in other districts,\n // prune out the current district. If/when we optimize compactness\n // to cache district boundaries (as before in my Python implementation),\n // we won't have to guard adding \"neighboring\" districts in this way.\n if (neighboringDistrict != districtID) {\n neighboringDistricts.add(neighboringDistrict);\n }\n\n if (neighboringDistricts.size > 1) {\n bEmbedded = false;\n // No need to check any more neighbors\n break;\n }\n }\n }\n }\n // If a district is not embedded, there's no need to check anymore\n // border geos.\n if (!bEmbedded) {\n break;\n }\n }\n\n }\n\n return bEmbedded;\n}\n\n","module.exports = require(\"@dra2020/poly\");","module.exports = require(\"@dra2020/util\");","module.exports = require(\"assert\");"],"sourceRoot":""}