Don't bundle the community index anymore, fetch from CDN instead

Start fetching and preparing it just before the changeset gets sent
This commit is contained in:
Bryan Housel
2020-01-29 15:24:26 -05:00
parent b8a8927d33
commit fb4d658860
4 changed files with 60 additions and 51 deletions
-30
View File
@@ -1,43 +1,13 @@
export { dataLocales } from './locales.json';
export { en as dataEn } from '../dist/locales/en.json';
import {
features as ociCustomFeatures,
resources as ociResources
} from 'osm-community-index';
import { dataImagery } from './imagery.json';
import { presets } from './presets/presets.json';
import { defaults } from './presets/defaults.json';
import { categories } from './presets/categories.json';
import { fields } from './presets/fields.json';
import LocationConflation from '@ideditor/location-conflation';
import whichPolygon from 'which-polygon';
// index the osm-community-index
let ociFeatures = {};
const loco = new LocationConflation({ type: 'FeatureCollection', features: ociCustomFeatures });
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: Object.values(ociFeatures) })
},
imagery: dataImagery, //legacy
presets: {
presets: presets,