Correctly gather the community index resources

- old code assumed that each resource had a link back to a single geojson featureId
- this isn't the case anymore so we need to link them in data/index.js
This commit is contained in:
Bryan Housel
2020-01-16 10:06:35 -05:00
parent 7391266aa7
commit 1c998d186a
2 changed files with 34 additions and 31 deletions
+13 -3
View File
@@ -27,16 +27,26 @@ import whichPolygon from 'which-polygon';
// index the osm-community-index
let ociFeatures = {};
const loco = new LocationConflation({ type: 'FeatureCollection', features: ociCustomFeatures });
const ociFeatures = Object.values(ociResources)
.map(resource => loco.resolveLocationSet(resource.locationSet));
Object.values(ociResources).forEach(resource => {
const feature = loco.resolveLocationSet(resource.locationSet);
let ociFeature = ociFeatures[feature.id];
if (!ociFeature) {
ociFeature = JSON.parse(JSON.stringify(feature)); // deep clone
ociFeature.properties.resourceIDs = new Set();
ociFeatures[feature.id] = ociFeature;
}
ociFeature.properties.resourceIDs.add(resource.id);
});
export let data = {
community: {
features: ociFeatures,
resources: ociResources,
query: whichPolygon({ type: 'FeatureCollection', features: ociFeatures })
query: whichPolygon({ type: 'FeatureCollection', features: Object.values(ociFeatures) })
},
imagery: dataImagery, //legacy
presets: {