-
Notifications
You must be signed in to change notification settings - Fork 290
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
Label multipoint #409
Label multipoint #409
Conversation
@dmvaldman Can you please add screenshots showing highway shield spacing, too? |
@nvkelso spacing is configurable so we should be able to tune in the style. That said, I suspect this feature will be more useful for oneway arrows than for shields, because I assume shields will be less frequently spaced (in fact right now we are placing more than necessary and then the repeat logic culls them out, this PR could exacerbate that!), combined with tile discontinuities between lines makes it hard to get good continuous spacing. But, even if it's not placing very many shields, this PR will make it place them in better locations, away from the line vertices/intersections. |
I think we're close here, just a few questions to resolve: 1. Do we want to continue to support the existing behavior that places of points on line or polygon vertices? My feeling is that while this probably isn't the typical scenario, it's useful in some situations (like visualizing the geometry below) and would be nice to preserve -- though we could consider making it no longer the default. 2. If the answer to the above is yes, then we need an option for specifying the placement strategy, as @dmvaldman suggests. Mapbox calls their similar placement options A couple possibilities: I would avoid I'm also unsure if we currently have a need for a "midpoints" placement strategy, though it is worth considering for shields (where I think keeping them away from vertices/intersections is more important than actually spacing them out, given that they don't need to repeat too often). Terminology like 3. Ambiguity with Could also consider renaming 4. Angle of point/sprite I'm OK with either 5. Polygon handling @nvkelso @blair1618 thoughts on all of the above please? |
💯 @dmvaldman thanks for the extra shield animated GIF! Ship it! For terminology:
|
What about |
@bcamper I missed your earlier comment, responses to all below:
Yes (agree). Especially to allow data editing like the OSM discussion.
These sound slightly different to me. One is about general label alignment and implied angle changes (snapping to point(s), lines, or polygon centroid), versus specific placement strategy (start, stop, all vertexes, midpoint of line, poor man's centroid, centroid on surface, the more interesting "best" placement Mapbox just blogged about). The repeat / placement strategy extensions would include (midpoint between vertexes, centroids in all parts of multi-polygon).
Agree with Agree with renaming
If I've chosen to "align" my label to the line, then I think the default I've wanted to do angles for points for a while. Viewpoints from OSM include this (expressed often in cardinal directions but I'd convert that to 0-360° server side in tiles).
+1 |
set default placement to 80px
e.g. arrow sprite should be facing up for angle 0
@dmvaldman follow-up from IRL discussion: let's make sure that at least one point is placed on each geometry (maybe only if that one point will fit along the line length?). |
1a05fbf
to
f0c143b
Compare
move some draw group calc to one-time preprocess step
(more consistent with other classes)
…ement (matches behavior for polyline builder)
matches existing behavior and cheapest to compute, so for now asking users to opt in to more specific strategies
@@ -11,7 +11,7 @@ import Geo from '../../geo'; | |||
import Vector from '../../vector'; | |||
import Collision from '../../labels/collision'; | |||
import LabelPoint from '../../labels/label_point'; | |||
import placePointsOnLine from '../../labels/label_multipoint'; | |||
import placePointsOnLine from '../../labels/point_placement'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
I made some updates re: the issues discussed above:
Not yet implemented: changing I think this is in good pretty good shape and can be merged, with syntax/naming changes made before final release if needed. Comments @dmvaldman @blair1618 @nvkelso? I have some additional comments around point/shield placement that I will follow up with. |
Going to merge this as-is to coordinate with other features, but feel free to comment on above and we can make adjustments in master (pre-release). |
Based on tangrams/tangram#409 – @bcamper to review, with the further expectation of `repeat_distance` being renamed `repeat_tolerance` at some point tbd.
let positions = []; | ||
let angles = []; | ||
|
||
let distance = 0.5 * remainder; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dmvaldman can you explain the heuristic of halving the remainder "placing space" here? I was thinking of starting the line interpolation from remainder/num_labels
... Basically to distribute the actual placing between n labels. Will be good know if I am totally in the wrong direction here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect. Picture speaks more than words :). Thanks
WIP for different strategies to place point-like features along line geometry. Previously point features on lines would just place the points at the endpoints of the line segments. However for use-cases like highway shields and street arrows you may want different behavior. Street arrows should be "evenly spaced" along a line, for instance.
Here's an example for this scene file snippet
Here
arrow
is a user-defined texture.We may want to consider a better terminology than
spacing
, as the similarly torepeat_distance
is a source for confusion. Similarly forauto
angles. We may also want to include aplacement_strategy
option such asendpoints
,midpoints
,spaced
or something like that.In the code, I call this new class
label_multipoint
, but this is pretty unclear, so we can also revisit the naming oflabel_line
(which is becoming highly specialized for text labels) andlabel_multipoint
, etc.