Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

Support for using `within expression` with layout propery will be implemented separately.

- [core] Add support for using `within expression` with layout propery. ([#16194](https://github.com/mapbox/mapbox-gl-native/pull/16194))

### 🏁 Performance improvements

- [core] Loading images to style optimization ([#16187](https://github.com/mapbox/mapbox-gl-native/pull/16187))
Expand Down
33 changes: 33 additions & 0 deletions include/mbgl/style/property_expression.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,20 @@ class PropertyExpression final : public PropertyExpressionBase {
finalDefaultValue);
}

T evaluate(const GeometryTileFeature& feature, const CanonicalTileID& canonical, T finalDefaultValue) const {
return evaluate(expression::EvaluationContext(&feature).withCanonicalTileID(&canonical), finalDefaultValue);
}

T evaluate(const GeometryTileFeature& feature,
const std::set<std::string>& availableImages,
const CanonicalTileID& canonical,
T finalDefaultValue) const {
return evaluate(expression::EvaluationContext(&feature)
.withAvailableImages(&availableImages)
.withCanonicalTileID(&canonical),
finalDefaultValue);
}

T evaluate(float zoom, const GeometryTileFeature& feature, T finalDefaultValue) const {
return evaluate(expression::EvaluationContext(zoom, &feature), finalDefaultValue);
}
Expand All @@ -85,6 +99,25 @@ class PropertyExpression final : public PropertyExpressionBase {
finalDefaultValue);
}

T evaluate(float zoom,
const GeometryTileFeature& feature,
const std::set<std::string>& availableImages,
const CanonicalTileID& canonical,
T finalDefaultValue) const {
return evaluate(expression::EvaluationContext(zoom, &feature)
.withAvailableImages(&availableImages)
.withCanonicalTileID(&canonical),
finalDefaultValue);
}

T evaluate(float zoom,
const GeometryTileFeature& feature,
const CanonicalTileID& canonical,
T finalDefaultValue) const {
return evaluate(expression::EvaluationContext(zoom, &feature).withCanonicalTileID(&canonical),
finalDefaultValue);
}

T evaluate(float zoom, const GeometryTileFeature& feature, const FeatureState& state, T finalDefaultValue) const {
assert(!isFeatureConstant());
return evaluate(expression::EvaluationContext(zoom, &feature, &state), finalDefaultValue);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"network": [
[
"probeNetwork - default - end",
1,
84942
],
[
"probeNetwork - default - start",
0,
0
]
],
"gfx": [
[
"probeGFX - default - end",
13,
17,
21,
1,
[
207208,
207208
],
[
210,
210
],
[
944,
944
]
]
]
}
3 changes: 1 addition & 2 deletions metrics/ignores/platform-all.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,5 @@
"render-tests/text-variable-anchor/left-top-right-buttom-offset-tile-map-mode":"https://github.com/mapbox/mapbox-gl-js/pull/9202",
"render-tests/line-pattern/with-dasharray":"https://github.com/mapbox/mapbox-gl-js/pull/9189",
"render-tests/symbol-sort-key/placement-tile-boundary-right-then-left": "https://github.com/mapbox/mapbox-gl-js/pull/9054",
"render-tests/line-dasharray/zero-length-gap":"https://github.com/mapbox/mapbox-gl-js/pull/9246",
"render-tests/within/layout-text": "TODO: Fix by enabling `within` expreesion with layout property"
"render-tests/line-dasharray/zero-length-gap":"https://github.com/mapbox/mapbox-gl-js/pull/9246"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"network": [
[
"probeNetwork - default - end",
1,
84942
],
[
"probeNetwork - default - start",
0,
0
]
],
"gfx": [
[
"probeGFX - default - end",
13,
17,
21,
1,
[
207208,
207208
],
[
210,
210
],
[
944,
944
]
]
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"network": [
[
"probeNetwork - default - end",
1,
84942
],
[
"probeNetwork - default - start",
0,
0
]
],
"gfx": [
[
"probeGFX - default - end",
13,
17,
21,
1,
[
207208,
207208
],
[
210,
210
],
[
944,
944
]
]
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"network": [
[
"probeNetwork - default - end",
1,
84942
],
[
"probeNetwork - default - start",
0,
0
]
],
"gfx": [
[
"probeGFX - default - end",
13,
17,
21,
1,
[
207208,
207208
],
[
210,
210
],
[
944,
944
]
]
]
}
30 changes: 20 additions & 10 deletions src/mbgl/layout/pattern_layout.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ struct PatternFeatureInserter<void> {
std::unique_ptr<GeometryTileFeature> feature,
PatternLayerMap patternDependencyMap,
float /*zoom*/,
const PropertiesType&) {
const PropertiesType&,
const CanonicalTileID&) {
features.emplace_back(index, std::move(feature), std::move(patternDependencyMap));
}
};
Expand All @@ -58,9 +59,10 @@ struct PatternFeatureInserter {
std::unique_ptr<GeometryTileFeature> feature,
PatternLayerMap patternDependencyMap,
float zoom,
const PropertiesType& properties) {
const PropertiesType& properties,
const CanonicalTileID& canonical) {
const auto& sortKeyProperty = properties.template get<SortKeyPropertyType>();
float sortKey = sortKeyProperty.evaluate(*feature, zoom, SortKeyPropertyType::defaultValue());
float sortKey = sortKeyProperty.evaluate(*feature, zoom, canonical, SortKeyPropertyType::defaultValue());
PatternFeature patternFeature{index, std::move(feature), std::move(patternDependencyMap), sortKey};
const auto lowerBound = std::lower_bound(features.cbegin(), features.cend(), patternFeature);
features.insert(lowerBound, std::move(patternFeature));
Expand Down Expand Up @@ -127,12 +129,17 @@ class PatternLayout : public Layout {
const auto min = patternProperty.evaluate(*feature,
zoom - 1,
layoutParameters.availableImages,
parameters.tileID.canonical,
PatternPropertyType::defaultValue());
const auto mid = patternProperty.evaluate(*feature,
zoom,
layoutParameters.availableImages,
parameters.tileID.canonical,
PatternPropertyType::defaultValue());
const auto mid = patternProperty.evaluate(
*feature, zoom, layoutParameters.availableImages, PatternPropertyType::defaultValue());
const auto max = patternProperty.evaluate(*feature,
zoom + 1,
layoutParameters.availableImages,
parameters.tileID.canonical,
PatternPropertyType::defaultValue());

layoutParameters.imageDependencies.emplace(min.to.id(), ImageType::Pattern);
Expand All @@ -145,14 +152,17 @@ class PatternLayout : public Layout {
}
}

PatternFeatureInserter<SortKeyPropertyType>::insert(
features, i, std::move(feature), std::move(patternDependencyMap), zoom, layout);
PatternFeatureInserter<SortKeyPropertyType>::insert(features,
i,
std::move(feature),
std::move(patternDependencyMap),
zoom,
layout,
parameters.tileID.canonical);
}
};

bool hasDependencies() const override {
return hasPattern;
}
bool hasDependencies() const override { return hasPattern; }

void createBucket(const ImagePositions& patternPositions,
std::unique_ptr<FeatureIndex>& featureIndex,
Expand Down
Loading