diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2016-02-11 17:30:35 -0800 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-02-11 17:30:35 -0800 |
commit | 62bbf2627a32a57188e4026aca8dc337e07ded7f (patch) | |
tree | 4db2a7e2bef2491eb7a8b98b0caa8b61aeae7283 /src/mbgl/tile/geometry_tile.hpp | |
parent | 43c44eccdc56c50e41e8efbe5f7a34b57eed756f (diff) | |
download | qtlocation-mapboxgl-62bbf2627a32a57188e4026aca8dc337e07ded7f.tar.gz |
[core] Organize files that were in map folder better
Fixes #996
Diffstat (limited to 'src/mbgl/tile/geometry_tile.hpp')
-rw-r--r-- | src/mbgl/tile/geometry_tile.hpp | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/src/mbgl/tile/geometry_tile.hpp b/src/mbgl/tile/geometry_tile.hpp new file mode 100644 index 0000000000..5cb2f96fdc --- /dev/null +++ b/src/mbgl/tile/geometry_tile.hpp @@ -0,0 +1,85 @@ +#ifndef MBGL_MAP_GEOMETRY_TILE +#define MBGL_MAP_GEOMETRY_TILE + +#include <mapbox/variant.hpp> + +#include <mbgl/style/value.hpp> +#include <mbgl/util/chrono.hpp> +#include <mbgl/util/ptr.hpp> +#include <mbgl/util/vec.hpp> +#include <mbgl/util/noncopyable.hpp> +#include <mbgl/util/optional.hpp> + +#include <cstdint> +#include <string> +#include <vector> +#include <functional> + +namespace mbgl { + +enum class FeatureType : uint8_t { + Unknown = 0, + Point = 1, + LineString = 2, + Polygon = 3 +}; + +typedef std::vector<std::vector<Coordinate>> GeometryCollection; + +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 GeometryCollection getGeometries() const = 0; + virtual uint32_t getExtent() const = 0; +}; + +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; +}; + +class GeometryTile : private util::noncopyable { +public: + virtual ~GeometryTile() = default; + virtual util::ptr<GeometryTileLayer> getLayer(const std::string&) const = 0; +}; + +class FileRequest; + +class GeometryTileMonitor : private util::noncopyable { +public: + virtual ~GeometryTileMonitor() = default; + + using Callback = std::function<void (std::exception_ptr, + std::unique_ptr<GeometryTile>, + optional<SystemTimePoint> modified, + optional<SystemTimePoint> expires)>; + /* + * Monitor the tile held by this object for changes. When the tile is loaded for the first time, + * or updates, the callback is executed. If an error occurs, the first parameter will be set. + * Otherwise it will be null. If there is no data for the requested tile, the second parameter + * will be null. + * + * To cease monitoring, release the returned Request. + */ + virtual std::unique_ptr<FileRequest> monitorTile(const Callback&) = 0; +}; + +class GeometryTileFeatureExtractor { +public: + GeometryTileFeatureExtractor(const GeometryTileFeature& feature_) + : feature(feature_) {} + + optional<Value> getValue(const std::string& key) const; + +private: + const GeometryTileFeature& feature; +}; + +} // namespace mbgl + +#endif |