From 46326252bcb137263e5de9847ac5cbc5f9f769c5 Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Thu, 8 Nov 2018 13:17:13 -0500 Subject: [PATCH] Rewrite `source.polygon` into array of outers without holes (closes #5264, closes #5250, closes #5272) --- modules/renderer/background.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/modules/renderer/background.js b/modules/renderer/background.js index b52db0415..ea41e0264 100644 --- a/modules/renderer/background.js +++ b/modules/renderer/background.js @@ -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({