Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply repeat group logic to points #424

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/styles/points/points.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
},

Expand Down