diff options
Diffstat (limited to 'include/mbgl/style/sources')
-rw-r--r-- | include/mbgl/style/sources/custom_geometry_source.hpp | 58 | ||||
-rw-r--r-- | include/mbgl/style/sources/geojson_source.hpp | 2 | ||||
-rw-r--r-- | include/mbgl/style/sources/raster_dem_source.hpp | 25 | ||||
-rw-r--r-- | include/mbgl/style/sources/raster_source.hpp | 4 |
4 files changed, 87 insertions, 2 deletions
diff --git a/include/mbgl/style/sources/custom_geometry_source.hpp b/include/mbgl/style/sources/custom_geometry_source.hpp new file mode 100644 index 0000000000..9daeeb3819 --- /dev/null +++ b/include/mbgl/style/sources/custom_geometry_source.hpp @@ -0,0 +1,58 @@ +#pragma once + +#include <mbgl/style/source.hpp> +#include <mbgl/util/geo.hpp> +#include <mbgl/util/geojson.hpp> +#include <mbgl/util/range.hpp> +#include <mbgl/util/constants.hpp> + +namespace mbgl { + +class OverscaledTileID; +class CanonicalTileID; +template <class T> +class Actor; + +namespace style { + +using TileFunction = std::function<void(const CanonicalTileID&)>; + +class CustomTileLoader; + +class CustomGeometrySource : public Source { +public: + struct TileOptions { + double tolerance = 0.375; + uint16_t tileSize = util::tileSize; + uint16_t buffer = 128; + bool clip = false; + bool wrap = false; + }; + + struct Options { + TileFunction fetchTileFunction; + TileFunction cancelTileFunction; + Range<uint8_t> zoomRange = { 0, 18}; + TileOptions tileOptions; + }; +public: + CustomGeometrySource(std::string id, CustomGeometrySource::Options options); + ~CustomGeometrySource() final; + void loadDescription(FileSource&) final; + void setTileData(const CanonicalTileID&, const GeoJSON&); + void invalidateTile(const CanonicalTileID&); + void invalidateRegion(const LatLngBounds&); + // Private implementation + class Impl; + const Impl& impl() const; +private: + std::unique_ptr<Actor<CustomTileLoader>> loader; +}; + +template <> +inline bool Source::is<CustomGeometrySource>() const { + return getType() == SourceType::CustomVector; +} + +} // namespace style +} // namespace mbgl diff --git a/include/mbgl/style/sources/geojson_source.hpp b/include/mbgl/style/sources/geojson_source.hpp index 5bdf1ef957..372e7c7a78 100644 --- a/include/mbgl/style/sources/geojson_source.hpp +++ b/include/mbgl/style/sources/geojson_source.hpp @@ -3,6 +3,7 @@ #include <mbgl/style/source.hpp> #include <mbgl/util/geojson.hpp> #include <mbgl/util/optional.hpp> +#include <mbgl/util/constants.hpp> namespace mbgl { @@ -14,6 +15,7 @@ struct GeoJSONOptions { // GeoJSON-VT options uint8_t minzoom = 0; uint8_t maxzoom = 18; + uint16_t tileSize = util::tileSize; uint16_t buffer = 128; double tolerance = 0.375; diff --git a/include/mbgl/style/sources/raster_dem_source.hpp b/include/mbgl/style/sources/raster_dem_source.hpp new file mode 100644 index 0000000000..82588613bc --- /dev/null +++ b/include/mbgl/style/sources/raster_dem_source.hpp @@ -0,0 +1,25 @@ +#pragma once + +#include <mbgl/style/sources/raster_source.hpp> +#include <mbgl/util/tileset.hpp> +#include <mbgl/util/variant.hpp> + +namespace mbgl { + +class AsyncRequest; + +namespace style { + +class RasterDEMSource : public RasterSource { +public: + RasterDEMSource(std::string id, variant<std::string, Tileset> urlOrTileset, uint16_t tileSize); + +}; + +template <> +inline bool Source::is<RasterDEMSource>() const { + return getType() == SourceType::RasterDEM; +} + +} // namespace style +} // namespace mbgl diff --git a/include/mbgl/style/sources/raster_source.hpp b/include/mbgl/style/sources/raster_source.hpp index 7f23a7ca4b..5aa81aa979 100644 --- a/include/mbgl/style/sources/raster_source.hpp +++ b/include/mbgl/style/sources/raster_source.hpp @@ -12,8 +12,8 @@ namespace style { class RasterSource : public Source { public: - RasterSource(std::string id, variant<std::string, Tileset> urlOrTileset, uint16_t tileSize); - ~RasterSource() final; + RasterSource(std::string id, variant<std::string, Tileset> urlOrTileset, uint16_t tileSize, SourceType sourceType = SourceType::Raster); + ~RasterSource() override; const variant<std::string, Tileset>& getURLOrTileset() const; optional<std::string> getURL() const; |