MySQL 8.0.30
Source Code Documentation
buffer_strategies.h
Go to the documentation of this file.
1#ifndef SQL_GIS_BUFFER_STRATEGIES_H_INCLUDED
2#define SQL_GIS_BUFFER_STRATEGIES_H_INCLUDED
3
4// Copyright (c) 2021, 2022, Oracle and/or its affiliates.
5//
6// This program is free software; you can redistribute it and/or modify
7// it under the terms of the GNU General Public License, version 2.0,
8// as published by the Free Software Foundation.
9//
10// This program is also distributed with certain software (including
11// but not limited to OpenSSL) that is licensed under separate terms,
12// as designated in a particular file or component or in included license
13// documentation. The authors of MySQL hereby grant you an additional
14// permission to link the program and your derivative works with the
15// separately licensed software that they have included with MySQL.
16//
17// This program is distributed in the hope that it will be useful,
18// but WITHOUT ANY WARRANTY; without even the implied warranty of
19// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20// GNU General Public License, version 2.0, for more details.
21//
22// You should have received a copy of the GNU General Public License
23// along with this program; if not, write to the Free Software
24// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
26/// @file
27///
28/// This file implements a struct that is used to hold information that
29/// decide how to compute the buffer of a geometry.
30
31#include <cstddef>
32
33namespace gis {
34
35// Used as cases in the switch in Item_func_st_buffer::parse_strategy.
36// Cannot use enum because switching on type uint.
37constexpr uint kEndRound = 1;
38constexpr uint kEndFlat = 2;
39constexpr uint kJoinRound = 3;
40constexpr uint kJoinMiter = 4;
41constexpr uint kPointCircle = 5;
42constexpr uint kPointSquare = 6;
43
45 // See Boost's documentation for information on bg::buffer's strategies.
46
47 std::size_t join_circle_value = 32;
48 std::size_t end_circle_value = 32;
49 std::size_t point_circle_value = 32;
50 double join_miter_value = 5.0;
51 double distance = 0;
52
53 bool join_is_set = false;
54 bool end_is_set = false;
55 bool point_is_set = false;
56
57 /// 8 possible combinations since 'End = round || flat', 'Join = round ||
58 /// miter', and 'Point = circle || square'. Default combo is 0, with
59 /// default values. Combo made by bitwise OR-ing.
60 /// 0 : join_round, end_round, point_circle
61 /// 1 : join_round, end_flat, point_circle
62 /// 2 : join_miter, end_round, point_circle
63 /// 3 : join_miter, end_flat, point_circle
64 /// 4 : join_round, end_round, point_square
65 /// 5 : join_round, end_flat, point_square
66 /// 6 : join_miter, end_round, point_square
67 /// 7 : join_miter, end_flat, point_square
68 int combination = 0;
69
70 bool set_end_round(double value) {
71 if (end_is_set ||
72 value >= static_cast<double>(std::numeric_limits<std::size_t>::max())) {
73 return true;
74 } else {
75 end_is_set = true;
76 end_circle_value = static_cast<std::size_t>(value);
77 return false;
78 }
79 }
80
81 bool set_end_flat() {
82 if (end_is_set) {
83 return true;
84 } else {
85 end_is_set = true;
86 combination |= 1;
87 return false;
88 }
89 }
90
91 bool set_join_round(double value) {
92 if (join_is_set ||
93 value >= static_cast<double>(std::numeric_limits<std::size_t>::max())) {
94 return true;
95 } else {
96 join_is_set = true;
97 join_circle_value = static_cast<std::size_t>(value);
98 return false;
99 }
100 }
101
102 bool set_join_miter(double value) {
103 if (join_is_set) {
104 return true;
105 } else {
106 join_is_set = true;
107 combination |= 2;
108 join_miter_value = value;
109 return false;
110 }
111 }
112
113 bool set_point_circle(double value) {
114 if (point_is_set ||
115 value >= static_cast<double>(std::numeric_limits<std::size_t>::max())) {
116 return true;
117 } else {
118 point_is_set = true;
119 point_circle_value = static_cast<std::size_t>(value);
120 return false;
121 }
122 }
123
125 if (point_is_set) {
126 return true;
127 } else {
128 point_is_set = true;
129 combination |= 4;
130 return false;
131 }
132 }
133};
134
135} // namespace gis
136
137#endif // SQL_GIS_BUFFER_H_INCLUDED
Definition: area.cc:46
constexpr uint kPointSquare
Definition: buffer_strategies.h:42
constexpr uint kJoinRound
Definition: buffer_strategies.h:39
constexpr uint kPointCircle
Definition: buffer_strategies.h:41
constexpr uint kEndFlat
Definition: buffer_strategies.h:38
constexpr uint kJoinMiter
Definition: buffer_strategies.h:40
constexpr uint kEndRound
Definition: buffer_strategies.h:37
Definition: buffer_strategies.h:44
std::size_t end_circle_value
Definition: buffer_strategies.h:48
std::size_t join_circle_value
Definition: buffer_strategies.h:47
bool set_join_miter(double value)
Definition: buffer_strategies.h:102
bool set_point_circle(double value)
Definition: buffer_strategies.h:113
bool point_is_set
Definition: buffer_strategies.h:55
int combination
8 possible combinations since 'End = round || flat', 'Join = round || miter', and 'Point = circle || ...
Definition: buffer_strategies.h:68
bool set_end_flat()
Definition: buffer_strategies.h:81
bool set_point_square()
Definition: buffer_strategies.h:124
bool set_join_round(double value)
Definition: buffer_strategies.h:91
double join_miter_value
Definition: buffer_strategies.h:50
bool join_is_set
Definition: buffer_strategies.h:53
std::size_t point_circle_value
Definition: buffer_strategies.h:49
bool set_end_round(double value)
Definition: buffer_strategies.h:70
double distance
Definition: buffer_strategies.h:51
bool end_is_set
Definition: buffer_strategies.h:54
unsigned int uint
Definition: uca-dump.cc:29