Skip to content
This repository was archived by the owner on Sep 28, 2020. It is now read-only.

Configuration

Kenny Shepard edited this page Aug 19, 2013 · 20 revisions

The configuration of the Public Mapping Project's software, DistrictBuilder, is controlled through a single configuration file. An example configuration file can be found in GitHub.

The most current configuration file can be found at docs/config.dist.xml

This page will walk you through the process of configuring your application with this configuration file.

DistrictBuilder

The main tag of the configuration file is DistrictBuilder. All other tags must reside inside of the DistrictBuilder tag.

Example 1:

<?xml version="1.0" encoding="utf-8"?>
<DistrictBuilder>
  <!-- all other configuration elements belong inside of this element -->
  ...
</DistrictBuilder>

Example 2: config.dist.xml

LegislativeBodies

The DistrictBuilder application maintains plans and associated metrics related by legislative bodies. A single legislative body may be something like "US Congress" for a state level body, or "Springfield Public School District" for a local body.

Legislative bodies are referred to by many other parts of the configuration, so they appear first in the configuration file.

This element contains a series of LegislativeBody tags.

Example 1:

<LegislativeBodies>
  <!-- this element contains a series of LegislativeBody elements -->
  ...
</LegislativeBodies>

Example 2: config.dist.xml

LegislativeBody

Each LegislativeBody tag customizes the behavior of the application when building a plan.

Attributes:

  • id - A unique identifier of this element. This must be unique for all LegislativeBody tags.
  • name - A name for the LegislativeBody, as it should be displayed in the application to users.
  • short_label - A short label for the items that comprise a plan. This must include a '%(district_id)s', which is used to substitute the member ID. For example: the US Congress legislative body's members are simply "%(district_id)s", which appear as "1" for the district with the ID of 1.
  • long_label - A long label for the items that comprise a plan. This must include a '%(district_id)s', which is used to substitute the member ID. For example: the US Congress legislative body's long_labels are "District %(district_id)s", which appear as "District 1" for the district with the ID of 1.
  • maxdistricts - The maximum number of members that may be included within a plan.
  • sort_key - The ranked position, relative to the other legislative bodies.
  • members - The name of the individual members in a LegislativeBody. New in v2.0

Example 1:

<LegislativeBody id="congress" name="Congressional" short_label="%(district_id)s" 
    long_label="District %(district_id)s" maxdistricts="18" sort_key="2" members="District"/>

Example 2: config.dist.xml

Regions

The Regions element contains Region elements, which define subsets of geography.

Example 1:

<Regions>
    <!-- Define some Regions, aggregations of smaller geographic units. -->
    ...
</Regions>

Example 2: config.dist.xml

Region

A Region is a subset of geographies, applied to give legislative bodies. For example, you may have all the data necessary for both a state- and a city-wide redistricting contest. In one DistrictBuilder instance, you may define multiple regions, one for each contest.

Attributes:

  • id - An id for the Region, used within the XML file only
  • name - A short name for the region, used along with a base geolevel's name to create a slug-like name for the region's geolevels
  • label - A label for the region to display in the Region Chooser
  • description - A long description of the region, possibly for use in tooltips or documentation
  • sort_key - The index to use when ordering items in the Region Chooser

This element contains references to the LegislativeBodies and GeoLevels applicable to the region. Please see Hierarchical Geometry for more information on GeoLevel hierarchies. This element may also contain a RegionFilter to determine the subset of Geounits within to the region.

Example 1:

<Region id="dc_area" name="dc_area" label="District of Columbia Area" description="The metropolitan counties around the District of Columbia" sort_key="2">
    ...
</Region>

Example 2: config.dist.xml

RegionFilter

The RegionFilter applies to its parent Region. It contains RegionCode elements that act on imported data.

Example 1:

<RegionFilter>
    <!-- Some RegionCode elements -->
</RegionFilter>

Example 2: config.dist.xml

RegionCode

A RegionCode element filters geounits in the given Geolevels for the region.

Attributes:

  • attr - The attribute (column name) in the shapefile to which this filter applies. For example, 2010 census data contains a hierarchical "GEOID10" FIPS code that is perfect for filtering.
  • value - The "target" value that the attribute must match to be placed in this region. This is a string match. Keep that in mind when leading 0s are present
  • start - Optional. The index in the attribute string at which the substring match starts
  • width - Optional. The number of characters to examine for the target value.

Example 1:

<RegionCode attr="GEOID10" value="51059" start="0" width="5" />

Example 2: config.dist.xml

Subjects

Each of the metrics available in the DistrictBuilder application are called Subjects. A subject may be something like the total population of an area, the number of registered voters, or the percentage of the population with a high school diploma.

This element contains a series of Subject tags.

Note: the user interface includes an Info popup tool, which lists a subset of all the available subjects available at the specified geography (e.g.: county, tract, or block). This popup tool will display the first three subjects in the order defined by the sortkey attribute, in addition to the subject flagged as the default.

Example 1:

<Subjects>
  <!-- this element contains a series of Subject elements -->
  ...
</Subjects>

Example 2: config.dist.xml

Subject

Each Subject tag defines a metric used in the application to measure the characteristics of each district as it is being built.

Attributes:

  • id - A unique identifier of this element. This must be unique for all Subject tags.
  • field - The name of the field/attribute of the shape in the shapefiles defined in the GeoLevel tag.
  • name - A long name of the Subject.
  • short_name - A short name of the Subject. This is used in the application menus and drop downs.
  • displayed - A flag indicating if this Subject should be used to create choropleth layers (true), or just used for scoring and ranking (false).
  • sortkey - The ranking order of this subject.
  • aliasfor - In cases where shapefiles have different field names for the same metrics, aliasfor is an ID of a Subject whose name, short_name, displayed, and sortkey attributes are used.
  • default - A flag that specifies if this subject is the default subject. The default subject is the subject that first appears as the basemap choropleths when viewing or editing a plan.
  • percentage_denominator - A subject id that will be used as a denominator to compute a percentage value, in addition to storing the raw data value.

Example 1:

<Subject id="pophisp" field="POPHIS" name="Hispanic or Latino" 
         short_name="Hispanic" displayed="false" sortkey="3" default="true"/>
<Subject id="vap" field="VAP" name="Voting Age Population" 
         short_name="VAP" displayed="false" sortkey="4"/>
<Subject id="vaphisp" field="VAPHIS" name="% Voting Age Population: Hispanic or Latino" 
         short_name="% Hispanic VAP" displayed="false" sortkey="5" percentage_denominator="vap"/>
<Subject id="pophisp1" field="POPHISP" aliasfor="pophisp" />

Example 2: config.dist.xml

Scoring

Scoring elements control how plans and districts are evaluated and compared against one another. For more information, see the Scoring detailed information.

Children:

Example 1:

<Scoring>
  <ScoreFunctions>
    ....
  </ScoreFunctions>
  <ScorePanels>
    ....
  </ScorePanels>
  <ScoreDisplays>
    ....
  </ScoreDisplays>
</Scoring>

Example 2: config.dist.xml

ContiguityOverrides

Optional configuration for geounits that require special contiguity rules.

Tests for contiguity will apply these overrides in order to account for contiguity when physical contiguity is not possible. For example, an island may need to be marked contiguous with one or more geounits on an adjacent coast (possibly containing harbors).

This element contains a series of ContiguityOverride tags.

Example:

<ContiguityOverrides>
  <!-- this element contains a series of ContiguityOverride elements -->
    ...
</ContiguityOverrides>

ContiguityOverride

A ContiguityOverride defines the contiguity override between two Geounits.

Attributes:

  • id - The portable id of the geounit in which to configure an override.
  • connect_to - The portable id of the geounit in which the geounit is to be considered contiguous with.

Example:

<ContiguityOverride id="510030112012077" connect_to="510030102011065" />

Adjacencies

Optional configuration for instances that calculate adjacency costs per district/plan (e.g. for determining travel distances/times). These values are stored in a KeyValueStore and are accessed when calculating adjacency costs via the adjacency calculator.

This element contains a series of Adjacency elements.

Example:

<Adjacency>
  <!-- this element contains a series of Adjacency elements -->
    ...
</Adjacency>

Adjacency

An Adjacency defines a set of adjacency data to be stored in the system. Each adjacency file must be tab-delimited with three columns and no header. The first two columns represent the adjacent geounits, in the form of portable_ids, and the third column represents the cost, which is a floating point value.

Attributes:

  • path - The path to the adjacency file.
  • regionref - A reference to the region in which these adjacency rows correspond to.

Example:

<Adjacency path="/projects/PublicMapping/DistrictBuilder/test_adj.txt" regionref="test"/>

MultiMemberDistrictConfigs

Optional configuration for legislative bodies that support multi-member districts.

This element contains a series of MultiMemberDistrictConfig tags.

Example:

<MultiMemberDistrictConfigs>
  <!-- this element contains a series of MultiMemberDistrictConfig elements -->
    ...
</MultiMemberDistrictConfigs>

MultiMemberDistrictConfig

A MultiMemberDistrictConfig defines the parameters to use for a legislative body that supports districts with multiple representatives.

Attributes:

  • legeislativebodyref - Reference to a legislative body this configuration is for
  • min_multi_districts - Minimum allowed number of multi-member districts in a plan
  • max_multi_districts - Maximum allowed number of multi-member districts in a plan
  • min_multi_district_members - Minimum allowed number of members per multi-member districts
  • max_multi_district_members - Maximum allowed number of members per multi-member districts
  • min_plan_members - Minimum allowed number of total members per plan
  • max_plan_members - Maximum allowed number of total members per plan
  • multi_district_label_format - the format to be used for displaying a map label of a multi-member district. This format string will be passed to python's 'format' function with the named arguments: 'name' (district name) and 'num_members' (number of representatives)

Example:

<MultiMemberDistrictConfig legislativebodyref="congress"
    min_multi_districts="2" max_multi_districts="5"
    min_multi_district_members="3" max_multi_district_members="7"
    min_plan_members="25" max_plan_members="35"
    multi_district_label_format="{name} [{num_members}]" />

GeoLevels

DistrictBuilder may contain multiple geographic levels, or GeoLevels. The application requires the geography to be accurately nested and hierarchical. The GeoLevel elements defined in this element must be defined by the smallest geography first, followed by the higher levels.

Please see Hierarchical Geometry and Simplified Geometry for more information on what types of geography may be used in DistrictBuilder.

This element contains a series of GeoLevel tags.

Example 1:

<GeoLevels>
  <!-- this element contains a series of GeoLevel elements -->
  ...
</GeoLevels>

Example 2: config.dist.xml

GeoLevel

A GeoLevel defines the data source for a set of geographic units. For more information on child elements, see [Geographic Levels].

Attributes:

  • id - A unique identifier of this element. This must be unique for all GeoLevel tags.
  • name - The name of this geographic level. This name appears in the application menus and dropdown lists.
  • min_zoom - The minimum zoom at which this geography is visible.
  • sort_key - The order in which this geography appears in the application menus and dropdown lists.
  • tolerance - The tolerance of the simplification algorithm, in database units. For the reference implementation, these units are in meters. This is the maximum distance that a generalized line (polygon boundary) may deviate from a highly detailed line. For Census Blocks, 2.5m is good, and for County boundaries, 250m is good.

Example 1:

<GeoLevel id="block" name="block" min_zoom="0" sort_key="3" tolerance="2.5">
  <Shapefile path="/projects/publicmapping/data/OH_39_census_block_web_mercator.shp">
    <Fields>
      <Field name="NAME00" type="name" />
      <Field name="BLKIDFP00" type="portable" />
      <Field name="STID00" type="tree" pos="0" width="2" />
      <Field name="CTYID00" type="tree" pos="1" width="3" />
      <Field name="TRCT00" type="tree" pos="2" width="6" />
      <Field name="FIPS00" type="tree" pos="3" width="6" />
    </Fields>
  </Shapefile>
</GeoLevel>

Example 2: config.dist.xml

Templates

A list of plans to create for all users of the system. These system-wide template plans will be owned by the administrative user (the first user with 'staff' status).

Example 1:

<Templates>
  <!-- this element contains a series of Template elements -->
  ...
</Templates>

Example 2: config.dist.xml

Template

A template defines a plan that is based on a district index (sometimes called a block correspondence) file.

Attributes:

  • name - The name of this template plan. This name appears in the plan chooser.

Children:

Example 1:

<Template name="Congressional">
  <LegislativeBody ref="congress"/>
  <Blockfile path="/projects/publicmapping/data/OH_congressional_blockfile.csv"/>
</Template>

Example 2: config.dist.xml

LegislativeBody

Attributes:

  • ref - A reference to a LegislativeBody id in a previously defined LegislativeBody element.

Example: Please see the Template example.

Blockfile

Attributes:

  • path - The full file system path to a district index file that matches geographic units to districts.

Example: Please see the Template example.

Project

All configuration items relevant to the django web project are contained within this element. The other top-level configuration elements relate to the data in the application, and (for the most part), don't configure the web application. Those settings are contained within this element and its children.

For more information on child elements, see [Project Configuration[(#wiki-project-configuration).

Attributes:

  • root - The absolute path to the top folder of DistrictBuilder. If checked out of GitHub, this is the absolute path to the source folder.
  • sessionquota - The maximum number of concurrent sessions to permit at any one time. A concurrent session is any session that is created by the application, and has been active within the last sessiontimeout minutes.
  • sessiontimeout - The number of minutes that may elapse before a session is considered inactive. An inactive session will not immediately log out a user; only if the sessionquota is reached will a user with an inactive session be redirected to the login page.

Children:

Example 1:

<Project root="/projects/publicmapping/trunk" sessionquota="5" sessiontimeout="15">
  <!-- This element contains a Database, Admin, Redistricting, Reporting, and Mailer element. -->
</Project>

Example 2: config.dist.xml

Geographic Levels

A geographic level, or GeoLevel, defines relationships between geography, legislative bodies, and targets (and indirectly, subjects). For each geographic level, it must be specified which legislative body uses this geography, and which targets should be used in that body. Please note that these LegislativeBodies and LegislativeBody elements are not the same as the top-level configuration elements.

Children:

Files

List the files that contain the spatial and attribute data for this geographic level. A set of files can include either:

  • A Shapefile, which contains both the geometry and the attributes, or
  • A Geography and Attributes file, which contain the geometry and attributes, respectively. Geography is required, but Attributes is optional.

Children:

Shapefile

A description of the file that contains the geometry and attributes of each unit of geography at a geographic level.

Attributes:

  • path - The absolute system path to the specified shapefile.

Children:

Example: config.dist.xml

Geography

A description of the file that contains the geometry of each unit of geography at a geographic level. This file must contain a unique ID and name for each geographic unit.

Attributes:

  • path - The absolute system path to the specified shapefile.

Children:

Example: config.dist.xml

Attributes

An optional file that contains the demographic attributes for display and visualization. Each record in the Attributes file must relate to one geographic unit via the geographic unit's ''portable'' field. An Attribute file may be either a CSV of DBF file.

Attributes:

  • path - The absolute system path to the specified shapefile.

Children:

Fields

A list of the relevant fields in the file that are used for identification, labeling, and hierarchy.

Children:

Example 1:

<Fields>
  <Field name="NAME10" type="name"/>
  <Field name="GEOID10" type="portable"/>
  <Field name="STATEFP10" type="tree" pos="0" width="2" />
  <Field name="COUNTYFP10" type="tree" pos="1" width="3" />
  <Field name="VTDST10" type="tree" pos="2" width="4" />
</Fields>

Example 2: config.dist.xml

Field

An element that can map a field in a shapefile or data table to a label, portable ID, or portion of a tree code.

Attributes:

  • name - The name of the field/column. Required.
  • type - The type of field, currently supported are: "name", "portable", or "tree". Required.
  • pos - Only used for "tree" type fields, this defines the order in which the fields are combined to generate a hierarchical ID. Optional.
  • width - Only used for "tree" type fields, this defines the width, in characters, that the field should take up, in cases where the ID is not a uniform string width.

Example: Please see the Fields example.

Project Configuration

Database

Database connection settings. The usual database connection settings go in here. Currently supported database backends are:

Attributes:

  • name - The name of the database.
  • user - The name of the user used to connect to the database.
  • password - The password for the user when connecting to the database. This is stored in plaintext.
  • host - Optional. The hostname of the database server. Defaults to 'localhost'.

Example 1:

<Database name="databasename" user="databaseuser" password="plaintextpassword"/>

Example 2: config.dist.xml

KeyValueStore

KeyValueStore connection settings. This is currenly only used for the Adjacency feature. If adjacencies are not being used in the instance, this need not be configured. Currently supported key-value store backends are:

Attributes:

  • host - The hostname of the key-value store.
  • port - The name of the user used to connect to the key-value store.
  • password - The password for the user when connecting to the key-value store. This is stored in plaintext.

Example:

<KeyValueStore host="localhost" port="6379" password=""/>  

Internationalization

Internationalization and localization settings. All supported locales (languages) are listed here. One locale must be designated as the default.

Attributes:

  • timezone - The timezone of the server.
  • default - Which Language is the default. This is the "code" attribute of the child Language element.

Example 1:

<Internationalization timezone="US/Eastern" default="en">
    <Language code="en" label="English" />
    <Language code="fr" label="French" />
    <Language code="es" label="Spanish" />
</Internationalization>

Example 2: config.dist.xml

Language

A language supported in DistrictBuilder. Each supported language must have accompanying message (.po) files for the django, djangojs, and xmlconfig domain.

Attributes:

  • code - The locale code for the language.
  • label - The label for the language -- this may be any text.

Example: Please see the Internationalization example above.

Admin

The administrative user for the django project. This will be the administrative (or staff) user created when the django database is created. These settings are used automatically by django to send notifications of application fault during production.

Attributes:

  • user - The user name. This is typically "admin".
  • email - The email address for the admin user.
  • password - The password for the admin user.

Example 1:

<Admin user="admin" email="admin@domain.name"/>

Example 2: config.dist.xml

Redistricting

Settings for the redistricting django application. These settings include namespaces, map settings, and map styles. Optionally, GoogleAnalytics accounts can be incorporated to track page visits.

Children:

Example 1:

<Redistricting>
  <MapServer hostname="" ns="gmu" nshref="http://gmu.azavea.com/" 
             adminuser="admin" adminpass="plaintextpassword" maxfeatures="100"
             styles="/projects/publicmapping/trunk/sld" />
  <GoogleAnalytics account="" domain=""/>
  <Upload maxsize="5300"/>
  <FixUnassigned minpercent="99" comparatorsubject="poptot" />
  <MaxUndos duringedit="50" afteredit="10" />
</Redistricting>

Example 2: config.dist.xml

MapServer

Information about the GeoServer installation used to serve up maps and features for the redistricting application.

Attributes:

  • hostname - The hostname of the map server. To use the same hostname as the web application, leave this blank.
  • ns - The XML namespace for map features. This is required.
  • nshref - The XML namespace href for map features. This is required.
  • adminuser - The administrative user for GeoServer -- Note: this is a different user than the one specified in the [#PRJ-Admin Admin] setting.
  • adminpass - The administrative user password for GeoServer.
  • maxfeatures - The maximum number of features. This is used to prevent massive geometric operations that may bog down the web application and degrade performance during editing.
  • styles - The absolute path to the SLD files used to display the geography in the map tiles. If checked out of SVN, this is the absolute path to the [source:/trunk/sld/ trunk/sld/] folder.
  • basemaps - Information about the mapserver and geoserver settings. The options are displayed in the order in which they are set, with the first one being set to the default base layer. If this is not set, it will default to osm-road. If the desire is to have no base layer, set it to the empty string. This attribute is optional, and can be any set to any combination (CSV) of the following:
    • osm-road
    • arc-road
    • google-road
    • google-aerial
    • google-hybrid
    • bing-road
    • bing-aerial
    • bing-hybrid

Example 1: Please see the Redistricting example.

Example 2: config.dist.xml

GoogleAnalytics

Note: This is optional.

Attributes:

  • account - The GoogleAnalytics account.
  • domain - The GoogleAnalytics domain.

Example: Please see the Redistricting example.

MaxUndos

Attributes:

  • duringedit - The maximum number of undos that are allowed while a plan is being edited.
  • afteredit - The maximum number of undos that are kept after the user navigates away from the plan.

Example: Please see the Redistricting example.

FixUnassigned

Attributes:

  • minpercent - The minimum percentage of assigned units required in order to perform fixes for adjacent unassigned units. This does not apply to unassigned units wholly contained within a districts -- those don't require a minimum.
  • comparatorsubject - Name of the subject used for deciding which district to assign an adjacent unassigned geounit to in the case of multiple adjacent districts. The district with the lower value for this subject is always favored.

Example: Please see the Redistricting example.

Upload

Attributes:

  • maxsize - The maximum size in KB of the uploaded district index (sometimes called a block correspondence) file.

Example 1: Please see the Redistricting example.

Example 2: config.dist.xml

Reporting

This sections is used to configure reporting, which is displayed in the Evaluate tab of the application. Currently, there are two different methods of reporting that may be configured: BARD, and reports using the scoring mechanism of ScoreFunctions, ScorePanels, and ScoreDisplays.

For BARD, the required sections are BardConfigs, and BardBodyConfigs. Please see Bard Report Configuration for more details.

For DistrictBuilder calculalator-based scoring, there is one required section: CalculatorReports. This section has a single, required attribute: tempdir, which is the path in which the reports are stored and served from.

Example:

<Reporting>
    <CalculatorReports tempdir="/projects/publicmapping/local/reports" />
</Reporting>

The rest of the configuration is performed with ScoreDisplays, ScorePanels, and ScoreFunctions.

Example:

        <ScoreDisplay legislativebodyref="congress" type="reports"            
            title="Congressional Reports" cssclass="reports congress">  
            <ScorePanel ref="report_panel_population" />
            <ScorePanel ref="report_panel_majmin" /> 
            <ScorePanel ref="report_panel_compactness" />   
            <ScorePanel ref="report_panel_party" />      
            <ScorePanel ref="report_panel_spatial" />             
        </ScoreDisplay>                                               

        <ScorePanel id="report_panel_population" type="district" position="2"  
            title="Population" template="report_panel.html" cssclass="reports population" >   
            <Score ref="report_score_total_population_congress" />     
            <Score ref="report_score_total_population_senate" />      
            <Score ref="report_score_total_population_house" />   
            <Score ref="report_score_vap" />      
            <Score ref="report_score_vapblk" />
            <Score ref="report_score_vaphisp" />   
        </ScorePanel>                              

        <ScoreFunction id="report_score_total_population_congress" type="district" 
            calculator="publicmapping.redistricting.reportcalculators.Population"
            label="Total Population" >  
            <LegislativeBody ref="congress"/>   
            <SubjectArgument name="value" ref="poptot" /> 
            <Argument name="min" value="723729" />  
            <Argument name="max" value="731003" />  
        </ScoreFunction>         

Each ScorePanel defines a group of scores. On the Evaluate tab of the application, the grouping is performed both in terms of selection of which reports are to be displayed, as well as report output. A checkbox is created for each ScoreFunction found in each panel, and each checkbox directly corresponds to a report that is run and displayed. The ScorePanel title is used as a parent heading, and a checkbox is also created for it, which can be used for toggling all of the ScoreFunctions within it.

Mailer

The configuration settings to configure django's email subsystem.

Attributes:

  • server - The outgoing SMTP server that will handle the mail delivery for all emails the system sends.
  • port - The outgoing SMTP server port. 25 for unencrypted, 785 for encrypted (typically).
  • username - If your SMTP server requires authentication, supply a username for authentication.
  • password - If your SMTP server requires authentication, supply a password for authentication.
  • use_tls - If your SMTP server requires TLS, set this to "true".
  • submission_email - If plans are to be submitted to a contest via the 'Share' tab, supply an email address here for where they should be sent. This is optional, and if it is not set, the submission section will not be available to the user.

Example: config.dist.xml

Scoring

The scoring settings define the calculators and combinations of scores that can be used to evaluate a plan or district and provide either a boolean or metric which can be used to compare plans against each other.

ScoreFunctions

A list of ScoreFunctions available.

Children:

ScoreFunction

A ScoreFunction defines a calculator and its arguments. A ScoreFunction can evaluate an individual district or an entire plan. In addition, a ScoreFunction can reference another ScoreFunction, in order to support composition or weighting of different scores.

Attributes:

  • id - The ID of this ScoreFunction. This is required, as the ScoreFunction is referenced by ScorePanels and Validation rules later on.
  • type - The type, which can be "district" or "plan". A district score accepts and evaluates one district at a time; a plan score accepts a plan, and evaluates a plan at once.
  • calculator - The fully namespaced Python class that will perform this calculation. This Python class must be in the Python path of the django web application.
  • label - An optional label that can be used when a score is being displayed.
  • description - An optional description of how this score function works.
  • user_selectable - Set this ScoreFunction as selectable in the user interface.

Children:

Example 1:

<ScoreFunction id="district_blk_percent" type="district" 
               calculator="publicmapping.redistricting.calculators.Percent">
  <SubjectArgument name="numerator" ref="popblk" />
  <SubjectArgument name="denominator" ref="poptot" />
  <LegislativeBody ref="congress" />
</ScoreFunction>

Example 2: config.dist.xml

Argument

A literal argument to a calculator. This may be useful for thresholds or numerical targets.

Attributes:

  • name - The name of the argument. This must match a keyword argument to the calculator Python class assigned in the ScoreFunction.
  • value - The literal value for the argument. This must be a decimal value.

Example 1:

<Argument name="target" value="727366" />

Example 2: config.dist.xml

SubjectArgument

An argument that corresponds to a Subject value of the district(s) being computed.

Attributes:

  • name - The name of the argument. This must match a keyword argument to the calculator Python class assigned in the ScoreFunction.
  • ref - The ID of the Subject that should be retrieved.

Example 1:

<SubjectArgument name="value" ref="poptot" />

Example 2: config.dist.xml

ScoreArgument

An argument that corresponds to another ScoreFunction, which should be evaluated first.

Attributes:

  • name - The name of the argument. This must match a keyword argument to the calculator Python class assigned in the ScoreFunction.
  • ref - The ID of the ScoreFunction that should be computed before invoking the calculator.

Example 1:

<ScoreArgument name="value" ref="district_blk_percent" />

Example 2: config.dist.xml

LegislativeBody

A legislative body that uses this Score. Optional. Only used if the ScoreFunction should be restricted to a subset of all available LegislativeBodies. By default, the ScoreFunction may be applied to all LegislativeBodies.

Attributes:

  • ref - A reference to a LegislativeBody id in a previously defined LegislativeBody element.

Example 1: Please see the ScoreFunction example.

Example 2: config.dist.xml

ScorePanels

A list of panels that display either many scores for a plan, or many scores for districts in one plan.

Children:

ScorePanel

A panel in a ScoreDisplay that displays some scores. Depending on the type of the ScorePanel, the panel will display ScoreFunction results slightly differently:

  • if a panel is a district type, it will display the scores for all the districts in a plan.
  • if a panel is a plan type, it will display the scores for all plans.
  • if a panel is a plan summary type, it will display multiple scores for a single plan.

Attributes:

  • id - The ID of this ScorePanel. The ScorePanel is referenced later, and may be included in one or more ScoreDisplays
  • type - The type of ScorePanel. This must be one of:
    • plan
    • plan summary
    • district
  • cssclass - The CSS class that should be attached to this panel. In the Leaderboard, there are multiple instances of the same type of panel, and they are distinguished by their styling.
  • template - The template that should be used to render the computed scores to HTML for display.
  • is_ascending - Whether or not the scores should be arranged in ascending order. Default is true.
  • title - The title to be displayed in this score panel.

Children:

Example 1:

<ScorePanel id="panel_info" type="district"
            cssclass="district_basic_info" template="district.html">
  <Score ref="district_poptot" />
  <Score ref="district_contiguous" />
  <Score ref="district_schwartzberg" />
</ScorePanel>

Example 2: config.dist.xml

Score

A reference within a ScorePanel to a ScoreFunction, to indicate which scores should be computed and displayed in the panel.

Attributes:

  • ref - A reference to the ScoreFunction ID.

Example: Please see the ScorePanel example.

ScoreDisplays

A list of UI groups that display computed scores to clients. Each display may contain one or more ScorePanels.

Children:

ScoreDisplay

A UI group that displays a set of computed scores to clients. A single ScoreDisplay may contain one or more ScorePanels.

Attributes:

  • id - The ID of this score display. IMPORTANT NOTE: The id of some score displays is used to determine "defaults" in a language-agnostic way. See [Special ScoreDisplays](Special ScoreDisplays) for more info.
  • legislativebodyref - The ID of the legislative body that this display applies to.
  • type - The type of display. Currently supported type values are:
    • leaderboard
    • sidebar
  • title - The title of this panel. Depending on the type of panel, this title may appear in different places. Optional.
  • cssclass - A CSS class to assist in UI styling.

Children:

Example 1:

<ScoreDisplay legislativebodyref="congress" type="sidebar" 
              title="Basic Information" cssclass="">
  <ScorePanel ref="panel_summary" />
  <ScorePanel ref="panel_info" />
</ScoreDisplay>

Example 2: config.dist.xml

ScorePanel

A reference to a previously defined ScorePanel.

Attributes:

  • ref - The ID of a previously defined ScorePanel.

Example: Please see the ScoreDisplay example.

Validation

The validation settings define the validation criteria for plans

Criteria

A list of validation Criteria for a given legislative body

Children:

Attributes:

  • legislativebodyref - The id of the LegislativeBody that this validation Criteria applies to.

Example: config.dist.xml

Criterion

A validation Criterion defines a single validation procedure to be run on a plan

Attributes:

  • id - The ID for this Criterion.
  • name - The name for this Criterion.
  • description - Descriptive text for this Criterion. Will be displayed to the user when validation fails.

Children:

Example 1:

<ScoreFunction id="district_blk_percent" type="district" 
               calculator="publicmapping.redistricting.calculators.Percent">
  <SubjectArgument name="numerator" ref="popblk" />
  <SubjectArgument name="denominator" ref="poptot" />
</ScoreFunction>

<Criteria legislativebodyref="congress">
    <Criterion name="AllContiguous - Congress" description="&lt;p&gt;Your plan does not meet the \
        competition criteria for Contiguity&lt;/p&gt;&lt;p&gt;Every part of a district must be \
        reachable from every other part without crossing the district's borders. All districts \
        within a plan must be contiguous. Water contiguity is permitted given Virginia's extensive \
        coastal region. 'Point contiguity' or 'touch-point contiguity' where two sections of a \
        district are connected at a single point is not permitted.&lt;/p&gt;">
        ...
    </Criterion>
</Criteria>

Example 2: config.dist.xml

Score

A reference to a score function

Attributes:

  • ref - A reference to a ScoreFunction to be used for this validation procedure

Example:

<Score ref="plan_multi_member" />

Clone this wiki locally