15 #include "CUnit/Basic.h" 31 CU_ASSERT_EQUAL(rv, srid);
36 CU_ASSERT_EQUAL(rv, srid);
41 CU_ASSERT_EQUAL(rv, srid);
46 CU_ASSERT_EQUAL(rv, srid);
51 CU_ASSERT_EQUAL(rv, srid);
56 CU_ASSERT_EQUAL(rv, srid);
61 CU_ASSERT_EQUAL(rv, srid);
65 CU_ASSERT_EQUAL(rv,type);
69 CU_ASSERT_EQUAL(rv,z);
72 CU_ASSERT_EQUAL(rv,0);
135 CU_ASSERT_EQUAL(rv, srid);
146 CU_ASSERT_EQUAL(rv, srid);
151 CU_ASSERT_EQUAL(rv, srid);
156 CU_ASSERT_EQUAL(rv, srid);
166 CU_ASSERT_EQUAL( size, 32 );
171 CU_ASSERT_EQUAL( size, 40 );
176 CU_ASSERT_EQUAL( size, 80 );
181 CU_ASSERT_EQUAL( size, 48 );
186 CU_ASSERT_EQUAL( size, 96 );
191 CU_ASSERT_EQUAL( size, 104 );
194 g =
lwgeom_from_wkt(
"POLYGON((-1 -1, -1 2, 2 2, 2 -1, -1 -1), (0 0, 0 1, 1 1, 1 0, 0 0))",
LW_PARSER_CHECK_NONE);
196 CU_ASSERT_EQUAL( size, 184 );
208 CU_ASSERT_DOUBLE_EQUAL(b.
xmin, 0.0, 0.0000001);
216 CU_ASSERT_DOUBLE_EQUAL(b.
xmin, 0.0, 0.0000001);
217 CU_ASSERT(isinf(b.
ymax));
224 CU_ASSERT_DOUBLE_EQUAL(b.
xmin, 0.0, 0.0000001);
225 CU_ASSERT(isinf(b.
ymax));
232 CU_ASSERT(isnan(b.
ymax));
267 "LINESTRING(-1 -1,-1 2.5,2 2,2 -1)",
269 "MULTIPOINT(0.9 0.9,0.9 0.9,0.9 0.9,0.9 0.9,0.9 0.9,0.9 0.9)",
270 "SRID=1;MULTILINESTRING EMPTY",
271 "SRID=1;MULTILINESTRING((-1 -1,-1 2.5,2 2,2 -1),(-1 -1,-1 2.5,2 2,2 -1),(-1 -1,-1 2.5,2 2,2 -1),(-1 -1,-1 2.5,2 2,2 -1))",
272 "SRID=1;MULTILINESTRING((-1 -1,-1 2.5,2 2,2 -1),(-1 -1,-1 2.5,2 2,2 -1),(-1 -1,-1 2.5,2 2,2 -1),(-1 -1,-1 2.5,2 2,2 -1))",
273 "POLYGON((-1 -1,-1 2.5,2 2,2 -1,-1 -1),(0 0,0 1,1 1,1 0,0 0))",
275 "SRID=4326;POLYGON((-1 -1,-1 2.5,2 2,2 -1,-1 -1),(0 0,0 1,1 1,1 0,0 0))",
276 "SRID=4326;POLYGON EMPTY",
277 "SRID=4326;POLYGON((-1 -1,-1 2.5,2 2,2 -1,-1 -1),(0 0,0 1,1 1,1 0,0 0),(-0.5 -0.5,-0.5 -0.4,-0.4 -0.4,-0.4 -0.5,-0.5 -0.5))",
278 "SRID=100000;POLYGON((-1 -1 3,-1 2.5 3,2 2 3,2 -1 3,-1 -1 3),(0 0 3,0 1 3,1 1 3,1 0 3,0 0 3),(-0.5 -0.5 3,-0.5 -0.4 3,-0.4 -0.4 3,-0.4 -0.5 3,-0.5 -0.5 3))",
279 "SRID=4326;MULTIPOLYGON(((-1 -1,-1 2.5,2 2,2 -1,-1 -1),(0 0,0 1,1 1,1 0,0 0),(-0.5 -0.5,-0.5 -0.4,-0.4 -0.4,-0.4 -0.5,-0.5 -0.5)),((-1 -1,-1 2.5,2 2,2 -1,-1 -1),(0 0,0 1,1 1,1 0,0 0),(-0.5 -0.5,-0.5 -0.4,-0.4 -0.4,-0.4 -0.5,-0.5 -0.5)))",
280 "SRID=4326;MULTIPOLYGON EMPTY",
281 "SRID=4326;GEOMETRYCOLLECTION(POINT(0 1),POLYGON((-1 -1,-1 2.5,2 2,2 -1,-1 -1),(0 0,0 1,1 1,1 0,0 0)),MULTIPOLYGON(((-1 -1,-1 2.5,2 2,2 -1,-1 -1),(0 0,0 1,1 1,1 0,0 0),(-0.5 -0.5,-0.5 -0.4,-0.4 -0.4,-0.4 -0.5,-0.5 -0.5))))",
282 "SRID=4326;GEOMETRYCOLLECTION EMPTY",
283 "SRID=4326;GEOMETRYCOLLECTION(POINT EMPTY,MULTIPOLYGON EMPTY)",
284 "MULTICURVE((5 5 1 3,3 5 2 2,3 3 3 1,0 3 1 1),CIRCULARSTRING(0 0 0 0,0.26794 1 3 -2,0.5857864 1.414213 1 2))",
285 "MULTISURFACE(CURVEPOLYGON(CIRCULARSTRING(-2 0,-1 -1,0 0,1 -1,2 0,0 2,-2 0),(-1 0,0 0.5,1 0,0 1,-1 0)),((7 8,10 10,6 14,4 11,7 8)))",
286 "MULTISURFACE(CURVEPOLYGON(CIRCULARSTRING EMPTY))",
289 for ( i = 0; i < (
sizeof ewkt/
sizeof(
char*)); i++ )
303 CU_ASSERT_STRING_EQUAL(in_ewkt, out_ewkt);
306 CU_ASSERT( (geom->
bbox != NULL) || (geom2->
bbox == NULL) );
323 struct gserialized_empty_cases {
328 struct gserialized_empty_cases cases[] = {
329 {
"POINT EMPTY", 1 },
331 {
"LINESTRING EMPTY", 1 },
332 {
"MULTILINESTRING EMPTY", 1 },
333 {
"MULTILINESTRING(EMPTY)", 1 },
334 {
"MULTILINESTRING(EMPTY,EMPTY)", 1 },
335 {
"MULTILINESTRING(EMPTY,(0 0,1 1))", 0 },
336 {
"MULTILINESTRING((0 0,1 1),EMPTY)", 0 },
337 {
"MULTILINESTRING(EMPTY,(0 0,1 1),EMPTY)", 0 },
338 {
"MULTILINESTRING(EMPTY,EMPTY,EMPTY)", 1 },
339 {
"GEOMETRYCOLLECTION(POINT EMPTY,MULTILINESTRING(EMPTY,EMPTY,EMPTY))", 1 },
340 {
"GEOMETRYCOLLECTION(POINT EMPTY,MULTILINESTRING(EMPTY),POINT(1 1))", 0 },
341 {
"GEOMETRYCOLLECTION(POINT EMPTY,MULTILINESTRING(EMPTY, (0 0)),POINT EMPTY)", 0 },
342 {
"GEOMETRYCOLLECTION(POLYGON EMPTY,POINT EMPTY,MULTILINESTRING(EMPTY,EMPTY),POINT EMPTY)", 1 },
343 {
"GEOMETRYCOLLECTION(POLYGON EMPTY,GEOMETRYCOLLECTION(POINT EMPTY),MULTILINESTRING(EMPTY,EMPTY),POINT EMPTY)", 1 },
347 while( cases[i].wkt )
354 CU_ASSERT_EQUAL(ie, cases[i].isempty);
374 CU_ASSERT_EQUAL(z, 1);
375 CU_ASSERT_EQUAL(m, 0);
377 str =
"LINESTRINGM ";
382 CU_ASSERT_EQUAL(z, 0);
383 CU_ASSERT_EQUAL(m, 1);
385 str =
"MULTIPOLYGONZM";
390 CU_ASSERT_EQUAL(z, 1);
391 CU_ASSERT_EQUAL(m, 1);
393 str =
" GEOMETRYCOLLECTIONZM ";
398 CU_ASSERT_EQUAL(z, 1);
399 CU_ASSERT_EQUAL(m, 1);
401 str =
" GEOMERYCOLLECTIONZM ";
416 geom =
lwgeom_from_wkt(
"SRID=1;MULTILINESTRING((-1 -131,-1 2.5,2 2,2 -1),(-1 -1,-1 2.5,2 2,2 -1),(-1 -1,-1 2.5,2 2,2 -1),(-1 -1,-1 2.5,2 2,2 -1))",
LW_PARSER_CHECK_NONE);
420 geom =
lwgeom_from_wkt(
"SRID=4326;MULTIPOLYGON(((-1 -1,-1 2.5,211 2,2 -1,-1 -1),(0 0,0 1,1 1,1 0,0 0),(-0.5 -0.5,-0.5 -0.4,-0.4 -0.4,-0.4 -0.5,-0.5 -0.5)),((-1 -1,-1 2.5,2 2,2 -1,-1 -1),(0 0,0 1,1 1,1 0,0 0),(-0.5 -0.5,-0.5 -0.4,-0.4 -0.4,-0.4 -0.5,-0.5 -0.5)))",
LW_PARSER_CHECK_NONE);
525 testbox = (g->
bbox != NULL);
536 CU_ASSERT_DOUBLE_EQUAL(g->
bbox->
xmax, ymax, 0.00001);
537 CU_ASSERT_DOUBLE_EQUAL(g->
bbox->
ymax, xmax, 0.00001);
541 if (t == NULL) fprintf(stderr,
"In:%s", in);
543 fprintf(stderr,
"\nIn: %s\nOut: %s\nTheo: %s\n", in, t, out);
545 CU_ASSERT_STRING_EQUAL(t, out)
562 "LINESTRING(1 2,3 4)",
563 "LINESTRING(2 1,4 3)" 567 "POLYGON((1 2,3 4,5 6,1 2))",
568 "POLYGON((2 1,4 3,6 5,2 1))" 572 "POLYGON((1 2,3 4,5 6,1 2),(7 8,9 10,11 12,7 8))",
573 "POLYGON((2 1,4 3,6 5,2 1),(8 7,10 9,12 11,8 7))" 577 "MULTIPOINT(1 2,3 4)",
578 "MULTIPOINT(2 1,4 3)" 582 "MULTILINESTRING((1 2,3 4),(5 6,7 8))",
583 "MULTILINESTRING((2 1,4 3),(6 5,8 7))" 587 "MULTIPOLYGON(((1 2,3 4,5 6,7 8)),((9 10,11 12,13 14,10 9)))",
588 "MULTIPOLYGON(((2 1,4 3,6 5,8 7)),((10 9,12 11,14 13,9 10)))" 592 "GEOMETRYCOLLECTION EMPTY",
593 "GEOMETRYCOLLECTION EMPTY" 597 "GEOMETRYCOLLECTION(POINT(1 2),LINESTRING(3 4,5 6))",
598 "GEOMETRYCOLLECTION(POINT(2 1),LINESTRING(4 3,6 5))" 602 "GEOMETRYCOLLECTION(POINT(1 2),GEOMETRYCOLLECTION(LINESTRING(3 4,5 6)))",
603 "GEOMETRYCOLLECTION(POINT(2 1),GEOMETRYCOLLECTION(LINESTRING(4 3,6 5)))" 607 "CIRCULARSTRING(-2 0,0 2,2 0,0 2,2 4)",
608 "CIRCULARSTRING(0 -2,2 0,0 2,2 0,4 2)" 612 "COMPOUNDCURVE(CIRCULARSTRING(0 1,1 1,1 0),(1 0,0 1))",
613 "COMPOUNDCURVE(CIRCULARSTRING(1 0,1 1,0 1),(0 1,1 0))" 617 "CURVEPOLYGON(CIRCULARSTRING(-2 0,-1 -1,0 0,1 -1,2 0,0 2,-2 0),(-1 0,0 0.5,1 0,0 1,-1 0))",
618 "CURVEPOLYGON(CIRCULARSTRING(0 -2,-1 -1,0 0,-1 1,0 2,2 0,0 -2),(0 -1,0.5 0,0 1,1 0,0 -1))" 622 "MULTICURVE((5 5,3 5,3 3,0 3),CIRCULARSTRING(0 0,2 1,2 3))",
623 "MULTICURVE((5 5,5 3,3 3,3 0),CIRCULARSTRING(0 0,1 2,3 2))" 627 "MULTISURFACE(CURVEPOLYGON(CIRCULARSTRING(-2 0,-1 -1,0 0,1 -1,2 0,0 2,-2 0),(-1 0,0 0.5,1 0,0 1,-1 0)),((7 8,10 10,6 14,4 11,7 8)))",
628 "MULTISURFACE(CURVEPOLYGON(CIRCULARSTRING(0 -2,-1 -1,0 0,-1 1,0 2,2 0,0 -2),(0 -1,0.5 0,0 1,1 0,0 -1)),((8 7,10 10,14 6,11 4,8 7)))" 657 "SRID=4326;POINT(1 2)",
658 "SRID=4326;POINT(2 1)" 669 double d = 1000000.123456789123456789;
675 CU_ASSERT_DOUBLE_EQUAL(f,d, 0.0000001);
678 CU_ASSERT_DOUBLE_EQUAL(f,e, 0.0000001);
682 CU_ASSERT_DOUBLE_EQUAL(f,d, 0.0000001);
686 CU_ASSERT_DOUBLE_EQUAL(f,d, 0.0000001);
690 CU_ASSERT_DOUBLE_EQUAL(f,d, 0.0000001);
695 CU_ASSERT_DOUBLE_EQUAL(f, d, 0.0000001);
700 CU_ASSERT_DOUBLE_EQUAL(f, d, 0.0000001);
705 CU_ASSERT_DOUBLE_EQUAL(f, d, 0.0000001);
710 CU_ASSERT_DOUBLE_EQUAL(f, d, 0.0000001);
726 "LINESTRING(-1 -1,-1 2.5,2 2,2 -1)",
727 "MULTIPOINT(0.9 0.9,0.9 0.9,0.9 0.9,0.9 0.9,0.9 0.9,0.9 0.9)",
728 "SRID=1;MULTILINESTRING((-1 -1,-1 2.5,2 2,2 -1),(-1 -1,-1 2.5,2 2,2 -1),(-1 -1,-1 2.5,2 2,2 -1),(-1 -1,-1 2.5,2 2,2 -1))",
729 "SRID=1;MULTILINESTRING((-1 -1,-1 2.5,2 2,2 -1),(-1 -1,-1 2.5,2 2,2 -1),(-1 -1,-1 2.5,2 2,2 -1),(-1 -1,-1 2.5,2 2,2 -1))",
730 "POLYGON((-1 -1,-1 2.5,2 2,2 -1,-1 -1),(0 0,0 1,1 1,1 0,0 0))",
731 "SRID=4326;POLYGON((-1 -1,-1 2.5,2 2,2 -1,-1 -1),(0 0,0 1,1 1,1 0,0 0))",
732 "SRID=4326;POLYGON((-1 -1,-1 2.5,2 2,2 -1,-1 -1),(0 0,0 1,1 1,1 0,0 0),(-0.5 -0.5,-0.5 -0.4,-0.4 -0.4,-0.4 -0.5,-0.5 -0.5))",
733 "SRID=100000;POLYGON((-1 -1 3,-1 2.5 3,2 2 3,2 -1 3,-1 -1 3),(0 0 3,0 1 3,1 1 3,1 0 3,0 0 3),(-0.5 -0.5 3,-0.5 -0.4 3,-0.4 -0.4 3,-0.4 -0.5 3,-0.5 -0.5 3))",
734 "SRID=4326;MULTIPOLYGON(((-1 -1,-1 2.5,2 2,2 -1,-1 -1),(0 0,0 1,1 1,1 0,0 0),(-0.5 -0.5,-0.5 -0.4,-0.4 -0.4,-0.4 -0.5,-0.5 -0.5)),((-1 -1,-1 2.5,2 2,2 -1,-1 -1),(0 0,0 1,1 1,1 0,0 0),(-0.5 -0.5,-0.5 -0.4,-0.4 -0.4,-0.4 -0.5,-0.5 -0.5)))",
735 "SRID=4326;GEOMETRYCOLLECTION(POINT(0 1),POLYGON((-1 -1,-1 2.5,2 2,2 -1,-1 -1),(0 0,0 1,1 1,1 0,0 0)),MULTIPOLYGON(((-1 -1,-1 2.5,2 2,2 -1,-1 -1),(0 0,0 1,1 1,1 0,0 0),(-0.5 -0.5,-0.5 -0.4,-0.4 -0.4,-0.4 -0.5,-0.5 -0.5))))",
736 "MULTICURVE((5 5 1 3,3 5 2 2,3 3 3 1,0 3 1 1),CIRCULARSTRING(0 0 0 0,0.26794 1 3 -2,0.5857864 1.414213 1 2))",
737 "MULTISURFACE(CURVEPOLYGON(CIRCULARSTRING(-2 0,-1 -1,0 0,1 -1,2 0,0 2,-2 0),(-1 0,0 0.5,1 0,0 1,-1 0)),((7 8,10 10,6 14,4 11,7 8)))",
738 "TIN(((0 0 0,0 0 1,0 1 0,0 0 0)),((0 0 0,0 1 0,1 0 0,0 0 0)),((0 0 0,1 0 0,0 0 1,0 0 0)),((1 0 0,0 1 0,0 0 1,1 0 0)))" 742 for ( i = 0; i < (
sizeof ewkt/
sizeof(
char *)); i++ )
752 if (strcmp(in_ewkt, out_ewkt))
753 fprintf(stderr,
"\nExp: %s\nObt: %s\n", in_ewkt, out_ewkt);
754 CU_ASSERT_STRING_EQUAL(in_ewkt, out_ewkt);
770 char *in_ewkt, *out_ewkt;
776 in_ewkt =
"POLYGON((0 0,0 10,10 10,10 0,0 0))";
778 if (strcmp(in_ewkt, out_ewkt))
779 fprintf(stderr,
"\nExp: %s\nObt: %s\n", in_ewkt, out_ewkt);
780 CU_ASSERT_STRING_EQUAL(in_ewkt, out_ewkt);
788 in_ewkt =
"POLYGON((0 0,0 10,10 10,10 0,0 0))";
790 if (strcmp(in_ewkt, out_ewkt))
791 fprintf(stderr,
"\nExp: %s\nObt: %s\n", in_ewkt, out_ewkt);
792 CU_ASSERT_STRING_EQUAL(in_ewkt, out_ewkt);
797 geom =
lwgeom_from_wkt(
"POLYGON((0 0,10 0,10 10,0 10,0 0),(2 2,2 4,4 2,2 2),(6 2,8 2,8 4,6 2))",
LW_PARSER_CHECK_NONE);
800 in_ewkt =
"POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,4 2,2 4,2 2),(6 2,8 2,8 4,6 2))";
802 if (strcmp(in_ewkt, out_ewkt))
803 fprintf(stderr,
"\nExp: %s\nObt: %s\n", in_ewkt, out_ewkt);
804 CU_ASSERT_STRING_EQUAL(in_ewkt, out_ewkt);
809 geom =
lwgeom_from_wkt(
"POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,4 2,2 4,2 2),(6 2,8 4,8 2,6 2))",
LW_PARSER_CHECK_NONE);
812 in_ewkt =
"POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,4 2,2 4,2 2),(6 2,8 2,8 4,6 2))";
814 if (strcmp(in_ewkt, out_ewkt))
815 fprintf(stderr,
"\nExp: %s\nObt: %s\n", in_ewkt, out_ewkt);
816 CU_ASSERT_STRING_EQUAL(in_ewkt, out_ewkt);
822 in_ewkt =
"0103000000010000000500000000917E9BA468294100917E9B8AEA2841C976BE1FA4682941C976BE9F8AEA2841B39ABE1FA46829415ACCC29F8AEA284137894120A4682941C976BE9F8AEA284100917E9BA468294100917E9B8AEA2841";
869 geom =
lwgeom_from_wkt(
"GEOMETRYCOLLECTION(GEOMETRYCOLLECTION EMPTY, POINT EMPTY, LINESTRING EMPTY, POLYGON EMPTY, MULTIPOINT EMPTY, MULTILINESTRING EMPTY, MULTIPOLYGON EMPTY, GEOMETRYCOLLECTION(MULTIPOLYGON EMPTY))",
LW_PARSER_CHECK_NONE);
946 geom =
lwgeom_from_wkt(
"GEOMETRYCOLLECTION(GEOMETRYCOLLECTION EMPTY, POINT EMPTY, LINESTRING EMPTY, POLYGON EMPTY, MULTIPOINT EMPTY, MULTILINESTRING EMPTY, MULTIPOLYGON EMPTY, GEOMETRYCOLLECTION(MULTIPOLYGON EMPTY))",
LW_PARSER_CHECK_NONE);
951 geom2 =
lwgeom_from_wkt(
"GEOMETRYCOLLECTION(GEOMETRYCOLLECTION EMPTY, POINT EMPTY, LINESTRING EMPTY, POLYGON EMPTY, MULTIPOINT EMPTY, MULTILINESTRING EMPTY, MULTIPOLYGON EMPTY, GEOMETRYCOLLECTION(MULTIPOLYGON EMPTY))",
LW_PARSER_CHECK_NONE);
977 char *in_ewkt, *out_ewkt;
981 in_ewkt =
"COMPOUNDCURVE((0 0,10 0))";
983 if (strcmp(in_ewkt, out_ewkt))
984 fprintf(stderr,
"\nExp: %s\nObt: %s\n", in_ewkt, out_ewkt);
985 CU_ASSERT_STRING_EQUAL(in_ewkt, out_ewkt);
992 in_ewkt =
"MULTICURVE((0 0,10 0))";
994 if (strcmp(in_ewkt, out_ewkt))
995 fprintf(stderr,
"\nExp: %s\nObt: %s\n", in_ewkt, out_ewkt);
996 CU_ASSERT_STRING_EQUAL(in_ewkt, out_ewkt);
1003 in_ewkt =
"CURVEPOLYGON((0 0,10 0,10 10,0 10,0 0))";
1005 if (strcmp(in_ewkt, out_ewkt))
1006 fprintf(stderr,
"\nExp: %s\nObt: %s\n", in_ewkt, out_ewkt);
1007 CU_ASSERT_STRING_EQUAL(in_ewkt, out_ewkt);
1014 in_ewkt =
"MULTISURFACE(((0 0,10 0,10 10,0 10,0 0)))";
1016 if (strcmp(in_ewkt, out_ewkt))
1017 fprintf(stderr,
"\nExp: %s\nObt: %s\n", in_ewkt, out_ewkt);
1018 CU_ASSERT_STRING_EQUAL(in_ewkt, out_ewkt);
1052 geom =
lwgeom_from_wkt(
"SRID=4326;GEOMETRYCOLLECTION(POINT(0 1 2 3),POLYGON((-1 -1 0 1,-1 2.5 0 1,2 2 0 1,2 -1 0 1,-1 -1 0 1),(0 0 1 2,0 1 1 2,1 1 1 2,1 0 2 3,0 0 1 2)),LINESTRING(0 0 0 0, 1 2 3 4))",
LW_PARSER_CHECK_NONE);
1053 factor.
x = 2; factor.
y = 3; factor.
z = 4; factor.
m = 5;
1056 ASSERT_STRING_EQUAL(out_ewkt,
"SRID=4326;GEOMETRYCOLLECTION(POINT(0 3 8 15),POLYGON((-2 -3 0 5,-2 7.5 0 5,4 6 0 5,4 -3 0 5,-2 -3 0 5),(0 0 4 10,0 3 4 10,2 3 4 10,2 0 8 15,0 0 4 10)),LINESTRING(0 0 0 0,2 6 12 20))");
1062 factor.
x = 2; factor.
y = 3; factor.
z = 4; factor.
m = 5;
1120 "MULTIPOINT (EMPTY)",
1121 "MULTILINESTRING EMPTY",
1122 "MULTILINESTRING (EMPTY)" 1125 for ( i = 0; i < (
sizeof ewkt/
sizeof(
char*)); i++ )
1149 "POINT (2.2945672355 48.85822923236)",
1150 "POINTZ (2.2945672355 48.85822923236 15)",
1151 "POINTM (2.2945672355 48.85822923236 12)",
1152 "POINT ZM (2.2945672355 48.85822923236 12 2)",
1153 "MULTIPOINT ((-76.45402132523 44.225406213532))",
1154 "MULTIPOINT Z ((-76.45402132523 44.225406213532 112))",
1155 "MULTIPOINT ZM ((-76.45402132523 44.225406213532 112 44))",
1156 "LINESTRING (2.2945672355 48.85822923236, -76.45402132523 44.225406213532)",
1157 "LINESTRING Z (2.2945672355 48.85822923236 6, -76.45402132523 44.225406213532 8)",
1158 "LINESTRING ZM (2.2945672355 48.85822923236 3 2, -76.45402132523 44.225406213532 9 4)",
1159 "MULTILINESTRING ((2.2945672355 48.85822923236, -76.45402132523 44.225406213532))",
1160 "MULTILINESTRING Z ((2.2945672355 48.85822923236 4, -76.45402132523 44.225406213532 3))" 1163 for ( i = 0; i < (
sizeof ewkt/
sizeof(
char*)); i++ )
1167 GBOX box_from_lwgeom;
1180 CU_ASSERT_TRUE(
gbox_same(&box_from_peek, &box_from_lwgeom));
1194 "MULTIPOINT ((-76.45402132523 44.225406213532), (-72 33))",
1195 "LINESTRING (2.2945672355 48.85822923236, -76.45402132523 44.225406213532, -72 33)",
1196 "MULTILINESTRING ((2.2945672355 48.85822923236, -76.45402132523 44.225406213532, -72 33))",
1197 "MULTILINESTRING ((2.2945672355 48.85822923236, -76.45402132523 44.225406213532), (-72 33, -71 32))" 1200 for ( i = 0; i < (
sizeof ewkt/
sizeof(
char*)); i++ )
1228 CU_ASSERT_EQUAL(
SIGNUM(-5.0),-1);
1229 CU_ASSERT_EQUAL(
SIGNUM( 5.0), 1);
1230 CU_ASSERT_EQUAL(
SIGNUM( 0.0), 0);
1231 CU_ASSERT_EQUAL(
SIGNUM(10) * 5, 5);
1232 CU_ASSERT_EQUAL(
SIGNUM(-10) * 5, -5);
1241 CU_pSuite suite = CU_add_suite(
"serialization/deserialization", NULL, NULL);
#define TYPMOD_GET_TYPE(typmod)
static void test_gserialized_from_lwgeom_size(void)
int gserialized_read_gbox_p(const GSERIALIZED *g, GBOX *gbox)
Pull a GBOX from the header of a GSERIALIZED, if one is available.
static void test_on_gser_lwgeom_count_vertices(void)
#define TYPMOD_GET_M(typmod)
LWCOLLECTION * lwcollection_extract(LWCOLLECTION *col, int type)
Takes a potentially heterogeneous collection and returns a homogeneous collection consisting only of ...
#define TYPMOD_SET_Z(typmod)
char * lwgeom_to_wkt(const LWGEOM *geom, uint8_t variant, int precision, size_t *size_out)
WKT emitter function.
static void test_typmod_macros(void)
#define FLAGS_GET_READONLY(flags)
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void test_gbox_same_2d(void)
static void test_gserialized_is_empty(void)
static void test_lwgeom_scale(void)
#define ASSERT_STRING_EQUAL(o, e)
static int gserialized_peek_gbox_p(const GSERIALIZED *g, GBOX *gbox)
#define FLAGS_GET_GEODETIC(flags)
char * lwgeom_to_ewkt(const LWGEOM *lwgeom)
Return an alloced string.
#define TYPMOD_GET_SRID(typmod)
Macros for manipulating the 'typemod' int.
void lwgeom_free(LWGEOM *geom)
int geometry_type_from_string(const char *str, uint8_t *type, int *z, int *m)
Calculate type integer and dimensional flags from string input.
void lwline_free(LWLINE *line)
void lwgeom_scale(LWGEOM *geom, const POINT4D *factors)
static void test_geometry_type_from_string(void)
#define FLAGS_GET_ZM(flags)
void gserialized_set_srid(GSERIALIZED *s, int32_t srid)
Write the SRID into the serialized form (it is packed into three bytes so this is a handy function)...
double lwline_length_2d(const LWLINE *line)
static void test_lwgeom_force_clockwise(void)
float next_float_down(double d)
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
static void test_lwcollection_extract(void)
#define FLAGS_SET_GEODETIC(flags, value)
static void test_lwgeom_as_curve(void)
static void test_gbox_serialized_size(void)
int gserialized_has_bbox(const GSERIALIZED *gser)
Check if a GSERIALIZED has a bounding box without deserializing first.
static void test_flags_macros(void)
void lwgeom_drop_bbox(LWGEOM *lwgeom)
Call this function to drop BBOX and SRID from LWGEOM.
LWGEOM * lwgeom_flip_coordinates(LWGEOM *in)
Reverse the X and Y coordinate order.
static void test_lwgeom_free(void)
int gserialized_is_empty(const GSERIALIZED *g)
Check if a GSERIALIZED is empty without deserializing first.
float next_float_up(double d)
int lwgeom_calculate_gbox(const LWGEOM *lwgeom, GBOX *gbox)
Calculate bounding box of a geometry, automatically taking into account whether it is cartesian or ge...
#define LW_PARSER_CHECK_NONE
#define FLAGS_SET_Z(flags, value)
void lwgeom_force_clockwise(LWGEOM *lwgeom)
Ensure the outer ring is clockwise oriented and all inner rings are counter-clockwise.
void gbox_float_round(GBOX *gbox)
Round given GBOX to float boundaries.
static void do_lwgeom_flip_coordinates(char *in, char *out)
void lwmpoint_free(LWMPOINT *mpt)
static void test_serialized_srid(void)
void libgeom_suite_setup(void)
void gbox_init(GBOX *gbox)
Zero out all the entries in the GBOX.
static void test_f2d(void)
#define FLAGS_GET_BBOX(flags)
void test_signum_macro(void)
static void test_lwgeom_calculate_gbox(void)
LWLINE * lwline_from_lwmpoint(int srid, const LWMPOINT *mpoint)
#define SRID_UNKNOWN
Unknown SRID value.
#define PG_ADD_TEST(suite, testfunc)
static void test_lwgeom_is_empty(void)
void test_gserialized_peek_gbox_p_fails_for_unsupported_cases(void)
#define TYPMOD_SET_TYPE(typmod, type)
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
int gbox_same_2d(const GBOX *g1, const GBOX *g2)
Check if 2 given GBOX are the same in x and y.
LWGEOM * lwgeom_clone(const LWGEOM *lwgeom)
Clone LWGEOM object.
char lwgeom_same(const LWGEOM *lwgeom1, const LWGEOM *lwgeom2)
geom1 same as geom2 iff
uint8_t gflags(int hasz, int hasm, int geodetic)
Construct a new flags char.
LWGEOM * lwgeom_from_hexwkb(const char *hexwkb, const char check)
#define FLAGS_SET_BBOX(flags, value)
void test_gserialized_peek_gbox_p_gets_correct_box(void)
static void test_lwgeom_flip_coordinates(void)
static void test_lwgeom_clone(void)
size_t gserialized_from_lwgeom_size(const LWGEOM *geom)
Calculate required memory segment to contain a serialized form of the LWGEOM.
static void test_lwgeom_same(void)
static void test_lwline_from_lwmpoint(void)
static void test_lwgeom_from_gserialized(void)
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
void lwgeom_add_bbox(LWGEOM *lwgeom)
Compute a bbox if not already computed.
#define FLAGS_GET_M(flags)
static size_t gserialized_from_lwgeom_any(const LWGEOM *geom, uint8_t *buf)
void lwcollection_free(LWCOLLECTION *col)
#define ASSERT_DOUBLE_EQUAL(o, e)
#define TYPMOD_SET_SRID(typmod, srid)
LWGEOM * lwgeom_as_curve(const LWGEOM *lwgeom)
Create a new LWGEOM of the appropriate CURVE* type.
int lwgeom_is_clockwise(LWGEOM *lwgeom)
Check clockwise orientation on LWGEOM polygons.
#define TYPMOD_GET_Z(typmod)
void * lwalloc(size_t size)
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members) ...
GSERIALIZED * gserialized_from_lwgeom(LWGEOM *geom, size_t *size)
Allocate a new GSERIALIZED from an LWGEOM.
int lwgeom_count_vertices(const LWGEOM *geom)
Count the total number of vertices in any LWGEOM.
int gbox_same_2d_float(const GBOX *g1, const GBOX *g2)
Check if two given GBOX are the same in x and y, or would round to the same GBOX in x and if serializ...
int gbox_same(const GBOX *g1, const GBOX *g2)
Check if 2 given Gbox are the same.
void test_gserialized_peek_gbox_p_no_box_when_empty(void)
static void test_lwgeom_count_vertices(void)
int32_t gserialized_get_srid(const GSERIALIZED *s)
Extract the SRID from the serialized form (it is packed into three bytes so this is a handy function)...
size_t gbox_serialized_size(uint8_t flags)
Return the number of bytes necessary to hold a GBOX of this dimension in serialized form...
#define SIGNUM(n)
Macro that returns: -1 if n < 0, 1 if n > 0, 0 if n == 0.
#define FLAGS_SET_READONLY(flags, value)
#define FLAGS_SET_M(flags, value)
int lwgeom_calculate_gbox_cartesian(const LWGEOM *lwgeom, GBOX *gbox)
Calculate the 2-4D bounding box of a geometry.