fpdcc / ccfp-asset-dashboard

CCFP Asset Dashboard
0 stars 1 forks source link

Programatically get a project's zones and political districts based on the project's GIS assets #126

Closed smcalilly closed 2 years ago

smcalilly commented 2 years ago

Will also need to remove this from the project edit form and instead show a list of zones/districts

smcalilly commented 2 years ago

There are several pieces to do this. At a high level:

  1. Add a geometry field to the district and zone models to have the boundaries
  2. Write import script to associate the boundaries from their GIS database to our models
  3. Calculate the districts/zones for a project based on the assets associated with all the phases for a project
  4. List the districts/zones based on the project model attribute

At a low level:

1. Add geometry field to these models

Alternatively, we could have a new Boundary model with a geometry and then relate each model to it.

Or, we could just add new unmanaged models with the districts (which we'll already need to do so we can most easily import) and then use those models anywhere we need districts/zones.

2. Import boundaries from their GIS database

Their pinus schema has these tables:

One problem with these data: the house and senate districts are a specific year, so this will break whenever new house/senate boundaries are drawn and a new table is added with the new boundaries.

3. Calculate the districts/zones for a project

I'm not sure the best approach here. Using a phase's GIS assets, we'll need to find the intersection of each asset with each district/zone boundary.

4. List the districts/zones in the Project detail view/UI

We'll need to figure out our strategy for step 3 before we can do this. Once we figure out that, this piece should be straightfoward.

fgregg commented 2 years ago

sounds good.

write the import_shape script assuming that we have the data in the repo somewhere as geojson already.