summaryrefslogtreecommitdiff
path: root/src/mbgl/style/layers/circle_layer_impl.cpp
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-10-28 16:39:50 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-02-02 09:44:42 -0800
commit141e995806576364d185626176c1b993fc519291 (patch)
treeecdc41fc7699f2a1a9e9456157348451ebe99597 /src/mbgl/style/layers/circle_layer_impl.cpp
parent6a6bddb4537004cc1bfc506e76772de74d33f3f7 (diff)
downloadqtlocation-mapboxgl-141e995806576364d185626176c1b993fc519291.tar.gz
[core] Add support for data-driven styling
Diffstat (limited to 'src/mbgl/style/layers/circle_layer_impl.cpp')
-rw-r--r--src/mbgl/style/layers/circle_layer_impl.cpp22
1 files changed, 8 insertions, 14 deletions
diff --git a/src/mbgl/style/layers/circle_layer_impl.cpp b/src/mbgl/style/layers/circle_layer_impl.cpp
index 136522e41c..655ad9b5b9 100644
--- a/src/mbgl/style/layers/circle_layer_impl.cpp
+++ b/src/mbgl/style/layers/circle_layer_impl.cpp
@@ -1,5 +1,4 @@
#include <mbgl/style/layers/circle_layer_impl.hpp>
-#include <mbgl/style/bucket_parameters.hpp>
#include <mbgl/renderer/circle_bucket.hpp>
#include <mbgl/geometry/feature_index.hpp>
#include <mbgl/util/math.hpp>
@@ -15,27 +14,22 @@ void CircleLayer::Impl::cascade(const CascadeParameters& parameters) {
bool CircleLayer::Impl::evaluate(const PropertyEvaluationParameters& parameters) {
paint.evaluate(parameters);
- passes = (paint.evaluated.get<CircleRadius>() > 0 && paint.evaluated.get<CircleColor>().a > 0 && paint.evaluated.get<CircleOpacity>() > 0)
+ passes = (paint.evaluated.get<CircleRadius>().constantOr(1) > 0
+ && paint.evaluated.get<CircleColor>().constantOr(Color::black()).a > 0
+ && paint.evaluated.get<CircleOpacity>().constantOr(1) > 0)
? RenderPass::Translucent : RenderPass::None;
return paint.hasTransition();
}
-std::unique_ptr<Bucket> CircleLayer::Impl::createBucket(BucketParameters& parameters, const GeometryTileLayer& layer) const {
- auto bucket = std::make_unique<CircleBucket>(parameters.mode);
-
- parameters.eachFilteredFeature(filter, layer, [&] (const auto& feature, std::size_t index, const std::string& layerName) {
- auto geometries = feature.getGeometries();
- bucket->addGeometry(geometries);
- parameters.featureIndex.insert(geometries, index, layerName, id);
- });
-
- return std::move(bucket);
+std::unique_ptr<Bucket> CircleLayer::Impl::createBucket(const BucketParameters& parameters, const std::vector<const Layer*>& layers) const {
+ return std::make_unique<CircleBucket>(parameters, layers);
}
float CircleLayer::Impl::getQueryRadius() const {
const std::array<float, 2>& translate = paint.evaluated.get<CircleTranslate>();
- return paint.evaluated.get<CircleRadius>() + util::length(translate[0], translate[1]);
+ return paint.evaluated.get<CircleRadius>().constantOr(CircleRadius::defaultValue())
+ + util::length(translate[0], translate[1]);
}
bool CircleLayer::Impl::queryIntersectsGeometry(
@@ -47,7 +41,7 @@ bool CircleLayer::Impl::queryIntersectsGeometry(
auto translatedQueryGeometry = FeatureIndex::translateQueryGeometry(
queryGeometry, paint.evaluated.get<CircleTranslate>(), paint.evaluated.get<CircleTranslateAnchor>(), bearing, pixelsToTileUnits);
- auto circleRadius = paint.evaluated.get<CircleRadius>() * pixelsToTileUnits;
+ auto circleRadius = paint.evaluated.get<CircleRadius>().constantOr(CircleRadius::defaultValue()) * pixelsToTileUnits;
return util::polygonIntersectsBufferedMultiPoint(
translatedQueryGeometry.value_or(queryGeometry), geometry, circleRadius);