-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathbox.h
428 lines (340 loc) · 9.35 KB
/
box.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
#ifndef __PGS_BOX_H__
#define __PGS_BOX_H__
#include "path.h"
/* Box datatype declarations */
/*
* Spherical box structure. The definition of a spherical box
* using two spherical points: south-west and north-east.
*/
typedef struct
{
SPoint sw; /* South-west value of a box */
SPoint ne; /* North-east value of a box */
} SBOX;
/* PGS_RELATIONSHIPS */
/* PGS_BOX_CIRCLE_REL Box and circle */
#define PGS_BOX_CIRCLE_AVOID 0 /* box avoids circle */
#define PGS_BOX_CONT_CIRCLE 1 /* box contains circle */
#define PGS_CIRCLE_CONT_BOX 2 /* circle contains box */
#define PGS_BOX_CIRCLE_EQUAL 3 /* circle equals box */
#define PGS_BOX_CIRCLE_OVER 4 /* circle and box overlap */
/* PGS_BOX_LINE_REL Box and line */
#define PGS_BOX_LINE_AVOID 0 /* box avoids line */
#define PGS_BOX_CONT_LINE 1 /* box contains line */
#define PGS_BOX_LINE_OVER 2 /* box and line overlap */
/* PGS_BOX_PATH_REL Box and path */
#define PGS_BOX_PATH_AVOID 0 /* box avoids path */
#define PGS_BOX_CONT_PATH 1 /* box contains path */
#define PGS_BOX_PATH_OVER 2 /* box and path overlap */
/* PGS_BOX_POLY_REL Box and polygon */
#define PGS_BOX_POLY_AVOID 0 /* box avoids polygon */
#define PGS_BOX_CONT_POLY 1 /* box contains polygon */
#define PGS_POLY_CONT_BOX 2 /* polygon contains box */
#define PGS_BOX_POLY_OVER 3 /* polygon and box overlap */
/* PGS_BOX_ELLIPSE_REL Box and ellipse */
#define PGS_BOX_ELLIPSE_AVOID 0 /* box avoids ellipse */
#define PGS_BOX_CONT_ELLIPSE 1 /* box contains ellipse */
#define PGS_ELLIPSE_CONT_BOX 2 /* ellipse contains box */
#define PGS_BOX_ELLIPSE_OVER 3 /* ellipse and box overlap */
/* PGS_BOX_REL Box and box */
#define PGS_BOX_AVOID 0 /* box avoids other box */
#define PGS_BOX_CONT 1 /* box contains other box */
#define PGS_BOX_OVER 2 /* boxes overlap */
/*
* Checks whether two boxes are equal.
*/
bool sbox_eq(SBOX *b1, SBOX *b2);
/*
* Checks whether a point is contained by a box.
*/
bool sbox_cont_point(const SBOX *b, const SPoint *p);
/*
* Input function of a box.
*/
Datum spherebox_in(PG_FUNCTION_ARGS);
/*
* Input function of a box from two points. The first point
* is the south-west position, the second the north-east position.
*/
Datum spherebox_in_from_points(PG_FUNCTION_ARGS);
/*
* Returns the south-west edge of a box.
*/
Datum spherebox_sw(PG_FUNCTION_ARGS);
/*
* Returns the north-east edge of a box.
*/
Datum spherebox_ne(PG_FUNCTION_ARGS);
/*
* Returns the south-east edge of a box.
*/
Datum spherebox_se(PG_FUNCTION_ARGS);
/*
* Returns the north-west edge of a box.
*/
Datum spherebox_nw(PG_FUNCTION_ARGS);
/*
* Returns the area of a box.
*/
Datum spherebox_area(PG_FUNCTION_ARGS);
/*
* Returns the circumference of a box.
*/
Datum spherebox_circ(PG_FUNCTION_ARGS);
/*
* Checks whether two boxes are equal.
*/
Datum spherebox_equal(PG_FUNCTION_ARGS);
/*
* Checks whether two boxes are not equal.
*/
Datum spherebox_equal_neg(PG_FUNCTION_ARGS);
/*
* Checks whether a point is contained by a box.
*/
Datum spherebox_cont_point(PG_FUNCTION_ARGS);
/*
* Checks whether a point isn't contained by a box.
*/
Datum spherebox_cont_point_neg(PG_FUNCTION_ARGS);
/*
* Checks whether a point is contained by a box.
*/
Datum spherebox_cont_point_com(PG_FUNCTION_ARGS);
/*
* Checks whether a point isn't contained by a box.
*/
Datum spherebox_cont_point_com_neg(PG_FUNCTION_ARGS);
/*
* Checks whether a box contains a circle.
*/
Datum spherebox_cont_circle(PG_FUNCTION_ARGS);
/*
* Checks whether a box doesn't contain a circle.
*/
Datum spherebox_cont_circle_neg(PG_FUNCTION_ARGS);
/*
* Checks whether a box contains a circle.
*/
Datum spherebox_cont_circle_com(PG_FUNCTION_ARGS);
/*
* Checks whether a box doesn't contain a circle.
*/
Datum spherebox_cont_circle_com_neg(PG_FUNCTION_ARGS);
/*
* Checks whether a circle contains a box.
*/
Datum spherecircle_cont_box(PG_FUNCTION_ARGS);
/*
* Checks whether a circle doesn't contain a box.
*/
Datum spherecircle_cont_box_neg(PG_FUNCTION_ARGS);
/*
* Checks whether a circle contains a box.
*/
Datum spherecircle_cont_box_com(PG_FUNCTION_ARGS);
/*
* Checks whether a circle doesn't contain a box.
*/
Datum spherecircle_cont_box_com_neg(PG_FUNCTION_ARGS);
/*
* Checks whether a circle and a box overlap.
*/
Datum spherebox_overlap_circle(PG_FUNCTION_ARGS);
/*
* Checks whether a circle and a box don't overlap.
*/
Datum spherebox_overlap_circle_neg(PG_FUNCTION_ARGS);
/*
* Checks whether a circle and a box overlap.
*/
Datum spherebox_overlap_circle_com(PG_FUNCTION_ARGS);
/*
* Checks whether a circle and a box don't overlap.
*/
Datum spherebox_overlap_circle_com_neg(PG_FUNCTION_ARGS);
/*
* Checks whether a box contains a line.
*/
Datum spherebox_cont_line(PG_FUNCTION_ARGS);
/*
* Checks whether a box doesn't contain a line.
*/
Datum spherebox_cont_line_neg(PG_FUNCTION_ARGS);
/*
* Checks whether a box contains a line.
*/
Datum spherebox_cont_line_com(PG_FUNCTION_ARGS);
/*
* Checks whether a box doesn't contain a line.
*/
Datum spherebox_cont_line_com_neg(PG_FUNCTION_ARGS);
/*
* Checks whether a box and a line overlap.
*/
Datum spherebox_overlap_line(PG_FUNCTION_ARGS);
/*
* Checks whether a box and a line don't overlap.
*/
Datum spherebox_overlap_line_neg(PG_FUNCTION_ARGS);
/*
* Checks whether a box and a line overlap.
*/
Datum spherebox_overlap_line_com(PG_FUNCTION_ARGS);
/*
* Checks whether a box and a line don't overlap.
*/
Datum spherebox_overlap_line_com_neg(PG_FUNCTION_ARGS);
/*
* Checks whether a box contains a path.
*/
Datum spherebox_cont_path(PG_FUNCTION_ARGS);
/*
* Checks whether a box doesn't contain a path.
*/
Datum spherebox_cont_path_neg(PG_FUNCTION_ARGS);
/*
* Checks whether a box contains a path.
*/
Datum spherebox_cont_path_com(PG_FUNCTION_ARGS);
/*
* Checks whether a box doesn't contain a path.
*/
Datum spherebox_cont_path_com_neg(PG_FUNCTION_ARGS);
/*
* Checks whether a box and a path overlap.
*/
Datum spherebox_overlap_path(PG_FUNCTION_ARGS);
/*
* Checks whether a box and a path don't overlap.
*/
Datum spherebox_overlap_path_neg(PG_FUNCTION_ARGS);
/*
* Checks whether a box and a path overlap.
*/
Datum spherebox_overlap_path_com(PG_FUNCTION_ARGS);
/*
* Checks whether a box and a path don't overlap.
*/
Datum spherebox_overlap_path_com_neg(PG_FUNCTION_ARGS);
/*
* Checks whether a box contains a polygon.
*/
Datum spherebox_cont_poly(PG_FUNCTION_ARGS);
/*
* Checks whether a box doesn't contain a polygon.
*/
Datum spherebox_cont_poly_neg(PG_FUNCTION_ARGS);
/*
* Checks whether a box contains a polygon.
*/
Datum spherebox_cont_poly_com(PG_FUNCTION_ARGS);
/*
* Checks whether a box doesn't contain a polygon.
*/
Datum spherebox_cont_poly_com_neg(PG_FUNCTION_ARGS);
/*
* Checks whether a polygon contains a box.
*/
Datum spherepoly_cont_box(PG_FUNCTION_ARGS);
/*
* Checks whether a polygon doesn't contain a box.
*/
Datum spherepoly_cont_box_neg(PG_FUNCTION_ARGS);
/*
* Checks whether a polygon contains a box.
*/
Datum spherepoly_cont_box_com(PG_FUNCTION_ARGS);
/*
* Checks whether a polygon doesn't contain a box.
*/
Datum spherepoly_cont_box_com_neg(PG_FUNCTION_ARGS);
/*
* Checks whether a polygon and a box overlap.
*/
Datum spherebox_overlap_poly(PG_FUNCTION_ARGS);
/*
* Checks whether a polygon and a box don't overlap.
*/
Datum spherebox_overlap_poly_neg(PG_FUNCTION_ARGS);
/*
* Checks whether a polygon and a box overlap.
*/
Datum spherebox_overlap_poly_com(PG_FUNCTION_ARGS);
/*
* Checks whether a polygon and a box don't overlap.
*/
Datum spherebox_overlap_poly_com_neg(PG_FUNCTION_ARGS);
/*
* Checks whether a box contains an ellipse.
*/
Datum spherebox_cont_ellipse(PG_FUNCTION_ARGS);
/*
* Checks whether a box doesn't contain an ellipse.
*/
Datum spherebox_cont_ellipse_neg(PG_FUNCTION_ARGS);
/*
* Checks whether a box contains an ellipse.
*/
Datum spherebox_cont_ellipse_com(PG_FUNCTION_ARGS);
/*
* Checks whether a box doesn't contain an ellipse.
*/
Datum spherebox_cont_ellipse_com_neg(PG_FUNCTION_ARGS);
/*
* Checks whether an ellipse contains a box.
*/
Datum sphereellipse_cont_box(PG_FUNCTION_ARGS);
/*
* Checks whether an ellipse doesn't contain a box.
*/
Datum sphereellipse_cont_box_neg(PG_FUNCTION_ARGS);
/*
* Checks whether an ellipse contains a box.
*/
Datum sphereellipse_cont_box_com(PG_FUNCTION_ARGS);
/*
* Checks whether an ellipse doesn't contain a box.
*/
Datum sphereellipse_cont_box_com_neg(PG_FUNCTION_ARGS);
/*
* Checks whether an ellipse and a box overlap.
*/
Datum spherebox_overlap_ellipse(PG_FUNCTION_ARGS);
/*
* Checks whether an ellipse and a box don't overlap.
*/
Datum spherebox_overlap_ellipse_neg(PG_FUNCTION_ARGS);
/*
* Checks whether an ellipse and a box overlap.
*/
Datum spherebox_overlap_ellipse_com(PG_FUNCTION_ARGS);
/*
* Checks whether an ellipse and a box don't overlap.
*/
Datum spherebox_overlap_ellipse_com_neg(PG_FUNCTION_ARGS);
/*
* Checks whether a box contains another box.
*/
Datum spherebox_cont_box(PG_FUNCTION_ARGS);
/*
* Checks whether a box doesn't contain another box.
*/
Datum spherebox_cont_box_neg(PG_FUNCTION_ARGS);
/*
* Checks whether a box contains another box.
*/
Datum spherebox_cont_box_com(PG_FUNCTION_ARGS);
/*
* Checks whether a box doesn't contain another box.
*/
Datum spherebox_cont_box_com_neg(PG_FUNCTION_ARGS);
/*
* Checks whether two boxes overlap.
*/
Datum spherebox_overlap_box(PG_FUNCTION_ARGS);
/*
* Checks whether two boxes don't overlap.
*/
Datum spherebox_overlap_box_neg(PG_FUNCTION_ARGS);
#endif