1 /*
2
3 check_relations_fncts.c -- SpatiaLite Test Case
4
5 This does "boundary conditions" and error checks for gg_relations
6 functions that are hard to test with SQL.
7
8 Author: Brad Hards <bradh@frogmouth.net>
9
10 ------------------------------------------------------------------------------
11
12 Version: MPL 1.1/GPL 2.0/LGPL 2.1
13
14 The contents of this file are subject to the Mozilla Public License Version
15 1.1 (the "License"); you may not use this file except in compliance with
16 the License. You may obtain a copy of the License at
17 http://www.mozilla.org/MPL/
18
19 Software distributed under the License is distributed on an "AS IS" basis,
20 WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
21 for the specific language governing rights and limitations under the
22 License.
23
24 The Original Code is the SpatiaLite library
25
26 The Initial Developer of the Original Code is Alessandro Furieri
27
28 Portions created by the Initial Developer are Copyright (C) 2011
29 the Initial Developer. All Rights Reserved.
30
31 Contributor(s):
32 Brad Hards <bradh@frogmouth.net>
33
34 Alternatively, the contents of this file may be used under the terms of
35 either the GNU General Public License Version 2 or later (the "GPL"), or
36 the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
37 in which case the provisions of the GPL or the LGPL are applicable instead
38 of those above. If you wish to allow use of your version of this file only
39 under the terms of either the GPL or the LGPL, and not to allow others to
40 use your version of this file under the terms of the MPL, indicate your
41 decision by deleting the provisions above and replace them with the notice
42 and other provisions required by the GPL or the LGPL. If you do not delete
43 the provisions above, a recipient may use your version of this file under
44 the terms of any one of the MPL, the GPL or the LGPL.
45
46 */
47 #include <stdlib.h>
48 #include <stdio.h>
49 #include <string.h>
50 #include <math.h>
51
52 #include <spatialite/gaiaconfig.h>
53
54 #include "sqlite3.h"
55 #include "spatialite.h"
56 #include "spatialite/gaiageo.h"
57
58 static const double double_eps = 0.00000001;
59
60 int
test_extra_mode()61 test_extra_mode ()
62 {
63 #ifndef OMIT_GEOS /* only if GEOS is supported */
64 int ret;
65 sqlite3 *handle;
66 int result;
67 int returnValue = 0;
68 gaiaGeomCollPtr geom_pt1;
69 gaiaGeomCollPtr geom_pt2;
70 gaiaGeomCollPtr geom_ln1;
71 gaiaGeomCollPtr geom_ln2;
72 gaiaGeomCollPtr geom_pg;
73 gaiaGeomCollPtr g;
74 gaiaLinestringPtr ln;
75 gaiaPolygonPtr pg;
76 gaiaRingPtr rng;
77 void *cache = spatialite_alloc_connection ();
78
79 /* Tests start here */
80 ret =
81 sqlite3_open_v2 (":memory:", &handle,
82 SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL);
83 if (ret != SQLITE_OK)
84 {
85 fprintf (stderr, "cannot open in-memory db: %s\n",
86 sqlite3_errmsg (handle));
87 sqlite3_close (handle);
88 return -101;
89 }
90
91 spatialite_init_ex (handle, cache, 0);
92
93 /* preparing a Point */
94 geom_pt1 = gaiaAllocGeomColl ();
95 gaiaAddPointToGeomColl (geom_pt1, 30.0, 30.0);
96 gaiaMbrGeometry (geom_pt1);
97
98 /* preparing another Point */
99 geom_pt2 = gaiaAllocGeomColl ();
100 gaiaAddPointToGeomColl (geom_pt2, 10.5, 1.5);
101 gaiaMbrGeometry (geom_pt2);
102
103 /* preparing a Linestring */
104 geom_ln1 = gaiaAllocGeomColl ();
105 ln = gaiaAddLinestringToGeomColl (geom_ln1, 3);
106 gaiaSetPoint (ln->Coords, 0, 5.0, 0.0);
107 gaiaSetPoint (ln->Coords, 1, 5.0, 20.0);
108 gaiaSetPoint (ln->Coords, 2, 0.0, 20.0);
109 gaiaMbrGeometry (geom_ln1);
110
111 /* preparing another Linestring */
112 geom_ln2 = gaiaAllocGeomColl ();
113 ln = gaiaAddLinestringToGeomColl (geom_ln2, 4);
114 gaiaSetPoint (ln->Coords, 0, 0.0, 20.0);
115 gaiaSetPoint (ln->Coords, 1, 5.0, 20.0);
116 gaiaSetPoint (ln->Coords, 2, 5.0, 0.0);
117 gaiaSetPoint (ln->Coords, 3, 0.0, 0.0);
118 gaiaMbrGeometry (geom_ln2);
119
120 /* preparing a Polygon */
121 geom_pg = gaiaAllocGeomColl ();
122 pg = gaiaAddPolygonToGeomColl (geom_pg, 5, 1);
123 rng = pg->Exterior;
124 gaiaSetPoint (rng->Coords, 0, 1.5, 1.5);
125 gaiaSetPoint (rng->Coords, 1, 10.5, 1.5);
126 gaiaSetPoint (rng->Coords, 2, 10.5, 10.5);
127 gaiaSetPoint (rng->Coords, 3, 1.5, 10.5);
128 gaiaSetPoint (rng->Coords, 4, 1.5, 1.5);
129 rng = gaiaAddInteriorRing (pg, 0, 5);
130 gaiaSetPoint (rng->Coords, 0, 5.5, 5.5);
131 gaiaSetPoint (rng->Coords, 1, 6.5, 1.5);
132 gaiaSetPoint (rng->Coords, 2, 6.5, 6.5);
133 gaiaSetPoint (rng->Coords, 3, 5.5, 6.5);
134 gaiaSetPoint (rng->Coords, 4, 5.5, 5.5);
135 gaiaMbrGeometry (geom_pg);
136
137 result = gaiaGeomCollDisjoint_r (cache, geom_pt1, geom_ln1);
138 if (result != 1)
139 {
140 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
141 result);
142 returnValue = -102;
143 goto exit;
144 }
145 result = gaiaGeomCollDisjoint_r (cache, geom_pt2, geom_pg);
146 if (result != 0)
147 {
148 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
149 result);
150 returnValue = -103;
151 goto exit;
152 }
153 result = gaiaGeomCollDisjoint_r (cache, geom_pg, geom_ln1);
154 if (result != 0)
155 {
156 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
157 result);
158 returnValue = -104;
159 goto exit;
160 }
161
162 result = gaiaGeomCollOverlaps_r (cache, geom_pt2, geom_ln1);
163 if (result != 0)
164 {
165 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
166 result);
167 returnValue = -105;
168 goto exit;
169 }
170 result = gaiaGeomCollOverlaps_r (cache, geom_pt2, geom_pg);
171 if (result != 0)
172 {
173 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
174 result);
175 returnValue = -106;
176 goto exit;
177 }
178 result = gaiaGeomCollOverlaps_r (cache, geom_pg, geom_ln1);
179 if (result != 0)
180 {
181 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
182 result);
183 returnValue = -107;
184 goto exit;
185 }
186
187 result = gaiaGeomCollCrosses_r (cache, geom_pt2, geom_ln1);
188 if (result != 0)
189 {
190 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
191 result);
192 returnValue = -108;
193 goto exit;
194 }
195 result = gaiaGeomCollCrosses_r (cache, geom_pt2, geom_pg);
196 if (result != 0)
197 {
198 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
199 result);
200 returnValue = -109;
201 goto exit;
202 }
203 result = gaiaGeomCollCrosses_r (cache, geom_pg, geom_ln1);
204 if (result != 1)
205 {
206 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
207 result);
208 returnValue = -110;
209 goto exit;
210 }
211
212 result = gaiaGeomCollTouches_r (cache, geom_pt2, geom_ln1);
213 if (result != 0)
214 {
215 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
216 result);
217 returnValue = -111;
218 goto exit;
219 }
220 result = gaiaGeomCollTouches_r (cache, geom_pt2, geom_pg);
221 if (result != 1)
222 {
223 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
224 result);
225 returnValue = -112;
226 goto exit;
227 }
228 result = gaiaGeomCollTouches_r (cache, geom_pg, geom_ln1);
229 if (result != 0)
230 {
231 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
232 result);
233 returnValue = -113;
234 goto exit;
235 }
236
237 result = gaiaGeomCollWithin_r (cache, geom_pt2, geom_ln1);
238 if (result != 0)
239 {
240 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
241 result);
242 returnValue = -114;
243 goto exit;
244 }
245 result = gaiaGeomCollWithin_r (cache, geom_pt2, geom_pg);
246 if (result != 0)
247 {
248 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
249 result);
250 returnValue = -115;
251 goto exit;
252 }
253 result = gaiaGeomCollWithin_r (cache, geom_pg, geom_ln1);
254 if (result != 0)
255 {
256 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
257 result);
258 returnValue = -116;
259 goto exit;
260 }
261
262 result = gaiaGeomCollContains_r (cache, geom_pt2, geom_ln1);
263 if (result != 0)
264 {
265 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
266 result);
267 returnValue = -117;
268 goto exit;
269 }
270 result = gaiaGeomCollContains_r (cache, geom_pg, geom_pt2);
271 if (result != 0)
272 {
273 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
274 result);
275 returnValue = -118;
276 goto exit;
277 }
278 result = gaiaGeomCollContains_r (cache, geom_pg, geom_ln1);
279 if (result != 0)
280 {
281 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
282 result);
283 returnValue = -119;
284 goto exit;
285 }
286
287 result = gaiaGeomCollCovers_r (cache, geom_pt1, geom_ln1);
288 if (result != 0)
289 {
290 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
291 result);
292 returnValue = -120;
293 goto exit;
294 }
295 result = gaiaGeomCollCovers_r (cache, geom_pg, geom_pt2);
296 if (result != 1)
297 {
298 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
299 result);
300 returnValue = -121;
301 goto exit;
302 }
303 result = gaiaGeomCollCovers_r (cache, geom_pg, geom_ln1);
304 if (result != 0)
305 {
306 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
307 result);
308 returnValue = -122;
309 goto exit;
310 }
311
312 result = gaiaGeomCollCoveredBy_r (cache, geom_pt2, geom_ln1);
313 if (result != 0)
314 {
315 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
316 result);
317 returnValue = -120;
318 goto exit;
319 }
320 result = gaiaGeomCollCoveredBy_r (cache, geom_pt2, geom_pg);
321 if (result != 1)
322 {
323 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
324 result);
325 returnValue = -121;
326 goto exit;
327 }
328 result = gaiaGeomCollCoveredBy_r (cache, geom_pg, geom_ln1);
329 if (result != 0)
330 {
331 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
332 result);
333 returnValue = -122;
334 goto exit;
335 }
336
337 g = gaiaSharedPaths_r (cache, geom_ln1, geom_ln2);
338 if (g == NULL)
339 {
340 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
341 result);
342 returnValue = -123;
343 goto exit;
344 }
345 gaiaFreeGeomColl (g);
346 g = gaiaSharedPaths_r (cache, geom_ln1, geom_ln2);
347 if (g == NULL)
348 {
349 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
350 result);
351 returnValue = -124;
352 goto exit;
353 }
354 gaiaFreeGeomColl (g);
355
356 /* Cleanup and exit */
357 exit:
358 gaiaFreeGeomColl (geom_pt1);
359 gaiaFreeGeomColl (geom_pt2);
360 gaiaFreeGeomColl (geom_ln1);
361 gaiaFreeGeomColl (geom_ln2);
362 gaiaFreeGeomColl (geom_pg);
363
364 ret = sqlite3_close (handle);
365 if (ret != SQLITE_OK)
366 {
367 fprintf (stderr, "sqlite3_close() error: %s\n",
368 sqlite3_errmsg (handle));
369 return -133;
370 }
371
372 spatialite_cleanup_ex (cache);
373 return returnValue;
374
375 #endif /* end GEOS conditional */
376 return 0;
377 }
378
379 int
test_current_mode()380 test_current_mode ()
381 {
382 #ifndef OMIT_GEOS /* only if GEOS is supported */
383 int ret;
384 sqlite3 *handle;
385 int result;
386 double resultDouble;
387 int returnValue = 0;
388 gaiaGeomCollPtr geom;
389 gaiaGeomCollPtr g;
390 gaiaPolygonPtr pg;
391 gaiaRingPtr rng;
392 void *cache = spatialite_alloc_connection ();
393
394 /* Common setup */
395 gaiaGeomCollPtr validGeometry = gaiaAllocGeomColl ();
396 double dummyResultArg = 0.0;
397 double dummyResultArg2 = 0.0;
398
399 /* Tests start here */
400 ret =
401 sqlite3_open_v2 (":memory:", &handle,
402 SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL);
403 if (ret != SQLITE_OK)
404 {
405 fprintf (stderr, "cannot open in-memory db: %s\n",
406 sqlite3_errmsg (handle));
407 sqlite3_close (handle);
408 return -1;
409 }
410
411 spatialite_init_ex (handle, cache, 0);
412
413 /* null inputs for a range of geometry functions */
414 result = gaiaGeomCollEquals_r (cache, 0, validGeometry);
415 if (result != -1)
416 {
417 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
418 result);
419 returnValue = -1;
420 goto exit;
421 }
422
423 result = gaiaGeomCollEquals_r (cache, validGeometry, 0);
424 if (result != -1)
425 {
426 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
427 result);
428 returnValue = -2;
429 goto exit;
430 }
431
432 result = gaiaGeomCollEquals_r (cache, 0, 0);
433 if (result != -1)
434 {
435 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
436 result);
437 returnValue = -3;
438 goto exit;
439 }
440
441 result = gaiaGeomCollIntersects_r (cache, 0, validGeometry);
442 if (result != -1)
443 {
444 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
445 result);
446 returnValue = -4;
447 goto exit;
448 }
449
450 result = gaiaGeomCollIntersects_r (cache, validGeometry, 0);
451 if (result != -1)
452 {
453 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
454 result);
455 returnValue = -5;
456 goto exit;
457 }
458
459 result = gaiaGeomCollIntersects_r (cache, 0, 0);
460 if (result != -1)
461 {
462 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
463 result);
464 returnValue = -6;
465 goto exit;
466 }
467
468 result = gaiaGeomCollOverlaps_r (cache, 0, validGeometry);
469 if (result != -1)
470 {
471 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
472 result);
473 returnValue = -7;
474 goto exit;
475 }
476
477 result = gaiaGeomCollOverlaps_r (cache, validGeometry, 0);
478 if (result != -1)
479 {
480 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
481 result);
482 returnValue = -8;
483 goto exit;
484 }
485
486 result = gaiaGeomCollOverlaps_r (cache, 0, 0);
487 if (result != -1)
488 {
489 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
490 result);
491 returnValue = -9;
492 goto exit;
493 }
494
495 result = gaiaGeomCollCrosses_r (cache, 0, validGeometry);
496 if (result != -1)
497 {
498 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
499 result);
500 returnValue = -10;
501 goto exit;
502 }
503
504 result = gaiaGeomCollCrosses_r (cache, validGeometry, 0);
505 if (result != -1)
506 {
507 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
508 result);
509 returnValue = -11;
510 goto exit;
511 }
512
513 result = gaiaGeomCollCrosses_r (cache, 0, 0);
514 if (result != -1)
515 {
516 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
517 result);
518 returnValue = -12;
519 goto exit;
520 }
521
522 result = gaiaGeomCollTouches_r (cache, 0, validGeometry);
523 if (result != -1)
524 {
525 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
526 result);
527 returnValue = -13;
528 goto exit;
529 }
530
531 result = gaiaGeomCollTouches_r (cache, validGeometry, 0);
532 if (result != -1)
533 {
534 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
535 result);
536 returnValue = -14;
537 goto exit;
538 }
539
540 result = gaiaGeomCollTouches_r (cache, 0, 0);
541 if (result != -1)
542 {
543 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
544 result);
545 returnValue = -15;
546 goto exit;
547 }
548
549 result = gaiaGeomCollDisjoint_r (cache, 0, validGeometry);
550 if (result != -1)
551 {
552 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
553 result);
554 returnValue = -16;
555 goto exit;
556 }
557
558 result = gaiaGeomCollDisjoint_r (cache, validGeometry, 0);
559 if (result != -1)
560 {
561 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
562 result);
563 returnValue = -17;
564 goto exit;
565 }
566
567 result = gaiaGeomCollDisjoint_r (cache, 0, 0);
568 if (result != -1)
569 {
570 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
571 result);
572 returnValue = -18;
573 goto exit;
574 }
575
576 result = gaiaGeomCollWithin_r (cache, 0, validGeometry);
577 if (result != -1)
578 {
579 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
580 result);
581 returnValue = -19;
582 goto exit;
583 }
584
585 result = gaiaGeomCollWithin_r (cache, validGeometry, 0);
586 if (result != -1)
587 {
588 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
589 result);
590 returnValue = -20;
591 goto exit;
592 }
593
594 result = gaiaGeomCollWithin_r (cache, 0, 0);
595 if (result != -1)
596 {
597 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
598 result);
599 returnValue = -21;
600 goto exit;
601 }
602
603 result = gaiaGeomCollContains_r (cache, 0, validGeometry);
604 if (result != -1)
605 {
606 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
607 result);
608 returnValue = -22;
609 goto exit;
610 }
611
612 result = gaiaGeomCollContains_r (cache, validGeometry, 0);
613 if (result != -1)
614 {
615 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
616 result);
617 returnValue = -23;
618 goto exit;
619 }
620
621 result = gaiaGeomCollContains_r (cache, 0, 0);
622 if (result != -1)
623 {
624 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
625 result);
626 returnValue = -24;
627 goto exit;
628 }
629
630 result = gaiaGeomCollRelate_r (cache, 0, validGeometry, "T********");
631 if (result != -1)
632 {
633 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
634 result);
635 returnValue = -25;
636 goto exit;
637 }
638
639 result = gaiaGeomCollRelate_r (cache, validGeometry, 0, "T********");
640 if (result != -1)
641 {
642 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
643 result);
644 returnValue = -26;
645 goto exit;
646 }
647
648 result = gaiaGeomCollRelate_r (cache, 0, 0, "T********");
649 if (result != -1)
650 {
651 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
652 result);
653 returnValue = -27;
654 goto exit;
655 }
656
657 result = gaiaHausdorffDistance_r (cache, 0, validGeometry, &dummyResultArg);
658 if (result != 0)
659 {
660 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
661 result);
662 returnValue = -34;
663 goto exit;
664 }
665
666 result = gaiaHausdorffDistance_r (cache, validGeometry, 0, &dummyResultArg);
667 if (result != 0)
668 {
669 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
670 result);
671 returnValue = -35;
672 goto exit;
673 }
674
675 result = gaiaHausdorffDistance_r (cache, 0, 0, &dummyResultArg);
676 if (result != 0)
677 {
678 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
679 result);
680 returnValue = -36;
681 goto exit;
682 }
683
684 result = gaiaGeomCollCovers_r (cache, 0, validGeometry);
685 if (result != -1)
686 {
687 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
688 result);
689 returnValue = -37;
690 goto exit;
691 }
692
693 result = gaiaGeomCollCovers_r (cache, validGeometry, 0);
694 if (result != -1)
695 {
696 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
697 result);
698 returnValue = -38;
699 goto exit;
700 }
701
702 result = gaiaGeomCollCovers_r (cache, 0, 0);
703 if (result != -1)
704 {
705 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
706 result);
707 returnValue = -39;
708 goto exit;
709 }
710
711 result = gaiaGeomCollCoveredBy_r (cache, 0, validGeometry);
712 if (result != -1)
713 {
714 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
715 result);
716 returnValue = -40;
717 goto exit;
718 }
719
720 result = gaiaGeomCollCoveredBy_r (cache, validGeometry, 0);
721 if (result != -1)
722 {
723 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
724 result);
725 returnValue = -41;
726 goto exit;
727 }
728
729 result = gaiaGeomCollCoveredBy_r (cache, 0, 0);
730 if (result != -1)
731 {
732 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
733 result);
734 returnValue = -42;
735 goto exit;
736 }
737
738 result = gaiaGeomCollDistance_r (cache, 0, validGeometry, &dummyResultArg);
739 if (result != 0)
740 {
741 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
742 result);
743 returnValue = -43;
744 goto exit;
745 }
746
747 result = gaiaGeomCollDistance_r (cache, validGeometry, 0, &dummyResultArg);
748 if (result != 0)
749 {
750 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
751 result);
752 returnValue = -44;
753 goto exit;
754 }
755
756 result = gaiaGeomCollDistance_r (cache, 0, 0, &dummyResultArg);
757 if (result != 0)
758 {
759 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
760 result);
761 returnValue = -45;
762 goto exit;
763 }
764 /* Check some of the single geometry analysis routines */
765
766 result = gaiaGeomCollLength_r (cache, 0, &dummyResultArg);
767 if (result != 0)
768 {
769 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
770 result);
771 returnValue = -46;
772 goto exit;
773 }
774
775 result = gaiaGeomCollArea_r (cache, 0, &dummyResultArg);
776 if (result != 0)
777 {
778 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
779 result);
780 returnValue = -47;
781 goto exit;
782 }
783
784 result =
785 gaiaGeomCollCentroid_r (cache, 0, &dummyResultArg, &dummyResultArg2);
786 if (result != 0)
787 {
788 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
789 result);
790 returnValue = -48;
791 goto exit;
792 }
793
794 result =
795 gaiaGetPointOnSurface_r (cache, 0, &dummyResultArg, &dummyResultArg2);
796 if (result != 0)
797 {
798 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
799 result);
800 returnValue = -49;
801 goto exit;
802 }
803
804 result = gaiaIsSimple_r (cache, 0);
805 if (result != -1)
806 {
807 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
808 result);
809 returnValue = -32;
810 goto exit;
811 }
812
813 result = gaiaIsValid_r (cache, 0);
814 if (result != -1)
815 {
816 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
817 result);
818 returnValue = -33;
819 goto exit;
820 }
821
822 resultDouble = gaiaLineLocatePoint_r (cache, 0, validGeometry);
823 if (fabs (resultDouble - -1.0) > double_eps)
824 {
825 fprintf (stderr, "bad result at %s:%i: %f\n", __FILE__, __LINE__,
826 resultDouble);
827 returnValue = -62;
828 goto exit;
829 }
830
831 resultDouble = gaiaLineLocatePoint_r (cache, validGeometry, 0);
832 if (fabs (resultDouble - -1.0) > double_eps)
833 {
834 fprintf (stderr, "bad result at %s:%i: %f\n", __FILE__, __LINE__,
835 resultDouble);
836 returnValue = -63;
837 goto exit;
838 }
839
840 resultDouble = gaiaLineLocatePoint_r (cache, 0, 0);
841 if (fabs (resultDouble - -1.0) > double_eps)
842 {
843 fprintf (stderr, "bad result at %s:%i: %f\n", __FILE__, __LINE__,
844 resultDouble);
845 returnValue = -64;
846 goto exit;
847 }
848
849 /* geometry generating functionality */
850 geom = NULL;
851 geom = gaiaLinesCutAtNodes (0, validGeometry);
852 if (geom != NULL)
853 {
854 gaiaFree (geom);
855 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
856 returnValue = -50;
857 goto exit;
858 }
859
860 geom = gaiaLinesCutAtNodes (validGeometry, 0);
861 if (geom != NULL)
862 {
863 gaiaFree (geom);
864 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
865 returnValue = -51;
866 goto exit;
867 }
868
869 geom = gaiaLinesCutAtNodes (0, 0);
870 if (geom != NULL)
871 {
872 gaiaFree (geom);
873 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
874 returnValue = -52;
875 goto exit;
876 }
877
878 geom = gaiaUnaryUnion_r (cache, 0);
879 if (geom != NULL)
880 {
881 gaiaFree (geom);
882 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
883 returnValue = -53;
884 goto exit;
885 }
886
887 geom = gaiaLineMerge (0);
888 if (geom != NULL)
889 {
890 gaiaFree (geom);
891 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
892 returnValue = -54;
893 goto exit;
894 }
895
896 geom = gaiaSnap_r (cache, 0, validGeometry, 4);
897 if (geom != NULL)
898 {
899 gaiaFree (geom);
900 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
901 returnValue = -55;
902 goto exit;
903 }
904
905 geom = gaiaSnap_r (cache, validGeometry, 0, 4);
906 if (geom != NULL)
907 {
908 gaiaFree (geom);
909 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
910 returnValue = -56;
911 goto exit;
912 }
913
914 geom = gaiaSnap_r (cache, 0, 0, 4);
915 if (geom != NULL)
916 {
917 gaiaFree (geom);
918 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
919 returnValue = -57;
920 goto exit;
921 }
922
923 geom = gaiaShortestLine_r (cache, 0, validGeometry);
924 if (geom != NULL)
925 {
926 gaiaFree (geom);
927 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
928 returnValue = -58;
929 goto exit;
930 }
931
932 geom = gaiaShortestLine_r (cache, validGeometry, 0);
933 if (geom != NULL)
934 {
935 gaiaFree (geom);
936 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
937 returnValue = -59;
938 goto exit;
939 }
940
941 geom = gaiaShortestLine_r (cache, 0, 0);
942 if (geom != NULL)
943 {
944 gaiaFree (geom);
945 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
946 returnValue = -60;
947 goto exit;
948 }
949
950 geom = gaiaLineSubstring_r (cache, 0, 0, 1);
951 if (geom != NULL)
952 {
953 gaiaFree (geom);
954 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
955 returnValue = -61;
956 goto exit;
957 }
958
959 geom = gaiaGeometryIntersection_r (cache, 0, validGeometry);
960 if (geom != NULL)
961 {
962 gaiaFree (geom);
963 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
964 returnValue = -65;
965 goto exit;
966 }
967
968 geom = gaiaGeometryIntersection_r (cache, validGeometry, 0);
969 if (geom != NULL)
970 {
971 gaiaFree (geom);
972 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
973 returnValue = -66;
974 goto exit;
975 }
976
977 geom = gaiaGeometryIntersection_r (cache, 0, 0);
978 if (geom != NULL)
979 {
980 gaiaFree (geom);
981 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
982 returnValue = -67;
983 goto exit;
984 }
985
986 geom = gaiaGeometryUnion_r (cache, 0, validGeometry);
987 if (geom != NULL)
988 {
989 gaiaFree (geom);
990 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
991 returnValue = -68;
992 goto exit;
993 }
994
995 geom = gaiaGeometryUnion_r (cache, validGeometry, 0);
996 if (geom != NULL)
997 {
998 gaiaFree (geom);
999 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
1000 returnValue = -69;
1001 goto exit;
1002 }
1003
1004 geom = gaiaGeometryUnion_r (cache, 0, 0);
1005 if (geom != NULL)
1006 {
1007 gaiaFree (geom);
1008 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
1009 returnValue = -70;
1010 goto exit;
1011 }
1012
1013 geom = gaiaGeometryDifference_r (cache, 0, validGeometry);
1014 if (geom != NULL)
1015 {
1016 gaiaFree (geom);
1017 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
1018 returnValue = -71;
1019 goto exit;
1020 }
1021
1022 geom = gaiaGeometryDifference_r (cache, validGeometry, 0);
1023 if (geom != NULL)
1024 {
1025 gaiaFree (geom);
1026 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
1027 returnValue = -72;
1028 goto exit;
1029 }
1030
1031 geom = gaiaGeometryDifference_r (cache, 0, 0);
1032 if (geom != NULL)
1033 {
1034 gaiaFree (geom);
1035 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
1036 returnValue = -73;
1037 goto exit;
1038 }
1039
1040 geom = gaiaGeometrySymDifference_r (cache, 0, validGeometry);
1041 if (geom != NULL)
1042 {
1043 gaiaFree (geom);
1044 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
1045 returnValue = -74;
1046 goto exit;
1047 }
1048
1049 geom = gaiaGeometrySymDifference_r (cache, validGeometry, 0);
1050 if (geom != NULL)
1051 {
1052 gaiaFree (geom);
1053 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
1054 returnValue = -75;
1055 goto exit;
1056 }
1057
1058 geom = gaiaGeometrySymDifference_r (cache, 0, 0);
1059 if (geom != NULL)
1060 {
1061 gaiaFree (geom);
1062 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
1063 returnValue = -76;
1064 goto exit;
1065 }
1066
1067 geom = gaiaBoundary_r (cache, 0);
1068 if (geom != NULL)
1069 {
1070 gaiaFree (geom);
1071 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
1072 returnValue = -77;
1073 goto exit;
1074 }
1075
1076 geom = gaiaGeomCollSimplify_r (cache, 0, 1.0);
1077 if (geom != NULL)
1078 {
1079 gaiaFree (geom);
1080 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
1081 returnValue = -78;
1082 goto exit;
1083 }
1084
1085 geom = gaiaGeomCollSimplifyPreserveTopology_r (cache, 0, 1.0);
1086 if (geom != NULL)
1087 {
1088 gaiaFree (geom);
1089 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
1090 returnValue = -79;
1091 goto exit;
1092 }
1093
1094 geom = gaiaConvexHull_r (cache, 0);
1095 if (geom != NULL)
1096 {
1097 gaiaFree (geom);
1098 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
1099 returnValue = -80;
1100 goto exit;
1101 }
1102
1103 geom = gaiaGeomCollBuffer_r (cache, 0, 0.1, 10);
1104 if (geom != NULL)
1105 {
1106 gaiaFree (geom);
1107 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
1108 returnValue = -81;
1109 goto exit;
1110 }
1111
1112 geom = gaiaOffsetCurve_r (cache, 0, 1.5, 10, 1);
1113 if (geom != NULL)
1114 {
1115 gaiaFree (geom);
1116 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
1117 returnValue = -82;
1118 goto exit;
1119 }
1120
1121 geom = gaiaSingleSidedBuffer_r (cache, 0, 1.5, 10, 1);
1122 if (geom != NULL)
1123 {
1124 gaiaFree (geom);
1125 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
1126 returnValue = -83;
1127 goto exit;
1128 }
1129
1130 geom = gaiaSharedPaths_r (cache, 0, validGeometry);
1131 if (geom != NULL)
1132 {
1133 gaiaFree (geom);
1134 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
1135 returnValue = -84;
1136 goto exit;
1137 }
1138
1139 geom = gaiaSharedPaths_r (cache, validGeometry, 0);
1140 if (geom != NULL)
1141 {
1142 gaiaFree (geom);
1143 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
1144 returnValue = -85;
1145 goto exit;
1146 }
1147
1148 geom = gaiaSharedPaths_r (cache, 0, 0);
1149 if (geom != NULL)
1150 {
1151 gaiaFree (geom);
1152 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
1153 returnValue = -86;
1154 goto exit;
1155 }
1156
1157 geom = gaiaLineInterpolatePoint_r (cache, 0, 0.6);
1158 if (geom != NULL)
1159 {
1160 gaiaFree (geom);
1161 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
1162 returnValue = -87;
1163 goto exit;
1164 }
1165
1166 /* Test some strange conditions */
1167 result = gaiaGeomCollLength_r (cache, validGeometry, &dummyResultArg);
1168 if (result != 0)
1169 {
1170 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
1171 result);
1172 returnValue = -88;
1173 goto exit;
1174 }
1175
1176 /* preparing a collection of Polygons */
1177 geom = gaiaAllocGeomColl ();
1178 pg = gaiaAddPolygonToGeomColl (geom, 5, 1);
1179 rng = pg->Exterior;
1180 gaiaSetPoint (rng->Coords, 0, 1.5, 1.5);
1181 gaiaSetPoint (rng->Coords, 1, 10.5, 1.5);
1182 gaiaSetPoint (rng->Coords, 2, 10.5, 10.5);
1183 gaiaSetPoint (rng->Coords, 3, 1.5, 10.5);
1184 gaiaSetPoint (rng->Coords, 4, 1.5, 1.5);
1185 rng = gaiaAddInteriorRing (pg, 0, 5);
1186 gaiaSetPoint (rng->Coords, 0, 5.5, 5.5);
1187 gaiaSetPoint (rng->Coords, 1, 6.5, 1.5);
1188 gaiaSetPoint (rng->Coords, 2, 6.5, 6.5);
1189 gaiaSetPoint (rng->Coords, 3, 5.5, 6.5);
1190 gaiaSetPoint (rng->Coords, 4, 5.5, 5.5);
1191 pg = gaiaAddPolygonToGeomColl (geom, 5, 1);
1192 rng = pg->Exterior;
1193 gaiaSetPoint (rng->Coords, 0, 8.5, 8.5);
1194 gaiaSetPoint (rng->Coords, 1, 18.5, 8.5);
1195 gaiaSetPoint (rng->Coords, 2, 18.5, 18.5);
1196 gaiaSetPoint (rng->Coords, 3, 8.5, 18.5);
1197 gaiaSetPoint (rng->Coords, 4, 8.5, 8.5);
1198 rng = gaiaAddInteriorRing (pg, 0, 5);
1199 gaiaSetPoint (rng->Coords, 0, 11.5, 11.5);
1200 gaiaSetPoint (rng->Coords, 1, 12.5, 11.5);
1201 gaiaSetPoint (rng->Coords, 2, 12.5, 12.5);
1202 gaiaSetPoint (rng->Coords, 3, 11.5, 12.5);
1203 gaiaSetPoint (rng->Coords, 4, 11.5, 11.5);
1204 pg = gaiaAddPolygonToGeomColl (geom, 5, 0);
1205 rng = pg->Exterior;
1206 gaiaSetPoint (rng->Coords, 0, 4.5, 4.5);
1207 gaiaSetPoint (rng->Coords, 1, 30.5, 4.5);
1208 gaiaSetPoint (rng->Coords, 2, 30.5, 30.5);
1209 gaiaSetPoint (rng->Coords, 3, 4.5, 30.5);
1210 gaiaSetPoint (rng->Coords, 4, 4.5, 4.5);
1211
1212 /* Tests Polygons UnaryUnion [as in aggregate ST_Union] */
1213 g = gaiaUnaryUnion_r (cache, geom);
1214 if (g == NULL)
1215 {
1216 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
1217 returnValue = -89;
1218 goto exit;
1219 }
1220 result = gaiaGeomCollLength_r (cache, g, &dummyResultArg);
1221 if (result == 1
1222 && (dummyResultArg >= 122.84232 && dummyResultArg <= 122.84233))
1223 ;
1224 else
1225 {
1226 fprintf (stderr, "bad result at %s:%i: %i %f\n", __FILE__, __LINE__,
1227 result, dummyResultArg);
1228 returnValue = -90;
1229 goto exit;
1230 }
1231 gaiaFreeGeomColl (g);
1232
1233 /* Tests Polygons UnionCascaded [as in aggregate ST_Union] */
1234 g = gaiaUnionCascaded_r (cache, geom);
1235 if (g == NULL)
1236 {
1237 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
1238 returnValue = -91;
1239 goto exit;
1240 }
1241 result = gaiaGeomCollLength_r (cache, g, &dummyResultArg);
1242 if (result == 1
1243 && (dummyResultArg >= 122.84232 && dummyResultArg <= 122.84233))
1244 ;
1245 else
1246 {
1247 fprintf (stderr, "bad result at %s:%i: %i %f\n", __FILE__, __LINE__,
1248 result, dummyResultArg);
1249 returnValue = -92;
1250 goto exit;
1251 }
1252 gaiaFreeGeomColl (g);
1253 gaiaFreeGeomColl (geom);
1254
1255 /* Cleanup and exit */
1256 exit:
1257 gaiaFreeGeomColl (validGeometry);
1258
1259 ret = sqlite3_close (handle);
1260 if (ret != SQLITE_OK)
1261 {
1262 fprintf (stderr, "sqlite3_close() error: %s\n",
1263 sqlite3_errmsg (handle));
1264 return -133;
1265 }
1266
1267 spatialite_cleanup_ex (cache);
1268 return returnValue;
1269
1270 #endif /* end GEOS conditional */
1271 return 0;
1272 }
1273
1274 int
test_legacy_mode()1275 test_legacy_mode ()
1276 {
1277 #ifndef OMIT_GEOS /* only if GEOS is supported */
1278 int ret;
1279 sqlite3 *handle;
1280 int result;
1281 double resultDouble;
1282 int returnValue = 0;
1283 gaiaGeomCollPtr geom;
1284 gaiaGeomCollPtr g;
1285 gaiaPolygonPtr pg;
1286 gaiaRingPtr rng;
1287
1288 /* Common setup */
1289 gaiaGeomCollPtr validGeometry = gaiaAllocGeomColl ();
1290 double dummyResultArg = 0.0;
1291 double dummyResultArg2 = 0.0;
1292
1293 spatialite_init (0);
1294
1295 /* Tests start here */
1296 ret =
1297 sqlite3_open_v2 (":memory:", &handle,
1298 SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL);
1299 if (ret != SQLITE_OK)
1300 {
1301 fprintf (stderr, "cannot open in-memory db: %s\n",
1302 sqlite3_errmsg (handle));
1303 sqlite3_close (handle);
1304 return -1;
1305 }
1306
1307 /* null inputs for a range of geometry functions */
1308 result = gaiaGeomCollEquals (0, validGeometry);
1309 if (result != -1)
1310 {
1311 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
1312 result);
1313 returnValue = -1;
1314 goto exit;
1315 }
1316
1317 result = gaiaGeomCollEquals (validGeometry, 0);
1318 if (result != -1)
1319 {
1320 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
1321 result);
1322 returnValue = -2;
1323 goto exit;
1324 }
1325
1326 result = gaiaGeomCollEquals (0, 0);
1327 if (result != -1)
1328 {
1329 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
1330 result);
1331 returnValue = -3;
1332 goto exit;
1333 }
1334
1335 result = gaiaGeomCollIntersects (0, validGeometry);
1336 if (result != -1)
1337 {
1338 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
1339 result);
1340 returnValue = -4;
1341 goto exit;
1342 }
1343
1344 result = gaiaGeomCollIntersects (validGeometry, 0);
1345 if (result != -1)
1346 {
1347 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
1348 result);
1349 returnValue = -5;
1350 goto exit;
1351 }
1352
1353 result = gaiaGeomCollIntersects (0, 0);
1354 if (result != -1)
1355 {
1356 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
1357 result);
1358 returnValue = -6;
1359 goto exit;
1360 }
1361
1362 result = gaiaGeomCollOverlaps (0, validGeometry);
1363 if (result != -1)
1364 {
1365 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
1366 result);
1367 returnValue = -7;
1368 goto exit;
1369 }
1370
1371 result = gaiaGeomCollOverlaps (validGeometry, 0);
1372 if (result != -1)
1373 {
1374 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
1375 result);
1376 returnValue = -8;
1377 goto exit;
1378 }
1379
1380 result = gaiaGeomCollOverlaps (0, 0);
1381 if (result != -1)
1382 {
1383 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
1384 result);
1385 returnValue = -9;
1386 goto exit;
1387 }
1388
1389 result = gaiaGeomCollCrosses (0, validGeometry);
1390 if (result != -1)
1391 {
1392 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
1393 result);
1394 returnValue = -10;
1395 goto exit;
1396 }
1397
1398 result = gaiaGeomCollCrosses (validGeometry, 0);
1399 if (result != -1)
1400 {
1401 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
1402 result);
1403 returnValue = -11;
1404 goto exit;
1405 }
1406
1407 result = gaiaGeomCollCrosses (0, 0);
1408 if (result != -1)
1409 {
1410 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
1411 result);
1412 returnValue = -12;
1413 goto exit;
1414 }
1415
1416 result = gaiaGeomCollTouches (0, validGeometry);
1417 if (result != -1)
1418 {
1419 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
1420 result);
1421 returnValue = -13;
1422 goto exit;
1423 }
1424
1425 result = gaiaGeomCollTouches (validGeometry, 0);
1426 if (result != -1)
1427 {
1428 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
1429 result);
1430 returnValue = -14;
1431 goto exit;
1432 }
1433
1434 result = gaiaGeomCollTouches (0, 0);
1435 if (result != -1)
1436 {
1437 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
1438 result);
1439 returnValue = -15;
1440 goto exit;
1441 }
1442
1443 result = gaiaGeomCollDisjoint (0, validGeometry);
1444 if (result != -1)
1445 {
1446 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
1447 result);
1448 returnValue = -16;
1449 goto exit;
1450 }
1451
1452 result = gaiaGeomCollDisjoint (validGeometry, 0);
1453 if (result != -1)
1454 {
1455 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
1456 result);
1457 returnValue = -17;
1458 goto exit;
1459 }
1460
1461 result = gaiaGeomCollDisjoint (0, 0);
1462 if (result != -1)
1463 {
1464 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
1465 result);
1466 returnValue = -18;
1467 goto exit;
1468 }
1469
1470 result = gaiaGeomCollWithin (0, validGeometry);
1471 if (result != -1)
1472 {
1473 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
1474 result);
1475 returnValue = -19;
1476 goto exit;
1477 }
1478
1479 result = gaiaGeomCollWithin (validGeometry, 0);
1480 if (result != -1)
1481 {
1482 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
1483 result);
1484 returnValue = -20;
1485 goto exit;
1486 }
1487
1488 result = gaiaGeomCollWithin (0, 0);
1489 if (result != -1)
1490 {
1491 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
1492 result);
1493 returnValue = -21;
1494 goto exit;
1495 }
1496
1497 result = gaiaGeomCollContains (0, validGeometry);
1498 if (result != -1)
1499 {
1500 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
1501 result);
1502 returnValue = -22;
1503 goto exit;
1504 }
1505
1506 result = gaiaGeomCollContains (validGeometry, 0);
1507 if (result != -1)
1508 {
1509 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
1510 result);
1511 returnValue = -23;
1512 goto exit;
1513 }
1514
1515 result = gaiaGeomCollContains (0, 0);
1516 if (result != -1)
1517 {
1518 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
1519 result);
1520 returnValue = -24;
1521 goto exit;
1522 }
1523
1524 result = gaiaGeomCollRelate (0, validGeometry, "T********");
1525 if (result != -1)
1526 {
1527 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
1528 result);
1529 returnValue = -25;
1530 goto exit;
1531 }
1532
1533 result = gaiaGeomCollRelate (validGeometry, 0, "T********");
1534 if (result != -1)
1535 {
1536 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
1537 result);
1538 returnValue = -26;
1539 goto exit;
1540 }
1541
1542 result = gaiaGeomCollRelate (0, 0, "T********");
1543 if (result != -1)
1544 {
1545 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
1546 result);
1547 returnValue = -27;
1548 goto exit;
1549 }
1550
1551 result = gaiaHausdorffDistance (0, validGeometry, &dummyResultArg);
1552 if (result != 0)
1553 {
1554 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
1555 result);
1556 returnValue = -34;
1557 goto exit;
1558 }
1559
1560 result = gaiaHausdorffDistance (validGeometry, 0, &dummyResultArg);
1561 if (result != 0)
1562 {
1563 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
1564 result);
1565 returnValue = -35;
1566 goto exit;
1567 }
1568
1569 result = gaiaHausdorffDistance (0, 0, &dummyResultArg);
1570 if (result != 0)
1571 {
1572 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
1573 result);
1574 returnValue = -36;
1575 goto exit;
1576 }
1577
1578 result = gaiaGeomCollCovers (0, validGeometry);
1579 if (result != -1)
1580 {
1581 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
1582 result);
1583 returnValue = -37;
1584 goto exit;
1585 }
1586
1587 result = gaiaGeomCollCovers (validGeometry, 0);
1588 if (result != -1)
1589 {
1590 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
1591 result);
1592 returnValue = -38;
1593 goto exit;
1594 }
1595
1596 result = gaiaGeomCollCovers (0, 0);
1597 if (result != -1)
1598 {
1599 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
1600 result);
1601 returnValue = -39;
1602 goto exit;
1603 }
1604
1605 result = gaiaGeomCollCoveredBy (0, validGeometry);
1606 if (result != -1)
1607 {
1608 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
1609 result);
1610 returnValue = -40;
1611 goto exit;
1612 }
1613
1614 result = gaiaGeomCollCoveredBy (validGeometry, 0);
1615 if (result != -1)
1616 {
1617 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
1618 result);
1619 returnValue = -41;
1620 goto exit;
1621 }
1622
1623 result = gaiaGeomCollCoveredBy (0, 0);
1624 if (result != -1)
1625 {
1626 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
1627 result);
1628 returnValue = -42;
1629 goto exit;
1630 }
1631
1632 result = gaiaGeomCollDistance (0, validGeometry, &dummyResultArg);
1633 if (result != 0)
1634 {
1635 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
1636 result);
1637 returnValue = -43;
1638 goto exit;
1639 }
1640
1641 result = gaiaGeomCollDistance (validGeometry, 0, &dummyResultArg);
1642 if (result != 0)
1643 {
1644 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
1645 result);
1646 returnValue = -44;
1647 goto exit;
1648 }
1649
1650 result = gaiaGeomCollDistance (0, 0, &dummyResultArg);
1651 if (result != 0)
1652 {
1653 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
1654 result);
1655 returnValue = -45;
1656 goto exit;
1657 }
1658 /* Check some of the single geometry analysis routines */
1659
1660 result = gaiaGeomCollLength (0, &dummyResultArg);
1661 if (result != 0)
1662 {
1663 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
1664 result);
1665 returnValue = -46;
1666 goto exit;
1667 }
1668
1669 result = gaiaGeomCollArea (0, &dummyResultArg);
1670 if (result != 0)
1671 {
1672 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
1673 result);
1674 returnValue = -47;
1675 goto exit;
1676 }
1677
1678 result = gaiaGeomCollCentroid (0, &dummyResultArg, &dummyResultArg2);
1679 if (result != 0)
1680 {
1681 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
1682 result);
1683 returnValue = -48;
1684 goto exit;
1685 }
1686
1687 result = gaiaGetPointOnSurface (0, &dummyResultArg, &dummyResultArg2);
1688 if (result != 0)
1689 {
1690 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
1691 result);
1692 returnValue = -49;
1693 goto exit;
1694 }
1695
1696 result = gaiaIsSimple (0);
1697 if (result != -1)
1698 {
1699 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
1700 result);
1701 returnValue = -32;
1702 goto exit;
1703 }
1704
1705 result = gaiaIsValid (0);
1706 if (result != -1)
1707 {
1708 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
1709 result);
1710 returnValue = -33;
1711 goto exit;
1712 }
1713
1714 resultDouble = gaiaLineLocatePoint (0, validGeometry);
1715 if (fabs (resultDouble - -1.0) > double_eps)
1716 {
1717 fprintf (stderr, "bad result at %s:%i: %f\n", __FILE__, __LINE__,
1718 resultDouble);
1719 returnValue = -62;
1720 goto exit;
1721 }
1722
1723 resultDouble = gaiaLineLocatePoint (validGeometry, 0);
1724 if (fabs (resultDouble - -1.0) > double_eps)
1725 {
1726 fprintf (stderr, "bad result at %s:%i: %f\n", __FILE__, __LINE__,
1727 resultDouble);
1728 returnValue = -63;
1729 goto exit;
1730 }
1731
1732 resultDouble = gaiaLineLocatePoint (0, 0);
1733 if (fabs (resultDouble - -1.0) > double_eps)
1734 {
1735 fprintf (stderr, "bad result at %s:%i: %f\n", __FILE__, __LINE__,
1736 resultDouble);
1737 returnValue = -64;
1738 goto exit;
1739 }
1740
1741 /* geometry generating functionality */
1742 geom = NULL;
1743 geom = gaiaLinesCutAtNodes (0, validGeometry);
1744 if (geom != NULL)
1745 {
1746 gaiaFree (geom);
1747 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
1748 returnValue = -50;
1749 goto exit;
1750 }
1751
1752 geom = gaiaLinesCutAtNodes (validGeometry, 0);
1753 if (geom != NULL)
1754 {
1755 gaiaFree (geom);
1756 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
1757 returnValue = -51;
1758 goto exit;
1759 }
1760
1761 geom = gaiaLinesCutAtNodes (0, 0);
1762 if (geom != NULL)
1763 {
1764 gaiaFree (geom);
1765 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
1766 returnValue = -52;
1767 goto exit;
1768 }
1769
1770 geom = gaiaUnaryUnion (0);
1771 if (geom != NULL)
1772 {
1773 gaiaFree (geom);
1774 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
1775 returnValue = -53;
1776 goto exit;
1777 }
1778
1779 geom = gaiaLineMerge (0);
1780 if (geom != NULL)
1781 {
1782 gaiaFree (geom);
1783 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
1784 returnValue = -54;
1785 goto exit;
1786 }
1787
1788 geom = gaiaSnap (0, validGeometry, 4);
1789 if (geom != NULL)
1790 {
1791 gaiaFree (geom);
1792 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
1793 returnValue = -55;
1794 goto exit;
1795 }
1796
1797 geom = gaiaSnap (validGeometry, 0, 4);
1798 if (geom != NULL)
1799 {
1800 gaiaFree (geom);
1801 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
1802 returnValue = -56;
1803 goto exit;
1804 }
1805
1806 geom = gaiaSnap (0, 0, 4);
1807 if (geom != NULL)
1808 {
1809 gaiaFree (geom);
1810 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
1811 returnValue = -57;
1812 goto exit;
1813 }
1814
1815 geom = gaiaShortestLine (0, validGeometry);
1816 if (geom != NULL)
1817 {
1818 gaiaFree (geom);
1819 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
1820 returnValue = -58;
1821 goto exit;
1822 }
1823
1824 geom = gaiaShortestLine (validGeometry, 0);
1825 if (geom != NULL)
1826 {
1827 gaiaFree (geom);
1828 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
1829 returnValue = -59;
1830 goto exit;
1831 }
1832
1833 geom = gaiaShortestLine (0, 0);
1834 if (geom != NULL)
1835 {
1836 gaiaFree (geom);
1837 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
1838 returnValue = -60;
1839 goto exit;
1840 }
1841
1842 geom = gaiaLineSubstring (0, 0, 1);
1843 if (geom != NULL)
1844 {
1845 gaiaFree (geom);
1846 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
1847 returnValue = -61;
1848 goto exit;
1849 }
1850
1851 geom = gaiaGeometryIntersection (0, validGeometry);
1852 if (geom != NULL)
1853 {
1854 gaiaFree (geom);
1855 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
1856 returnValue = -65;
1857 goto exit;
1858 }
1859
1860 geom = gaiaGeometryIntersection (validGeometry, 0);
1861 if (geom != NULL)
1862 {
1863 gaiaFree (geom);
1864 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
1865 returnValue = -66;
1866 goto exit;
1867 }
1868
1869 geom = gaiaGeometryIntersection (0, 0);
1870 if (geom != NULL)
1871 {
1872 gaiaFree (geom);
1873 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
1874 returnValue = -67;
1875 goto exit;
1876 }
1877
1878 geom = gaiaGeometryUnion (0, validGeometry);
1879 if (geom != NULL)
1880 {
1881 gaiaFree (geom);
1882 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
1883 returnValue = -68;
1884 goto exit;
1885 }
1886
1887 geom = gaiaGeometryUnion (validGeometry, 0);
1888 if (geom != NULL)
1889 {
1890 gaiaFree (geom);
1891 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
1892 returnValue = -69;
1893 goto exit;
1894 }
1895
1896 geom = gaiaGeometryUnion (0, 0);
1897 if (geom != NULL)
1898 {
1899 gaiaFree (geom);
1900 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
1901 returnValue = -70;
1902 goto exit;
1903 }
1904
1905 geom = gaiaGeometryDifference (0, validGeometry);
1906 if (geom != NULL)
1907 {
1908 gaiaFree (geom);
1909 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
1910 returnValue = -71;
1911 goto exit;
1912 }
1913
1914 geom = gaiaGeometryDifference (validGeometry, 0);
1915 if (geom != NULL)
1916 {
1917 gaiaFree (geom);
1918 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
1919 returnValue = -72;
1920 goto exit;
1921 }
1922
1923 geom = gaiaGeometryDifference (0, 0);
1924 if (geom != NULL)
1925 {
1926 gaiaFree (geom);
1927 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
1928 returnValue = -73;
1929 goto exit;
1930 }
1931
1932 geom = gaiaGeometrySymDifference (0, validGeometry);
1933 if (geom != NULL)
1934 {
1935 gaiaFree (geom);
1936 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
1937 returnValue = -74;
1938 goto exit;
1939 }
1940
1941 geom = gaiaGeometrySymDifference (validGeometry, 0);
1942 if (geom != NULL)
1943 {
1944 gaiaFree (geom);
1945 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
1946 returnValue = -75;
1947 goto exit;
1948 }
1949
1950 geom = gaiaGeometrySymDifference (0, 0);
1951 if (geom != NULL)
1952 {
1953 gaiaFree (geom);
1954 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
1955 returnValue = -76;
1956 goto exit;
1957 }
1958
1959 geom = gaiaBoundary (0);
1960 if (geom != NULL)
1961 {
1962 gaiaFree (geom);
1963 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
1964 returnValue = -77;
1965 goto exit;
1966 }
1967
1968 geom = gaiaGeomCollSimplify (0, 1.0);
1969 if (geom != NULL)
1970 {
1971 gaiaFree (geom);
1972 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
1973 returnValue = -78;
1974 goto exit;
1975 }
1976
1977 geom = gaiaGeomCollSimplifyPreserveTopology (0, 1.0);
1978 if (geom != NULL)
1979 {
1980 gaiaFree (geom);
1981 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
1982 returnValue = -79;
1983 goto exit;
1984 }
1985
1986 geom = gaiaConvexHull (0);
1987 if (geom != NULL)
1988 {
1989 gaiaFree (geom);
1990 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
1991 returnValue = -80;
1992 goto exit;
1993 }
1994
1995 geom = gaiaGeomCollBuffer (0, 0.1, 10);
1996 if (geom != NULL)
1997 {
1998 gaiaFree (geom);
1999 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
2000 returnValue = -81;
2001 goto exit;
2002 }
2003
2004 geom = gaiaOffsetCurve (0, 1.5, 10, 1);
2005 if (geom != NULL)
2006 {
2007 gaiaFree (geom);
2008 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
2009 returnValue = -82;
2010 goto exit;
2011 }
2012
2013 geom = gaiaSingleSidedBuffer (0, 1.5, 10, 1);
2014 if (geom != NULL)
2015 {
2016 gaiaFree (geom);
2017 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
2018 returnValue = -83;
2019 goto exit;
2020 }
2021
2022 geom = gaiaSharedPaths (0, validGeometry);
2023 if (geom != NULL)
2024 {
2025 gaiaFree (geom);
2026 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
2027 returnValue = -84;
2028 goto exit;
2029 }
2030
2031 geom = gaiaSharedPaths (validGeometry, 0);
2032 if (geom != NULL)
2033 {
2034 gaiaFree (geom);
2035 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
2036 returnValue = -85;
2037 goto exit;
2038 }
2039
2040 geom = gaiaSharedPaths (0, 0);
2041 if (geom != NULL)
2042 {
2043 gaiaFree (geom);
2044 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
2045 returnValue = -86;
2046 goto exit;
2047 }
2048
2049 geom = gaiaLineInterpolatePoint (0, 0.6);
2050 if (geom != NULL)
2051 {
2052 gaiaFree (geom);
2053 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
2054 returnValue = -87;
2055 goto exit;
2056 }
2057
2058 /* Test some strange conditions */
2059 result = gaiaGeomCollLength (validGeometry, &dummyResultArg);
2060 if (result != 0)
2061 {
2062 fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
2063 result);
2064 returnValue = -88;
2065 goto exit;
2066 }
2067
2068 /* preparing a collection of Polygons */
2069 geom = gaiaAllocGeomColl ();
2070 pg = gaiaAddPolygonToGeomColl (geom, 5, 1);
2071 rng = pg->Exterior;
2072 gaiaSetPoint (rng->Coords, 0, 1.5, 1.5);
2073 gaiaSetPoint (rng->Coords, 1, 10.5, 1.5);
2074 gaiaSetPoint (rng->Coords, 2, 10.5, 10.5);
2075 gaiaSetPoint (rng->Coords, 3, 1.5, 10.5);
2076 gaiaSetPoint (rng->Coords, 4, 1.5, 1.5);
2077 rng = gaiaAddInteriorRing (pg, 0, 5);
2078 gaiaSetPoint (rng->Coords, 0, 5.5, 5.5);
2079 gaiaSetPoint (rng->Coords, 1, 6.5, 1.5);
2080 gaiaSetPoint (rng->Coords, 2, 6.5, 6.5);
2081 gaiaSetPoint (rng->Coords, 3, 5.5, 6.5);
2082 gaiaSetPoint (rng->Coords, 4, 5.5, 5.5);
2083 pg = gaiaAddPolygonToGeomColl (geom, 5, 1);
2084 rng = pg->Exterior;
2085 gaiaSetPoint (rng->Coords, 0, 8.5, 8.5);
2086 gaiaSetPoint (rng->Coords, 1, 18.5, 8.5);
2087 gaiaSetPoint (rng->Coords, 2, 18.5, 18.5);
2088 gaiaSetPoint (rng->Coords, 3, 8.5, 18.5);
2089 gaiaSetPoint (rng->Coords, 4, 8.5, 8.5);
2090 rng = gaiaAddInteriorRing (pg, 0, 5);
2091 gaiaSetPoint (rng->Coords, 0, 11.5, 11.5);
2092 gaiaSetPoint (rng->Coords, 1, 12.5, 11.5);
2093 gaiaSetPoint (rng->Coords, 2, 12.5, 12.5);
2094 gaiaSetPoint (rng->Coords, 3, 11.5, 12.5);
2095 gaiaSetPoint (rng->Coords, 4, 11.5, 11.5);
2096 pg = gaiaAddPolygonToGeomColl (geom, 5, 0);
2097 rng = pg->Exterior;
2098 gaiaSetPoint (rng->Coords, 0, 4.5, 4.5);
2099 gaiaSetPoint (rng->Coords, 1, 30.5, 4.5);
2100 gaiaSetPoint (rng->Coords, 2, 30.5, 30.5);
2101 gaiaSetPoint (rng->Coords, 3, 4.5, 30.5);
2102 gaiaSetPoint (rng->Coords, 4, 4.5, 4.5);
2103
2104
2105 #ifndef GEOS_ONLY_REENTRANT /* skipping legacy mode test (non-thread-safe GEOS API) */
2106 /* Tests Polygons UnaryUnion [as in aggregate ST_Union] */
2107 g = gaiaUnaryUnion (geom);
2108 if (g == NULL)
2109 {
2110 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
2111 returnValue = -89;
2112 goto exit;
2113 }
2114 result = gaiaGeomCollLength (g, &dummyResultArg);
2115 if (result == 1
2116 && (dummyResultArg >= 122.84232 && dummyResultArg <= 122.84233))
2117 ;
2118 else
2119 {
2120 fprintf (stderr, "bad result at %s:%i: %i %f\n", __FILE__, __LINE__,
2121 result, dummyResultArg);
2122 returnValue = -90;
2123 goto exit;
2124 }
2125 gaiaFreeGeomColl (g);
2126
2127 /* Tests Polygons UnionCascaded [as in aggregate ST_Union] */
2128 g = gaiaUnionCascaded (geom);
2129 if (g == NULL)
2130 {
2131 fprintf (stderr, "bad result at %s:%i\n", __FILE__, __LINE__);
2132 returnValue = -91;
2133 goto exit;
2134 }
2135 result = gaiaGeomCollLength (g, &dummyResultArg);
2136 if (result == 1
2137 && (dummyResultArg >= 122.84232 && dummyResultArg <= 122.84233))
2138 ;
2139 else
2140 {
2141 fprintf (stderr, "bad result at %s:%i: %i %f\n", __FILE__, __LINE__,
2142 result, dummyResultArg);
2143 returnValue = -92;
2144 goto exit;
2145 }
2146 gaiaFreeGeomColl (g);
2147 #endif
2148 gaiaFreeGeomColl (geom);
2149
2150 /* Cleanup and exit */
2151 exit:
2152 gaiaFreeGeomColl (validGeometry);
2153
2154 ret = sqlite3_close (handle);
2155 if (ret != SQLITE_OK)
2156 {
2157 fprintf (stderr, "sqlite3_close() error: %s\n",
2158 sqlite3_errmsg (handle));
2159 return -133;
2160 }
2161
2162 spatialite_cleanup ();
2163 return returnValue;
2164
2165 #endif /* end GEOS conditional */
2166 return 0;
2167 }
2168
2169 int
main(int argc,char * argv[])2170 main (int argc, char *argv[])
2171 {
2172 int ret;
2173 if (argc > 1 || argv[0] == NULL)
2174 argc = 1; /* silencing stupid compiler warnings */
2175 ret = test_current_mode ();
2176 if (ret != 0)
2177 return ret;
2178 ret = test_extra_mode ();
2179 if (ret != 0)
2180 return ret;
2181 ret = test_legacy_mode ();
2182 if (ret != 0)
2183 return ret;
2184 return 0;
2185 }
2186