Repository navigation
Add line-gradient property - #6303
Conversation
356f32f to
121f74a
Compare
| return `CrossFadedProperty<${flowType(property)}>`; | ||
| } else if (property.name === 'heatmap-color') { | ||
| return `HeatmapColorProperty`; | ||
| } else if (property.name === 'heatmap-color' || property.name === 'line-gradient') { |
There was a problem hiding this comment.
It's great that we have a second property with the same semantics as heatmap-color -- that increases the likelihood that heatmap-color is not some odd exception (and as we know, the odd exceptions are disproportionately expensive to maintain).
Since we now have two similarly-behaving properties, it's worth finding a generic way to capture that the style spec and replace the property name comparisons here with the use of a semantic property like isDataDriven uses. Such a property would probably be useful for Studio as well. As a schema design question, it intersects with #4194 -- although in light of this new information, I'm not sure my proposal there is still the best choice. @lbud do you want to think about this and come up with a proposal?
I'm working on this (#6389) but ended up splitting it off this branch as it complicates things quite a bit and conflates two different issues. I'm thinking maybe we should merge this as is (not as part of the 0.45 release) and follow it up immediately with a PR accomplishing #6389 (comment). Does that sound alright? |
jfirebaugh
left a comment
There was a problem hiding this comment.
LGTM. Can you post benchmarks results?
Instead of indexing all features for querying, index only those that are actually within the tile boundaries. This prevents duplicate results from being returned for point features. This is only a partial fix for the duplicate results problem (lines and polygons can still return duplicate results).
…e of consistency with vector tiles), necessitating splitting MultiLineString features into individual LineStrings so they can hold their own distance attributes * Add render test
* Add unit tests for color ramp rendering
…s), clean up style-spec ref, add validation to ensure gradients are only used with geojson sources
Porting of mapbox/mapbox-gl-js#6303 See the link above for the description of the feature and its limitations). Based on patch from @lbud (Lauren Budorick).
Porting of mapbox/mapbox-gl-js#6303 See the link above for the description of the feature and its limitations). Based on patch from @lbud (Lauren Budorick).
|
👍 |
Porting of mapbox/mapbox-gl-js#6303 See the link above for the description of the feature and its limitations). Based on patch from @lbud (Lauren Budorick).
Porting of mapbox/mapbox-gl-js#6303 See the link above for the description of the feature and its limitations). Based on patch from @lbud (Lauren Budorick).
Porting of mapbox/mapbox-gl-js#6303 See the link above for the description of the feature and its limitations). Based on patch from @lbud (Lauren Budorick).
This PR adds support for gradient lines, with the following limitations:
line-gradientcan only be used for lines with GeoJSON sources"lineMetrics": trueoptionline-gradientcannot be used in conjunction withline-dasharrayorline-patternheatmap-color,line-gradientmust be specified using an expression with a specialline-progressproperty: for example,Overview of changes:
lineMetricsoption to GeoJSON sources, which is passed through to geojson-vt in order to track distance metrics for linestring featuresline-gradientline paint property, which specifies a gradient and is used in the same wayheatmap-coloris used to write a 256x1px texture containing the gradientHeatmapColorPropertytoColorRampPropertyto be used for both, and abstracts color ramp image creation into a utility module for use in bothLineBucket:mapbox_clip_startandmapbox_clip_endproperties, which are special properties added by geojson-vt whenlineMetrics=true, and if sodistanceattribute of each vertex to [0, 215) relative to the length of the entire original line geometryline_gradientshaders which sample from the line gradient texture based on the distance varying.Refs #4095.
Benchmarks:
http://bl.ocks.org/lbud/raw/e96f30170bfc39a6e3f1ddd2c0cc8fa1/ — the only benchmark I'd expect to potentially be affected by this is
LayerLine, which in the linked benchmarks looks like it improves but when repeatedly running benchmarks actually stays just about equal. I also added a temporaryLayerLineGradientbenchmark (bottom of page) and it is, expectedly, just a little bit slower than the plainLayerLine, which doe not render to or sample from a texture.Launch Checklist