6 #include <simo/shapes_fwd.hpp> 7 #include <simo/geom/detail/bounds.hpp> 8 #include <simo/geom/detail/types.hpp> 9 #include <simo/geom/detail/utils.hpp> 10 #include <simo/exceptions.hpp> 37 return static_cast<const T*
>(
this)->geom_type_();
50 case geometry_type::POINT:
52 case geometry_type::POINTZ:
54 case geometry_type::POINTM:
56 case geometry_type::POINTZM:
58 case geometry_type::MULTIPOINT:
60 case geometry_type::MULTIPOINTZ:
61 return "MultiPoint Z";
62 case geometry_type::MULTIPOINTM:
63 return "MultiPoint M";
64 case geometry_type::MULTIPOINTZM:
65 return "MultiPoint ZM";
66 case geometry_type::LINESTRING:
68 case geometry_type::LINESTRINGZ:
69 return "LineString Z";
70 case geometry_type::LINESTRINGM:
71 return "LineString M";
72 case geometry_type::LINESTRINGZM:
73 return "LineString ZM";
74 case geometry_type::MULTILINESTRING:
75 return "MultiLineString";
76 case geometry_type::MULTILINESTRINGZ:
77 return "MultiLineString Z";
78 case geometry_type::MULTILINESTRINGM:
79 return "MultiLineString M";
80 case geometry_type::MULTILINESTRINGZM:
81 return "MultiLineString ZM";
82 case geometry_type::POLYGON:
84 case geometry_type::POLYGONZ:
86 case geometry_type::POLYGONM:
88 case geometry_type::POLYGONZM:
90 case geometry_type::MULTIPOLYGON:
91 return "MultiPolygon";
92 case geometry_type::MULTIPOLYGONZ:
93 return "MultiPolygon Z";
94 case geometry_type::MULTIPOLYGONM:
95 return "MultiPolygon M";
96 case geometry_type::MULTIPOLYGONZM:
97 return "MultiPolygon ZM";
98 case geometry_type::GEOMETRYCOLLECTION:
99 return "GeometryCollection";
100 case geometry_type::GEOMETRYCOLLECTIONZ:
101 return "GeometryCollection Z";
102 case geometry_type::GEOMETRYCOLLECTIONM:
103 return "GeometryCollection M";
104 case geometry_type::GEOMETRYCOLLECTIONZM:
105 return "GeometryCollection ZM";
117 dimension_type
dim() const noexcept
119 int value =
static_cast<int>(
geom_type());
120 if (value >= 1000 and value < 2000)
122 return dimension_type::XYZ;
124 if (value >= 2000 and value < 3000)
126 return dimension_type::XYM;
130 return dimension_type::XYZM;
132 return dimension_type::XY;
146 case dimension_type::XYZM:
148 case dimension_type::XYZ:
149 case dimension_type::XYM:
164 return static_cast<const T*
>(
this)->throw_for_invalid_();
175 return static_cast<const T*
>(
this)->is_closed_();
205 return static_cast<const T*
>(
this)->bounds_();
216 int value =
static_cast<int>(
geom_type());
217 return (value >= 1000 and value < 2000) or value >= 3000;
228 int value =
static_cast<int>(
geom_type());
229 return value >= 2000;
244 return T::from_json_(json);
255 std::string
json(std::int32_t precision = -1)
const 257 return static_cast<const T*
>(
this)->json_(precision);
272 return T::from_wkt_(wkt);
283 std::string
wkt(std::int32_t precision = -1)
const 285 return static_cast<const T*
>(
this)->wkt_(precision);
geometry_type geom_type() const noexcept
Returns the geometry type.
Base class for all geometries.
static T from_json(const std::string &json)
Creates a geometry from a geojson string.
Exception thrown when a geometry error is found.
bool is_closed() const noexcept
Whether the geometry is closed.
static T from_wkt(const std::string &wkt)
Creates a Geometry from a wkt string.
Represents an axis-aligned bounding box.
dimension_type dim() const noexcept
Returns the dimension type for the geometry.
bool has_z() const noexcept
Whether the geometry has the z-coordinate.
bool is_valid() const noexcept
Whether the geometry is valid.
std::string json(std::int32_t precision=-1) const
Dumps the geojson representation of the geometry.
bool has_m() const noexcept
Whether the geometry has the m-coordinate (measurement coordinate)
std::string tagged_text() const noexcept
Returns the geometry type as a string.
std::string wkt(std::int32_t precision=-1) const
Dumps the wkt representation of the geometry.
bounds_t bounds() const
Returns the bounding box of the geometry.
void throw_for_invalid() const
Raise an error if the geometry is invalid.
size_t ndim() const noexcept
Returns the number of dimensions of the geometry.