Speedup imagery index with which-polygon

(closes #5226)
This commit is contained in:
Bryan Housel
2018-08-16 16:26:01 -04:00
parent ef0636ad01
commit 8b3637e55d
4 changed files with 54 additions and 48 deletions
+9 -7
View File
@@ -1,3 +1,5 @@
import _values from 'lodash-es/values';
export { wikipedia as dataWikipedia } from 'wmf-sitematrix';
export { default as dataSuggestions } from 'name-suggestion-index/name-suggestions.json';
@@ -24,31 +26,31 @@ import { categories } from './presets/categories.json';
import { fields } from './presets/fields.json';
import { geoArea as d3_geoArea } from 'd3-geo';
import _values from 'lodash-es/values';
import whichPolygon from 'which-polygon';
var features = _values(ociFeatures).map(function(feature) {
// workaround for which-polygon
// only supports `properties`, not `id`
// index the osm-community-index
var ociFeatureCollection = _values(ociFeatures).map(function(feature) {
// workaround for which-polygon: only supports `properties`, not `id`
// https://github.com/mapbox/which-polygon/pull/6
feature.properties = {
id: feature.id,
area: d3_geoArea(feature) // also precompute areas
};
return feature;
});
export var data = {
community: {
features: ociFeatures,
resources: ociResources,
query: whichPolygon({
type: 'FeatureCollection',
features: features
features: ociFeatureCollection
})
},
imagery: dataImagery,
imagery: dataImagery, //legacy
presets: {
presets: presets,
defaults: defaults,