Open JuLink opened 1 year ago
Thanks for this detailed bug report @JuLink !
Maybe @stefankarschti has an idea what could be going on since he worked with the line layer recently.
The colorRamp has 256 steps here and the filter here may produce this effect for long lines. I suggest either increase the gradient texture size / change filter to nearest / introduce intermediate points for long lines.
(later edit) On a second thought, for this particular case there's a gradient from red to green, blue to red and so on, so the Nearest texture filter may do show a crisper transition.
You can also try breaking the line into segments for each traffic value / color.
Thanks for the quick response @stefankarschti and @louwers. I'm not sure to understand if it's something I can do as a user of the SDK or if it's something that needs to be change on the SDK itself.
Can you help me understand how I can change these filters and texture sizes with the current iOS API ?
I tried what you suggest in your last message (splitting the line by segments of the same colour), but I can't find a way to properly join the different line segments, especialy on tight curved roads for instance. The line cap of each segment doesn't connect properly to the next, and I found that the round line cap do not give the expected result.
hello @JuLink !
my suggestion is to fix it as a user of the SDK by breaking into more lines. My expectation is that the rounded line cap should work (opaque, no alpha). If there is an issue with the line cap, please submit it.
Hello,
Getting back to this issue, sorry for the delay 😥
We implemented a variant of your suggestion @stefankarschti. We don't have any gradient, but the result is pretty acceptable.
What we ended up doing is creating multiple polyline, one for each traffic intensity. Each polyline has a butt cap and to avoid the gap between two polylines (when they are angled for instance), each polyline takes a few coordinates of the following one. This make the end of one polyline disapear bellow the next one and there is no gap in between.
Thanks for the suggestion.
Describe the bug Using
NSExpression(forMGLInterpolating:curveType:parameters:stops:)
for theMGLLineStyleLayer.lineGradient
on a long Polyine with small increment in between stops leads to incorrect rendering of the gradient and missing colours.In my project, I'm trying to create a polyline for an itinerary that shows the traffic. To do that I create a Polyline and compute stops for a lineGradient so that the transition between two segments of the polyline with different colours is as small as possible. Here is a schematic representation:
[green]--------[green]--[red]--------[red]--[blue]--------[blue]--[orange]--------[orange]
where each[colour]
is a stop (associated with its colour) and each gradient between different colours is as small as possible.This seems to work properly only if the segments are large enough relatively to the length of the whole polyline.
To Reproduce You can use the following snippet that reproduces the issue. In the snippet you can comment/uncomment the lines in the
viewDidAppear
method to see the issue and the expected behaviour. To show the expected behaviour the last point of the polyline is simply moved to a closer distance from the rest, decreasing the length of the whole polyline (which increases the relative size of each segment).Expected behavior The final rendering when using a long polyline (in the exemple where the last point is really far) should display the proper colour on each segment and all the stops should be interpreted. The length of the polyline should not influence which stops are taken into account during interpolation.
Platform information (please complete the following information):