From 5c7dfd948ffd52f2b60dcfe052176da788f17893 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Mon, 13 Jun 2016 10:59:33 -0700 Subject: =?UTF-8?q?[core]=20*Tile=20=E2=86=94=20*TileData?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- src/mbgl/tile/geometry_tile_data.hpp | 122 ++++++++++++++++++----------------- 1 file changed, 63 insertions(+), 59 deletions(-) (limited to 'src/mbgl/tile/geometry_tile_data.hpp') 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 -#include -#include -#include +#include #include - -#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include #include +#include 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 tile, - optional modified_, - optional 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>& result, - const GeometryCoordinates& queryGeometry, - const TransformState&, - const optional>& 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; - void cancel() override; +class GeometryCoordinates : public std::vector { +public: + using coordinate_type = int16_t; + using std::vector::vector; +}; -private: - void redoPlacement(); +class GeometryCollection : public std::vector { +public: + using coordinate_type = int16_t; + using std::vector::vector; +}; - style::Style& style; - Worker& worker; - TileWorker tileWorker; +class GeometryTileFeature : private util::noncopyable { +public: + virtual ~GeometryTileFeature() = default; + virtual FeatureType getType() const = 0; + virtual optional getValue(const std::string& key) const = 0; + virtual Feature::property_map getProperties() const { return Feature::property_map(); } + virtual optional getID() const { return {}; } + virtual GeometryCollection getGeometries() const = 0; +}; - std::unique_ptr workRequest; +class GeometryTileLayer : private util::noncopyable { +public: + virtual ~GeometryTileLayer() = default; + virtual std::size_t featureCount() const = 0; + virtual util::ptr 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> buckets; +class GeometryTileData : private util::noncopyable { +public: + virtual ~GeometryTileData() = default; + virtual util::ptr getLayer(const std::string&) const = 0; +}; - std::unique_ptr featureIndex; - std::unique_ptr geometryTile; +// classifies an array of rings into polygons with outer rings and holes +std::vector 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 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 -- cgit v1.2.1