Shapes
GIS made easy, a lightweight header-only planar geometry library for Modern C++
Public Member Functions | Static Public Member Functions | List of all members
simo::shapes::basic_geometry< T > Class Template Reference

Base class for all geometries. More...

#include <geometry.hpp>

Inheritance diagram for simo::shapes::basic_geometry< T >:
simo::shapes::basic_linestring< T > simo::shapes::basic_multilinestring< T > simo::shapes::basic_multipoint< T > simo::shapes::basic_multipolygon< T > simo::shapes::basic_point< T > simo::shapes::basic_point_m< T > simo::shapes::basic_point_z< T > simo::shapes::basic_point_zm< T > simo::shapes::basic_polygon< T >

Public Member Functions

geometry_type geom_type () const noexcept
 Returns the geometry type. More...
 
std::string tagged_text () const noexcept
 Returns the geometry type as a string. More...
 
dimension_type dim () const noexcept
 Returns the dimension type for the geometry. More...
 
size_t ndim () const noexcept
 Returns the number of dimensions of the geometry. More...
 
void throw_for_invalid () const
 Raise an error if the geometry is invalid. More...
 
bool is_closed () const noexcept
 Whether the geometry is closed. More...
 
bool is_valid () const noexcept
 Whether the geometry is valid. More...
 
bounds_t bounds () const
 Returns the bounding box of the geometry. More...
 
bool has_z () const noexcept
 Whether the geometry has the z-coordinate. More...
 
bool has_m () const noexcept
 Whether the geometry has the m-coordinate (measurement coordinate) More...
 
std::string json (std::int32_t precision=-1) const
 Dumps the geojson representation of the geometry. More...
 
std::string wkt (std::int32_t precision=-1) const
 Dumps the wkt representation of the geometry. More...
 

Static Public Member Functions

static T from_json (const std::string &json)
 Creates a geometry from a geojson string. More...
 
static T from_wkt (const std::string &wkt)
 Creates a Geometry from a wkt string. More...
 

Detailed Description

template<typename T>
class simo::shapes::basic_geometry< T >

Base class for all geometries.

Template Parameters
Tthe geometry type (e.g. Point, Polygon, LineString)
Since
0.0.1

Definition at line 26 of file geometry.hpp.

Member Function Documentation

template<typename T>
bounds_t simo::shapes::basic_geometry< T >::bounds ( ) const
inline

Returns the bounding box of the geometry.

Returns
a bounds object
Since
0.0.1

Definition at line 203 of file geometry.hpp.

template<typename T>
dimension_type simo::shapes::basic_geometry< T >::dim ( ) const
inlinenoexcept

Returns the dimension type for the geometry.

Returns
the dimension type
Since
0.0.1

Definition at line 117 of file geometry.hpp.

template<typename T>
static T simo::shapes::basic_geometry< T >::from_json ( const std::string &  json)
inlinestatic

Creates a geometry from a geojson string.

Parameters
jsonthe geojson string
Returns
a Geometry object
See also
https://tools.ietf.org/html/rfc7946
Since
0.0.1

Definition at line 242 of file geometry.hpp.

template<typename T>
static T simo::shapes::basic_geometry< T >::from_wkt ( const std::string &  wkt)
inlinestatic

Creates a Geometry from a wkt string.

Parameters
wktthe wkt string
Returns
a Geometry object
See also
https://tools.ietf.org/html/rfc7946
Since
0.0.1

Definition at line 270 of file geometry.hpp.

template<typename T>
geometry_type simo::shapes::basic_geometry< T >::geom_type ( ) const
inlinenoexcept

Returns the geometry type.

Returns
the geometry type
Since
0.0.1

Definition at line 35 of file geometry.hpp.

template<typename T>
bool simo::shapes::basic_geometry< T >::has_m ( ) const
inlinenoexcept

Whether the geometry has the m-coordinate (measurement coordinate)

Returns
true if the geometry has m-coordinate, otherwise false
Since
0.0.1

Definition at line 226 of file geometry.hpp.

template<typename T>
bool simo::shapes::basic_geometry< T >::has_z ( ) const
inlinenoexcept

Whether the geometry has the z-coordinate.

Returns
true if the geometry has z-coordinate, otherwise false
Since
0.0.1

Definition at line 214 of file geometry.hpp.

template<typename T>
bool simo::shapes::basic_geometry< T >::is_closed ( ) const
inlinenoexcept

Whether the geometry is closed.

Returns
true if the geometry is closed, otherwise false
Since
0.0.1

Definition at line 173 of file geometry.hpp.

template<typename T>
bool simo::shapes::basic_geometry< T >::is_valid ( ) const
inlinenoexcept

Whether the geometry is valid.

Returns
true if the geometry is valid, otherwise false
Since
0.0.1

Definition at line 184 of file geometry.hpp.

template<typename T>
std::string simo::shapes::basic_geometry< T >::json ( std::int32_t  precision = -1) const
inline

Dumps the geojson representation of the geometry.

Parameters
precisionthe output precision
Returns
a geojson string
See also
https://tools.ietf.org/html/rfc7946
Since
0.0.1

Definition at line 255 of file geometry.hpp.

template<typename T>
size_t simo::shapes::basic_geometry< T >::ndim ( ) const
inlinenoexcept

Returns the number of dimensions of the geometry.

Returns
the number of dimensions
Note
the number of dimensions is (x, y) = 2, (x, y, z) = 3, (x, y, m) = 3 and (x, y, z, m) = 4
Since
0.0.1

Definition at line 142 of file geometry.hpp.

template<typename T>
std::string simo::shapes::basic_geometry< T >::tagged_text ( ) const
inlinenoexcept

Returns the geometry type as a string.

Returns
the geometry type as a string
Since
0.0.1

Definition at line 46 of file geometry.hpp.

template<typename T>
void simo::shapes::basic_geometry< T >::throw_for_invalid ( ) const
inline

Raise an error if the geometry is invalid.

Exceptions
geometry_errorthe geometry error
Since
0.0.1

Definition at line 162 of file geometry.hpp.

template<typename T>
std::string simo::shapes::basic_geometry< T >::wkt ( std::int32_t  precision = -1) const
inline

Dumps the wkt representation of the geometry.

Parameters
precisionthe output precision
Returns
a wkt string
See also
https://tools.ietf.org/html/rfc7946
Since
0.0.1

Definition at line 283 of file geometry.hpp.


The documentation for this class was generated from the following file: