koopjs / koop-socrata

Socrata provider for Koop.
Other
8 stars 7 forks source link

Handle Multiple Spatial Columns in Socrata #8

Closed pholleran closed 9 years ago

pholleran commented 9 years ago

Detroit, Michigan has a number of datasets with multiple location columns. A need exists to specify which to map against and, potentially, create multiple items/ids based on the column mapped.

Example: https://data.detroitmi.gov/Property-Parcels/Building-Permits/stpb-gint?

Socrata.js was modified to look for a '!' character, indicating a defined location column. Syntax: url/socrata/id!definedColumn

Mapping different location columns creates different entries in the koop cache:

chelm commented 9 years ago

Hey @pholleran its a bit hard for me to know what exactly has changed here as the file changes look like bulk copy paste changes? can you highlight whats different?

pholleran commented 9 years ago

@chelm, sorry about that. My GitHub noob-ism caused me to maintain a fork of the koopjs/koop-socrata module separate from the installation of koopjs I was using to test the changes, which led to the copy-paste. If you can suggest a cleaner way of testing/maintaining the local fork I will gladly follow it for future changes.

Highlights:

  1. Lines 44-45: added two variables - locFieldName (name of the location field supplied by the URL paramater) and urlid (to store the Socrata ID for use in URL construction)
  2. Lines 47-54: test for presence of loc column in URL and handle
  3. Lines 81-83: if a locFieldName is present use it as the location field
chelm commented 9 years ago

@pholleran no problem. One way to dev this would be to remove the node_modules/koop-socrata and replace it with you github fork of this repo. Then you can modify files in place and test it within the overall koop app structure.

Okay looks cool. I'll merge it once I pull it down and test it.

jgravois commented 9 years ago

i've played around a bit with maintaining references to patched fork/branches of individual providers so if you get stuck @pholleran, i'd be happy to try and help.

chelm commented 9 years ago

Okay I see, so I missed that you're encoding the location name in the url key. That clears this up and is a pretty great solution. Shows that you understand why we couldnt just add a query string param. Very nice.

ungoldman commented 9 years ago

You can use npm link to test something that's in development as a dependency in a local project.

https://docs.npmjs.com/cli/link

:grin: