Skip to content

Commit

Permalink
Add repeat_distance and repeat_group logic for point styles. Default …
Browse files Browse the repository at this point in the history
…distance to 0.
  • Loading branch information
dmvaldman committed Sep 8, 2016
1 parent b7fb7e9 commit 7c120e0
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/styles/points/points.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,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 || 0, parseFloat);

// Optional text styling
draw.text = this.preprocessText(draw.text); // will return null if valid text styling wasn't provided
if (draw.text) {
Expand Down Expand Up @@ -400,6 +403,24 @@ Object.assign(Points, {
layout.offset = StyleParser.evalCachedProperty(draw.offset, context) || StyleParser.zeroPair;
layout.buffer = StyleParser.evalCachedProperty(draw.buffer, context) || StyleParser.zeroPair;

// repeat minimum distance
layout.repeat_distance = StyleParser.evalCachedProperty(draw.repeat_distance, context);
if (layout.repeat_distance == null) {
layout.repeat_distance = Geo.tile_size;
}
layout.repeat_distance *= layout.units_per_pixel;

// repeat group key
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
}

// label priority (lower is higher)
let priority = draw.priority;
if (priority != null) {
Expand Down

0 comments on commit 7c120e0

Please sign in to comment.