MySQL 8.0.39
Source Code Documentation
Gis_polygon Class Reference

#include <spatial.h>

Inheritance diagram for Gis_polygon:
[legend]

Public Types

typedef Gis_polygon self
 
typedef Gis_polygon_ring ring_type
 
typedef Gis_wkb_vector< ring_typeinner_container_type
 
- Public Types inherited from Geometry
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

uint32 get_data_size () const override
 
bool init_from_wkt (Gis_read_stream *trs, String *wkb) override
 
uint init_from_wkb (THD *thd, const char *wkb, uint len, wkbByteOrder bo, String *res) override
 
bool get_data_as_wkt (String *txt, wkb_parser *wkb) const override
 
bool get_mbr (MBR *mbr, wkb_parser *wkb) const override
 
int exterior_ring (String *result) const override
 
int num_interior_ring (uint32 *n_int_rings) const override
 
int interior_ring_n (uint32 num, String *result) const override
 
uint32 feature_dimension () const override
 
const Class_infoget_class_info () const override
 
bool reverse_coordinates () override
 Reverses the coordinates of a geometry. More...
 
bool validate_coordinate_range (double srs_angular_unit, bool *long_out_of_range, bool *lat_out_of_range, double *out_of_range_value) override
 Check that the coordinates of a geometry is within the valid range. More...
 
ring_typeouter () const
 
inner_container_typeinners () const
 
void clear ()
 Clears outer and inner rings. More...
 
 Gis_polygon (const void *wkb, size_t nbytes, const Flags_t &flags, gis::srid_t srid)
 
 Gis_polygon (bool isbgadapter=true)
 
 Gis_polygon (const self &r)
 Copy constructor. More...
 
Gis_polygonoperator= (const Gis_polygon &rhs)
 Deep assignment from polygon 'o' to this object. More...
 
 ~Gis_polygon () override
 
void to_wkb_unparsed ()
 Make the polygon's data in a single buffer as WKB format. More...
 
void set_ptr (void *ptr, size_t len)
 Set WKB data to this object, the WKB data will be used read only. More...
 
void donate_data () override
 
bool set_polygon_ring_order ()
 Set this polygon's outer ring to be CCW and inner rings to be CW. More...
 
inner_container_typeinner_rings () const SUPPRESS_UBSAN
 
void set_inner_rings (inner_container_type *inns) SUPPRESS_UBSAN
 
- Public Member Functions inherited from Geometry
virtual ~Geometry ()
 
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 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_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 point_n (uint32 num, String *result) const
 
virtual int geometry_n (uint32 num, String *result) const
 
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...
 
Flags_t get_flags () const
 
void set_flags (const Flags_t &flags)
 

Private Member Functions

void make_rings ()
 Make outer ring and inner rings objects for this polygon if it doesn't have one yet. More...
 

Private Attributes

inner_container_typem_inn_rings
 

Additional Inherited Members

- Static Public Member Functions inherited from Geometry
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 inherited from Geometry
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 inherited from Geometry
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 inherited from Geometry
static Class_infofind_class (int type_id)
 
static Class_infofind_class (const char *name, size_t len)
 
- Protected Attributes inherited from Geometry
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 inherited from Geometry
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
 

Member Typedef Documentation

◆ inner_container_type

◆ ring_type

◆ self

Constructor & Destructor Documentation

◆ Gis_polygon() [1/3]

Gis_polygon::Gis_polygon ( const void *  wkb,
size_t  nbytes,
const Flags_t flags,
gis::srid_t  srid 
)

◆ Gis_polygon() [2/3]

Gis_polygon::Gis_polygon ( bool  isbgadapter = true)
inlineexplicit

◆ Gis_polygon() [3/3]

Gis_polygon::Gis_polygon ( const self r)

Copy constructor.

Coordinate type, closed-ness and direction will never change.

Parameters
ranother polygon of same coordinate type, ring closed-ness and ring direction.

◆ ~Gis_polygon()

Gis_polygon::~Gis_polygon ( )
override

Member Function Documentation

◆ clear()

void Gis_polygon::clear ( )
inline

Clears outer and inner rings.

◆ donate_data()

void Gis_polygon::donate_data ( )
inlineoverridevirtual

Reimplemented from Geometry.

◆ exterior_ring()

int Gis_polygon::exterior_ring ( String result) const
overridevirtual

Reimplemented from Geometry.

◆ feature_dimension()

uint32 Gis_polygon::feature_dimension ( ) const
inlineoverridevirtual

Reimplemented from Geometry.

◆ get_class_info()

const Geometry::Class_info * Gis_polygon::get_class_info ( ) const
overridevirtual

Reimplemented from Geometry.

◆ get_data_as_wkt()

bool Gis_polygon::get_data_as_wkt ( String txt,
wkb_parser wkb 
) const
overridevirtual

Reimplemented from Geometry.

◆ get_data_size()

uint32 Gis_polygon::get_data_size ( ) const
overridevirtual

Reimplemented from Geometry.

◆ get_mbr()

bool Gis_polygon::get_mbr ( MBR mbr,
wkb_parser wkb 
) const
overridevirtual

Reimplemented from Geometry.

◆ init_from_wkb()

uint Gis_polygon::init_from_wkb ( THD thd,
const char *  wkb,
uint  len,
wkbByteOrder  bo,
String res 
)
overridevirtual

Reimplemented from Geometry.

◆ init_from_wkt()

bool Gis_polygon::init_from_wkt ( Gis_read_stream trs,
String wkb 
)
overridevirtual

Reimplemented from Geometry.

◆ inner_rings()

inner_container_type * Gis_polygon::inner_rings ( ) const
inline

◆ inners()

inner_container_type & Gis_polygon::inners ( ) const
inline

◆ interior_ring_n()

int Gis_polygon::interior_ring_n ( uint32  num,
String result 
) const
overridevirtual

Reimplemented from Geometry.

◆ make_rings()

void Gis_polygon::make_rings ( )
private

Make outer ring and inner rings objects for this polygon if it doesn't have one yet.

Outer ring and inner rings have to have separated memory space, because we can't predict which one will be edited first. So the polygon object doesn't directly have memory, its m_ptr points to the outer ring, its m_inn_rings points to the inner rings, each have its own memory address and length, and Gis_polygon::get_nbytes returns the sum of them.

If the polygon doesn't own memory, then there is only one piece of memory passed into it and used by it, otherwise the two pieces of memory are separately allocated and released.

◆ num_interior_ring()

int Gis_polygon::num_interior_ring ( uint32 n_int_rings) const
overridevirtual

Reimplemented from Geometry.

◆ operator=()

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

Deep assignment from polygon 'o' to this object.

Parameters
rhsthe Gis_polygon instance to duplicate from.

◆ outer()

ring_type & Gis_polygon::outer ( ) const
inline

◆ reverse_coordinates()

bool Gis_polygon::reverse_coordinates ( )
overridevirtual

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

Implements Geometry.

◆ set_inner_rings()

void Gis_polygon::set_inner_rings ( inner_container_type inns)
inline

◆ set_polygon_ring_order()

bool Gis_polygon::set_polygon_ring_order ( )

Set this polygon's outer ring to be CCW and inner rings to be CW.

Returns
on error returns true, on success returns false.

◆ set_ptr()

void Gis_polygon::set_ptr ( void *  ptr,
size_t  len 
)

Set WKB data to this object, the WKB data will be used read only.

Parameters
ptrWKB data pointer.
lenWKB data number of bytes.

◆ to_wkb_unparsed()

void Gis_polygon::to_wkb_unparsed ( )

Make the polygon's data in a single buffer as WKB format.

This polygon must be one for BG use before this call, and after this call it can never be passed into BG functions directly after this call, and it is suitable as a Gis_polygon for MySQL GIS code, because it's exactly the same as a Gis_polygon object returned by Geometry::create_from_wkt/wkb.

◆ validate_coordinate_range()

bool Gis_polygon::validate_coordinate_range ( double  srs_angular_unit,
bool *  long_out_of_range,
bool *  lat_out_of_range,
double *  out_of_range_value 
)
overridevirtual

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.

Implements Geometry.

Member Data Documentation

◆ m_inn_rings

inner_container_type* Gis_polygon::m_inn_rings
private

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