12 #include "common/datatypes/Value.h"
22 enum class GeoShape : uint32_t {
29 std::ostream& operator<<(std::ostream& os,
const GeoShape& shape);
46 Coordinate(
double lng,
double lat) : x(lng), y(lat) {}
57 return std::abs(x - rhs.x) < kEpsilon && std::abs(y - rhs.y) < kEpsilon;
60 return !(*
this == rhs);
87 bool operator==(
const Point& rhs)
const {
88 return coord == rhs.coord;
90 bool operator<(
const Point& rhs)
const {
91 return coord < rhs.coord;
96 std::vector<Coordinate> coordList;
99 explicit LineString(
const std::vector<Coordinate>& v) : coordList(v) {}
100 explicit LineString(std::vector<Coordinate>&& v) : coordList(std::move(v)) {}
102 uint32_t numCoord()
const {
103 return coordList.size();
113 bool operator==(
const LineString& rhs)
const {
114 return coordList == rhs.coordList;
117 return coordList < rhs.coordList;
122 std::vector<std::vector<Coordinate>> coordListList;
125 explicit Polygon(
const std::vector<std::vector<Coordinate>>& v) : coordListList(v) {}
126 explicit Polygon(std::vector<std::vector<Coordinate>>&& v) : coordListList(std::move(v)) {}
128 uint32_t numCoordList()
const {
129 return coordListList.size();
133 coordListList.clear();
139 bool operator==(
const Polygon& rhs)
const {
140 return coordListList == rhs.coordListList;
142 bool operator<(
const Polygon& rhs)
const {
143 return coordListList < rhs.coordListList;
148 std::variant<Point, LineString, Polygon> geo_;
158 GeoShape shape()
const;
160 const Point& point()
const;
162 const Polygon& polygon()
const;
164 Point& mutablePoint();
168 std::string asWKT()
const;
170 std::string asWKB()
const;
172 std::string toString()
const {
184 bool operator==(
const Geography& rhs)
const;
185 bool operator<(
const Geography& rhs)
const;
188 inline std::ostream& operator<<(std::ostream& os,
const Geography& g) {
189 return os << g.toString();
198 struct hash<nebula::Geography> {