MySQL  8.0.28
Source Code Documentation
rtree_support.cc File Reference

This file implements the set of functions that storage engines can call to do geometrical operations. More...

#include "sql/gis/rtree_support.h"
#include <algorithm>
#include <cmath>
#include <limits>
#include <boost/geometry.hpp>
#include "my_byteorder.h"
#include "my_inttypes.h"
#include "sql/current_thd.h"
#include "sql/dd/cache/dictionary_client.h"
#include "sql/dd/types/spatial_reference_system.h"
#include "sql/gis/box.h"
#include "sql/gis/box_traits.h"
#include "sql/gis/covered_by_functor.h"
#include "sql/gis/disjoint_functor.h"
#include "sql/gis/equals_functor.h"
#include "sql/gis/geometries.h"
#include "sql/gis/geometries_cs.h"
#include "sql/gis/intersects_functor.h"
#include "sql/gis/mbr_utils.h"
#include "sql/gis/srid.h"
#include "sql/gis/wkb.h"
#include "sql/spatial.h"
#include "sql/sql_class.h"
#include "sql/srs_fetcher.h"
#include "template_utils.h"

Functions

dd::Spatial_reference_systemfetch_srs (gis::srid_t srid)
 Fetches a copy of the dictionary entry for a spatial reference system. More...
 
bool mbr_contain_cmp (const dd::Spatial_reference_system *srs, rtr_mbr_t *a, rtr_mbr_t *b)
 Checks if one MBR covers another MBR. More...
 
bool mbr_equal_cmp (const dd::Spatial_reference_system *srs, rtr_mbr_t *a, rtr_mbr_t *b)
 Checks if two MBRs are equal. More...
 
bool mbr_intersect_cmp (const dd::Spatial_reference_system *srs, rtr_mbr_t *a, rtr_mbr_t *b)
 Checks if two MBRs intersect each other. More...
 
bool mbr_disjoint_cmp (const dd::Spatial_reference_system *srs, rtr_mbr_t *a, rtr_mbr_t *b)
 Checks if two MBRs are disjoint. More...
 
bool mbr_within_cmp (const dd::Spatial_reference_system *srs, rtr_mbr_t *a, rtr_mbr_t *b)
 Checks if one MBR is covered by another MBR. More...
 
void mbr_join (const dd::Spatial_reference_system *srs, double *a, const double *b, int n_dim[[maybe_unused]])
 
double mbr_join_area (const dd::Spatial_reference_system *srs, const double *a, const double *b, int n_dim[[maybe_unused]])
 
double compute_area (const dd::Spatial_reference_system *srs, const double *a, int n_dim[[maybe_unused]])
 
int get_mbr_from_store (const dd::Spatial_reference_system *srs, const uchar *store, uint size, uint n_dims[[maybe_unused]], double *mbr, gis::srid_t *srid)
 
double rtree_area_increase (const dd::Spatial_reference_system *srs, const uchar *mbr_a, const uchar *mbr_b, int mbr_len[[maybe_unused]], double *ab_area)
 
double rtree_area_overlapping (const dd::Spatial_reference_system *srs, const uchar *mbr_a, const uchar *mbr_b, int mbr_len[[maybe_unused]])
 

Detailed Description

This file implements the set of functions that storage engines can call to do geometrical operations.

Function Documentation

◆ compute_area()

double compute_area ( const dd::Spatial_reference_system srs,
const double *  a,
int n_dim]  [[maybe_unused] 
)

◆ fetch_srs()

Fetches a copy of the dictionary entry for a spatial reference system.

Spatial reference dictionary cache objects have a limited lifetime, typically until the end of a transaction. This function returns a clone of the dictionary object so that it is valid also after the transaction has ended. This is necessary since InnoDB may do index operations after the transaction has ended.

Parameters
[in]sridThe spatial reference system ID to look up.
Returns
The spatial reference system dictionary entry, or nullptr.

◆ get_mbr_from_store()

int get_mbr_from_store ( const dd::Spatial_reference_system srs,
const uchar store,
uint  size,
uint n_dims]  [[maybe_unused],
double *  mbr,
gis::srid_t srid 
)

◆ mbr_contain_cmp()

bool mbr_contain_cmp ( const dd::Spatial_reference_system srs,
rtr_mbr_t a,
rtr_mbr_t b 
)

Checks if one MBR covers another MBR.

Warning
Despite the name, this function computes the covers relation, not contains.

For both MBRs, the coordinates of the MBR's minimum corners must be smaller than or equal to the corresponding coordinates of the maximum corner.

Parameters
[in]srsSpatial reference system.
[in]aThe first MBR.
[in]bThe second MBR.
Return values
trueMBR a contains MBR b.
falseMBR a doesn't contain MBR b.

◆ mbr_disjoint_cmp()

bool mbr_disjoint_cmp ( const dd::Spatial_reference_system srs,
rtr_mbr_t a,
rtr_mbr_t b 
)

Checks if two MBRs are disjoint.

For both MBRs, the coordinates of the MBR's minimum corners must be smaller than or equal to the corresponding coordinates of the maximum corner.

Return values
trueThe MBRs are disjoint.
falseThe MBRs intersect each other.

◆ mbr_equal_cmp()

bool mbr_equal_cmp ( const dd::Spatial_reference_system srs,
rtr_mbr_t a,
rtr_mbr_t b 
)

Checks if two MBRs are equal.

For both MBRs, the coordinates of the MBR's minimum corners must be smaller than or equal to the corresponding coordinates of the maximum corner.

Parameters
[in]srsSpatial reference system.
[in]aThe first MBR.
[in]bThe second MBR.
Return values
trueThe two MBRs are equal.
falseThe two MBRs aren't equal.

◆ mbr_intersect_cmp()

bool mbr_intersect_cmp ( const dd::Spatial_reference_system srs,
rtr_mbr_t a,
rtr_mbr_t b 
)

Checks if two MBRs intersect each other.

Parameters
[in]srsSpatial reference system.
[in]aThe first MBR.
[in]bThe second MBR.

For both MBRs, the coordinates of the MBR's minimum corners must be smaller than or equal to the corresponding coordinates of the maximum corner.

Return values
trueThe MBRs intersect each other.
falseThe MBRs are disjoint.

◆ mbr_join()

void mbr_join ( const dd::Spatial_reference_system srs,
double *  a,
const double *  b,
int n_dim]  [[maybe_unused] 
)

◆ mbr_join_area()

double mbr_join_area ( const dd::Spatial_reference_system srs,
const double *  a,
const double *  b,
int n_dim]  [[maybe_unused] 
)

◆ mbr_within_cmp()

bool mbr_within_cmp ( const dd::Spatial_reference_system srs,
rtr_mbr_t a,
rtr_mbr_t b 
)

Checks if one MBR is covered by another MBR.

Warning
Despite the name, this function computes the covered_by relation, not within.
Note
If the minimum corner coordinates are larger than the corresponding coordinates of the maximum corner, and if not all a and b coordinates are the same, the function returns the inverse result, i.e., return true if a is not covered by b.
Parameters
[in]srsSpatial reference system.
[in]aThe first MBR.
[in]bThe second MBR.
Return values
trueMBR a is within MBR b.
falseMBR a isn't within MBR b.

◆ rtree_area_increase()

double rtree_area_increase ( const dd::Spatial_reference_system srs,
const uchar mbr_a,
const uchar mbr_b,
int mbr_len]  [[maybe_unused],
double *  ab_area 
)

◆ rtree_area_overlapping()

double rtree_area_overlapping ( const dd::Spatial_reference_system srs,
const uchar mbr_a,
const uchar mbr_b,
int mbr_len]  [[maybe_unused] 
)