From 1dccff51d99b16c5ea54c5a7b8124d679a1d5265 Mon Sep 17 00:00:00 2001 From: Brett Camper Date: Wed, 12 Oct 2016 11:17:17 -0400 Subject: [PATCH] apply repeat group logic to points (in addition to text labels) --- src/styles/points/points.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/styles/points/points.js b/src/styles/points/points.js index b79edefb2..1597b3c89 100755 --- a/src/styles/points/points.js +++ b/src/styles/points/points.js @@ -343,6 +343,9 @@ Object.assign(Points, { // Buffer (1d value or 2d array, expand 1d to 2d) draw.buffer = StyleParser.createPropertyCache(draw.buffer, v => (Array.isArray(v) ? v : [v, v]).map(parseFloat) || 0); + // Repeat rules + draw.repeat_distance = StyleParser.createPropertyCache(draw.repeat_distance, parseFloat); + // Optional text styling draw.text = this.preprocessText(draw.text); // will return null if valid text styling wasn't provided if (draw.text) { @@ -397,6 +400,23 @@ Object.assign(Points, { } layout.priority = priority; + // repeat minimum distance + layout.repeat_distance = StyleParser.evalCachedProperty(draw.repeat_distance, context); + layout.repeat_distance *= layout.units_per_pixel; + + // repeat group key - only needed if a non-zero repeat distance + if (layout.repeat_distance) { + if (typeof draw.repeat_group === 'function') { + layout.repeat_group = draw.repeat_group(context); + } + else if (typeof draw.repeat_group === 'string') { + layout.repeat_group = draw.repeat_group; + } + else { + layout.repeat_group = draw.key; // default to unique set of matching layers + } + } + return layout; },