-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Add line-gradient property #6303
Conversation
356f32f
to
121f74a
Compare
@@ -44,8 +44,8 @@ global.propertyType = function (property) { | |||
return `DataDrivenProperty<${flowType(property)}>`; | |||
} else if (/-pattern$/.test(property.name) || property.name === 'line-dasharray') { | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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? |
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.
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-gradient
can only be used for lines with GeoJSON sources"lineMetrics": true
optionline-gradient
cannot be used in conjunction withline-dasharray
orline-pattern
heatmap-color
,line-gradient
must be specified using an expression with a specialline-progress
property: for example,Overview of changes:
lineMetrics
option to GeoJSON sources, which is passed through to geojson-vt in order to track distance metrics for linestring featuresline-gradient
line paint property, which specifies a gradient and is used in the same wayheatmap-color
is used to write a 256x1px texture containing the gradientHeatmapColorProperty
toColorRampProperty
to be used for both, and abstracts color ramp image creation into a utility module for use in bothLineBucket
:mapbox_clip_start
andmapbox_clip_end
properties, which are special properties added by geojson-vt whenlineMetrics=true
, and if sodistance
attribute of each vertex to [0, 215) relative to the length of the entire original line geometryline_gradient
shaders 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 temporaryLayerLineGradient
benchmark (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