| 1 | /***************************************************************************** |
| 2 | Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. |
| 3 | Copyright (c) 2019, 2020, MariaDB Corporation. |
| 4 | |
| 5 | This program is free software; you can redistribute it and/or modify |
| 6 | it under the terms of the GNU General Public License as published by |
| 7 | the Free Software Foundation; version 2 of the License. |
| 8 | |
| 9 | This program is distributed in the hope that it will be useful, |
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | GNU General Public License for more details. |
| 13 | |
| 14 | You should have received a copy of the GNU General Public License |
| 15 | along with this program; if not, write to the Free Software Foundation, |
| 16 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA |
| 17 | *****************************************************************************/ |
| 18 | |
| 19 | /**************************************************//** |
| 20 | @file gis0geo.h |
| 21 | The r-tree define from MyISAM |
| 22 | *******************************************************/ |
| 23 | |
| 24 | #ifndef _gis0geo_h |
| 25 | #define _gis0geo_hcxx . . $ `storage/innobase/include/gis0geo.h:25:9`! |
| 26 | |
| 27 | #include "my_global.h"cxx . . $ `<file>/include/my_global.h`/ |
| 28 | #include "string.h" |
| 29 | |
| 30 | #define SPTYPEcxx . . $ `storage/innobase/include/gis0geo.h:30:9`! HA_KEYTYPE_DOUBLE |
| 31 | #define SPLENcxx . . $ `storage/innobase/include/gis0geo.h:31:9`! 8 |
| 32 | |
| 33 | /* Since the mbr could be a point or a linestring, in this case, area of |
| 34 | mbr is 0. So, we define this macro for calculating the area increasing |
| 35 | when we need to enlarge the mbr. */ |
| 36 | #define LINE_MBR_WEIGHTScxx . . $ `storage/innobase/include/gis0geo.h:36:9`! 0.001 |
| 37 | |
| 38 | /* Types of "well-known binary representation" (wkb) format. */ |
| 39 | enum wkbTypecxx . . $ wkbType# |
| 40 | { |
| 41 | wkbPointcxx . . $ wkbPoint. = 1, |
| 42 | wkbLineStringcxx . . $ wkbLineString. = 2, |
| 43 | wkbPolygoncxx . . $ wkbPolygon. = 3, |
| 44 | wkbMultiPointcxx . . $ wkbMultiPoint. = 4, |
| 45 | wkbMultiLineStringcxx . . $ wkbMultiLineString. = 5, |
| 46 | wkbMultiPolygoncxx . . $ wkbMultiPolygon. = 6, |
| 47 | wkbGeometryCollectioncxx . . $ wkbGeometryCollection. = 7 |
| 48 | }; |
| 49 | |
| 50 | /* Byte order of "well-known binary representation" (wkb) format. */ |
| 51 | enum wkbByteOrdercxx . . $ wkbByteOrder# |
| 52 | { |
| 53 | wkbXDRcxx . . $ wkbXDR. = 0, /* Big Endian */ |
| 54 | wkbNDRcxx . . $ wkbNDR. = 1 /* Little Endian */ |
| 55 | }; |
| 56 | |
| 57 | /*************************************************************//** |
| 58 | Calculate minimal bounding rectangle (mbr) of the spatial object |
| 59 | stored in "well-known binary representation" (wkb) format. |
| 60 | @return 0 if ok */ |
| 61 | int |
| 62 | rtree_mbr_from_wkbcxx . . $ rtree_mbr_from_wkb(6265091e19e3543f).( |
| 63 | /*===============*/ |
| 64 | const ucharcxx . . $ uchar#* wkb, /*!< in: pointer to wkb. */ |
| 65 | uint size, /*!< in: size of wkb. */ |
| 66 | uint n_dims, /*!< in: dimensions. */ |
| 67 | double* mbr); /*!< in/out: mbr. */ |
| 68 | |
| 69 | /* Rtree split node structure. */ |
| 70 | struct rtr_split_node_tcxx . . $ rtr_split_node_t# |
| 71 | { |
| 72 | double squarecxx . . $ rtr_split_node_t#square.; /* square of the mbr.*/ |
| 73 | uint16_tcxx . . $ uint16_t# n_nodecxx . . $ rtr_split_node_t#n_node.; /* group: 1 or 2, or 0=unassigned */ |
| 74 | uint16_tcxx . . $ uint16_t# key_lencxx . . $ rtr_split_node_t#key_len.; /* key length */ |
| 75 | ucharcxx . . $ uchar#* keycxx . . $ rtr_split_node_t#key.; /* key. */ |
| 76 | double* coordscxx . . $ rtr_split_node_t#coords.; /* mbr. */ |
| 77 | }; |
| 78 | |
| 79 | /*************************************************************//** |
| 80 | Inline function for reserving coords */ |
| 81 | inline |
| 82 | static |
| 83 | double* |
| 84 | reserve_coordscxx . . $ reserve_coords(36ccea358bf7131a).(double **d_buffer, /*!< in/out: buffer. */ |
| 85 | int n_dim) /*!< in: dimensions. */ |
| 86 | /*===========*/ |
| 87 | { |
| 88 | double *coords = *d_buffer; |
| 89 | (*d_buffer) += n_dim * 2; |
| 90 | return coords; |
| 91 | } |
| 92 | |
| 93 | /*************************************************************//** |
| 94 | Split rtree nodes. |
| 95 | Return which group the first rec is in. */ |
| 96 | int |
| 97 | split_rtree_nodecxx . . $ split_rtree_node(c17a5ffdb83ded64).( |
| 98 | /*=============*/ |
| 99 | rtr_split_node_tcxx . . $ rtr_split_node_t#* node, /*!< in: split nodes.*/ |
| 100 | int n_entries, /*!< in: entries number.*/ |
| 101 | int all_size, /*!< in: total key's size.*/ |
| 102 | int key_size, /*!< in: key's size.*/ |
| 103 | int min_size, /*!< in: minimal group size.*/ |
| 104 | int size1, /*!< in: size of group.*/ |
| 105 | int size2, /*!< in: initial group sizes */ |
| 106 | double** d_buffer, /*!< in/out: buffer.*/ |
| 107 | int n_dim, /*!< in: dimensions. */ |
| 108 | ucharcxx . . $ uchar#* first_rec); /*!< in: the first rec. */ |
| 109 | |
| 110 | /** Compare two minimum bounding rectangles. |
| 111 | @param mode comparison operator |
| 112 | MBR_INTERSECT(a,b) a overlaps b |
| 113 | MBR_CONTAIN(a,b) a contains b |
| 114 | MBR_DISJOINT(a,b) a disjoint b |
| 115 | MBR_WITHIN(a,b) a within b |
| 116 | MBR_EQUAL(a,b) All coordinates of MBRs are equal |
| 117 | MBR_DATA(a,b) Data reference is the same |
| 118 | @param b first MBR |
| 119 | @param a second MBR |
| 120 | @retval 0 if the predicate holds |
| 121 | @retval 1 if the precidate does not hold */ |
| 122 | int rtree_key_cmpcxx . . $ rtree_key_cmp(ecd671439de5c384).(page_cur_mode_tcxx . . $ page_cur_mode_t# mode, const void *b, const void *a); |
| 123 | #endif |