Skip to content

Commit

Permalink
Rewrite source.polygon into array of outers without holes
Browse files Browse the repository at this point in the history
(closes #5264, closes #5250, closes #5272)
  • Loading branch information
bhousel committed Nov 8, 2018
1 parent a73a75d commit 4632625
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion modules/renderer/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,14 +376,22 @@ export function rendererBackground(context) {
// build efficient index and querying for data.imagery
var features = data.imagery.map(function(source) {
if (!source.polygon) return null;

// Add an extra array nest to each element in `source.polygon`
// so the rings are not treated as a bunch of holes:
// what we have: [ [[outer],[hole],[hole]] ]
// what we want: [ [[outer]],[[outer]],[[outer]] ]
var rings = source.polygon.map(function(ring) { return [ring]; });

var feature = {
type: 'Feature',
properties: { id: source.id },
geometry: { type: 'MultiPolygon', coordinates: [ source.polygon ] }
geometry: { type: 'MultiPolygon', coordinates: rings }
};

data.imagery.features[source.id] = feature;
return feature;

}).filter(Boolean);

data.imagery.query = whichPolygon({
Expand Down

0 comments on commit 4632625

Please sign in to comment.