diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2016-06-13 10:59:33 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-06-13 10:59:33 -0700 |
commit | 5c7dfd948ffd52f2b60dcfe052176da788f17893 (patch) | |
tree | 596d02b0e28d6e7649f9527af2834c90c3c3b056 /src/mbgl/tile/geometry_tile_data.hpp | |
parent | 3ab7c1cca3aa4658b40af1d7d591850e005d011e (diff) | |
download | qtlocation-mapboxgl-5c7dfd948ffd52f2b60dcfe052176da788f17893.tar.gz |
[core] *Tile ↔ *TileData
Tile is now the main base class; RasterTile, VectorTile, etc are its subclasses. GeometryTileData and its subclasses form the piece that's passed to the worker.
Diffstat (limited to 'src/mbgl/tile/geometry_tile_data.hpp')
-rw-r--r-- | src/mbgl/tile/geometry_tile_data.hpp | 122 |
1 files changed, 63 insertions, 59 deletions
diff --git a/src/mbgl/tile/geometry_tile_data.hpp b/src/mbgl/tile/geometry_tile_data.hpp index 6c7ff2f3d9..753ba6b8a2 100644 --- a/src/mbgl/tile/geometry_tile_data.hpp +++ b/src/mbgl/tile/geometry_tile_data.hpp @@ -1,79 +1,83 @@ #pragma once -#include <mbgl/tile/tile_data.hpp> -#include <mbgl/tile/tile_worker.hpp> -#include <mbgl/text/placement_config.hpp> -#include <mbgl/util/atomic.hpp> +#include <mbgl/util/geometry.hpp> #include <mbgl/util/feature.hpp> - -#include <memory> +#include <mbgl/util/chrono.hpp> +#include <mbgl/util/ptr.hpp> +#include <mbgl/util/noncopyable.hpp> +#include <mbgl/util/optional.hpp> +#include <mbgl/util/variant.hpp> +#include <mbgl/util/constants.hpp> + +#include <cstdint> +#include <string> +#include <vector> #include <unordered_map> +#include <functional> namespace mbgl { -class AsyncRequest; -class GeometryTile; -class GeometryTileSource; -class FeatureIndex; - -namespace style { -class Style; -} - -class GeometryTileData : public TileData { -public: - GeometryTileData(const OverscaledTileID&, - std::string sourceID, - style::Style&, - const MapMode); - - ~GeometryTileData(); - - void setError(std::exception_ptr err); - - void setData(std::unique_ptr<GeometryTile> tile, - optional<Timestamp> modified_, - optional<Timestamp> expires_); - - Bucket* getBucket(const style::Layer&) override; - - bool parsePending() override; +enum class FeatureType : uint8_t { + Unknown = 0, + Point = 1, + LineString = 2, + Polygon = 3 +}; - void redoPlacement(PlacementConfig) override; +class CanonicalTileID; - void queryRenderedFeatures( - std::unordered_map<std::string, std::vector<Feature>>& result, - const GeometryCoordinates& queryGeometry, - const TransformState&, - const optional<std::vector<std::string>>& layerIDs) override; +// Normalized vector tile coordinates. +// Each geometry coordinate represents a point in a bidimensional space, +// varying from -V...0...+V, where V is the maximum extent applicable. +using GeometryCoordinate = Point<int16_t>; - void cancel() override; +class GeometryCoordinates : public std::vector<GeometryCoordinate> { +public: + using coordinate_type = int16_t; + using std::vector<GeometryCoordinate>::vector; +}; -private: - void redoPlacement(); +class GeometryCollection : public std::vector<GeometryCoordinates> { +public: + using coordinate_type = int16_t; + using std::vector<GeometryCoordinates>::vector; +}; - style::Style& style; - Worker& worker; - TileWorker tileWorker; +class GeometryTileFeature : private util::noncopyable { +public: + virtual ~GeometryTileFeature() = default; + virtual FeatureType getType() const = 0; + virtual optional<Value> getValue(const std::string& key) const = 0; + virtual Feature::property_map getProperties() const { return Feature::property_map(); } + virtual optional<uint64_t> getID() const { return {}; } + virtual GeometryCollection getGeometries() const = 0; +}; - std::unique_ptr<AsyncRequest> workRequest; +class GeometryTileLayer : private util::noncopyable { +public: + virtual ~GeometryTileLayer() = default; + virtual std::size_t featureCount() const = 0; + virtual util::ptr<const GeometryTileFeature> getFeature(std::size_t) const = 0; + virtual std::string getName() const = 0; +}; - // Contains all the Bucket objects for the tile. Buckets are render - // objects and they get added by tile parsing operations. - std::unordered_map<std::string, std::unique_ptr<Bucket>> buckets; +class GeometryTileData : private util::noncopyable { +public: + virtual ~GeometryTileData() = default; + virtual util::ptr<GeometryTileLayer> getLayer(const std::string&) const = 0; +}; - std::unique_ptr<FeatureIndex> featureIndex; - std::unique_ptr<const GeometryTile> geometryTile; +// classifies an array of rings into polygons with outer rings and holes +std::vector<GeometryCollection> classifyRings(const GeometryCollection&); - // Stores the placement configuration of the text that is currently placed on the screen. - PlacementConfig placedConfig; +// Truncate polygon to the largest `maxHoles` inner rings by area. +void limitHoles(GeometryCollection&, uint32_t maxHoles); - // Stores the placement configuration of how the text should be placed. This isn't necessarily - // the one that is being displayed. - PlacementConfig targetConfig; +// convert from GeometryTileFeature to Feature (eventually we should eliminate GeometryTileFeature) +Feature convertFeature(const GeometryTileFeature&, const CanonicalTileID&); - // Used to signal the worker that it should abandon parsing this tile as soon as possible. - util::Atomic<bool> obsolete { false }; -}; +// Fix up possibly-non-V2-compliant polygon geometry using angus clipper. +// The result is guaranteed to have correctly wound, strictly simple rings. +GeometryCollection fixupPolygons(const GeometryCollection&); } // namespace mbgl |