This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
55 changed files
with
4,027 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
include/mbgl/style/conversion/heatmap_color_property_value.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#pragma once | ||
|
||
#include <mbgl/style/heatmap_color_property_value.hpp> | ||
#include <mbgl/style/conversion.hpp> | ||
#include <mbgl/style/conversion/constant.hpp> | ||
#include <mbgl/style/conversion/function.hpp> | ||
#include <mbgl/style/conversion/expression.hpp> | ||
#include <mbgl/style/expression/value.hpp> | ||
#include <mbgl/style/expression/is_constant.hpp> | ||
#include <mbgl/style/expression/is_expression.hpp> | ||
#include <mbgl/style/expression/find_zoom_curve.hpp> | ||
|
||
namespace mbgl { | ||
namespace style { | ||
namespace conversion { | ||
|
||
template <> | ||
struct Converter<HeatmapColorPropertyValue> { | ||
optional<HeatmapColorPropertyValue> operator()(const Convertible& value, Error& error) const { | ||
if (isUndefined(value)) { | ||
return HeatmapColorPropertyValue(); | ||
} else if (isExpression(value)) { | ||
optional<std::unique_ptr<Expression>> expression = convert<std::unique_ptr<Expression>>(value, error, expression::type::Color); | ||
if (!expression) { | ||
return {}; | ||
} | ||
if (!isFeatureConstant(**expression)) { | ||
error = { "property expressions not supported" }; | ||
return {}; | ||
} | ||
if (!isZoomConstant(**expression)) { | ||
error = { "zoom expressions not supported" }; | ||
return {}; | ||
} | ||
return {HeatmapColorPropertyValue(std::move(*expression))}; | ||
} else { | ||
error = { "heatmap-color must be an expression" }; | ||
return {}; | ||
} | ||
} | ||
}; | ||
|
||
} // namespace conversion | ||
} // namespace style | ||
} // namespace mbgl | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#pragma once | ||
|
||
#include <mbgl/util/variant.hpp> | ||
#include <mbgl/style/undefined.hpp> | ||
#include <mbgl/style/function/camera_function.hpp> | ||
|
||
namespace mbgl { | ||
namespace style { | ||
|
||
/* | ||
* Special-case implementation of (a subset of) the PropertyValue<T> interface | ||
* used for building the HeatmapColor paint property traits class. | ||
*/ | ||
class HeatmapColorPropertyValue { | ||
private: | ||
std::shared_ptr<expression::Expression> value; | ||
|
||
friend bool operator==(const HeatmapColorPropertyValue& lhs, const HeatmapColorPropertyValue& rhs) { | ||
return *(lhs.value) == *(rhs.value); | ||
} | ||
|
||
friend bool operator!=(const HeatmapColorPropertyValue& lhs, const HeatmapColorPropertyValue& rhs) { | ||
return !(lhs == rhs); | ||
} | ||
|
||
public: | ||
HeatmapColorPropertyValue() : value(nullptr) {} | ||
HeatmapColorPropertyValue(std::shared_ptr<expression::Expression> value_) : value(std::move(value_)) {} | ||
|
||
bool isUndefined() const { return value.get() == nullptr; } | ||
|
||
// noop, needed for batch evaluation of paint property values to compile | ||
template <typename Evaluator> | ||
Color evaluate(const Evaluator&, TimePoint = {}) const { return {}; } | ||
|
||
Color evaluate(double heatmapDensity) const { | ||
const auto result = value->evaluate(expression::EvaluationContext({}, nullptr, {heatmapDensity})); | ||
return *expression::fromExpressionValue<Color>(*result); | ||
} | ||
|
||
bool isDataDriven() const { return false; } | ||
bool hasDataDrivenPropertyDifference(const HeatmapColorPropertyValue&) const { return false; } | ||
}; | ||
|
||
|
||
} // namespace style | ||
} // namespace mbgl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ enum class LayerType { | |
Background, | ||
Custom, | ||
FillExtrusion, | ||
Heatmap | ||
}; | ||
|
||
} // namespace style | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// This file is generated. Do not edit. | ||
|
||
#pragma once | ||
|
||
#include <mbgl/style/layer.hpp> | ||
#include <mbgl/style/filter.hpp> | ||
#include <mbgl/style/property_value.hpp> | ||
#include <mbgl/style/data_driven_property_value.hpp> | ||
#include <mbgl/style/heatmap_color_property_value.hpp> | ||
|
||
#include <mbgl/util/color.hpp> | ||
|
||
namespace mbgl { | ||
namespace style { | ||
|
||
class TransitionOptions; | ||
|
||
class HeatmapLayer : public Layer { | ||
public: | ||
HeatmapLayer(const std::string& layerID, const std::string& sourceID); | ||
~HeatmapLayer() final; | ||
|
||
// Source | ||
const std::string& getSourceID() const; | ||
const std::string& getSourceLayer() const; | ||
void setSourceLayer(const std::string& sourceLayer); | ||
|
||
void setFilter(const Filter&); | ||
const Filter& getFilter() const; | ||
|
||
// Visibility | ||
void setVisibility(VisibilityType) final; | ||
|
||
// Zoom range | ||
void setMinZoom(float) final; | ||
void setMaxZoom(float) final; | ||
|
||
// Paint properties | ||
|
||
static DataDrivenPropertyValue<float> getDefaultHeatmapRadius(); | ||
DataDrivenPropertyValue<float> getHeatmapRadius() const; | ||
void setHeatmapRadius(DataDrivenPropertyValue<float>); | ||
void setHeatmapRadiusTransition(const TransitionOptions&); | ||
TransitionOptions getHeatmapRadiusTransition() const; | ||
|
||
static DataDrivenPropertyValue<float> getDefaultHeatmapWeight(); | ||
DataDrivenPropertyValue<float> getHeatmapWeight() const; | ||
void setHeatmapWeight(DataDrivenPropertyValue<float>); | ||
void setHeatmapWeightTransition(const TransitionOptions&); | ||
TransitionOptions getHeatmapWeightTransition() const; | ||
|
||
static PropertyValue<float> getDefaultHeatmapIntensity(); | ||
PropertyValue<float> getHeatmapIntensity() const; | ||
void setHeatmapIntensity(PropertyValue<float>); | ||
void setHeatmapIntensityTransition(const TransitionOptions&); | ||
TransitionOptions getHeatmapIntensityTransition() const; | ||
|
||
static HeatmapColorPropertyValue getDefaultHeatmapColor(); | ||
HeatmapColorPropertyValue getHeatmapColor() const; | ||
void setHeatmapColor(HeatmapColorPropertyValue); | ||
void setHeatmapColorTransition(const TransitionOptions&); | ||
TransitionOptions getHeatmapColorTransition() const; | ||
|
||
static PropertyValue<float> getDefaultHeatmapOpacity(); | ||
PropertyValue<float> getHeatmapOpacity() const; | ||
void setHeatmapOpacity(PropertyValue<float>); | ||
void setHeatmapOpacityTransition(const TransitionOptions&); | ||
TransitionOptions getHeatmapOpacityTransition() const; | ||
|
||
// Private implementation | ||
|
||
class Impl; | ||
const Impl& impl() const; | ||
|
||
Mutable<Impl> mutableImpl() const; | ||
HeatmapLayer(Immutable<Impl>); | ||
std::unique_ptr<Layer> cloneRef(const std::string& id) const final; | ||
}; | ||
|
||
template <> | ||
inline bool Layer::is<HeatmapLayer>() const { | ||
return getType() == LayerType::Heatmap; | ||
} | ||
|
||
} // namespace style | ||
} // namespace mbgl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.