@dra2020/district-analytics
v17.1.0
Published
District analytics TypeScript package
Keywords
Readme
District Analytics
A layer between dra-client and fn-all (the scoring lambda), on the one hand, and dra-analytics, on the other,
that knows enough about DRA and the analytics proper in dra-analytics to take data in, compose the various lower-level
analytics calls, and make the various artifacts: scorecard, ratings, requirements checklist, etc. This allows the callers
to remain high-level and agnostic of the analytics specifics and the analytics proper to no nothing about DRA.
Build Status
Sample Code
import * as DA from 'district-analytics';
// Create a session request
let sr = {} as DA.SessionRequest;
sr['title'] = "NC 2020 Congress";
sr['stateXX'] = "NC";
sr['nDistricts'] = 14;
sr['planType'] = PlanType.congress; // One or ...
sr['legislativeDistricts'] = false; // ... the other
sr['data'] = data as T.GeoFeatureCollection;
sr['counties'] = counties as T.GeoFeatureCollection;
sr['graph'] = graph as T.ContiguityGraph;
sr['plan'] = planByGeoID as DA.PlanByGeoID;
sr['districtShapes'] = districtShapes as T.GeoFeatureCollection;
sr['aggregates'] = aggregates as PF.PackedFields[];
sr['config'] = config as T.Dict;
// Create an analytics session
let s = new DA.AnalyticsSession(sr);
// Run the analytics
let bLog = false;
s.analyzePlan(bLog);
// Retrieve the artifacts
const scorecard: DA.Scorecard = s.getPlanScorecard();
const ratings: DA.Ratings = s.getRatings();
const requirements: DA.RequirementsChecklist = s.getRequirementsChecklist();