merge vec2 and Coordinate

This commit is contained in:
Konstantin Käfer
2014-03-18 17:57:09 +01:00
parent 6c61fb7fa5
commit 25ff0b253f
6 changed files with 16 additions and 22 deletions

View File

@@ -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,

View File

@@ -26,7 +26,6 @@ class BucketDescription;
class OutlineShader;
class PlainShader;
class PatternShader;
struct Coordinate;
struct pbf;
class FillBucket : public Bucket {

View File

@@ -15,7 +15,6 @@ class LineVertexBuffer;
class TriangleElementsBuffer;
class LineShader;
class LinejoinShader;
struct Coordinate;
struct pbf;
class LineBucket : public Bucket {

View File

@@ -19,7 +19,6 @@ class Style;
class PointVertexBuffer;
class BucketDescription;
class PointShader;
struct Coordinate;
struct pbf;
class PointBucket : public Bucket {

View File

@@ -18,7 +18,6 @@ class TextShader;
class VectorTileFeature;
class VectorTileFace;
class VectorTilePlacement;
struct Coordinate;
struct pbf;
class TextBucket : public Bucket {

View File

@@ -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