MySQL  8.0.16
Source Code Documentation
gis Namespace Reference

Namespaces

 srs
 

Classes

class  Area
 Area functor that calls boost::geometry::area with the correct parameter types. More...
 
class  Box
 A 2d box with sides parallel to the coordinate system grid. More...
 
class  Cartesian_box
 A Cartesian 2d box. More...
 
class  Cartesian_geometrycollection
 A Cartesian 2d geometry collection. More...
 
class  Cartesian_linearring
 A Cartesian 2d linear ring. More...
 
class  Cartesian_linestring
 A Cartesian 2d linestring. More...
 
class  Cartesian_multilinestring
 A Cartesian 2d multilinestring. More...
 
class  Cartesian_multipoint
 A Cartesian 2d multipoint. More...
 
class  Cartesian_multipolygon
 A Cartesian 2d multipolygon. More...
 
class  Cartesian_point
 A Cartesian 2d point. More...
 
class  Cartesian_polygon
 A Cartesian 2d polygon. More...
 
class  Coordinate_range_visitor
 A visitor that checks if coordinates are within range for a spatial reference system. More...
 
class  Covered_by
 Covered_by functor that calls Boost.Geometry with the correct parameter types. More...
 
class  Crosses
 Crosses functor that calls Boost.Geometry with the correct parameter types. More...
 
class  Curve
 An abstract 2d curve. More...
 
class  Difference
 Difference functor that calls Boost.Geometry with the correct parameter types. More...
 
class  Disjoint
 Disjoint functor that calls Boost.Geometry with the correct parameter types. More...
 
class  Distance
 Distance functor that calls Boost.Geometry with the correct parameter types. More...
 
class  Distance_sphere
 Functor that calls Boost.Geometry with the correct parameter types. More...
 
class  Equals
 Equals functor that calls Boost.Geometry with the correct parameter types. More...
 
class  Functor
 The base class of all functors that takes two geometry arguments. More...
 
class  Geographic_box
 A Geographic 2d box. More...
 
class  Geographic_geometrycollection
 A geographic (ellipsoidal) 2d geometry collection. More...
 
class  Geographic_linearring
 A geographic (ellipsoidal) 2d linear ring. More...
 
class  Geographic_linestring
 A geographic (ellipsoidal) 2d linestring. More...
 
class  Geographic_multilinestring
 A geographic (ellipsoidal) 2d multilinestring. More...
 
class  Geographic_multipoint
 A geographic (ellipsoidal) 2d multipoint. More...
 
class  Geographic_multipolygon
 A geographic (ellipsoidal) 2d multipolygon. More...
 
class  Geographic_point
 A geographic (ellipsoidal) 2d point. More...
 
class  Geographic_polygon
 A geographic (ellipsoidal) 2d polygon. More...
 
class  Geometry
 Abstract superclass for all geometric objects. More...
 
class  Geometry_visitor
 Abstract visitor class to be used on class Geometry and descendants. More...
 
class  Geometrycollection
 A collection of geometries. More...
 
class  Intersects
 Intersects functor that calls Boost.Geometry with the correct parameter types. More...
 
class  invalid_geometry_exception
 Invalid geometry exception. More...
 
class  Is_simple
 Is_simple functor calls boost::geometry::is_simple with the correct parameter types. More...
 
class  Is_valid
 
struct  latitude_out_of_range_exception
 Latitude out of range exception. More...
 
class  Length
 Length functor that calls Boost.Geometry with the correct parameter types. More...
 
class  Linearring
 A ring-shaped linestring. More...
 
class  Linestring
 A string of connected line segments. More...
 
struct  longitude_out_of_range_exception
 Longitude out of range exception. More...
 
class  Multicurve
 An abstract collection of curves. More...
 
class  Multilinestring
 A colletion of linestrings. More...
 
class  Multipoint
 A collection of points. More...
 
class  Multipolygon
 A collection of polygons. More...
 
class  Multisurface
 An abstract collection of surfaces. More...
 
class  Nop_visitor
 A visitor that implements the entire interface and does nothing. More...
 
class  not_implemented_exception
 Function/parameter combination not implemented exception. More...
 
class  null_value_exception
 NULL value exception. More...
 
class  Overlaps
 Overlaps functor that calls Boost.Geometry with the correct parameter types. More...
 
class  Point
 A 2d point. More...
 
class  Polygon
 A polygon consisting of an outer ring and zero or more interior rings defining holes in the polygon. More...
 
class  Ring_flip_visitor
 A visitor that flips polygon rings so that exterior rings are in a counter-clockwise direction and interior rings in a clockwise direction. More...
 
class  Simplify
 Simplify functor that calls Boost.Geometry with the correct parameter types. More...
 
class  Surface
 An abstract 2d surface. More...
 
class  too_large_polygon_exception
 Too large polygon exception. More...
 
class  Touches
 Touches functor that calls Boost.Geometry with the correct parameter types. More...
 
class  Transform
 Transform functor that calls Boost.Geometry with the correct parameter types. More...
 
class  Unary_functor
 The base class of all functors that take one geometry argument. More...
 
class  Union
 Union functor that calls Boost.Geometry with the correct parameter types. More...
 
struct  Unit
 
class  Within
 Within functor that calls Boost.Geometry with the correct parameter types. More...
 
class  Wkb_parser
 
class  Wkb_size_visitor
 A visitor that computes the size of a WKB representation of a geometry. More...
 
class  Wkb_visitor
 A visitor that serializes the geometry to little-endian WKB and appends it to a string. More...
 

Typedefs

typedef std::uint32_t srid_t
 A spatial reference system ID (SRID). More...
 

Enumerations

enum  Geometry_type : std::uint32_t {
  Geometry_type::kGeometry = 0, Geometry_type::kPoint = 1, Geometry_type::kLinestring = 2, Geometry_type::kPolygon = 3,
  Geometry_type::kMultipoint = 4, Geometry_type::kMultilinestring = 5, Geometry_type::kMultipolygon = 6, Geometry_type::kGeometrycollection = 7
}
 Types of geometry objects. More...
 
enum  Coordinate_system { Coordinate_system::kCartesian = 0, Coordinate_system::kGeographic = 1 }
 Types of coordinate systems. More...
 
enum  Ring_direction { Ring_direction::kCW = 0, Ring_direction::kCCW = 1, Ring_direction::kUnknown = 2 }
 Direction of a ring. More...
 
enum  Unit_Type { Unit_Type::kLinear }
 
enum  Byte_order : std::uint8_t { Byte_order::XDR = 0, Byte_order::NDR = 1 }
 WKB endianness. More...
 

Functions

bool area (const dd::Spatial_reference_system *srs, const Geometry *g, const char *func_name, double *result, bool *result_null) noexcept
 
bool mbr_covered_by (const dd::Spatial_reference_system *srs, const Geometry *g1, const Geometry *g2, const char *func_name, bool *covered_by, bool *null) noexcept
 Computes the covered by relation between the minimum bounding rectangles of two geometries. More...
 
template<typename GC >
static bool geometry_collection_apply_crosses (const Crosses &f, const Geometry *g1, const Geometry *g2)
 Apply a Crosses functor to two geometries, which both may be geometry collections, and return the booelan result of the functor applied on each combination of elements in the collections. More...
 
bool crosses (const dd::Spatial_reference_system *srs, const Geometry *g1, const Geometry *g2, const char *func_name, bool *crosses, bool *null) noexcept
 Computes the crosses relation between two geometries. More...
 
template<typename GC >
static bool geometry_collection_apply_disjoint (const Disjoint &f, const Geometry *g1, const Geometry *g2)
 Apply a Disjoint functor to two geometries, which both may be geometry collections, and return the boolean result of the functor applied on each combination of elements in the collections. More...
 
bool disjoint (const dd::Spatial_reference_system *srs, const Geometry *g1, const Geometry *g2, const char *func_name, bool *disjoint, bool *null) noexcept
 Computes the disjoint relation between two geometries. More...
 
bool mbr_disjoint (const dd::Spatial_reference_system *srs, const Geometry *g1, const Geometry *g2, const char *func_name, bool *disjoint, bool *null) noexcept
 Computes the disjoint relation between the minimum bounding rectangles of two geometries. More...
 
bool distance (const dd::Spatial_reference_system *srs, const Geometry *g1, const Geometry *g2, double *distance, bool *is_null) noexcept
 Computes the distance between two geometries. More...
 
template<typename GC >
static double geometry_collection_apply_min (const Functor< double > *f, const Geometry *g1, const Geometry *g2)
 Apply a Functor<double> to two geometries, which both may be geometry collections, and return the minimum result of the functor applied on each combination of elements in the collections. More...
 
static Geographic_point reinterpret_as_degrees (const Cartesian_point &g)
 Map Cartesian geometry to geographic, mapping degrees east = x, degrees north = y. More...
 
static Geographic_multipoint reinterpret_as_degrees (const Cartesian_multipoint &g)
 Map Cartesian geometry to geographic, mapping degrees east = x, degrees north = y. More...
 
bool distance_sphere (const dd::Spatial_reference_system *srs, const Geometry *g1, const Geometry *g2, const char *func_name, double sphere_radius, double *result, bool *result_null) noexcept
 Compute the approximate distance between two geometries by assuming the world is a sphere. More...
 
template<typename GC >
static bool geometry_collection_apply_equals (const Equals &f, const Geometry *g1, const Geometry *g2)
 Apply an Equals functor to two geometries, which both may be geometry collections, and return the boolean result of the functor applied on each combination of elements in the collections. More...
 
bool equals (const dd::Spatial_reference_system *srs, const Geometry *g1, const Geometry *g2, const char *func_name, bool *equals, bool *null) noexcept
 Computes the equals relation between two geometries. More...
 
bool mbr_equals (const dd::Spatial_reference_system *srs, const Geometry *g1, const Geometry *g2, const char *func_name, bool *equals, bool *null) noexcept
 Computes the equals relation between the minimum bounding rectangles of two geometries. More...
 
template<typename Pt , typename Ls , typename Py , typename GC , typename MPt , typename MLs , typename MPy >
static void typed_split_gc (const GC *gc, MPt *mpt, MLs *mls, MPy *mpy)
 
void split_gc (const Geometrycollection *gc, std::unique_ptr< Multipoint > *mpt, std::unique_ptr< Multilinestring > *mls, std::unique_ptr< Multipolygon > *mpy)
 Splits a geometrycollection into points, linestrings and polygons. More...
 
template<typename MPt , typename MLs , typename MPy >
void typed_gc_union (double semi_major, double semi_minor, std::unique_ptr< Multipoint > *mpt, std::unique_ptr< Multilinestring > *mls, std::unique_ptr< Multipolygon > *mpy)
 
void gc_union (double semi_major, double semi_minor, std::unique_ptr< Multipoint > *mpt, std::unique_ptr< Multilinestring > *mls, std::unique_ptr< Multipolygon > *mpy)
 Cleans up overlapping geometries so that the geometrycollection is broken down into non-overlapping collections. More...
 
const char * type_to_name (Geometry_type type)
 Get the type name string corresponding to a geometry type. More...
 
bool operator< (const Point &lhs, const Point &rhs)
 Compares two points. More...
 
template<typename GC >
static bool geometry_collection_apply_intersects (const Intersects &f, const Geometry *g1, const Geometry *g2)
 Apply an Intersects functor to two geometries, which both may be geometry collections, and return the booelan result of the functor applied on each combination of elements in the collections. More...
 
bool intersects (const dd::Spatial_reference_system *srs, const Geometry *g1, const Geometry *g2, const char *func_name, bool *intersects, bool *null) noexcept
 Computes the intersects relation between two geometries. More...
 
bool mbr_intersects (const dd::Spatial_reference_system *srs, const Geometry *g1, const Geometry *g2, const char *func_name, bool *intersects, bool *null) noexcept
 Computes the intersects relation between the minimum bounding rectangles of two geometries. More...
 
bool is_simple (const dd::Spatial_reference_system *srs, const Geometry *g, const char *func_name, bool *result, bool *result_null) noexcept
 Test whether geometry is geometrically simple. More...
 
bool is_valid (const dd::Spatial_reference_system *srs, const Geometry *g, const char *func_name, bool *is_valid) noexcept
 Decides if a geometry is valid. More...
 
bool length (const dd::Spatial_reference_system *srs, const Geometry *g1, double *distance, bool *null) noexcept
 Computes the length of linestrings and multilinestrings. More...
 
bool mbrs_are_equal (Box const &mbr1, Box const &mbr2)
 Checks if two MBRs are equal. More...
 
bool mbr_is_empty (Box const &mbr)
 Checks if an MBR is empty. More...
 
bool mbr_is_point (Box const &mbr)
 Checks if an MBR represents a point. More...
 
bool mbr_is_line (Box const &mbr)
 Checks if an MBR represents a line. More...
 
static void merge_mbrs (const std::vector< Cartesian_box > &boxes, Cartesian_box *mbr)
 Merges a vector of Cartesian MBRs into one common MBR. More...
 
static void merge_mbrs (const std::vector< Geographic_box > &boxes, Geographic_box *mbr)
 Merges a vector of geographic MBRs into one common MBR. More...
 
static void cartesian_envelope (const Geometry *g, Cartesian_box *mbr)
 Computes the envelope of a Cartesian geometry. More...
 
static void geographic_envelope (const Geometry *g, double semi_major, double semi_minor, Geographic_box *mbr)
 Computes the envelope of a geographic geometry. More...
 
void box_envelope (const Geometry *g, const dd::Spatial_reference_system *srs, Box *mbr)
 Computes the envelope of a geometry. More...
 
template<typename GC >
static bool geometry_collection_apply_overlaps (const Overlaps &f, const Geometry *g1, const Geometry *g2)
 Apply an Overlaps functor to two geometries, which both may be geometry collections, and return the booelan result of the functor applied on each combination of elements in the collections. More...
 
bool overlaps (const dd::Spatial_reference_system *srs, const Geometry *g1, const Geometry *g2, const char *func_name, bool *overlaps, bool *null) noexcept
 Computes the overlaps relation between two geometries. More...
 
bool mbr_overlaps (const dd::Spatial_reference_system *srs, const Geometry *g1, const Geometry *g2, const char *func_name, bool *overlaps, bool *null) noexcept
 Computes the overlaps relation between the minimum bounding rectangles of two geometries. More...
 
bool mbr_touches (const dd::Spatial_reference_system *srs, const Geometry *g1, const Geometry *g2, const char *func_name, bool *touches, bool *null) noexcept
 Computes the touches relation between the minimum bounding rectangles of two geometries. More...
 
bool mbr_within (const dd::Spatial_reference_system *srs, const Geometry *g1, const Geometry *g2, const char *func_name, bool *within, bool *null) noexcept
 Computes the within relation between the minimum bounding rectangles of two geometries. More...
 
bool touches (const dd::Spatial_reference_system *srs, const Geometry *g1, const Geometry *g2, const char *func_name, bool *touches, bool *null) noexcept
 Computes the touches relation between two geometries. More...
 
bool within (const dd::Spatial_reference_system *srs, const Geometry *g1, const Geometry *g2, const char *func_name, bool *within, bool *null) noexcept
 Computes the within relation between two geometries. More...
 
bool simplify (const dd::Spatial_reference_system *srs, const Geometry &g, double max_distance, const char *func_name, std::unique_ptr< Geometry > *result) noexcept
 Simplifies a geometry using the Douglas-Peucker algorithm. More...
 
collation_unordered_map< std::string, Unitunits ()
 A function to obtaint the supported units for the gis module. More...
 
bool get_conversion_factor (const std::string &unit, double *conversion_factor)
 Retrieves the length of the unit in meters. More...
 
template<typename GC >
static bool geometry_collection_apply_touches (const Touches &f, const Geometry *g1, const Geometry *g2)
 Apply a Touches functor to two geometries, which both may be geometry collections, and return the booelan result of the functor applied on each combination of elements in the collections. More...
 
bool transform (const dd::Spatial_reference_system *source_srs, const Geometry &in, const dd::Spatial_reference_system *target_srs, const char *func_name, std::unique_ptr< Geometry > *out) noexcept
 Transforms a geometry from one SRS to another. More...
 
static bool is_valid_type (Geometry_type type)
 Checks if a given type is a valid (and supported) WKB type. More...
 
static bool is_subtype_of (Geometry_type sub, Geometry_type super)
 Checks if a given type is a subtype of a given supertype. More...
 
static bool is_valid_type_or_subtype (Geometry_type sub, Geometry_type super)
 Checks if a given type is a valid type and that it is a subtype of a given supertype. More...
 
std::unique_ptr< Geometryparse_wkb (THD *thd, const dd::Spatial_reference_system *srs, const char *wkb, std::size_t length, bool ignore_axis_order=false)
 Parses a geometry WKB string and constructs a geometry object. More...
 
bool parse_srid (const char *str, std::size_t length, srid_t *srid)
 Parses an SRID from a little-endian string. More...
 
bool parse_geometry (THD *thd, const char *func_name, const String *str, const dd::Spatial_reference_system **srs, std::unique_ptr< Geometry > *geometry, bool treat_unknown_srid_as_cartesian=false)
 Parses a little-endian geometry string (SRID + WKB). More...
 
bool write_geometry (const dd::Spatial_reference_system *srs, Geometry &geometry, String *str)
 Writes a little-endian geometry string (SRID + WKB). More...
 

Typedef Documentation

◆ srid_t

typedef std::uint32_t gis::srid_t

A spatial reference system ID (SRID).

This type matches the SRID storage format in MySQL.

Enumeration Type Documentation

◆ Byte_order

enum gis::Byte_order : std::uint8_t
strong

WKB endianness.

Enumerator
XDR 

Big endian.

NDR 

Little endian.

◆ Coordinate_system

Types of coordinate systems.

Enumerator
kCartesian 

A Cartesian plane with the same unit in both directions.

kGeographic 

An ellipsoidal system with longitude and latitude coordinates, both in the same unit.

◆ Geometry_type

enum gis::Geometry_type : std::uint32_t
strong

Types of geometry objects.

Not all are instantiable.

The values and the storage type are the same as used in WKB.

Enumerator
kGeometry 
kPoint 
kLinestring 
kPolygon 
kMultipoint 
kMultilinestring 
kMultipolygon 
kGeometrycollection 

◆ Ring_direction

enum gis::Ring_direction
strong

Direction of a ring.

Enumerator
kCW 

Clockwise.

kCCW 

Counterclockwise.

kUnknown 

Unknown.

Used only as an output value when the function is unable to determine the ring direction, e.g., if the ring contains only repetitions of the same point, or if there is a spike in the ring.

◆ Unit_Type

enum gis::Unit_Type
strong
Enumerator
kLinear 

Function Documentation

◆ area()

bool gis::area ( const dd::Spatial_reference_system srs,
const Geometry g,
const char *  func_name,
double *  result,
bool result_null 
)
noexcept

◆ box_envelope()

void gis::box_envelope ( const Geometry g,
const dd::Spatial_reference_system srs,
Box mbr 
)

Computes the envelope of a geometry.

The result may be a collapsed MBR.

Parameters
[in]gThe geometry.
[in]srsThe spatial reference system of the geometry.
[out]mbrThe envelope.

◆ cartesian_envelope()

static void gis::cartesian_envelope ( const Geometry g,
Cartesian_box mbr 
)
static

Computes the envelope of a Cartesian geometry.

The MBR returned may be a collapsed box.

Parameters
[in]gThe geometry.
[out]mbrThe envelope of g.

◆ crosses()

bool gis::crosses ( const dd::Spatial_reference_system srs,
const Geometry g1,
const Geometry g2,
const char *  func_name,
bool crosses,
bool null 
)
noexcept

Computes the crosses relation between two geometries.

Both geometries must be in the same coordinate system (Cartesian or geographic), and the coordinate system of the geometries must match the coordinate system of the SRID. It is the caller's responsibility to guarantee this.

Parameters
[in]srsThe spatial reference system, common to both geometries.
[in]g1First geometry.
[in]g2Second geometry.
[in]func_nameFunction name used in error reporting.
[out]crossesWhether g1 crosses g2.
[out]nullTrue if the return value is NULL.
Return values
falseSuccess.
trueAn error has occurred. The error has been reported with my_error().

◆ disjoint()

bool gis::disjoint ( const dd::Spatial_reference_system srs,
const Geometry g1,
const Geometry g2,
const char *  func_name,
bool disjoint,
bool null 
)
noexcept

Computes the disjoint relation between two geometries.

Both geometries must be in the same coordinate system (Cartesian or geographic), and the coordinate system of the geometries must match the coordinate system of the SRID. It is the caller's responsibility to guarantee this.

Parameters
[in]srsThe spatial reference system, common to both geometries.
[in]g1First geometry.
[in]g2Second geometry.
[in]func_nameFunction name used in error reporting.
[out]disjointWhether g1 is disjoint from g2.
[out]nullTrue if the return value is NULL.
Return values
falseSuccess.
trueAn error has occurred. The error has been reported with my_error().

◆ distance()

bool gis::distance ( const dd::Spatial_reference_system srs,
const Geometry g1,
const Geometry g2,
double *  distance,
bool is_null 
)
noexcept

Computes the distance between two geometries.

Both geometries must be in the same coordinate system (Cartesian or geographic), and the coordinate system of the geometries must match the coordinate system of the SRID. It is the caller's responsibility to guarantee this.

Parameters
[in]srsThe spatial reference system, common to both geometries.
[in]g1First geometry.
[in]g2Second geometry.
[out]distanceThe shortest distance between g1 and g2 in the SRS' linear unit.
[out]is_nullTrue if the return value is NULL.
Return values
falseSuccess.
trueAn error has occurred. The error has been reported with my_error().

◆ distance_sphere()

bool gis::distance_sphere ( const dd::Spatial_reference_system srs,
const Geometry g1,
const Geometry g2,
const char *  func_name,
double  sphere_radius,
double *  result,
bool result_null 
)
noexcept

Compute the approximate distance between two geometries by assuming the world is a sphere.

The coordinate system of the geometries must match the coordinate system of the SRID. It is the caller's responsibility to guarantee this.

Parameters
[in]srsThe spatial reference system.
[in]g1Geometry 1.
[in]g2Geometry 2.
[in]func_nameFunction name used in error reporting.
[in]sphere_radiusRadius of sphere.
[out]resultDistance between g1 and g2. Invalid if result_null.
[out]result_nullWhether return value is NULL instead of result.
Return values
falseSuccess.
trueAn error has occurred. The error has been reported with my_error().

◆ equals()

bool gis::equals ( const dd::Spatial_reference_system srs,
const Geometry g1,
const Geometry g2,
const char *  func_name,
bool equals,
bool null 
)
noexcept

Computes the equals relation between two geometries.

Both geometries must be in the same coordinate system (Cartesian or geographic), and the coordinate system of the geometries must match the coordinate system of the SRID. It is the caller's responsibility to guarantee this.

Parameters
[in]srsThe spatial reference system, common to both geometries.
[in]g1First geometry.
[in]g2Second geometry.
[in]func_nameFunction name used in error reporting.
[out]equalsWhether g1 equals g2.
[out]nullTrue if the return value is NULL.
Return values
falseSuccess.
trueAn error has occurred. The error has been reported with my_error().

◆ gc_union()

void gis::gc_union ( double  semi_major,
double  semi_minor,
std::unique_ptr< Multipoint > *  mpt,
std::unique_ptr< Multilinestring > *  mls,
std::unique_ptr< Multipolygon > *  mpy 
)

Cleans up overlapping geometries so that the geometrycollection is broken down into non-overlapping collections.

All input collections may contain overlapping geometries and duplicates, including the multipolygon. This function requires that at least one of the inputs must be non-empty.

May throw exceptions from BG operations.

Parameters
[in]semi_majorSemi-major axis of ellipsoid.
[in]semi_minorSemi-minor axis of ellipsoid.
[in,out]mptAll points in the geometrycollection.
[in,out]mlsAll linestrings in the geometrycollection.
[in,out]mpyAll polygons in the geometrycollection.

◆ geographic_envelope()

static void gis::geographic_envelope ( const Geometry g,
double  semi_major,
double  semi_minor,
Geographic_box mbr 
)
static

Computes the envelope of a geographic geometry.

The MBR returned may be a collapsed box.

Parameters
[in]gThe geometry.
[in]semi_majorSemi-major axis of ellipsoid.
[in]semi_minorSemi-minor axis of ellipsoid.
[out]mbrThe envelope of g.

◆ geometry_collection_apply_crosses()

template<typename GC >
static bool gis::geometry_collection_apply_crosses ( const Crosses f,
const Geometry g1,
const Geometry g2 
)
static

Apply a Crosses functor to two geometries, which both may be geometry collections, and return the booelan result of the functor applied on each combination of elements in the collections.

Template Parameters
GCCoordinate specific gometry collection type.
Parameters
fFunctor to apply.
g1First geometry.
g2Second geometry.
Return values
trueg1 crosses g2.
falseg1 doesn't cross g2.

◆ geometry_collection_apply_disjoint()

template<typename GC >
static bool gis::geometry_collection_apply_disjoint ( const Disjoint f,
const Geometry g1,
const Geometry g2 
)
static

Apply a Disjoint functor to two geometries, which both may be geometry collections, and return the boolean result of the functor applied on each combination of elements in the collections.

Template Parameters
GCCoordinate specific gometry collection type.
Parameters
fFunctor to apply.
g1First geometry.
g2Second geometry.
Return values
trueg1 is disjoint from g2.
falseg1 isn't disjoint from g2.

◆ geometry_collection_apply_equals()

template<typename GC >
static bool gis::geometry_collection_apply_equals ( const Equals f,
const Geometry g1,
const Geometry g2 
)
static

Apply an Equals functor to two geometries, which both may be geometry collections, and return the boolean result of the functor applied on each combination of elements in the collections.

Template Parameters
GCCoordinate specific gometry collection type.
Parameters
fFunctor to apply.
g1First geometry.
g2Second geometry.
Return values
trueg1 equals g2.
falseg1 doesn't equal g2.

◆ geometry_collection_apply_intersects()

template<typename GC >
static bool gis::geometry_collection_apply_intersects ( const Intersects f,
const Geometry g1,
const Geometry g2 
)
static

Apply an Intersects functor to two geometries, which both may be geometry collections, and return the booelan result of the functor applied on each combination of elements in the collections.

Template Parameters
GCCoordinate specific gometry collection type.
Parameters
fFunctor to apply.
g1First geometry.
g2Second geometry.
Return values
trueg1 intersects g2.
falseg1 doesn't intersect g2.

◆ geometry_collection_apply_min()

template<typename GC >
static double gis::geometry_collection_apply_min ( const Functor< double > *  f,
const Geometry g1,
const Geometry g2 
)
static

Apply a Functor<double> to two geometries, which both may be geometry collections, and return the minimum result of the functor applied on each combination of elements in the collections.

Template Parameters
GCCoordinate specific gometry collection type.
Parameters
fFunctor to apply.
g1First geometry.
g2Second geometry.
Returns
The minimum result of f(g1_i, g2_j), for all g1_i, element of g1, and g2_j, element of g2.

◆ geometry_collection_apply_overlaps()

template<typename GC >
static bool gis::geometry_collection_apply_overlaps ( const Overlaps f,
const Geometry g1,
const Geometry g2 
)
static

Apply an Overlaps functor to two geometries, which both may be geometry collections, and return the booelan result of the functor applied on each combination of elements in the collections.

Template Parameters
GCCoordinate specific gometry collection type.
Parameters
fFunctor to apply.
g1First geometry.
g2Second geometry.
Return values
trueg1 overlaps g2.
falseg1 doesn't overlap g2.

◆ geometry_collection_apply_touches()

template<typename GC >
static bool gis::geometry_collection_apply_touches ( const Touches f,
const Geometry g1,
const Geometry g2 
)
static

Apply a Touches functor to two geometries, which both may be geometry collections, and return the booelan result of the functor applied on each combination of elements in the collections.

Template Parameters
GCCoordinate specific gometry collection type.
Parameters
fFunctor to apply.
g1First geometry.
g2Second geometry.
Return values
trueg1 touches g2.
falseg1 doesn't touch g2.

◆ get_conversion_factor()

bool gis::get_conversion_factor ( const std::string &  unit,
double *  conversion_factor 
)

Retrieves the length of the unit in meters.

Parameters
unitthe name of the unit we want the conversion factor for.
[out]conversion_factorA pointer to where the result should be put, not touched in case of error.
Return values
Trueif unit is not found.
Falsein case of success.

◆ intersects()

bool gis::intersects ( const dd::Spatial_reference_system srs,
const Geometry g1,
const Geometry g2,
const char *  func_name,
bool intersects,
bool null 
)
noexcept

Computes the intersects relation between two geometries.

Both geometries must be in the same coordinate system (Cartesian or geographic), and the coordinate system of the geometries must match the coordinate system of the SRID. It is the caller's responsibility to guarantee this.

Parameters
[in]srsThe spatial reference system, common to both geometries.
[in]g1First geometry.
[in]g2Second geometry.
[in]func_nameFunction name used in error reporting.
[out]intersectsWhether g1 intersects g2.
[out]nullTrue if the return value is NULL.
Return values
falseSuccess.
trueAn error has occurred. The error has been reported with my_error().

◆ is_simple()

bool gis::is_simple ( const dd::Spatial_reference_system srs,
const Geometry g,
const char *  func_name,
bool result,
bool result_null 
)
noexcept

Test whether geometry is geometrically simple.

The coordinate system of the geometry must match the coordinate system of the SRID. It is the caller's responsibility to guarantee this.

Parameters
[in]srsThe spatial reference system.
[in]gGeometry for testing.
[in]func_nameFunction name used in error reporting.
[out]resultWhether g is simple. Invalid if result_null.
[out]result_nullWhether return value is NULL instead of result.
Return values
falseSuccess.
trueAn error has occurred. The error has been reported with my_error().

◆ is_subtype_of()

static bool gis::is_subtype_of ( Geometry_type  sub,
Geometry_type  super 
)
static

Checks if a given type is a subtype of a given supertype.

Parameters
subThe type to check.
superThe supertype.
Return values
trueThe type is the supertype or a subtype of it.
falseThe type is neither the supertype nor a subtype of it.

◆ is_valid()

bool gis::is_valid ( const dd::Spatial_reference_system srs,
const Geometry g,
const char *  func_name,
bool is_valid 
)
noexcept

Decides if a geometry is valid.

The SRS must match the SRS referenced by the geometry, this is the caller's responsibility.

Parameters
[in]srsThe spatial reference system.
[in]gThe geometry
[in]func_nameFunction name used in error reporting.
[out]is_validThe validity of the geometry
Return values
falseNo error occured
trueAn error has occured, the error has been reported with my_error().

◆ is_valid_type()

static bool gis::is_valid_type ( Geometry_type  type)
static

Checks if a given type is a valid (and supported) WKB type.

Parameters
typeThe type to check
Return values
trueThe type is valid.
falseThe type is invalid.

◆ is_valid_type_or_subtype()

static bool gis::is_valid_type_or_subtype ( Geometry_type  sub,
Geometry_type  super 
)
static

Checks if a given type is a valid type and that it is a subtype of a given supertype.

Parameters
subThe type to check.
superThe supertype.
Return values
trueThe type is a valid subtype of the supertype.
falseThe type is invalid or not a subtype of the supertype.

◆ length()

bool gis::length ( const dd::Spatial_reference_system srs,
const Geometry g1,
double *  distance,
bool null 
)
noexcept

Computes the length of linestrings and multilinestrings.

Parameters
[in]srsThe spatial reference system.
[in]g1linestring or multilinestring.
[out]distanceThe length of g1 in the SRS linear unit.
[out]nullTrue if the return value is NULL.
Return values
falseSuccess.
trueAn error has occurred. The error has been reported with my_error().

◆ mbr_covered_by()

bool gis::mbr_covered_by ( const dd::Spatial_reference_system srs,
const Geometry g1,
const Geometry g2,
const char *  func_name,
bool covered_by,
bool null 
)
noexcept

Computes the covered by relation between the minimum bounding rectangles of two geometries.

Both geometries must be in the same coordinate system (Cartesian or geographic), and the coordinate system of the geometries must match the coordinate system of the SRID. It is the caller's responsibility to guarantee this.

Parameters
[in]srsThe spatial reference system, common to both geometries.
[in]g1First geometry.
[in]g2Second geometry.
[in]func_nameFunction name used in error reporting.
[out]covered_byWhether the MBR of g1 is covered by the MBR of g2.
[out]nullTrue if the return value is NULL.
Return values
falseSuccess.
trueAn error has occurred. The error has been reported with my_error().

◆ mbr_disjoint()

bool gis::mbr_disjoint ( const dd::Spatial_reference_system srs,
const Geometry g1,
const Geometry g2,
const char *  func_name,
bool disjoint,
bool null 
)
noexcept

Computes the disjoint relation between the minimum bounding rectangles of two geometries.

Both geometries must be in the same coordinate system (Cartesian or geographic), and the coordinate system of the geometries must match the coordinate system of the SRID. It is the caller's responsibility to guarantee this.

Parameters
[in]srsThe spatial reference system, common to both geometries.
[in]g1First geometry.
[in]g2Second geometry.
[in]func_nameFunction name used in error reporting.
[out]disjointWhether the MBR of g1 is disjoint from the MBR of g2.
[out]nullTrue if the return value is NULL.
Return values
falseSuccess.
trueAn error has occurred. The error has been reported with my_error().

◆ mbr_equals()

bool gis::mbr_equals ( const dd::Spatial_reference_system srs,
const Geometry g1,
const Geometry g2,
const char *  func_name,
bool equals,
bool null 
)
noexcept

Computes the equals relation between the minimum bounding rectangles of two geometries.

Both geometries must be in the same coordinate system (Cartesian or geographic), and the coordinate system of the geometries must match the coordinate system of the SRID. It is the caller's responsibility to guarantee this.

Parameters
[in]srsThe spatial reference system, common to both geometries.
[in]g1First geometry.
[in]g2Second geometry.
[in]func_nameFunction name used in error reporting.
[out]equalsWhether the MBR of g1 equals the MBR of g2.
[out]nullTrue if the return value is NULL.
Return values
falseSuccess.
trueAn error has occurred. The error has been reported with my_error().

◆ mbr_intersects()

bool gis::mbr_intersects ( const dd::Spatial_reference_system srs,
const Geometry g1,
const Geometry g2,
const char *  func_name,
bool intersects,
bool null 
)
noexcept

Computes the intersects relation between the minimum bounding rectangles of two geometries.

Both geometries must be in the same coordinate system (Cartesian or geographic), and the coordinate system of the geometries must match the coordinate system of the SRID. It is the caller's responsibility to guarantee this.

Parameters
[in]srsThe spatial reference system, common to both geometries.
[in]g1First geometry.
[in]g2Second geometry.
[in]func_nameFunction name used in error reporting.
[out]intersectsWhether the MBR of g1 intersects the MBR of g2.
[out]nullTrue if the return value is NULL.
Return values
falseSuccess.
trueAn error has occurred. The error has been reported with my_error().

◆ mbr_is_empty()

bool gis::mbr_is_empty ( Box const &  mbr)

Checks if an MBR is empty.

By default, BG box coordinates are NaN. If a geometry is empty, its box will have all NaN coordinates.

Parameters
[in]mbrMBR to check.
Return values
trueThe MBR is empty.
falseThe MBR is not empty.

◆ mbr_is_line()

bool gis::mbr_is_line ( Box const &  mbr)

Checks if an MBR represents a line.

Boxes around vertical and horizontal lines collapse so that either the minimum and maximum X coordinate or Y coordinate are equal.

Parameters
[in]mbrMBR to check.
Return values
trueThe MBR is a line.
falseThe MBR is not a line.

◆ mbr_is_point()

bool gis::mbr_is_point ( Box const &  mbr)

Checks if an MBR represents a point.

Boxes around points collapse so that min_corner == max_corner.

Parameters
[in]mbrMBR to check.
Return values
trueThe MBR is a point.
falseThe MBR is not a point.

◆ mbr_overlaps()

bool gis::mbr_overlaps ( const dd::Spatial_reference_system srs,
const Geometry g1,
const Geometry g2,
const char *  func_name,
bool overlaps,
bool null 
)
noexcept

Computes the overlaps relation between the minimum bounding rectangles of two geometries.

Both geometries must be in the same coordinate system (Cartesian or geographic), and the coordinate system of the geometries must match the coordinate system of the SRID. It is the caller's responsibility to guarantee this.

Parameters
[in]srsThe spatial reference system, common to both geometries.
[in]g1First geometry.
[in]g2Second geometry.
[in]func_nameFunction name used in error reporting.
[out]overlapsWhether the MBR of g1 overlaps the MBR of g2.
[out]nullTrue if the return value is NULL.
Return values
falseSuccess.
trueAn error has occurred. The error has been reported with my_error().

◆ mbr_touches()

bool gis::mbr_touches ( const dd::Spatial_reference_system srs,
const Geometry g1,
const Geometry g2,
const char *  func_name,
bool touches,
bool null 
)
noexcept

Computes the touches relation between the minimum bounding rectangles of two geometries.

Both geometries must be in the same coordinate system (Cartesian or geographic), and the coordinate system of the geometries must match the coordinate system of the SRID. It is the caller's responsibility to guarantee this.

Parameters
[in]srsThe spatial reference system, common to both geometries.
[in]g1First geometry.
[in]g2Second geometry.
[in]func_nameFunction name used in error reporting.
[out]touchesWhether the MBR of g1 touches the MBR of g2.
[out]nullTrue if the return value is NULL.
Return values
falseSuccess.
trueAn error has occurred. The error has been reported with my_error().

◆ mbr_within()

bool gis::mbr_within ( const dd::Spatial_reference_system srs,
const Geometry g1,
const Geometry g2,
const char *  func_name,
bool within,
bool null 
)
noexcept

Computes the within relation between the minimum bounding rectangles of two geometries.

Both geometries must be in the same coordinate system (Cartesian or geographic), and the coordinate system of the geometries must match the coordinate system of the SRID. It is the caller's responsibility to guarantee this.

Parameters
[in]srsThe spatial reference system, common to both geometries.
[in]g1First geometry.
[in]g2Second geometry.
[in]func_nameFunction name used in error reporting.
[out]withinWhether the MBR of g1 is within the MBR of g2.
[out]nullTrue if the return value is NULL.
Return values
falseSuccess.
trueAn error has occurred. The error has been reported with my_error().

◆ mbrs_are_equal()

bool gis::mbrs_are_equal ( Box const &  mbr1,
Box const &  mbr2 
)

Checks if two MBRs are equal.

Empty boxes are considered equal.

Parameters
[in]mbr1First MBR.
[in]mbr2Second MBR.
Return values
trueThe MBRs are equal.
falseThe MBRs are not equal.

◆ merge_mbrs() [1/2]

static void gis::merge_mbrs ( const std::vector< Cartesian_box > &  boxes,
Cartesian_box mbr 
)
static

Merges a vector of Cartesian MBRs into one common MBR.

Since the coordinate system doesn't wrap, the order in which MBRs are expanded doesn't matter.

Parameters
[in]boxesVector of MBRs to merge.
[out]mbrThe resulting MBR.

◆ merge_mbrs() [2/2]

static void gis::merge_mbrs ( const std::vector< Geographic_box > &  boxes,
Geographic_box mbr 
)
static

Merges a vector of geographic MBRs into one common MBR.

The coordinate system wraps, so the MBRs must be expanded in the correct order to avoid creating an MBR that is larger than necessary.

If the vector of boxes is empty, the result MBR is unchanged.

Parameters
[in]boxesVector of MBRs to merge.
[out]mbrThe resulting MBR.

◆ operator<()

bool gis::operator< ( const Point lhs,
const Point rhs 
)
inline

Compares two points.

The point with the lowest X coordinate is the smaller point. If X coordinates are equal, the point with the lowest Y coordinate is the smaller.

Parameters
lhsLeft hand side.
rhsRight hand side.
Return values
trueLeft hand side sorts before right hand side.
falseLeft hand side does not sort before right hand side.

◆ overlaps()

bool gis::overlaps ( const dd::Spatial_reference_system srs,
const Geometry g1,
const Geometry g2,
const char *  func_name,
bool overlaps,
bool null 
)
noexcept

Computes the overlaps relation between two geometries.

Both geometries must be in the same coordinate system (Cartesian or geographic), and the coordinate system of the geometries must match the coordinate system of the SRID. It is the caller's responsibility to guarantee this.

Parameters
[in]srsThe spatial reference system, common to both geometries.
[in]g1First geometry.
[in]g2Second geometry.
[in]func_nameFunction name used in error reporting.
[out]overlapsWhether g1 overlaps g2.
[out]nullTrue if the return value is NULL.
Return values
falseSuccess.
trueAn error has occurred. The error has been reported with my_error().

◆ parse_geometry()

bool gis::parse_geometry ( THD thd,
const char *  func_name,
const String str,
const dd::Spatial_reference_system **  srs,
std::unique_ptr< Geometry > *  geometry,
bool  treat_unknown_srid_as_cartesian = false 
)

Parses a little-endian geometry string (SRID + WKB).

The geometry is allocated on the heap and ownership is transferred to the caller.

Parameters
[in]thdThread handle
[in]func_nameThe function name to use in error messages.
[in]strThe geometry string.
[out]srsThe spatial reference system of the geometry.
[out]geometryThe geometry.
[in]treat_unknown_srid_as_cartesianWhether to treat unknown SRIDs as Cartesian. If false, raise an error if the SRID is unknown.
Return values
falseSuccess.
trueError. my_error() has been called.

◆ parse_srid()

bool gis::parse_srid ( const char *  str,
std::size_t  length,
srid_t srid 
)

Parses an SRID from a little-endian string.

Parameters
[in]strThe string.
[in]lengthLength of the string.
[out]sridThe SRID read from the string.
Return values
falseSuccess.
trueError. my_error() has not been called.

◆ parse_wkb()

std::unique_ptr< Geometry > gis::parse_wkb ( THD thd,
const dd::Spatial_reference_system srs,
const char *  wkb,
std::size_t  length,
bool  ignore_axis_order = false 
)

Parses a geometry WKB string and constructs a geometry object.

The geometry is allocated on the heap and ownership is transferred to the caller.

If ignore_axis_order is true, the string is assumed to be on the geometry storage format, not general WKB. The storage format differs from ordinary WKB by having a fixed x=longitude, y=latitude mapping.

Warning
This function checks if there are so many nested levels of geometry collections that the stack will be exhausted. If that happens, my_error is called and the function exits with no geometry value. However, if thd is nullptr, this check is disabled, and the caller is responsible for checking that there is enough stack to parse the WKB string.
Parameters
[in]thdThread handle.
srsThe SRS of the geometry.
wkbThe WKB string.
lengthLength of the WKB string.
ignore_axis_orderIgnore SRS axis order and assume it's always long-lat.
Returns
The geometry. If an error occurred, the return value is a null pointer. In case of stack overrun, my_error has been called.

◆ reinterpret_as_degrees() [1/2]

static Geographic_point gis::reinterpret_as_degrees ( const Cartesian_point g)
static

Map Cartesian geometry to geographic, mapping degrees east = x, degrees north = y.

Do not canonicalize coordinates of poles.

Used when a SQL function needs to accept Cartesian coordiates as a shorthand for geographic with some default SRS.

◆ reinterpret_as_degrees() [2/2]

static Geographic_multipoint gis::reinterpret_as_degrees ( const Cartesian_multipoint g)
static

Map Cartesian geometry to geographic, mapping degrees east = x, degrees north = y.

Do not canonicalize coordinates of poles.

Used when a SQL function needs to accept Cartesian coordiates as a shorthand for geographic with some default SRS.

◆ simplify()

bool gis::simplify ( const dd::Spatial_reference_system srs,
const Geometry g,
double  max_distance,
const char *  func_name,
std::unique_ptr< Geometry > *  result 
)
noexcept

Simplifies a geometry using the Douglas-Peucker algorithm.

Parameters
[in]srsThe spatial reference system, common to both geometries.
[in]gThe geometry.
[in]max_distanceCut-off distance (in coordinate units) of the Douglas-Peucker algorithm.
[in]func_nameFunction name used in error reporting.
[out]resultThe simplified geometry.
Return values
falseSuccess.
trueAn error has occurred. The error has been reported with my_error().

◆ split_gc()

void gis::split_gc ( const Geometrycollection gc,
std::unique_ptr< Multipoint > *  mpt,
std::unique_ptr< Multilinestring > *  mls,
std::unique_ptr< Multipolygon > *  mpy 
)

Splits a geometrycollection into points, linestrings and polygons.

All output collections may contain overlapping geometries and duplicates. This is not a problem for the multipoint and multilinestring outputs, but the multipolygon may be geometrically invalid.

Parameters
[in]gcGeometry collection.
[out]mptAll points in the geometrycollection.
[out]mlsAll linestrings in the geometrycollection.
[out]mpyAll polygons in the geometrycollection.

◆ touches()

bool gis::touches ( const dd::Spatial_reference_system srs,
const Geometry g1,
const Geometry g2,
const char *  func_name,
bool touches,
bool null 
)
noexcept

Computes the touches relation between two geometries.

Both geometries must be in the same coordinate system (Cartesian or geographic), and the coordinate system of the geometries must match the coordinate system of the SRID. It is the caller's responsibility to guarantee this.

Parameters
[in]srsThe spatial reference system, common to both geometries.
[in]g1First geometry.
[in]g2Second geometry.
[in]func_nameFunction name used in error reporting.
[out]touchesWhether g1 touches g2.
[out]nullTrue if the return value is NULL.
Return values
falseSuccess.
trueAn error has occurred. The error has been reported with my_error().

◆ transform()

bool gis::transform ( const dd::Spatial_reference_system source_srs,
const Geometry in,
const dd::Spatial_reference_system target_srs,
const char *  func_name,
std::unique_ptr< Geometry > *  out 
)
noexcept

Transforms a geometry from one SRS to another.

Parameters
[in]source_srsThe SRS of the input geometry.
[in]inThe geometry to transform.
[in]target_srsThe SRS of the output geometry.
[in]func_nameFunction name used in error reporting.
[out]outThe output geometry.
Return values
falseSuccess.
trueAn error has occurred. The error has been reported with my_error().

◆ type_to_name()

const char * gis::type_to_name ( Geometry_type  type)

Get the type name string corresponding to a geometry type.

Parameters
typeThe geometry type.
Returns
A string containing the type name (in uppercase).

◆ typed_gc_union()

template<typename MPt , typename MLs , typename MPy >
void gis::typed_gc_union ( double  semi_major,
double  semi_minor,
std::unique_ptr< Multipoint > *  mpt,
std::unique_ptr< Multilinestring > *  mls,
std::unique_ptr< Multipolygon > *  mpy 
)

◆ typed_split_gc()

template<typename Pt , typename Ls , typename Py , typename GC , typename MPt , typename MLs , typename MPy >
static void gis::typed_split_gc ( const GC *  gc,
MPt *  mpt,
MLs *  mls,
MPy *  mpy 
)
static

◆ units()

collation_unordered_map< std::string, Unit > gis::units ( )

A function to obtaint the supported units for the gis module.

Returns
Map of supported units for ST_DISTANCE

◆ within()

bool gis::within ( const dd::Spatial_reference_system srs,
const Geometry g1,
const Geometry g2,
const char *  func_name,
bool within,
bool null 
)
noexcept

Computes the within relation between two geometries.

Both geometries must be in the same coordinate system (Cartesian or geographic), and the coordinate system of the geometries must match the coordinate system of the SRID. It is the caller's responsibility to guarantee this.

Parameters
[in]srsThe spatial reference system, common to both geometries.
[in]g1First geometry.
[in]g2Second geometry.
[in]func_nameFunction name used in error reporting.
[out]withinWhether g1 lies within g2.
[out]nullTrue if the return value is NULL.
Return values
falseSuccess.
trueAn error has occurred. The error has been reported with my_error().

◆ write_geometry()

bool gis::write_geometry ( const dd::Spatial_reference_system srs,
Geometry geometry,
String str 
)

Writes a little-endian geometry string (SRID + WKB).

Parameters
[in]srsThe SRS of the geometry.
[in]geometryThe geometry.
[out]strThe string to write the geometry to.
Return values
falseSuccess.
trueError. my_error() has been called.