| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
/********************************************************************** |
|
2
|
|
|
|
|
|
|
* |
|
3
|
|
|
|
|
|
|
* GEOS - Geometry Engine Open Source |
|
4
|
|
|
|
|
|
|
* http://geos.osgeo.org |
|
5
|
|
|
|
|
|
|
* |
|
6
|
|
|
|
|
|
|
* Copyright (C) 2006 Refractions Research Inc. |
|
7
|
|
|
|
|
|
|
* |
|
8
|
|
|
|
|
|
|
* This is free software; you can redistribute and/or modify it under |
|
9
|
|
|
|
|
|
|
* the terms of the GNU Lesser General Public Licence as published |
|
10
|
|
|
|
|
|
|
* by the Free Software Foundation. |
|
11
|
|
|
|
|
|
|
* See the COPYING file for more information. |
|
12
|
|
|
|
|
|
|
* |
|
13
|
|
|
|
|
|
|
********************************************************************** |
|
14
|
|
|
|
|
|
|
* |
|
15
|
|
|
|
|
|
|
* Last port: geom/Envelope.java rev 1.46 (JTS-1.10) |
|
16
|
|
|
|
|
|
|
* |
|
17
|
|
|
|
|
|
|
**********************************************************************/ |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
#ifndef GEOS_GEOM_ENVELOPE_H |
|
20
|
|
|
|
|
|
|
#define GEOS_GEOM_ENVELOPE_H |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
#include |
|
24
|
|
|
|
|
|
|
#include |
|
25
|
|
|
|
|
|
|
#include |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
#include |
|
28
|
|
|
|
|
|
|
#include |
|
29
|
|
|
|
|
|
|
#include // for operator<< |
|
30
|
|
|
|
|
|
|
#include |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
namespace geos { |
|
33
|
|
|
|
|
|
|
namespace geom { // geos::geom |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
class Envelope; |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
/// Output operator |
|
38
|
|
|
|
|
|
|
GEOS_DLL std::ostream& operator<< (std::ostream& os, const Envelope& o); |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
class Coordinate; |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
/** |
|
43
|
|
|
|
|
|
|
* \class Envelope geom.h geos.h |
|
44
|
|
|
|
|
|
|
* |
|
45
|
|
|
|
|
|
|
* \brief |
|
46
|
|
|
|
|
|
|
* An Envelope defines a rectangulare region of the 2D coordinate plane. |
|
47
|
|
|
|
|
|
|
* |
|
48
|
|
|
|
|
|
|
* It is often used to represent the bounding box of a Geometry, |
|
49
|
|
|
|
|
|
|
* e.g. the minimum and maximum x and y values of the Coordinates. |
|
50
|
|
|
|
|
|
|
* |
|
51
|
|
|
|
|
|
|
* Note that Envelopes support infinite or half-infinite regions, by using |
|
52
|
|
|
|
|
|
|
* the values of Double_POSITIVE_INFINITY and |
|
53
|
|
|
|
|
|
|
* Double_NEGATIVE_INFINITY. |
|
54
|
|
|
|
|
|
|
* |
|
55
|
|
|
|
|
|
|
* When Envelope objects are created or initialized, |
|
56
|
|
|
|
|
|
|
* the supplies extent values are automatically sorted into the correct order. |
|
57
|
|
|
|
|
|
|
* |
|
58
|
|
|
|
|
|
|
*/ |
|
59
|
|
|
|
|
|
|
class GEOS_DLL Envelope { |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
public: |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
friend std::ostream& operator<< (std::ostream& os, const Envelope& o); |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
typedef std::unique_ptr Ptr; |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
/** \brief |
|
68
|
|
|
|
|
|
|
* Creates a null Envelope. |
|
69
|
|
|
|
|
|
|
*/ |
|
70
|
|
|
|
|
|
|
Envelope(void); |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
/** \brief |
|
73
|
|
|
|
|
|
|
* Creates an Envelope for a region defined by |
|
74
|
|
|
|
|
|
|
* maximum and minimum values. |
|
75
|
|
|
|
|
|
|
* |
|
76
|
|
|
|
|
|
|
* @param x1 the first x-value |
|
77
|
|
|
|
|
|
|
* @param x2 the second x-value |
|
78
|
|
|
|
|
|
|
* @param y1 the first y-value |
|
79
|
|
|
|
|
|
|
* @param y2 the second y-value |
|
80
|
|
|
|
|
|
|
*/ |
|
81
|
|
|
|
|
|
|
Envelope(double x1, double x2, double y1, double y2); |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
/** \brief |
|
84
|
|
|
|
|
|
|
* Creates an Envelope for a region defined by |
|
85
|
|
|
|
|
|
|
* two Coordinates. |
|
86
|
|
|
|
|
|
|
* |
|
87
|
|
|
|
|
|
|
* @param p1 the first Coordinate |
|
88
|
|
|
|
|
|
|
* @param p2 the second Coordinate |
|
89
|
|
|
|
|
|
|
*/ |
|
90
|
|
|
|
|
|
|
Envelope(const Coordinate& p1, const Coordinate& p2); |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
/** \brief |
|
93
|
|
|
|
|
|
|
* Creates an Envelope for a region defined by a single Coordinate. |
|
94
|
|
|
|
|
|
|
* |
|
95
|
|
|
|
|
|
|
* @param p the Coordinate |
|
96
|
|
|
|
|
|
|
*/ |
|
97
|
|
|
|
|
|
|
Envelope(const Coordinate& p); |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
/// Copy constructor |
|
100
|
|
|
|
|
|
|
Envelope(const Envelope &env); |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
/// Assignment operator |
|
103
|
|
|
|
|
|
|
Envelope& operator=(const Envelope& e); |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
/** \brief |
|
106
|
|
|
|
|
|
|
* Create an Envelope from an Envelope |
|
107
|
|
|
|
|
|
|
* string representation produced by Envelope.toString() |
|
108
|
|
|
|
|
|
|
*/ |
|
109
|
|
|
|
|
|
|
Envelope(const std::string &str); |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
~Envelope(void); |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
/** \brief |
|
114
|
|
|
|
|
|
|
* Test the point q to see whether it intersects the |
|
115
|
|
|
|
|
|
|
* Envelope defined by p1-p2 |
|
116
|
|
|
|
|
|
|
* |
|
117
|
|
|
|
|
|
|
* @param p1 one extremal point of the envelope |
|
118
|
|
|
|
|
|
|
* @param p2 another extremal point of the envelope |
|
119
|
|
|
|
|
|
|
* @param q the point to test for intersection |
|
120
|
|
|
|
|
|
|
* @return true if q intersects the envelope p1-p2 |
|
121
|
|
|
|
|
|
|
*/ |
|
122
|
|
|
|
|
|
|
static bool intersects(const Coordinate& p1, const Coordinate& p2, |
|
123
|
|
|
|
|
|
|
const Coordinate& q); |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
/** \brief |
|
126
|
|
|
|
|
|
|
* Test the envelope defined by p1-p2 for intersection |
|
127
|
|
|
|
|
|
|
* with the envelope defined by q1-q2 |
|
128
|
|
|
|
|
|
|
* |
|
129
|
|
|
|
|
|
|
* @param p1 one extremal point of the envelope P |
|
130
|
|
|
|
|
|
|
* @param p2 another extremal point of the envelope P |
|
131
|
|
|
|
|
|
|
* @param q1 one extremal point of the envelope Q |
|
132
|
|
|
|
|
|
|
* @param q2 another extremal point of the envelope Q |
|
133
|
|
|
|
|
|
|
* |
|
134
|
|
|
|
|
|
|
* @return true if Q intersects P |
|
135
|
|
|
|
|
|
|
*/ |
|
136
|
|
|
|
|
|
|
static bool intersects(const Coordinate& p1, const Coordinate& p2, |
|
137
|
|
|
|
|
|
|
const Coordinate& q1, const Coordinate& q2); |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
/** \brief |
|
140
|
|
|
|
|
|
|
* Initialize to a null Envelope. |
|
141
|
|
|
|
|
|
|
*/ |
|
142
|
|
|
|
|
|
|
void init(void); |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
/** \brief |
|
145
|
|
|
|
|
|
|
* Initialize an Envelope for a region defined by |
|
146
|
|
|
|
|
|
|
* maximum and minimum values. |
|
147
|
|
|
|
|
|
|
* |
|
148
|
|
|
|
|
|
|
* @param x1 the first x-value |
|
149
|
|
|
|
|
|
|
* @param x2 the second x-value |
|
150
|
|
|
|
|
|
|
* @param y1 the first y-value |
|
151
|
|
|
|
|
|
|
* @param y2 the second y-value |
|
152
|
|
|
|
|
|
|
*/ |
|
153
|
|
|
|
|
|
|
void init(double x1, double x2, double y1, double y2); |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
/** \brief |
|
156
|
|
|
|
|
|
|
* Initialize an Envelope to a region defined |
|
157
|
|
|
|
|
|
|
* by two Coordinates. |
|
158
|
|
|
|
|
|
|
* |
|
159
|
|
|
|
|
|
|
* @param p1 the first Coordinate |
|
160
|
|
|
|
|
|
|
* @param p2 the second Coordinate |
|
161
|
|
|
|
|
|
|
*/ |
|
162
|
|
|
|
|
|
|
void init(const Coordinate& p1, const Coordinate& p2); |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
/** \brief |
|
165
|
|
|
|
|
|
|
* Initialize an Envelope to a region defined |
|
166
|
|
|
|
|
|
|
* by a single Coordinate. |
|
167
|
|
|
|
|
|
|
* |
|
168
|
|
|
|
|
|
|
* @param p the Coordinate |
|
169
|
|
|
|
|
|
|
*/ |
|
170
|
|
|
|
|
|
|
void init(const Coordinate& p); |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
// use assignment operator instead |
|
173
|
|
|
|
|
|
|
//void init(Envelope env); |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
/** \brief |
|
176
|
|
|
|
|
|
|
* Makes this Envelope a "null" envelope, |
|
177
|
|
|
|
|
|
|
* that is, the envelope of the empty geometry. |
|
178
|
|
|
|
|
|
|
*/ |
|
179
|
|
|
|
|
|
|
void setToNull(void); |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
/** \brief |
|
182
|
|
|
|
|
|
|
* Returns true if this Envelope |
|
183
|
|
|
|
|
|
|
* is a "null" envelope. |
|
184
|
|
|
|
|
|
|
* |
|
185
|
|
|
|
|
|
|
* @return true if this Envelope |
|
186
|
|
|
|
|
|
|
* is uninitialized or is the envelope of the |
|
187
|
|
|
|
|
|
|
* empty geometry. |
|
188
|
|
|
|
|
|
|
*/ |
|
189
|
|
|
|
|
|
|
bool isNull(void) const; |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
/** \brief |
|
192
|
|
|
|
|
|
|
* Returns the difference between the maximum and minimum x values. |
|
193
|
|
|
|
|
|
|
* |
|
194
|
|
|
|
|
|
|
* @return max x - min x, or 0 if this is a null Envelope |
|
195
|
|
|
|
|
|
|
*/ |
|
196
|
|
|
|
|
|
|
double getWidth(void) const; |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
/** \brief |
|
199
|
|
|
|
|
|
|
* Returns the difference between the maximum and minimum y values. |
|
200
|
|
|
|
|
|
|
* |
|
201
|
|
|
|
|
|
|
* @return max y - min y, or 0 if this is a null Envelope |
|
202
|
|
|
|
|
|
|
*/ |
|
203
|
|
|
|
|
|
|
double getHeight(void) const; |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
/** |
|
206
|
|
|
|
|
|
|
* Gets the area of this envelope. |
|
207
|
|
|
|
|
|
|
* |
|
208
|
|
|
|
|
|
|
* @return the area of the envelope |
|
209
|
|
|
|
|
|
|
* @return 0.0 if the envelope is null |
|
210
|
|
|
|
|
|
|
*/ |
|
211
|
2
|
|
|
|
|
|
double getArea() const |
|
212
|
|
|
|
|
|
|
{ |
|
213
|
2
|
|
|
|
|
|
return getWidth() * getHeight(); |
|
214
|
|
|
|
|
|
|
} |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
/** |
|
217
|
|
|
|
|
|
|
* Returns the Envelope maximum y-value. min y > max y |
|
218
|
|
|
|
|
|
|
* indicates that this is a null Envelope. |
|
219
|
|
|
|
|
|
|
*/ |
|
220
|
|
|
|
|
|
|
double getMaxY() const; |
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
/** |
|
223
|
|
|
|
|
|
|
* Returns the Envelope maximum x-value. min x > max x |
|
224
|
|
|
|
|
|
|
* indicates that this is a null Envelope. |
|
225
|
|
|
|
|
|
|
*/ |
|
226
|
|
|
|
|
|
|
double getMaxX() const; |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
/** |
|
229
|
|
|
|
|
|
|
* Returns the Envelope minimum y-value. min y > max y |
|
230
|
|
|
|
|
|
|
* indicates that this is a null Envelope. |
|
231
|
|
|
|
|
|
|
*/ |
|
232
|
|
|
|
|
|
|
double getMinY() const; |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
/** |
|
235
|
|
|
|
|
|
|
* Returns the Envelope minimum x-value. min x > max x |
|
236
|
|
|
|
|
|
|
* indicates that this is a null Envelope. |
|
237
|
|
|
|
|
|
|
*/ |
|
238
|
|
|
|
|
|
|
double getMinX() const; |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
/** |
|
241
|
|
|
|
|
|
|
* Computes the coordinate of the centre of this envelope |
|
242
|
|
|
|
|
|
|
* (as long as it is non-null) |
|
243
|
|
|
|
|
|
|
* |
|
244
|
|
|
|
|
|
|
* @param centre The coordinate to write results into |
|
245
|
|
|
|
|
|
|
* @return NULL is the center could not be found |
|
246
|
|
|
|
|
|
|
* (null envelope). |
|
247
|
|
|
|
|
|
|
*/ |
|
248
|
|
|
|
|
|
|
bool centre(Coordinate& centre) const; |
|
249
|
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
/** |
|
251
|
|
|
|
|
|
|
* Computes the intersection of two {@link Envelopes} |
|
252
|
|
|
|
|
|
|
* |
|
253
|
|
|
|
|
|
|
* @param env the envelope to intersect with |
|
254
|
|
|
|
|
|
|
* @param result the envelope representing the intersection of |
|
255
|
|
|
|
|
|
|
* the envelopes (this will be the null envelope |
|
256
|
|
|
|
|
|
|
* if either argument is null, or they do not intersect) |
|
257
|
|
|
|
|
|
|
* @return false if not intersection is found |
|
258
|
|
|
|
|
|
|
*/ |
|
259
|
|
|
|
|
|
|
bool intersection(const Envelope& env, Envelope& result) const; |
|
260
|
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
/** \brief |
|
262
|
|
|
|
|
|
|
* Translates this envelope by given amounts in the X and Y direction. |
|
263
|
|
|
|
|
|
|
* |
|
264
|
|
|
|
|
|
|
* @param transX the amount to translate along the X axis |
|
265
|
|
|
|
|
|
|
* @param transY the amount to translate along the Y axis |
|
266
|
|
|
|
|
|
|
*/ |
|
267
|
|
|
|
|
|
|
void translate(double transX, double transY); |
|
268
|
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
/** \brief |
|
270
|
|
|
|
|
|
|
* Expands this envelope by a given distance in all directions. |
|
271
|
|
|
|
|
|
|
* Both positive and negative distances are supported. |
|
272
|
|
|
|
|
|
|
* |
|
273
|
|
|
|
|
|
|
* @param deltaX the distance to expand the envelope along |
|
274
|
|
|
|
|
|
|
* the X axis |
|
275
|
|
|
|
|
|
|
* @param deltaY the distance to expand the envelope along |
|
276
|
|
|
|
|
|
|
* the Y axis |
|
277
|
|
|
|
|
|
|
*/ |
|
278
|
|
|
|
|
|
|
void expandBy(double deltaX, double deltaY); |
|
279
|
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
/** \brief |
|
281
|
|
|
|
|
|
|
* Expands this envelope by a given distance in all directions. |
|
282
|
|
|
|
|
|
|
* Both positive and negative distances are supported. |
|
283
|
|
|
|
|
|
|
* |
|
284
|
|
|
|
|
|
|
* @param distance the distance to expand the envelope |
|
285
|
|
|
|
|
|
|
* @return this envelope |
|
286
|
|
|
|
|
|
|
*/ |
|
287
|
|
|
|
|
|
|
void expandBy(double distance) { expandBy(distance, distance); } |
|
288
|
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
/** \brief |
|
291
|
|
|
|
|
|
|
* Enlarges the boundary of the Envelope so that it contains |
|
292
|
|
|
|
|
|
|
* p. Does nothing if p is already on or within the boundaries. |
|
293
|
|
|
|
|
|
|
* |
|
294
|
|
|
|
|
|
|
* @param p the Coordinate to include |
|
295
|
|
|
|
|
|
|
*/ |
|
296
|
|
|
|
|
|
|
void expandToInclude(const Coordinate& p); |
|
297
|
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
/** \brief |
|
299
|
|
|
|
|
|
|
* Enlarges the boundary of the Envelope so that it contains |
|
300
|
|
|
|
|
|
|
* (x,y). Does nothing if (x,y) is already on or within the boundaries. |
|
301
|
|
|
|
|
|
|
* |
|
302
|
|
|
|
|
|
|
* @param x the value to lower the minimum x |
|
303
|
|
|
|
|
|
|
* to or to raise the maximum x to |
|
304
|
|
|
|
|
|
|
* @param y the value to lower the minimum y |
|
305
|
|
|
|
|
|
|
* to or to raise the maximum y to |
|
306
|
|
|
|
|
|
|
*/ |
|
307
|
|
|
|
|
|
|
void expandToInclude(double x, double y); |
|
308
|
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
/** \brief |
|
310
|
|
|
|
|
|
|
* Enlarges the boundary of the Envelope so that it contains |
|
311
|
|
|
|
|
|
|
* other. Does nothing if other is wholly on or |
|
312
|
|
|
|
|
|
|
* within the boundaries. |
|
313
|
|
|
|
|
|
|
* |
|
314
|
|
|
|
|
|
|
* @param other the Envelope to merge with |
|
315
|
|
|
|
|
|
|
*/ |
|
316
|
|
|
|
|
|
|
void expandToInclude(const Envelope* other); |
|
317
|
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
/** \brief |
|
319
|
|
|
|
|
|
|
* Tests if the Envelope other lies wholely |
|
320
|
|
|
|
|
|
|
* inside this Envelope (inclusive of the boundary). |
|
321
|
|
|
|
|
|
|
* |
|
322
|
|
|
|
|
|
|
* Note that this is not the same definition as the SFS |
|
323
|
|
|
|
|
|
|
* contains, which would exclude the envelope boundary. |
|
324
|
|
|
|
|
|
|
* |
|
325
|
|
|
|
|
|
|
* @param other the Envelope to check |
|
326
|
|
|
|
|
|
|
* @return true if other is contained in this |
|
327
|
|
|
|
|
|
|
* Envelope |
|
328
|
|
|
|
|
|
|
* |
|
329
|
|
|
|
|
|
|
* @see covers(Envelope) |
|
330
|
|
|
|
|
|
|
*/ |
|
331
|
3
|
|
|
|
|
|
bool contains(const Envelope& other) const { |
|
332
|
3
|
|
|
|
|
|
return covers(other); |
|
333
|
|
|
|
|
|
|
} |
|
334
|
|
|
|
|
|
|
|
|
335
|
3
|
|
|
|
|
|
bool contains(const Envelope* other) const { |
|
336
|
3
|
|
|
|
|
|
return contains(*other); |
|
337
|
|
|
|
|
|
|
} |
|
338
|
|
|
|
|
|
|
|
|
339
|
|
|
|
|
|
|
/** \brief |
|
340
|
|
|
|
|
|
|
* Returns true if the given point lies in |
|
341
|
|
|
|
|
|
|
* or on the envelope. |
|
342
|
|
|
|
|
|
|
* |
|
343
|
|
|
|
|
|
|
* @param p the point which this Envelope is |
|
344
|
|
|
|
|
|
|
* being checked for containing |
|
345
|
|
|
|
|
|
|
* @return true if the point lies in the interior or |
|
346
|
|
|
|
|
|
|
* on the boundary of this Envelope. |
|
347
|
|
|
|
|
|
|
*/ |
|
348
|
2
|
|
|
|
|
|
bool contains(const Coordinate& p) const { |
|
349
|
2
|
|
|
|
|
|
return covers(p.x, p.y); |
|
350
|
|
|
|
|
|
|
} |
|
351
|
|
|
|
|
|
|
|
|
352
|
|
|
|
|
|
|
/** \brief |
|
353
|
|
|
|
|
|
|
* Returns true if the given point lies in |
|
354
|
|
|
|
|
|
|
* or on the envelope. |
|
355
|
|
|
|
|
|
|
* |
|
356
|
|
|
|
|
|
|
* @param x the x-coordinate of the point which this |
|
357
|
|
|
|
|
|
|
* Envelope is |
|
358
|
|
|
|
|
|
|
* being checked for containing |
|
359
|
|
|
|
|
|
|
* |
|
360
|
|
|
|
|
|
|
* @param y the y-coordinate of the point which this |
|
361
|
|
|
|
|
|
|
* Envelope is being checked for containing |
|
362
|
|
|
|
|
|
|
* |
|
363
|
|
|
|
|
|
|
* @return true if (x, y) lies in |
|
364
|
|
|
|
|
|
|
* the interior or on the boundary of this |
|
365
|
|
|
|
|
|
|
* Envelope. |
|
366
|
|
|
|
|
|
|
*/ |
|
367
|
2
|
|
|
|
|
|
bool contains(double x, double y) const { |
|
368
|
2
|
|
|
|
|
|
return covers(x, y); |
|
369
|
|
|
|
|
|
|
} |
|
370
|
|
|
|
|
|
|
|
|
371
|
|
|
|
|
|
|
/** |
|
372
|
|
|
|
|
|
|
* Check if the point p |
|
373
|
|
|
|
|
|
|
* intersects (lies inside) the region of this Envelope. |
|
374
|
|
|
|
|
|
|
* |
|
375
|
|
|
|
|
|
|
* @param p the Coordinate to be tested |
|
376
|
|
|
|
|
|
|
* @return true if the point intersects this Envelope |
|
377
|
|
|
|
|
|
|
*/ |
|
378
|
|
|
|
|
|
|
bool intersects(const Coordinate& p) const; |
|
379
|
|
|
|
|
|
|
|
|
380
|
|
|
|
|
|
|
/** |
|
381
|
|
|
|
|
|
|
* Check if the point (x, y) |
|
382
|
|
|
|
|
|
|
* intersects (lies inside) the region of this Envelope. |
|
383
|
|
|
|
|
|
|
* |
|
384
|
|
|
|
|
|
|
* @param x the x-ordinate of the point |
|
385
|
|
|
|
|
|
|
* @param y the y-ordinate of the point |
|
386
|
|
|
|
|
|
|
* @return true if the point intersects this Envelope |
|
387
|
|
|
|
|
|
|
*/ |
|
388
|
|
|
|
|
|
|
bool intersects(double x, double y) const; |
|
389
|
|
|
|
|
|
|
|
|
390
|
|
|
|
|
|
|
/** |
|
391
|
|
|
|
|
|
|
* Check if the region defined by other Envelope |
|
392
|
|
|
|
|
|
|
* intersects (intersects) the region of this Envelope. |
|
393
|
|
|
|
|
|
|
* |
|
394
|
|
|
|
|
|
|
* @param other the Envelope which this Envelope is |
|
395
|
|
|
|
|
|
|
* being checked for intersection |
|
396
|
|
|
|
|
|
|
* |
|
397
|
|
|
|
|
|
|
* @return true if the Envelopes intersects |
|
398
|
|
|
|
|
|
|
*/ |
|
399
|
|
|
|
|
|
|
bool intersects(const Envelope* other) const; |
|
400
|
|
|
|
|
|
|
|
|
401
|
|
|
|
|
|
|
bool intersects(const Envelope& other) const; |
|
402
|
|
|
|
|
|
|
|
|
403
|
|
|
|
|
|
|
/** |
|
404
|
|
|
|
|
|
|
* Tests if the given point lies in or on the envelope. |
|
405
|
|
|
|
|
|
|
* |
|
406
|
|
|
|
|
|
|
*@param x the x-coordinate of the point which this Envelope is |
|
407
|
|
|
|
|
|
|
* being checked for containing |
|
408
|
|
|
|
|
|
|
*@param y the y-coordinate of the point which this Envelope is |
|
409
|
|
|
|
|
|
|
* being checked for containing |
|
410
|
|
|
|
|
|
|
*@return true if (x, y) lies in the interior or |
|
411
|
|
|
|
|
|
|
* on the boundary of this Envelope. |
|
412
|
|
|
|
|
|
|
*/ |
|
413
|
|
|
|
|
|
|
bool covers(double x, double y) const; |
|
414
|
|
|
|
|
|
|
|
|
415
|
|
|
|
|
|
|
/** |
|
416
|
|
|
|
|
|
|
* Tests if the given point lies in or on the envelope. |
|
417
|
|
|
|
|
|
|
* |
|
418
|
|
|
|
|
|
|
*@param p the point which this Envelope is |
|
419
|
|
|
|
|
|
|
* being checked for containing |
|
420
|
|
|
|
|
|
|
*@return true if the point lies in the interior or |
|
421
|
|
|
|
|
|
|
* on the boundary of this Envelope. |
|
422
|
|
|
|
|
|
|
*/ |
|
423
|
|
|
|
|
|
|
bool covers(const Coordinate *p) const; |
|
424
|
|
|
|
|
|
|
|
|
425
|
|
|
|
|
|
|
/** |
|
426
|
|
|
|
|
|
|
* Tests if the Envelope other lies wholely inside |
|
427
|
|
|
|
|
|
|
* this Envelope (inclusive of the boundary). |
|
428
|
|
|
|
|
|
|
* |
|
429
|
|
|
|
|
|
|
* @param other the Envelope to check |
|
430
|
|
|
|
|
|
|
* @return true if this Envelope covers the |
|
431
|
|
|
|
|
|
|
* other |
|
432
|
|
|
|
|
|
|
*/ |
|
433
|
|
|
|
|
|
|
bool covers(const Envelope& other) const; |
|
434
|
|
|
|
|
|
|
|
|
435
|
3
|
|
|
|
|
|
bool covers(const Envelope* other) const { |
|
436
|
3
|
|
|
|
|
|
return covers(*other); |
|
437
|
|
|
|
|
|
|
} |
|
438
|
|
|
|
|
|
|
|
|
439
|
|
|
|
|
|
|
|
|
440
|
|
|
|
|
|
|
/** \brief |
|
441
|
|
|
|
|
|
|
* Returns true if the Envelope other |
|
442
|
|
|
|
|
|
|
* spatially equals this Envelope. |
|
443
|
|
|
|
|
|
|
* |
|
444
|
|
|
|
|
|
|
* @param other the Envelope which this |
|
445
|
|
|
|
|
|
|
* Envelope is being checked for equality |
|
446
|
|
|
|
|
|
|
* |
|
447
|
|
|
|
|
|
|
* @return true if this and other |
|
448
|
|
|
|
|
|
|
* Envelope objs are spatially equal |
|
449
|
|
|
|
|
|
|
*/ |
|
450
|
|
|
|
|
|
|
bool equals(const Envelope* other) const; |
|
451
|
|
|
|
|
|
|
|
|
452
|
|
|
|
|
|
|
/** \brief |
|
453
|
|
|
|
|
|
|
* Returns a string of the form |
|
454
|
|
|
|
|
|
|
* Env[minx:maxx,miny:maxy] . |
|
455
|
|
|
|
|
|
|
* |
|
456
|
|
|
|
|
|
|
* @return a string of the form |
|
457
|
|
|
|
|
|
|
* Env[minx:maxx,miny:maxy] |
|
458
|
|
|
|
|
|
|
*/ |
|
459
|
|
|
|
|
|
|
std::string toString(void) const; |
|
460
|
|
|
|
|
|
|
|
|
461
|
|
|
|
|
|
|
/** \brief |
|
462
|
|
|
|
|
|
|
* Computes the distance between this and another |
|
463
|
|
|
|
|
|
|
* Envelope. |
|
464
|
|
|
|
|
|
|
* |
|
465
|
|
|
|
|
|
|
* The distance between overlapping Envelopes is 0. Otherwise, the |
|
466
|
|
|
|
|
|
|
* distance is the Euclidean distance between the closest points. |
|
467
|
|
|
|
|
|
|
*/ |
|
468
|
|
|
|
|
|
|
double distance(const Envelope* env) const; |
|
469
|
|
|
|
|
|
|
|
|
470
|
|
|
|
|
|
|
int hashCode() const; |
|
471
|
|
|
|
|
|
|
|
|
472
|
|
|
|
|
|
|
private: |
|
473
|
|
|
|
|
|
|
|
|
474
|
|
|
|
|
|
|
/** \brief |
|
475
|
|
|
|
|
|
|
* Splits a string into parts based on the supplied delimiters. |
|
476
|
|
|
|
|
|
|
* |
|
477
|
|
|
|
|
|
|
* This is a generic function that really belongs in a utility |
|
478
|
|
|
|
|
|
|
* file somewhere |
|
479
|
|
|
|
|
|
|
*/ |
|
480
|
|
|
|
|
|
|
std::vector split(const std::string &str, |
|
481
|
|
|
|
|
|
|
const std::string &delimiters = " "); |
|
482
|
|
|
|
|
|
|
|
|
483
|
|
|
|
|
|
|
static double distance(double x0,double y0,double x1,double y1); |
|
484
|
|
|
|
|
|
|
|
|
485
|
|
|
|
|
|
|
/// the minimum x-coordinate |
|
486
|
|
|
|
|
|
|
double minx; |
|
487
|
|
|
|
|
|
|
|
|
488
|
|
|
|
|
|
|
/// the maximum x-coordinate |
|
489
|
|
|
|
|
|
|
double maxx; |
|
490
|
|
|
|
|
|
|
|
|
491
|
|
|
|
|
|
|
/// the minimum y-coordinate |
|
492
|
|
|
|
|
|
|
double miny; |
|
493
|
|
|
|
|
|
|
|
|
494
|
|
|
|
|
|
|
/// the maximum y-coordinate |
|
495
|
|
|
|
|
|
|
double maxy; |
|
496
|
|
|
|
|
|
|
}; |
|
497
|
|
|
|
|
|
|
|
|
498
|
|
|
|
|
|
|
/// Checks if two Envelopes are equal (2D only check) |
|
499
|
|
|
|
|
|
|
GEOS_DLL bool operator==(const Envelope& a, const Envelope& b); |
|
500
|
|
|
|
|
|
|
|
|
501
|
|
|
|
|
|
|
} // namespace geos::geom |
|
502
|
|
|
|
|
|
|
} // namespace geos |
|
503
|
|
|
|
|
|
|
|
|
504
|
|
|
|
|
|
|
#ifdef GEOS_INLINE |
|
505
|
|
|
|
|
|
|
# include "geos/geom/Envelope.inl" |
|
506
|
|
|
|
|
|
|
#endif |
|
507
|
|
|
|
|
|
|
|
|
508
|
|
|
|
|
|
|
#endif // ndef GEOS_GEOM_ENVELOPE_H |