MySQL 8.4.2
Source Code Documentation
Geometry Class Referenceabstract

#include <spatial.h>

Inheritance diagram for Geometry:
[legend]

Classes

class  Class_info
 
class  Flags_t
 Highest byte is stores byte order, dimension, nomem and geotype as follows: bo: byte order, 1 for little endian(ndr), 0 for big endian(xdr); Currently it must be always wkb_ndr since it is MySQL's portable geometry format. More...
 
class  wkb_container
 Constant storage for WKB. More...
 
class  wkb_parser
 WKB parser, designed to traverse through WKB data from beginning of the buffer towards the end using a set of scan_xxx(), get_xxx() and skip_xxx() routines, with safety tests to avoid going beyond the buffer end. More...
 

Public Types

enum  wkbType {
  wkb_invalid_type = 0 , wkb_first = 1 , wkb_point = 1 , wkb_linestring = 2 ,
  wkb_polygon = 3 , wkb_multipoint = 4 , wkb_multilinestring = 5 , wkb_multipolygon = 6 ,
  wkb_geometrycollection = 7 , wkb_polygon_inner_rings = 31 , wkb_last = 31
}
 
enum  wkbByteOrder { wkb_xdr = 0 , wkb_ndr = 1 , wkb_invalid }
 
enum  enum_coordinate_reference_system { coord_first = 1 , cartesian = 1 , coord_last = 1 }
 
typedef Geometry *(* create_geom_t) (char *)
 Callback which creates Geometry objects on top of a given placement. More...
 

Public Member Functions

virtual ~Geometry ()
 
virtual const Class_infoget_class_info () const
 
virtual uint32 get_data_size () const
 
virtual bool init_from_wkt (Gis_read_stream *trs, String *wkb)
 
virtual uint init_from_wkb (THD *thd, const char *wkb, uint len, wkbByteOrder bo, String *res)
 
virtual bool get_data_as_wkt (String *txt, wkb_parser *wkb) const
 
virtual bool get_mbr (MBR *mbr, wkb_parser *wkb) const
 
bool get_mbr (MBR *mbr)
 
virtual bool dimension (uint32 *dim, wkb_parser *wkb) const
 
bool dimension (uint32 *dim) const
 
wkbType get_type () const
 
enum_coordinate_reference_system get_coordsys () const
 
virtual uint32 feature_dimension () const
 
virtual int get_x (double *) const
 
virtual int get_y (double *) const
 
virtual int geom_length (double *) const
 
virtual int is_closed (int *) const
 
virtual int num_interior_ring (uint32 *) const
 
virtual int num_points (uint32 *) const
 
virtual int num_geometries (uint32 *) const
 
virtual int copy_points (String *) const
 
virtual int start_point (String *) const
 
virtual int end_point (String *) const
 
virtual int exterior_ring (String *) const
 
virtual int point_n (uint32 num, String *result) const
 
virtual int interior_ring_n (uint32 num, String *result) const
 
virtual int geometry_n (uint32 num, String *result) const
 
virtual bool reverse_coordinates ()=0
 Reverses the coordinates of a geometry. More...
 
virtual bool validate_coordinate_range (double srs_angular_unit, bool *long_out_of_range, bool *lat_out_of_range, double *out_of_range_value)=0
 Check that the coordinates of a geometry is within the valid range. More...
 
bool as_wkt (String *wkt, wkb_parser *wkb) const
 
bool as_wkt (String *wkt) const
 
bool as_wkb (String *wkb, bool shallow_copy) const
 Write this geometry's WKB byte string into specified buffer, the SRID is not written into the buffer. More...
 
bool as_geometry (String *wkb, bool shallow_copy) const
 Write this geometry's GEOMETRY byte string into specified buffer, the SRID will be written before the WKB string to form a GEOMETRY byte string. More...
 
void set_data_ptr (const void *data, size_t data_len)
 
void set_data_ptr (const wkb_container *c)
 
void * get_data_ptr () const
 
bool envelope (String *result) const
 
bool envelope (MBR *mbr) const
 
bool is_polygon_ring () const
 
bool is_polygon_outer_ring () const
 
bool is_polygon_inner_ring () const
 
bool has_geom_header_space () const
 
void has_geom_header_space (bool b)
 
bool is_components_no_overlapped () const
 
void set_components_no_overlapped (bool b)
 
void set_props (uint16 flag)
 
uint16 get_props () const
 
void set_srid (gis::srid_t id)
 
gis::srid_t get_srid () const
 
const void * normalize_ring_order ()
 In place normalize polygons' rings, making outer ring CCW and inner rings CW by reversing the ring's points in the WKB buffer inplace. More...
 
 Geometry ()
 
 Geometry (const void *ptr, size_t len, const Flags_t &flags, gis::srid_t srid)
 Constructor used as BG adapter or by default constructors of children classes. More...
 
 Geometry (const Geometry &geo)
 
Geometryoperator= (const Geometry &rhs)
 Assignment operator for Geometry class, assignment operators of children classes calls this to do general assignment. More...
 
void * get_ptr () const
 
char * get_cptr () const
 
ucharget_ucptr () const
 
Geometryget_owner () const
 
void set_owner (Geometry *o)
 
void set_byte_order (Geometry::wkbByteOrder bo)
 
void set_dimension (char dim)
 
void set_geotype (Geometry::wkbType gt)
 
void set_nbytes (size_t n) const
 
void set_ownmem (bool b)
 Set whether this object has its own memory. More...
 
bool get_ownmem () const
 Returns whether this object has its own memory. More...
 
Geometry::wkbByteOrder get_byte_order () const
 
char get_dimension () const
 
Geometry::wkbType get_geotype () const
 
uint32 get_ogc_geotype () const
 Build an OGC standard type value from m_flags.zm and m_flags.geotype. More...
 
size_t get_nbytes () const
 
void set_ptr (const void *ptr)
 
bool is_bg_adapter () const
 Whether the Geometry object is created to be used by Boost Geometry or only by MySQL. More...
 
void set_bg_adapter (bool b) const
 Set whether this object is a BG adapter. More...
 
virtual void donate_data ()
 
Flags_t get_flags () const
 
void set_flags (const Flags_t &flags)
 

Static Public Member Functions

static Geometrycreate_by_typeid (Geometry_buffer *buffer, int type_id)
 
static Geometryconstruct (Geometry_buffer *buffer, const char *data, uint32 data_len, bool has_srid=true)
 Construct a Geometry object using GEOMETRY byte string. More...
 
static Geometryconstruct (Geometry_buffer *buffer, const String *str, bool has_srid=true)
 
static Geometrycreate_from_wkt (Geometry_buffer *buffer, Gis_read_stream *trs, String *wkt, bool init_stream=true, bool check_trailing=true)
 Read wkt text from trs, and write little endian wkb encoding into 'wkt', and create a Geometry instance in 'buffer'. More...
 
static Geometrycreate_from_wkb (THD *thd, Geometry_buffer *buffer, const char *wkb, uint32 len, String *res, bool init)
 Read from 'wkb' (which contains WKB encoded in either endianness) the geometry data, and write WKB of returned Geometry object in little endianness into 'res', and also create geometry object on 'buffer' and return it. More...
 
static bool is_valid_opengis_geotype (uint32 gtype)
 Check if a given geometry type is a valid geometry type according to OpenGIS. More...
 
static bool is_valid_geotype (uint32 gtype)
 Check if a given geometry type is a valid internal geometry type. More...
 
static bool is_valid_geotype (Geometry::wkbType gt)
 Check if a given geometry type is a valid internal geometry type. More...
 
static bool is_well_formed (const char *from, size_t length, wkbType type, wkbByteOrder bo)
 Verify that a string is a well-formed GEOMETRY string. More...
 

Static Public Attributes

static const uint32 MAX_GEOM_WKB_LENGTH = 0x3fffffff
 
static const gis::srid_t default_srid = 0
 
static String bad_geometry_data
 
static Class_infoci_collection [wkb_last+1]
 

Protected Member Functions

void append_points (String *txt, uint32 n_points, wkb_parser *wkb, uint32 offset, bool bracket_pt=false) const
 Append N points from packed format to text Before calling this function, caller must have already checked that wkb's buffer is complete and not truncated. More...
 
bool create_point (String *result, wkb_parser *wkb) const
 Create a point from data. More...
 
bool get_mbr_for_points (MBR *mbr, wkb_parser *wkb, uint offset) const
 Get most bounding rectangle (mbr) for X points. More...
 
bool is_length_verified () const
 
void set_length_verified (bool b) const
 
bool polygon_is_wkb_form () const
 In a polygon usable by boost geometry, the m_ptr points to the outer ring object, and m_inn_rings points to the inner rings, thus the polygon's data isn't stored in a single WKB. More...
 
void polygon_is_wkb_form (bool b)
 
bool has_out_of_line_components () const
 If call Gis_wkb_vector<T>::resize() to add a component to X, the geometry may have a geometry not stored inside the WKB buffer of X, hence X has out of line component. More...
 
void has_out_of_line_components (bool b)
 
void clear_wkb_data ()
 
virtual void shallow_push (const Geometry *)
 

Static Protected Member Functions

static Class_infofind_class (int type_id)
 
static Class_infofind_class (const char *name, size_t len)
 

Protected Attributes

Geometrym_owner
 The topmost (root) geometry object, whose m_ptr is the 1st byte of a wkb memory buffer. More...
 
void * m_ptr
 Pointer to the geometry's wkb data's 1st byte, right after its wkb header if any. More...
 

Static Protected Attributes

static const int POLYGON_OUTER_RING = 0x1
 
static const int POLYGON_INNER_RING = 0x2
 
static const int IS_BOOST_GEOMETRY_ADAPTER = 0x4
 
static const int GEOM_LENGTH_VERIFIED = 0x8
 
static const int HAS_OUT_OF_LINE_COMPONENTS = 0x10
 
static const int POLYGON_IN_WKB_FORM = 0x20
 
static const int HAS_GEOM_HEADER_SPACE = 0x40
 
static const int MULTIPOLYGON_NO_OVERLAPPED_COMPS = 0x80
 

Private Attributes

Flags_t m_flags
 Flags and meta information about this object. More...
 
gis::srid_t m_srid
 Srid of this object. More...
 

Friends

void parse_wkb_data (Geometry *geom, const char *p, size_t num_geoms)
 Parse the wkb buffer to build the component vector m_geo_vect for geom. More...
 

Member Typedef Documentation

◆ create_geom_t

typedef Geometry *(* Geometry::create_geom_t) (char *)

Callback which creates Geometry objects on top of a given placement.

Member Enumeration Documentation

◆ enum_coordinate_reference_system

Enumerator
coord_first 
cartesian 
coord_last 

◆ wkbByteOrder

Enumerator
wkb_xdr 
wkb_ndr 
wkb_invalid 

◆ wkbType

Enumerator
wkb_invalid_type 
wkb_first 
wkb_point 
wkb_linestring 
wkb_polygon 
wkb_multipoint 
wkb_multilinestring 
wkb_multipolygon 
wkb_geometrycollection 
wkb_polygon_inner_rings 
wkb_last 

Constructor & Destructor Documentation

◆ ~Geometry()

Geometry::~Geometry ( )
virtual

◆ Geometry() [1/3]

Geometry::Geometry ( )
inline

◆ Geometry() [2/3]

Geometry::Geometry ( const void *  ptr,
size_t  len,
const Flags_t flags,
gis::srid_t  srid 
)
inline

Constructor used as BG adapter or by default constructors of children classes.

Parameters
ptrWKB buffer address, or NULL for an empty object.
lenWKB buffer length in bytes.
flagsthe flags to set, no field is used for now except geotype.
sridsrid of the geometry.

◆ Geometry() [3/3]

Geometry::Geometry ( const Geometry geo)

Member Function Documentation

◆ append_points()

void Geometry::append_points ( String txt,
uint32  n_points,
wkb_parser wkb,
uint32  offset,
bool  bracket_pt = false 
) const
protected

Append N points from packed format to text Before calling this function, caller must have already checked that wkb's buffer is complete and not truncated.

Parameters
[out]txtAppend points here
n_pointsNumber of points
wkbPacked data
offsetOffset between points
bracket_ptwhether to bracket the point coordinate with (), multipoint need so.

◆ as_geometry()

bool Geometry::as_geometry ( String buf,
bool  shallow_copy 
) const

Write this geometry's GEOMETRY byte string into specified buffer, the SRID will be written before the WKB string to form a GEOMETRY byte string.

Parameters
bufThe buffer to write GEOMETRY byte string into.
shallow_copyWhether do shallow copy by using this object's memory without owning it or duplicating the byte string.
Returns
true if got error, false if successful.

◆ as_wkb()

bool Geometry::as_wkb ( String wkb,
bool  shallow_copy 
) const

Write this geometry's WKB byte string into specified buffer, the SRID is not written into the buffer.

Parameters
wkbThe buffer to write WKB byte string into.
shallow_copyWhether do shallow copy by using this object's memory without owning it or duplicating the byte string.
Returns
true if got error, false if successful.

◆ as_wkt() [1/2]

bool Geometry::as_wkt ( String wkt) const
inline

◆ as_wkt() [2/2]

bool Geometry::as_wkt ( String wkt,
wkb_parser wkb 
) const
inline

◆ clear_wkb_data()

void Geometry::clear_wkb_data ( )
protected

◆ construct() [1/2]

Geometry * Geometry::construct ( Geometry_buffer buffer,
const char *  data,
uint32  data_len,
bool  has_srid = true 
)
static

Construct a Geometry object using GEOMETRY byte string.

This function is called by all GIS functions to make a Geometry object from a GEOMETRY byte string, which can come from table storage, or returned from other GIS function, or directly provided by user via client.

The WKB can be of either endianness — when user directly pass WKB byte string to us, he/she can pass big endian WKB, otherwise the WKB is always little endian. And we should reject big endian WKB because all the rest of the GIS code assumes the internal WKB data being always little endian.

Parameters
bufferThe place where the Geometry object is constructed on.
datais a byte string with an optional srid prepending a WKB format byte string, which is called a GEOMETRY byte string and which is the inner storage format of all geometries in MySQL.
data_lennumber of bytes of the byte string referred by data.
has_sridwhether data argument starts with an srid or not. By default it's true, if false, data starts with WKB header, and caller is responsible to specify an srid to this object later.
Returns
Constructed geometry object.

◆ construct() [2/2]

static Geometry * Geometry::construct ( Geometry_buffer buffer,
const String str,
bool  has_srid = true 
)
inlinestatic

◆ copy_points()

virtual int Geometry::copy_points ( String ) const
inlinevirtual

◆ create_by_typeid()

Geometry * Geometry::create_by_typeid ( Geometry_buffer buffer,
int  type_id 
)
static

◆ create_from_wkb()

Geometry * Geometry::create_from_wkb ( THD thd,
Geometry_buffer buffer,
const char *  wkb,
uint32  len,
String res,
bool  init_stream 
)
static

Read from 'wkb' (which contains WKB encoded in either endianness) the geometry data, and write WKB of returned Geometry object in little endianness into 'res', and also create geometry object on 'buffer' and return it.

The returned Geometry object points to bytes (without WKB HEADER) in 'res'.

Parameters
thdThread context.
bufferthe place to create the returned Geometry object at.
wkbthe input WKB buffer which contains WKB of either endianness.
lenthe number of bytes of WKB in 'wkb'.
resthe buffer to write little endian WKB into.
init_streamWhether set WKB buffer pointer to returned Geometry object.
Returns
the created Geometry object.

◆ create_from_wkt()

Geometry * Geometry::create_from_wkt ( Geometry_buffer buffer,
Gis_read_stream trs,
String wkb,
bool  init_stream = true,
bool  check_trailing = true 
)
static

Read wkt text from trs, and write little endian wkb encoding into 'wkt', and create a Geometry instance in 'buffer'.

If 'init_stream' is true, shallow assign data in 'wkt' to the Geometry object to be returned.

Parameters
bufferPlace to create the returned Geometry object at.
trsWKT read stream.
wkbLittle endian WKB buffer for WKB data of the returned Geometry object.
init_streamWhether set WKB buffer pointer to returned Geometry object.
check_trailingWhether to flag an error (by returning nullptr) if there are trailing bytes in the string.
Returns
A Geometry object with data specified by the WKT.

◆ create_point()

bool Geometry::create_point ( String result,
wkb_parser wkb 
) const
protected

Create a point from data.

Parameters
[out]resultPut result here
wkbData for point is here.
Returns
false on success, true on error

◆ dimension() [1/2]

bool Geometry::dimension ( uint32 dim) const
inline

◆ dimension() [2/2]

virtual bool Geometry::dimension ( uint32 dim,
wkb_parser wkb 
) const
inlinevirtual

Reimplemented in Gis_geometry_collection.

◆ donate_data()

virtual void Geometry::donate_data ( )
inlinevirtual

◆ end_point()

virtual int Geometry::end_point ( String ) const
inlinevirtual

Reimplemented in Gis_line_string.

◆ envelope() [1/2]

bool Geometry::envelope ( MBR mbr) const

◆ envelope() [2/2]

bool Geometry::envelope ( String result) const

◆ exterior_ring()

virtual int Geometry::exterior_ring ( String ) const
inlinevirtual

Reimplemented in Gis_polygon.

◆ feature_dimension()

virtual uint32 Geometry::feature_dimension ( ) const
inlinevirtual

◆ find_class() [1/2]

Geometry::Class_info * Geometry::find_class ( const char *  name,
size_t  len 
)
staticprotected

◆ find_class() [2/2]

static Class_info * Geometry::find_class ( int  type_id)
inlinestaticprotected

◆ geom_length()

virtual int Geometry::geom_length ( double *  ) const
inlinevirtual

Reimplemented in Gis_line_string, and Gis_multi_line_string.

◆ geometry_n()

virtual int Geometry::geometry_n ( uint32  num,
String result 
) const
inlinevirtual

◆ get_byte_order()

Geometry::wkbByteOrder Geometry::get_byte_order ( ) const
inline

◆ get_class_info()

virtual const Class_info * Geometry::get_class_info ( ) const
inlinevirtual

◆ get_coordsys()

enum_coordinate_reference_system Geometry::get_coordsys ( ) const
inline

◆ get_cptr()

char * Geometry::get_cptr ( ) const
inline

◆ get_data_as_wkt()

virtual bool Geometry::get_data_as_wkt ( String txt,
wkb_parser wkb 
) const
inlinevirtual

◆ get_data_ptr()

void * Geometry::get_data_ptr ( ) const
inline

◆ get_data_size()

virtual uint32 Geometry::get_data_size ( ) const
inlinevirtual

◆ get_dimension()

char Geometry::get_dimension ( ) const
inline

◆ get_flags()

Flags_t Geometry::get_flags ( ) const
inline

◆ get_geotype()

Geometry::wkbType Geometry::get_geotype ( ) const
inline

◆ get_mbr() [1/2]

bool Geometry::get_mbr ( MBR mbr)
inline

◆ get_mbr() [2/2]

virtual bool Geometry::get_mbr ( MBR mbr,
wkb_parser wkb 
) const
inlinevirtual

◆ get_mbr_for_points()

bool Geometry::get_mbr_for_points ( MBR mbr,
wkb_parser wkb,
uint  offset 
) const
protected

Get most bounding rectangle (mbr) for X points.

Parameters
[out]mbrResult
wkbData for point is here.
offsetOffset between points
Returns
false on success, true on error

◆ get_nbytes()

size_t Geometry::get_nbytes ( ) const
inline

◆ get_ogc_geotype()

uint32 Geometry::get_ogc_geotype ( ) const
inline

Build an OGC standard type value from m_flags.zm and m_flags.geotype.

For now m_flags.zm is always 0 so simply call get_geotype(). We don't directly store the OGC defined values in order to save more bits of m_flags for other purposes; and also separating zm settings from basic geometry types is easier for coding and geometry type identification.

When we start to support Z/M settings we need to modify all code which call write_wkb_header and write_geometry_header to pass to them an OGC standard type value returned by this function or built similarly. And by doing so our internal runtime geometry type encoding will work consistently with OGC defined standard geometry type values in byte strings of WKB format.

Returns
OGC standard geometry type value.

◆ get_owner()

Geometry * Geometry::get_owner ( ) const
inline

◆ get_ownmem()

bool Geometry::get_ownmem ( ) const
inline

Returns whether this object has its own memory.

If so, the memory is released when this object is destroyed.

◆ get_props()

uint16 Geometry::get_props ( ) const
inline

◆ get_ptr()

void * Geometry::get_ptr ( ) const
inline

◆ get_srid()

gis::srid_t Geometry::get_srid ( ) const
inline

◆ get_type()

wkbType Geometry::get_type ( ) const
inline

◆ get_ucptr()

uchar * Geometry::get_ucptr ( ) const
inline

◆ get_x()

virtual int Geometry::get_x ( double *  ) const
inlinevirtual

Reimplemented in Gis_point.

◆ get_y()

virtual int Geometry::get_y ( double *  ) const
inlinevirtual

Reimplemented in Gis_point.

◆ has_geom_header_space() [1/2]

bool Geometry::has_geom_header_space ( ) const
inline

◆ has_geom_header_space() [2/2]

void Geometry::has_geom_header_space ( bool  b)
inline

◆ has_out_of_line_components() [1/2]

bool Geometry::has_out_of_line_components ( ) const
inlineprotected

If call Gis_wkb_vector<T>::resize() to add a component to X, the geometry may have a geometry not stored inside the WKB buffer of X, hence X has out of line component.

For such an X, user should call Gis_wkb_vector<T>::reassemble() before fetching its WKB data.

◆ has_out_of_line_components() [2/2]

void Geometry::has_out_of_line_components ( bool  b)
inlineprotected

◆ init_from_wkb()

virtual uint Geometry::init_from_wkb ( THD thd,
const char *  wkb,
uint  len,
wkbByteOrder  bo,
String res 
)
inlinevirtual

◆ init_from_wkt()

virtual bool Geometry::init_from_wkt ( Gis_read_stream trs,
String wkb 
)
inlinevirtual

◆ interior_ring_n()

virtual int Geometry::interior_ring_n ( uint32  num,
String result 
) const
inlinevirtual

Reimplemented in Gis_polygon.

◆ is_bg_adapter()

bool Geometry::is_bg_adapter ( ) const
inline

Whether the Geometry object is created to be used by Boost Geometry or only by MySQL.

There are some operations that only work for one type and can or must be skipped otherwise.

Returns
true if it's a BG adapter, false otherwise.

◆ is_closed()

virtual int Geometry::is_closed ( int *  ) const
inlinevirtual

Reimplemented in Gis_line_string, and Gis_multi_line_string.

◆ is_components_no_overlapped()

bool Geometry::is_components_no_overlapped ( ) const
inline

◆ is_length_verified()

bool Geometry::is_length_verified ( ) const
inlineprotected

◆ is_polygon_inner_ring()

bool Geometry::is_polygon_inner_ring ( ) const
inline

◆ is_polygon_outer_ring()

bool Geometry::is_polygon_outer_ring ( ) const
inline

◆ is_polygon_ring()

bool Geometry::is_polygon_ring ( ) const
inline

◆ is_valid_geotype() [1/2]

static bool Geometry::is_valid_geotype ( Geometry::wkbType  gt)
inlinestatic

Check if a given geometry type is a valid internal geometry type.

Both OpenGIS standard geometry types and internal geometry types of MySQL are regarded as valid.

Parameters
gtgeometry type to check
Return values
truevalid geometry type
falseinvalid geometry type

◆ is_valid_geotype() [2/2]

static bool Geometry::is_valid_geotype ( uint32  gtype)
inlinestatic

Check if a given geometry type is a valid internal geometry type.

Both OpenGIS standard geometry types and internal geometry types of MySQL are regarded as valid.

Parameters
gtypegeometry type to check
Return values
truevalid geometry type
falseinvalid geometry type

◆ is_valid_opengis_geotype()

static bool Geometry::is_valid_opengis_geotype ( uint32  gtype)
inlinestatic

Check if a given geometry type is a valid geometry type according to OpenGIS.

Internal geometry types of MySQL are regarded as invalid.

Parameters
gtypegeometry type to check
Return values
truevalid geometry type
falseinvalid geometry type

◆ is_well_formed()

bool Geometry::is_well_formed ( const char *  from,
size_t  length,
Geometry::wkbType  type,
Geometry::wkbByteOrder  bo 
)
static

Verify that a string is a well-formed GEOMETRY string.

This does not check if the geometry is geometrically valid.

See also
Geometry_well_formed_checker
Parameters
fromString to check
lengthLength of string
typeExpected type of geometry, or Geometry::wkb_invalid_type if any type is allowed
bobyte order
Returns
True if the string is a well-formed GEOMETRY string, false otherwise

◆ normalize_ring_order()

const void * Geometry::normalize_ring_order ( )

In place normalize polygons' rings, making outer ring CCW and inner rings CW by reversing the ring's points in the WKB buffer inplace.

This function can not be made a virtual function since BG adapter geometry objects may also need it.

Returns
the WKB buffer address of the geometry which contains the converted WKB data. If geometry data is invalid, returns NULL.

◆ num_geometries()

virtual int Geometry::num_geometries ( uint32 ) const
inlinevirtual

◆ num_interior_ring()

virtual int Geometry::num_interior_ring ( uint32 ) const
inlinevirtual

Reimplemented in Gis_polygon.

◆ num_points()

virtual int Geometry::num_points ( uint32 ) const
inlinevirtual

Reimplemented in Gis_line_string.

◆ operator=()

Geometry & Geometry::operator= ( const Geometry rhs)

Assignment operator for Geometry class, assignment operators of children classes calls this to do general assignment.

◆ point_n()

virtual int Geometry::point_n ( uint32  num,
String result 
) const
inlinevirtual

Reimplemented in Gis_line_string.

◆ polygon_is_wkb_form() [1/2]

bool Geometry::polygon_is_wkb_form ( ) const
inlineprotected

In a polygon usable by boost geometry, the m_ptr points to the outer ring object, and m_inn_rings points to the inner rings, thus the polygon's data isn't stored in a single WKB.

Users should call Gis_polygon::to_wkb_unparsed() before getting the polygon's wkb data, Gis_polygon::to_wkb_unparsed() will form a single WKB for the polygon and refer to it with m_ptr, and release the outer ring object and the inner rings objects, and such an polygon isn't usable by BG any more, it's exactly what we got with Geometry::create_from_wkt / Geometry::create_from_wkt.

◆ polygon_is_wkb_form() [2/2]

void Geometry::polygon_is_wkb_form ( bool  b)
inlineprotected

◆ reverse_coordinates()

virtual bool Geometry::reverse_coordinates ( )
pure virtual

Reverses the coordinates of a geometry.

Switches the coordinates of the wkb string pointed to by the Geometry. Ex: Used on a POINT(5,2), the result would be POINT(2, 5).

Return values
falsecoordinate reversal was successful
truecoordinate reversal was unsuccessful

Implemented in Gis_point, Gis_wkb_vector< T >, Gis_wkb_vector< Gis_point >, Gis_wkb_vector< Gis_line_string >, Gis_wkb_vector< Gis_polygon >, Gis_line_string, Gis_polygon, Gis_multi_point, Gis_multi_line_string, Gis_multi_polygon, and Gis_geometry_collection.

◆ set_bg_adapter()

void Geometry::set_bg_adapter ( bool  b) const
inline

Set whether this object is a BG adapter.

Parameters
btrue if it's a BG adapter, false otherwise. Have to declare this as const because even when a Geometry object's const adapter member function is called, it's regarded as a BG adapter object.

◆ set_byte_order()

void Geometry::set_byte_order ( Geometry::wkbByteOrder  bo)
inline

◆ set_components_no_overlapped()

void Geometry::set_components_no_overlapped ( bool  b)
inline

◆ set_data_ptr() [1/2]

void Geometry::set_data_ptr ( const void *  data,
size_t  data_len 
)
inline

◆ set_data_ptr() [2/2]

void Geometry::set_data_ptr ( const wkb_container c)
inline

◆ set_dimension()

void Geometry::set_dimension ( char  dim)
inline

◆ set_flags()

void Geometry::set_flags ( const Flags_t flags)
inline

◆ set_geotype()

void Geometry::set_geotype ( Geometry::wkbType  gt)
inline

◆ set_length_verified()

void Geometry::set_length_verified ( bool  b) const
inlineprotected

◆ set_nbytes()

void Geometry::set_nbytes ( size_t  n) const
inline

◆ set_owner()

void Geometry::set_owner ( Geometry o)
inline

◆ set_ownmem()

void Geometry::set_ownmem ( bool  b)
inline

Set whether this object has its own memory.

If so, the memory is released when this object is destroyed.

Parameters
btrue if this object has its own memory, false otherwise.

◆ set_props()

void Geometry::set_props ( uint16  flag)
inline

◆ set_ptr()

void Geometry::set_ptr ( const void *  ptr)
inline

◆ set_srid()

void Geometry::set_srid ( gis::srid_t  id)
inline

◆ shallow_push()

virtual void Geometry::shallow_push ( const Geometry )
inlineprotectedvirtual

◆ start_point()

virtual int Geometry::start_point ( String ) const
inlinevirtual

Reimplemented in Gis_line_string.

◆ validate_coordinate_range()

virtual bool Geometry::validate_coordinate_range ( double  srs_angular_unit,
bool *  long_out_of_range,
bool *  lat_out_of_range,
double *  out_of_range_value 
)
pure virtual

Check that the coordinates of a geometry is within the valid range.

Checks if the coordinates in a geometry are within allowed range of a geographic spatial reference system. Valid range for longitude and latitude coordinates in geographic spatial reference systems are (-180, 180) and [-90, 90] degrees, respectively.

Parameters
[in]srs_angular_unitUnit to radians conversion factor.
[out]long_out_of_rangeLongitude is out of range.
[out]lat_out_of_rangeLatitude is out of range.
[out]out_of_range_valueThe value that is out of range.
Return values
falseCoordinates are within allowed range.
trueCoordinates are not within allowed range, or an error occurred during range checking.

Implemented in Gis_point, Gis_line_string, Gis_polygon, Gis_multi_point, Gis_multi_line_string, Gis_multi_polygon, Gis_geometry_collection, Gis_wkb_vector< T >, Gis_wkb_vector< Gis_point >, Gis_wkb_vector< Gis_line_string >, and Gis_wkb_vector< Gis_polygon >.

Friends And Related Function Documentation

◆ parse_wkb_data

void parse_wkb_data ( Geometry geom,
const char *  p,
size_t  num_geoms 
)
friend

Parse the wkb buffer to build the component vector m_geo_vect for geom.

Set each geometry's wkb pointer into the Geometry objects inside m_geo_vect. Make it a standalone function in order to be able to access classes defined after class template Gis_wkb_vector.

Parameters
geomthe geometry to analyze and parse.
ppoints to the geometry's wkb data's 1st byte, right after its wkb header if any.
num_geomsnumber of following geometries, to be used only when parsing the WKB of a polygon's inner rings because there is no WKB header for the inner rings only.

Member Data Documentation

◆ bad_geometry_data

String Geometry::bad_geometry_data
static

◆ ci_collection

Geometry::Class_info * Geometry::ci_collection
static
Initial value:
= {
nullptr}

◆ default_srid

const gis::srid_t Geometry::default_srid = 0
static

◆ GEOM_LENGTH_VERIFIED

const int Geometry::GEOM_LENGTH_VERIFIED = 0x8
staticprotected

◆ HAS_GEOM_HEADER_SPACE

const int Geometry::HAS_GEOM_HEADER_SPACE = 0x40
staticprotected

◆ HAS_OUT_OF_LINE_COMPONENTS

const int Geometry::HAS_OUT_OF_LINE_COMPONENTS = 0x10
staticprotected

◆ IS_BOOST_GEOMETRY_ADAPTER

const int Geometry::IS_BOOST_GEOMETRY_ADAPTER = 0x4
staticprotected

◆ m_flags

Flags_t Geometry::m_flags
mutableprivate

Flags and meta information about this object.

Make it mutable to modify some flags in const member functions.

◆ m_owner

Geometry* Geometry::m_owner
protected

The topmost (root) geometry object, whose m_ptr is the 1st byte of a wkb memory buffer.

other geometry objects hold m_ptr which points inside somewhere in the memory buffer. when updating a geometry object, need to ask m_owner to reallocate memory if needed for new data.

◆ m_ptr

void* Geometry::m_ptr
protected

Pointer to the geometry's wkb data's 1st byte, right after its wkb header if any.

If the geometry is wkb_polygon, this field is a Gis_polygon_ring* pointer, pointing to the outer ring. Outer ring's wkb data is in the same wkb buffer as the inner rings, so we can get the wkb header from the outer ring like ((Geometry*)m_ptr)->get_ptr().

◆ m_srid

gis::srid_t Geometry::m_srid
private

Srid of this object.

◆ MAX_GEOM_WKB_LENGTH

const uint32 Geometry::MAX_GEOM_WKB_LENGTH = 0x3fffffff
static

◆ MULTIPOLYGON_NO_OVERLAPPED_COMPS

const int Geometry::MULTIPOLYGON_NO_OVERLAPPED_COMPS = 0x80
staticprotected

◆ POLYGON_IN_WKB_FORM

const int Geometry::POLYGON_IN_WKB_FORM = 0x20
staticprotected

◆ POLYGON_INNER_RING

const int Geometry::POLYGON_INNER_RING = 0x2
staticprotected

◆ POLYGON_OUTER_RING

const int Geometry::POLYGON_OUTER_RING = 0x1
staticprotected

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