| 1 |
/***************************************************************************** |
| 2 |
Copyright (c) 2014, 2026, Oracle and/or its affiliates. |
| 3 |
|
| 4 |
This program is free software; you can redistribute it and/or modify |
| 5 |
it under the terms of the GNU General Public License, version 2.0, |
| 6 |
as published by the Free Software Foundation. |
| 7 |
|
| 8 |
This program is designed to work with certain software (including |
| 9 |
but not limited to OpenSSL) that is licensed under separate terms, |
| 10 |
as designated in a particular file or component or in included license |
| 11 |
documentation. The authors of MySQL hereby grant you an additional |
| 12 |
permission to link the program and your derivative works with the |
| 13 |
separately licensed software that they have either included with |
| 14 |
the program or referenced in the documentation. |
| 15 |
|
| 16 |
This program is distributed in the hope that it will be useful, |
| 17 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 |
GNU General Public License, version 2.0, for more details. |
| 20 |
|
| 21 |
You should have received a copy of the GNU General Public License |
| 22 |
along with this program; if not, write to the Free Software |
| 23 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 24 |
*****************************************************************************/ |
| 25 |
|
| 26 |
/** @file gis0geo.h |
| 27 |
The r-tree define from MyISAM |
| 28 |
*******************************************************/ |
| 29 |
|
| 30 |
#ifndef _gis0geo_h |
| 31 |
#define _gis0geo_h |
| 32 |
|
| 33 |
#include "page0types.h" |
| 34 |
#include "sql/gis/rtree_support.h" |
| 35 |
|
| 36 |
constexpr uint32_t SPLEN = 8; |
| 37 |
|
| 38 |
namespace dd { |
| 39 |
class Spatial_reference_system; |
| 40 |
} |
| 41 |
|
| 42 |
/* Rtree split node structure. */ |
| 43 |
struct rtr_split_node_t { |
| 44 |
double square; /* square of the mbr.*/ |
| 45 |
int n_node; /* which group in.*/ |
| 46 |
uchar *key; /* key. */ |
| 47 |
double *coords; /* mbr. */ |
| 48 |
}; |
| 49 |
|
| 50 |
/** Inline function for reserving coords */ |
| 51 |
inline static double *reserve_coords(double **d_buffer, /*!< in/out: buffer. */ |
| 52 |
int n_dim) /*!< in: dimensions. */ |
| 53 |
{ |
| 54 |
double *coords = *d_buffer; |
| 55 |
(*d_buffer) += n_dim * 2; |
| 56 |
return coords; |
| 57 |
} |
| 58 |
|
| 59 |
/** Split rtree nodes. |
| 60 |
Return which group the first rec is in. */ |
| 61 |
int split_rtree_node( |
| 62 |
rtr_split_node_t *node, /*!< in: split nodes.*/ |
| 63 |
int n_entries, /*!< in: entries number.*/ |
| 64 |
int all_size, /*!< in: total key's size.*/ |
| 65 |
int key_size, /*!< in: key's size.*/ |
| 66 |
int min_size, /*!< in: minimal group size.*/ |
| 67 |
int size1, /*!< in: size of group.*/ |
| 68 |
int size2, /*!< in: initial group sizes */ |
| 69 |
double **d_buffer, /*!< in/out: buffer.*/ |
| 70 |
int n_dim, /*!< in: dimensions. */ |
| 71 |
uchar *first_rec, /*!< in: the first rec. */ |
| 72 |
const dd::Spatial_reference_system *srs); /*!< in: SRS of R-tree */ |
| 73 |
|
| 74 |
/** Compares two keys a and b depending on mode |
| 75 |
mode can contain these flags: |
| 76 |
PAGE_CUR_INTERSECT a intersects b |
| 77 |
PAGE_CUR_CONTAIN a contains b |
| 78 |
PAGE_CUR_DISJOINT a disjoint b |
| 79 |
PAGE_CUR_WITHIN a within b |
| 80 |
PAGE_CUR_MBR_EQUAL All coordinates of MBRs are equal |
| 81 |
@param[in] mode compare method |
| 82 |
@param[in] a first key |
| 83 |
@param[in] a_len first key len |
| 84 |
@param[in] b second key |
| 85 |
@param[in] b_len second_key_len |
| 86 |
@param[in] srs Spatial reference system of R-tree |
| 87 |
@retval true if the predicate is true, otherwise false. */ |
| 88 |
bool rtree_key_cmp(page_cur_mode_t mode, const uchar *a, int a_len, |
| 89 |
const uchar *b, int b_len, |
| 90 |
const dd::Spatial_reference_system *srs); |
| 91 |
#endif |