digidem / react-mapfilter

Visualizing, exploring, filtering and printing geographic data and geotagged photos and video
https://lab.digital-democracy.org/mapfilter
29 stars 11 forks source link

Support delimited fields #48

Open gmaclennan opened 8 years ago

gmaclennan commented 8 years ago

ODK Collect returns data from multi-select fields as space-delimited fields, e.g.

{impacts: 'deforestation contamination loss_of_biodiversity'}

This is a little tricky to use heuristics to recognize, so short-term we will probably need to manually define which fields are space-delimited.

They are also tricky to filter. We are restricted in this new version by Mapbox's filter language which only does exact matches on fields - for performance reasons I assume.

I think the solution is to flatten these fields into multiple fields e.g.:

{
  'impacts.0': 'deforestation',
  'impacts.1': 'contamination',
  'impacts.2': 'loss_of_biodiversity'
}

Then set the same filter on each of those fields. With datasets when many options are selected in a multi-select this might be a performance issue, but we will have to see. In many datasets there will only be max 3-4 options selected - in our field analysis we can track the max number so we only need ot set that number of filters.

GoGoCarl commented 6 years ago

Ah, this explains some of the odd behaviors I'd been seeing in these fields. Yes, definitely need this! @karissa do you think you could add this to the roadmap?

gmaclennan commented 6 years ago

@GoGoCarl for now if you convert these fields to arrays before passing them to MapFilter it should just work. MapFilter has no way of detecting these manually. The filter issue should work for these too.

GoGoCarl commented 6 years ago

Yep, that did the trick, thanks!