summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/llmr/map/vector_tile.hpp19
-rw-r--r--include/llmr/renderer/fill_bucket.hpp1
-rw-r--r--include/llmr/renderer/line_bucket.hpp1
-rw-r--r--include/llmr/renderer/point_bucket.hpp1
-rw-r--r--include/llmr/renderer/text_bucket.hpp1
-rw-r--r--include/llmr/util/vec.hpp15
6 files changed, 16 insertions, 22 deletions
diff --git a/include/llmr/map/vector_tile.hpp b/include/llmr/map/vector_tile.hpp
index 98f2a1ca38..67207563e3 100644
--- a/include/llmr/map/vector_tile.hpp
+++ b/include/llmr/map/vector_tile.hpp
@@ -2,6 +2,7 @@
#define LLMR_MAP_VECTOR_TILE
#include <llmr/util/pbf.hpp>
+#include <llmr/util/vec.hpp>
#include <llmr/style/value.hpp>
#include <vector>
#include <map>
@@ -15,24 +16,6 @@ class VectorTileLayer;
struct pbf;
-struct Coordinate {
- struct null {};
-
- Coordinate() : x(0), y(0) {}
- Coordinate(int16_t x, int16_t y) : x(x), y(y) {}
- Coordinate(null) : x(std::numeric_limits<int16_t>::min()), y(std::numeric_limits<int16_t>::min()) {}
- int16_t x;
- int16_t y;
-
- inline bool operator==(const Coordinate& other) const {
- return x == other.x && y == other.y;
- }
-
- inline operator bool() const {
- return x != std::numeric_limits<int16_t>::min() && y != std::numeric_limits<int16_t>::min();
- }
-};
-
enum class FeatureType {
Unknown = 0,
Point = 1,
diff --git a/include/llmr/renderer/fill_bucket.hpp b/include/llmr/renderer/fill_bucket.hpp
index 4c82b7b315..633ae8c2fd 100644
--- a/include/llmr/renderer/fill_bucket.hpp
+++ b/include/llmr/renderer/fill_bucket.hpp
@@ -26,7 +26,6 @@ class BucketDescription;
class OutlineShader;
class PlainShader;
class PatternShader;
-struct Coordinate;
struct pbf;
class FillBucket : public Bucket {
diff --git a/include/llmr/renderer/line_bucket.hpp b/include/llmr/renderer/line_bucket.hpp
index 8b03fc5ad4..16f7dac989 100644
--- a/include/llmr/renderer/line_bucket.hpp
+++ b/include/llmr/renderer/line_bucket.hpp
@@ -15,7 +15,6 @@ class LineVertexBuffer;
class TriangleElementsBuffer;
class LineShader;
class LinejoinShader;
-struct Coordinate;
struct pbf;
class LineBucket : public Bucket {
diff --git a/include/llmr/renderer/point_bucket.hpp b/include/llmr/renderer/point_bucket.hpp
index e48e4ceaae..d65435d68b 100644
--- a/include/llmr/renderer/point_bucket.hpp
+++ b/include/llmr/renderer/point_bucket.hpp
@@ -19,7 +19,6 @@ class Style;
class PointVertexBuffer;
class BucketDescription;
class PointShader;
-struct Coordinate;
struct pbf;
class PointBucket : public Bucket {
diff --git a/include/llmr/renderer/text_bucket.hpp b/include/llmr/renderer/text_bucket.hpp
index 5a19ebeda7..21c00cbdea 100644
--- a/include/llmr/renderer/text_bucket.hpp
+++ b/include/llmr/renderer/text_bucket.hpp
@@ -18,7 +18,6 @@ class TextShader;
class VectorTileFeature;
class VectorTileFace;
class VectorTilePlacement;
-struct Coordinate;
struct pbf;
class TextBucket : public Bucket {
diff --git a/include/llmr/util/vec.hpp b/include/llmr/util/vec.hpp
index 445160f15d..0191e3868d 100644
--- a/include/llmr/util/vec.hpp
+++ b/include/llmr/util/vec.hpp
@@ -4,6 +4,7 @@
#include <limits>
#include <type_traits>
#include <cmath>
+#include <cstdint>
namespace llmr {
@@ -15,10 +16,17 @@ struct vec2 {
T x, y;
inline vec2() {}
+
+ template<typename U = T, typename std::enable_if<std::numeric_limits<U>::has_quiet_NaN, int>::type = 0>
inline vec2(null) : x(std::numeric_limits<T>::quiet_NaN()), y(std::numeric_limits<T>::quiet_NaN()) {}
+ template<typename U = T, typename std::enable_if<!std::numeric_limits<U>::has_quiet_NaN, int>::type = 0>
+ inline vec2(null) : x(std::numeric_limits<T>::min()), y(std::numeric_limits<T>::min()) {}
+
inline vec2(const vec2& o) : x(o.x), y(o.y) {}
+
inline vec2(T x, T y) : x(x), y(y) {}
+
inline bool operator==(const vec2& rhs) const {
return x == rhs.x && y == rhs.y;
}
@@ -27,6 +35,11 @@ struct vec2 {
inline operator bool() const {
return !isnan(x) && !isnan(y);
}
+
+ template<typename U = T, typename std::enable_if<!std::numeric_limits<U>::has_quiet_NaN, int>::type = 0>
+ inline operator bool() const {
+ return x != std::numeric_limits<T>::min() && y != std::numeric_limits<T>::min();
+ }
};
template <typename T = double>
@@ -59,6 +72,8 @@ struct box {
vec2<double> center;
};
+typedef vec2<int16_t> Coordinate;
+
}
#endif