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);
129 CU_ASSERT_EQUAL(rv, srid);
140 CU_ASSERT_EQUAL(rv, srid);
145 CU_ASSERT_EQUAL(rv, srid);
150 CU_ASSERT_EQUAL(rv, srid);
160 CU_ASSERT_EQUAL( size, 32 );
165 CU_ASSERT_EQUAL( size, 40 );
170 CU_ASSERT_EQUAL( size, 80 );
175 CU_ASSERT_EQUAL( size, 48 );
180 CU_ASSERT_EQUAL( size, 96 );
185 CU_ASSERT_EQUAL( size, 104 );
188 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);
190 CU_ASSERT_EQUAL( size, 184 );
202 CU_ASSERT_DOUBLE_EQUAL(b.
xmin, 0.0, 0.0000001);
210 CU_ASSERT_DOUBLE_EQUAL(b.
xmin, 0.0, 0.0000001);
211 CU_ASSERT(isinf(b.
ymax));
218 CU_ASSERT_DOUBLE_EQUAL(b.
xmin, 0.0, 0.0000001);
219 CU_ASSERT(isinf(b.
ymax));
226 CU_ASSERT(isnan(b.
ymax));
244 "LINESTRING(-1 -1,-1 2.5,2 2,2 -1)",
246 "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)",
247 "SRID=1;MULTILINESTRING EMPTY",
248 "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))",
249 "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))",
250 "POLYGON((-1 -1,-1 2.5,2 2,2 -1,-1 -1),(0 0,0 1,1 1,1 0,0 0))",
252 "SRID=4326;POLYGON((-1 -1,-1 2.5,2 2,2 -1,-1 -1),(0 0,0 1,1 1,1 0,0 0))",
253 "SRID=4326;POLYGON EMPTY",
254 "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))",
255 "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))",
256 "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)))",
257 "SRID=4326;MULTIPOLYGON EMPTY",
258 "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))))",
259 "SRID=4326;GEOMETRYCOLLECTION EMPTY",
260 "SRID=4326;GEOMETRYCOLLECTION(POINT EMPTY,MULTIPOLYGON EMPTY)",
261 "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))",
262 "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)))",
263 "MULTISURFACE(CURVEPOLYGON(CIRCULARSTRING EMPTY))",
266 for ( i = 0; i < (
sizeof ewkt/
sizeof(
char*)); i++ )
277 CU_ASSERT_EQUAL(sz1, sz2);
283 CU_ASSERT_STRING_EQUAL(in_ewkt, out_ewkt);
286 CU_ASSERT( (geom->
bbox != NULL) || (geom2->
bbox == NULL) );
303 struct gserialized_empty_cases {
308 struct gserialized_empty_cases cases[] = {
309 {
"POINT EMPTY", 1 },
311 {
"LINESTRING EMPTY", 1 },
312 {
"MULTILINESTRING EMPTY", 1 },
313 {
"MULTILINESTRING(EMPTY)", 1 },
314 {
"MULTILINESTRING(EMPTY,EMPTY)", 1 },
315 {
"MULTILINESTRING(EMPTY,(0 0,1 1))", 0 },
316 {
"MULTILINESTRING((0 0,1 1),EMPTY)", 0 },
317 {
"MULTILINESTRING(EMPTY,(0 0,1 1),EMPTY)", 0 },
318 {
"MULTILINESTRING(EMPTY,EMPTY,EMPTY)", 1 },
319 {
"GEOMETRYCOLLECTION(POINT EMPTY,MULTILINESTRING(EMPTY,EMPTY,EMPTY))", 1 },
320 {
"GEOMETRYCOLLECTION(POINT EMPTY,MULTILINESTRING(EMPTY),POINT(1 1))", 0 },
321 {
"GEOMETRYCOLLECTION(POINT EMPTY,MULTILINESTRING(EMPTY, (0 0)),POINT EMPTY)", 0 },
322 {
"GEOMETRYCOLLECTION(POLYGON EMPTY,POINT EMPTY,MULTILINESTRING(EMPTY,EMPTY),POINT EMPTY)", 1 },
323 {
"GEOMETRYCOLLECTION(POLYGON EMPTY,GEOMETRYCOLLECTION(POINT EMPTY),MULTILINESTRING(EMPTY,EMPTY),POINT EMPTY)", 1 },
327 while( cases[i].wkt )
334 CU_ASSERT_EQUAL(ie, cases[i].isempty);
354 CU_ASSERT_EQUAL(z, 1);
355 CU_ASSERT_EQUAL(m, 0);
357 str =
"LINESTRINGM ";
362 CU_ASSERT_EQUAL(z, 0);
363 CU_ASSERT_EQUAL(m, 1);
365 str =
"MULTIPOLYGONZM";
370 CU_ASSERT_EQUAL(z, 1);
371 CU_ASSERT_EQUAL(m, 1);
373 str =
" GEOMETRYCOLLECTIONZM ";
378 CU_ASSERT_EQUAL(z, 1);
379 CU_ASSERT_EQUAL(m, 1);
381 str =
" GEOMERYCOLLECTIONZM ";
396 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);
400 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);
505 testbox = (g->
bbox != NULL);
516 CU_ASSERT_DOUBLE_EQUAL(g->
bbox->
xmax, ymax, 0.00001);
517 CU_ASSERT_DOUBLE_EQUAL(g->
bbox->
ymax, xmax, 0.00001);
521 if (t == NULL) fprintf(stderr,
"In:%s", in);
523 fprintf(stderr,
"\nIn: %s\nOut: %s\nTheo: %s\n", in, t, out);
525 CU_ASSERT_STRING_EQUAL(t, out)
542 "LINESTRING(1 2,3 4)",
543 "LINESTRING(2 1,4 3)"
547 "POLYGON((1 2,3 4,5 6,1 2))",
548 "POLYGON((2 1,4 3,6 5,2 1))"
552 "POLYGON((1 2,3 4,5 6,1 2),(7 8,9 10,11 12,7 8))",
553 "POLYGON((2 1,4 3,6 5,2 1),(8 7,10 9,12 11,8 7))"
557 "MULTIPOINT(1 2,3 4)",
558 "MULTIPOINT(2 1,4 3)"
562 "MULTILINESTRING((1 2,3 4),(5 6,7 8))",
563 "MULTILINESTRING((2 1,4 3),(6 5,8 7))"
567 "MULTIPOLYGON(((1 2,3 4,5 6,7 8)),((9 10,11 12,13 14,10 9)))",
568 "MULTIPOLYGON(((2 1,4 3,6 5,8 7)),((10 9,12 11,14 13,9 10)))"
572 "GEOMETRYCOLLECTION EMPTY",
573 "GEOMETRYCOLLECTION EMPTY"
577 "GEOMETRYCOLLECTION(POINT(1 2),LINESTRING(3 4,5 6))",
578 "GEOMETRYCOLLECTION(POINT(2 1),LINESTRING(4 3,6 5))"
582 "GEOMETRYCOLLECTION(POINT(1 2),GEOMETRYCOLLECTION(LINESTRING(3 4,5 6)))",
583 "GEOMETRYCOLLECTION(POINT(2 1),GEOMETRYCOLLECTION(LINESTRING(4 3,6 5)))"
587 "CIRCULARSTRING(-2 0,0 2,2 0,0 2,2 4)",
588 "CIRCULARSTRING(0 -2,2 0,0 2,2 0,4 2)"
592 "COMPOUNDCURVE(CIRCULARSTRING(0 1,1 1,1 0),(1 0,0 1))",
593 "COMPOUNDCURVE(CIRCULARSTRING(1 0,1 1,0 1),(0 1,1 0))"
597 "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))",
598 "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))"
602 "MULTICURVE((5 5,3 5,3 3,0 3),CIRCULARSTRING(0 0,2 1,2 3))",
603 "MULTICURVE((5 5,5 3,3 3,3 0),CIRCULARSTRING(0 0,1 2,3 2))"
607 "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)))",
608 "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)))"
637 "SRID=4326;POINT(1 2)",
638 "SRID=4326;POINT(2 1)"
649 double d = 1000000.123456789123456789;
655 CU_ASSERT_DOUBLE_EQUAL(f,d, 0.0000001);
658 CU_ASSERT_DOUBLE_EQUAL(f,e, 0.0000001);
662 CU_ASSERT_DOUBLE_EQUAL(f,d, 0.0000001);
666 CU_ASSERT_DOUBLE_EQUAL(f,d, 0.0000001);
670 CU_ASSERT_DOUBLE_EQUAL(f,d, 0.0000001);
675 CU_ASSERT_DOUBLE_EQUAL(f, d, 0.0000001);
680 CU_ASSERT_DOUBLE_EQUAL(f, d, 0.0000001);
685 CU_ASSERT_DOUBLE_EQUAL(f, d, 0.0000001);
690 CU_ASSERT_DOUBLE_EQUAL(f, d, 0.0000001);
706 "LINESTRING(-1 -1,-1 2.5,2 2,2 -1)",
707 "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)",
708 "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))",
709 "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))",
710 "POLYGON((-1 -1,-1 2.5,2 2,2 -1,-1 -1),(0 0,0 1,1 1,1 0,0 0))",
711 "SRID=4326;POLYGON((-1 -1,-1 2.5,2 2,2 -1,-1 -1),(0 0,0 1,1 1,1 0,0 0))",
712 "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))",
713 "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))",
714 "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)))",
715 "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))))",
716 "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))",
717 "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)))",
718 "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)))"
722 for ( i = 0; i < (
sizeof ewkt/
sizeof(
char *)); i++ )
732 if (strcmp(in_ewkt, out_ewkt))
733 fprintf(stderr,
"\nExp: %s\nObt: %s\n", in_ewkt, out_ewkt);
734 CU_ASSERT_STRING_EQUAL(in_ewkt, out_ewkt);
750 char *in_ewkt, *out_ewkt;
756 in_ewkt =
"POLYGON((0 0,0 10,10 10,10 0,0 0))";
758 if (strcmp(in_ewkt, out_ewkt))
759 fprintf(stderr,
"\nExp: %s\nObt: %s\n", in_ewkt, out_ewkt);
760 CU_ASSERT_STRING_EQUAL(in_ewkt, out_ewkt);
768 in_ewkt =
"POLYGON((0 0,0 10,10 10,10 0,0 0))";
770 if (strcmp(in_ewkt, out_ewkt))
771 fprintf(stderr,
"\nExp: %s\nObt: %s\n", in_ewkt, out_ewkt);
772 CU_ASSERT_STRING_EQUAL(in_ewkt, out_ewkt);
777 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);
780 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))";
782 if (strcmp(in_ewkt, out_ewkt))
783 fprintf(stderr,
"\nExp: %s\nObt: %s\n", in_ewkt, out_ewkt);
784 CU_ASSERT_STRING_EQUAL(in_ewkt, out_ewkt);
789 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);
792 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))";
794 if (strcmp(in_ewkt, out_ewkt))
795 fprintf(stderr,
"\nExp: %s\nObt: %s\n", in_ewkt, out_ewkt);
796 CU_ASSERT_STRING_EQUAL(in_ewkt, out_ewkt);
802 in_ewkt =
"0103000000010000000500000000917E9BA468294100917E9B8AEA2841C976BE1FA4682941C976BE9F8AEA2841B39ABE1FA46829415ACCC29F8AEA284137894120A4682941C976BE9F8AEA284100917E9BA468294100917E9B8AEA2841";
849 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);
926 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);
931 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);
957 char *in_ewkt, *out_ewkt;
961 in_ewkt =
"COMPOUNDCURVE((0 0,10 0))";
963 if (strcmp(in_ewkt, out_ewkt))
964 fprintf(stderr,
"\nExp: %s\nObt: %s\n", in_ewkt, out_ewkt);
965 CU_ASSERT_STRING_EQUAL(in_ewkt, out_ewkt);
972 in_ewkt =
"MULTICURVE((0 0,10 0))";
974 if (strcmp(in_ewkt, out_ewkt))
975 fprintf(stderr,
"\nExp: %s\nObt: %s\n", in_ewkt, out_ewkt);
976 CU_ASSERT_STRING_EQUAL(in_ewkt, out_ewkt);
983 in_ewkt =
"CURVEPOLYGON((0 0,10 0,10 10,0 10,0 0))";
985 if (strcmp(in_ewkt, out_ewkt))
986 fprintf(stderr,
"\nExp: %s\nObt: %s\n", in_ewkt, out_ewkt);
987 CU_ASSERT_STRING_EQUAL(in_ewkt, out_ewkt);
994 in_ewkt =
"MULTISURFACE(((0 0,10 0,10 10,0 10,0 0)))";
996 if (strcmp(in_ewkt, out_ewkt))
997 fprintf(stderr,
"\nExp: %s\nObt: %s\n", in_ewkt, out_ewkt);
998 CU_ASSERT_STRING_EQUAL(in_ewkt, out_ewkt);
1029 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);
1030 factor.
x = 2; factor.
y = 3; factor.
z = 4; factor.
m = 5;
1033 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))");
1039 factor.
x = 2; factor.
y = 3; factor.
z = 4; factor.
m = 5;
1095 "MULTIPOINT (EMPTY)",
1096 "MULTILINESTRING EMPTY",
1097 "MULTILINESTRING (EMPTY)"
1100 for ( i = 0; i < (
sizeof ewkt/
sizeof(
char*)); i++ )
1123 "POINT (2.2945672355 48.85822923236)",
1124 "POINTZ (2.2945672355 48.85822923236 15)",
1125 "POINTM (2.2945672355 48.85822923236 12)",
1126 "POINT ZM (2.2945672355 48.85822923236 12 2)",
1127 "MULTIPOINT ((-76.45402132523 44.225406213532))",
1128 "MULTIPOINT Z ((-76.45402132523 44.225406213532 112))",
1129 "MULTIPOINT ZM ((-76.45402132523 44.225406213532 112 44))",
1130 "LINESTRING (2.2945672355 48.85822923236, -76.45402132523 44.225406213532)",
1131 "LINESTRING Z (2.2945672355 48.85822923236 6, -76.45402132523 44.225406213532 8)",
1132 "LINESTRING ZM (2.2945672355 48.85822923236 3 2, -76.45402132523 44.225406213532 9 4)",
1133 "MULTILINESTRING ((2.2945672355 48.85822923236, -76.45402132523 44.225406213532))",
1134 "MULTILINESTRING Z ((2.2945672355 48.85822923236 4, -76.45402132523 44.225406213532 3))"
1137 for ( i = 0; i < (
sizeof ewkt/
sizeof(
char*)); i++ )
1141 GBOX box_from_lwgeom;
1154 CU_ASSERT_TRUE(
gbox_same(&box_from_peek, &box_from_lwgeom));
1167 "MULTIPOINT ((-76.45402132523 44.225406213532), (-72 33))",
1168 "LINESTRING (2.2945672355 48.85822923236, -76.45402132523 44.225406213532, -72 33)",
1169 "MULTILINESTRING ((2.2945672355 48.85822923236, -76.45402132523 44.225406213532, -72 33))",
1170 "MULTILINESTRING ((2.2945672355 48.85822923236, -76.45402132523 44.225406213532), (-72 33, -71 32))"
1173 for ( i = 0; i < (
sizeof ewkt/
sizeof(
char*)); i++ )
1184 uint8_t* ptr = (uint8_t*) gser;
1200 CU_ASSERT_EQUAL(
SIGNUM(-5.0),-1);
1201 CU_ASSERT_EQUAL(
SIGNUM( 5.0), 1);
1202 CU_ASSERT_EQUAL(
SIGNUM( 0.0), 0);
1203 CU_ASSERT_EQUAL(
SIGNUM(10) * 5, 5);
1204 CU_ASSERT_EQUAL(
SIGNUM(-10) * 5, -5);
1211 p->
x = p->
y = p->
z = p->
m = 0;
1213 CU_ASSERT(geom != NULL);
1215 CU_ASSERT(g != NULL);
1230 CU_ASSERT_EQUAL(p.
x, 1);
1231 CU_ASSERT_EQUAL(p.
y, 2);
1234 CU_ASSERT_EQUAL(p.
x, 10);
1235 CU_ASSERT_EQUAL(p.
y, 20);
1236 CU_ASSERT_EQUAL(p.
z, 30);
1239 CU_ASSERT_EQUAL(p.
x, 100);
1240 CU_ASSERT_EQUAL(p.
y, 200);
1241 CU_ASSERT_EQUAL(p.
m, 300);
1244 CU_ASSERT_EQUAL(p.
x, 1000);
1245 CU_ASSERT_EQUAL(p.
y, 2000);
1246 CU_ASSERT_EQUAL(p.
z, 3000);
1247 CU_ASSERT_EQUAL(p.
m, 4000);
1261 CU_pSuite suite = CU_add_suite(
"serialization/deserialization v1", NULL, NULL);
static void test_lwgeom_count_vertices(void)
static void do_lwgeom_swap_ordinates(char *in, char *out)
static void test_lwgeom_clone(void)
static void test_gserialized1_peek_first_point(void)
static void test_lwgeom_as_curve(void)
static void test_gserialized1_from_lwgeom_size(void)
static void test_lwgeom_scale(void)
static void test_gserialized1_is_empty(void)
static void test_lwgeom_free(void)
static void test_gserialized1_peek_gbox_p_no_box_when_empty(void)
static void test_lwgeom_force_clockwise(void)
static void test_f2d(void)
static void test_flags_macros(void)
static void test_on_gser_lwgeom_count_vertices(void)
static void test_lwgeom_swap_ordinates(void)
static void test_gserialized1_peek_gbox_p_gets_correct_box(void)
static void test_gserialized1_peek_gbox_p_fails_for_unsupported_cases(void)
static void test_gbox_same_2d(void)
static void test_lwgeom_calculate_gbox(void)
static void test_serialized1_srid(void)
static void test_lwline_from_lwmpoint(void)
static void test_lwgeom_same(void)
static void test_lwcollection_extract(void)
static int peek1_point_helper(char *geometry, POINT4D *p)
void gserialized1_suite_setup(void)
static void test_typmod_macros(void)
static void test_geometry_type_from_string(void)
static void test_signum_macro(void)
static void test_lwgeom_from_gserialized(void)
static void test_lwgeom_is_empty(void)
int gbox_same(const GBOX *g1, const GBOX *g2)
Check if 2 given Gbox are the same.
int gbox_same_2d(const GBOX *g1, const GBOX *g2)
Check if 2 given GBOX are the same in x and y.
void gbox_float_round(GBOX *gbox)
Round given GBOX to float boundaries.
int lwgeom_calculate_gbox_cartesian(const LWGEOM *lwgeom, GBOX *gbox)
Calculate the 2-4D bounding box of a geometry.
void gbox_init(GBOX *gbox)
Zero out all the entries in the GBOX.
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...
static size_t gserialized1_from_lwgeom_any(const LWGEOM *geom, uint8_t *buf)
int gserialized1_is_empty(const GSERIALIZED *g)
Check if a GSERIALIZED is empty without deserializing first.
uint8_t g1flags(int has_z, int has_m, int is_geodetic)
int32_t gserialized1_get_srid(const GSERIALIZED *s)
Extract the SRID from the serialized form (it is packed into three bytes so this is a handy function)...
int gserialized1_peek_gbox_p(const GSERIALIZED *g, GBOX *gbox)
int gserialized1_has_bbox(const GSERIALIZED *gser)
Check if a GSERIALIZED has a bounding box without deserializing first.
GSERIALIZED * gserialized1_from_lwgeom(LWGEOM *geom, size_t *size)
Allocate a new GSERIALIZED from an LWGEOM.
int gserialized1_peek_first_point(const GSERIALIZED *g, POINT4D *out_point)
size_t gserialized1_from_lwgeom_size(const LWGEOM *geom)
Return the memory size a GSERIALIZED will occupy for a given LWGEOM.
uint8_t lwflags_get_g1flags(lwflags_t lwflags)
void gserialized1_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).
static int gserialized1_read_gbox_p(const GSERIALIZED *g, GBOX *gbox)
#define G1FLAGS_SET_Z(gflags, value)
#define G1FLAGS_GET_M(gflags)
#define G1FLAGS_SET_M(gflags, value)
#define G1FLAGS_GET_ZM(gflags)
#define G1FLAGS_SET_BBOX(gflags, value)
#define G1FLAGS_GET_BBOX(gflags)
#define G1FLAGS_SET_GEODETIC(gflags, value)
#define G1FLAGS_GET_GEODETIC(gflags)
#define G1FLAGS_GET_Z(gflags)
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void cu_error_msg_reset()
#define ASSERT_DOUBLE_EQUAL(o, e)
#define PG_ADD_TEST(suite, testfunc)
#define ASSERT_STRING_EQUAL(o, e)
#define TYPMOD_GET_SRID(typmod)
Macros for manipulating the 'typemod' int.
char lwgeom_same(const LWGEOM *lwgeom1, const LWGEOM *lwgeom2)
geom1 same as geom2 iff
#define TYPMOD_SET_SRID(typmod, srid)
void lwmpoint_free(LWMPOINT *mpt)
LWGEOM * lwgeom_from_hexwkb(const char *hexwkb, const char check)
void lwgeom_free(LWGEOM *geom)
#define LW_PARSER_CHECK_NONE
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
char * lwgeom_to_ewkt(const LWGEOM *lwgeom)
Return an alloced string.
void lwgeom_drop_bbox(LWGEOM *lwgeom)
Call this function to drop BBOX and SRID from LWGEOM.
int geometry_type_from_string(const char *str, uint8_t *type, int *z, int *m)
Utility function to get type number from string.
void lwgeom_scale(LWGEOM *geom, const POINT4D *factors)
#define TYPMOD_GET_M(typmod)
uint32_t lwgeom_count_vertices(const LWGEOM *geom)
Count the total number of vertices in any LWGEOM.
#define TYPMOD_SET_TYPE(typmod, type)
LWGEOM * lwgeom_as_curve(const LWGEOM *lwgeom)
Create a new LWGEOM of the appropriate CURVE* type.
void lwgeom_swap_ordinates(LWGEOM *in, LWORD o1, LWORD o2)
Swap ordinate values in every vertex of the geometry.
void lwgeom_force_clockwise(LWGEOM *lwgeom)
Force Right-hand-rule on LWGEOM polygons.
void lwcollection_free(LWCOLLECTION *col)
#define TYPMOD_GET_TYPE(typmod)
LWLINE * lwline_from_lwmpoint(int32_t srid, const LWMPOINT *mpoint)
char * lwgeom_to_wkt(const LWGEOM *geom, uint8_t variant, int precision, size_t *size_out)
WKT emitter function.
LWGEOM * lwgeom_clone(const LWGEOM *lwgeom)
Clone LWGEOM object.
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...
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
LWCOLLECTION * lwcollection_extract(LWCOLLECTION *col, int type)
Takes a potentially heterogeneous collection and returns a homogeneous collection consisting only of ...
void * lwalloc(size_t size)
float next_float_up(double d)
#define SRID_UNKNOWN
Unknown SRID value.
#define TYPMOD_SET_Z(typmod)
int lwgeom_is_clockwise(LWGEOM *lwgeom)
Ensure the outer ring is clockwise oriented and all inner rings are counter-clockwise.
#define TYPMOD_GET_Z(typmod)
void lwgeom_add_bbox(LWGEOM *lwgeom)
Compute a bbox if not already computed.
float next_float_down(double d)
void lwline_free(LWLINE *line)
double lwline_length_2d(const LWLINE *line)
#define SIGNUM(n)
Macro that returns: -1 if n < 0, 1 if n > 0, 0 if n == 0.
static int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)