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.
refs #928: 90% of way to genericizing VectorTile
- Loading branch information
Showing
5 changed files
with
203 additions
and
148 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include <mbgl/map/geometry_tile.hpp> | ||
#include <mbgl/style/filter_expression_private.hpp> | ||
|
||
#include <iostream> | ||
|
||
using namespace mbgl; | ||
|
||
std::ostream& mbgl::operator<<(std::ostream& os, const GeometryFeatureType& type) { | ||
switch (type) { | ||
case GeometryFeatureType::Unknown: return os << "Unknown"; | ||
case GeometryFeatureType::Point: return os << "Point"; | ||
case GeometryFeatureType::LineString: return os << "LineString"; | ||
case GeometryFeatureType::Polygon: return os << "Polygon"; | ||
default: return os << "Invalid"; | ||
} | ||
} | ||
|
||
GeometryTile& GeometryTile::operator=(GeometryTile&& other) { | ||
if (this != &other) { | ||
layers.swap(other.layers); | ||
} | ||
return *this; | ||
} | ||
|
||
template <typename T> | ||
GeometryFilteredTileLayer<T>::iterator::iterator(const GeometryFilteredTileLayer<T>& parent_) | ||
: parent(parent_) { | ||
operator++(); | ||
} |
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,105 @@ | ||
#ifndef MBGL_MAP_GEOMETRY_TILE | ||
#define MBGL_MAP_GEOMETRY_TILE | ||
|
||
#include <mbgl/style/filter_expression.hpp> | ||
#include <mbgl/style/value.hpp> | ||
#include <mbgl/text/glyph.hpp> | ||
#include <mbgl/util/optional.hpp> | ||
|
||
#include <cstdint> | ||
#include <iosfwd> | ||
#include <map> | ||
#include <string> | ||
#include <unordered_map> | ||
#include <vector> | ||
|
||
namespace mbgl { | ||
|
||
class GeometryTileLayer; | ||
|
||
enum class GeometryFeatureType { | ||
Unknown = 0, | ||
Point = 1, | ||
LineString = 2, | ||
Polygon = 3 | ||
}; | ||
|
||
std::ostream& operator<<(std::ostream&, const GeometryFeatureType& type); | ||
|
||
template <typename T> | ||
class GeometryTileFeature { | ||
public: | ||
uint64_t id = 0; | ||
GeometryFeatureType type = GeometryFeatureType::Unknown; | ||
std::map<std::string, Value> properties; | ||
T geometries; | ||
}; | ||
|
||
template <typename T> | ||
std::ostream& operator<<(std::ostream&, const GeometryTileFeature<T>& feature); | ||
|
||
template <typename T> | ||
class GeometryTileTagExtractor { | ||
public: | ||
GeometryTileTagExtractor(const GeometryTileLayer&); | ||
|
||
void setTags(const T&); | ||
virtual mapbox::util::optional<Value> getValue(const std::string &key) const; | ||
inline void setType(GeometryFeatureType type_) { type = type_; } | ||
GeometryFeatureType getType() const { return type; } | ||
|
||
protected: | ||
const GeometryTileLayer &layer; | ||
GeometryFeatureType type = GeometryFeatureType::Unknown; | ||
}; | ||
|
||
|
||
template <typename T> | ||
class GeometryFilteredTileLayer { | ||
public: | ||
class iterator { | ||
public: | ||
iterator(const GeometryFilteredTileLayer&); | ||
virtual void operator++(); | ||
virtual bool operator!=(const iterator& other) const; | ||
virtual const T& operator*() const; | ||
|
||
protected: | ||
const GeometryFilteredTileLayer& parent; | ||
bool valid = false; | ||
}; | ||
|
||
public: | ||
GeometryFilteredTileLayer(const GeometryTileLayer&, const FilterExpression&); | ||
|
||
iterator begin() const; | ||
iterator end() const; | ||
|
||
public: | ||
const GeometryTileLayer& layer; | ||
const FilterExpression& filterExpression; | ||
}; | ||
|
||
std::ostream& operator<<(std::ostream&, const PositionedGlyph&); | ||
|
||
class GeometryTileLayer { | ||
public: | ||
std::string name; | ||
uint32_t extent = 4096; | ||
std::vector<std::string> keys; | ||
std::unordered_map<std::string, uint32_t> key_index; | ||
std::vector<Value> values; | ||
std::map<std::string, std::map<Value, Shaping>> shaping; | ||
}; | ||
|
||
class GeometryTile { | ||
public: | ||
GeometryTile& operator=(GeometryTile&& other); | ||
|
||
public: | ||
std::map<std::string, const GeometryTileLayer> layers; | ||
}; | ||
|
||
} | ||
|
||
#endif |
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.