15 #include "CUnit/Basic.h"
60 if ( ! g )
lwnotice(
"input wkt is invalid: %s", wkt);
78 if ( ! g )
lwnotice(
"input wkt is invalid: %s", wkt);
95 cu_twkb(
"POINT EMPTY", 0, 0, 0, 0);
96 CU_ASSERT_STRING_EQUAL(
s,
"0110");
98 cu_twkb(
"POINT(0 0)", 0, 0, 0, 0);
99 CU_ASSERT_STRING_EQUAL(
s,
"01000000");
101 cu_twkb(
"POINT(0 0 0 0)", 0, 0, 0, 0);
102 CU_ASSERT_STRING_EQUAL(
s,
"01080300000000");
106 CU_ASSERT_STRING_EQUAL(
s,
"0101000000000000");
111 CU_ASSERT_STRING_EQUAL(
s,
"0102020000");
115 CU_ASSERT_STRING_EQUAL(
s,
"010A0203000000");
119 CU_ASSERT_STRING_EQUAL(
s,
"010A030400000000");
122 cu_twkb(
"POINTZ(1 1 1)", 0,1,2, 0);
123 CU_ASSERT_STRING_EQUAL(
s,
"010845020214");
126 cu_twkb(
"POINTM(1 1 1)", 0,1,2, 0);
128 CU_ASSERT_STRING_EQUAL(
s,
"0108460202C801");
134 cu_twkb(
"LINESTRING(0 0,1 1)", 0, 0, 0, 0);
135 CU_ASSERT_STRING_EQUAL(
s,
"02000200000202");
138 cu_twkb(
"LINESTRING(0 0 1,1 1 2,2 2 3)", 0, 0, 0, 0);
139 CU_ASSERT_STRING_EQUAL(
s,
"02080103000002020202020202");
144 CU_ASSERT_STRING_EQUAL(
s,
"02010004000403000002020202");
147 cu_twkb(
"LINESTRING EMPTY", 0, 0, 0, 0);
148 CU_ASSERT_STRING_EQUAL(
s,
"0210");
154 cu_twkb(
"SRID=4;POLYGON((0 0 0, 0 1 0,1 1 0,1 0 0, 0 0 0))", 0, 0, 0, 0);
155 CU_ASSERT_STRING_EQUAL(
s,
"0308010105000000000200020000000100010000");
158 cu_twkb(
"SRID=14;POLYGON((0 0 0 1, 0 1 0 2,1 1 0 3,1 0 0 4, 0 0 0 5))", 0, 0, 0, 0);
159 CU_ASSERT_STRING_EQUAL(
s,
"03080301050000000200020002020000020001000201000002");
162 cu_twkb(
"POLYGON EMPTY", 0, 0, 0, 0);
163 CU_ASSERT_STRING_EQUAL(
s,
"0310");
169 cu_twkb(
"MULTIPOINT(0 0 0, 0 1 0,1 1 0,1 0 0, 0 0 0)", 0, 0, 0, 0);
170 CU_ASSERT_STRING_EQUAL(
s,
"04080105000000000200020000000100010000");
172 cu_twkb(
"MULTIPOINT(0 0 0, 0.26794919243112270647255365849413 1 3)",7 ,7 , 0, 0);
174 CU_ASSERT_STRING_EQUAL(
s,
"E4081D02000000888BC70280DAC409808ECE1C");
182 cu_twkb(
"MULTIPOLYGON(((0 0 0, 0 1 0,1 1 0,1 0 0, 0 0 0)),((-1 -1 0,-1 2 0,2 2 0,2 -1 0,-1 -1 0),(0 0 0, 0 1 0,1 1 0,1 0 0, 0 0 0)))", 0, 0, 0, 0);
183 CU_ASSERT_STRING_EQUAL(
s,
"060801020105000000000200020000000100010000020501010000060006000000050005000005020200000200020000000100010000");
188 cu_twkb(
"GEOMETRYCOLLECTION(LINESTRING(1 1, 2 2), LINESTRING(3 3, 4 4), LINESTRING(5 5, 6 6))", 0, 0, 0, 0);
190 CU_ASSERT_STRING_EQUAL(
s,
"07000302000202020202020002060602020200020A0A0202");
192 cu_twkb(
"GEOMETRYCOLLECTION(POLYGON((0 0 0, 0 1 0,1 1 0,1 0 0, 0 0 0)),POINT(1 1 1))", 0, 0, 0, 0);
194 CU_ASSERT_STRING_EQUAL(
s,
"070801020308010105000000000200020000000100010000010801020202");
196 cu_twkb(
"GEOMETRYCOLLECTION EMPTY", 0, 0, 0, 0);
197 CU_ASSERT_STRING_EQUAL(
s,
"0710");
209 CU_ASSERT_STRING_EQUAL(
s,
"040402040802020101");
210 CU_ASSERT_STRING_EQUAL(
w,
"MULTIPOINT(1 1,0 0)");
225 CU_ASSERT_STRING_EQUAL(
s,
"04060702040802020101");
226 CU_ASSERT_STRING_EQUAL(
w,
"MULTIPOINT(1 1,0 0)");
242 CU_ASSERT_STRING_EQUAL(
s,
"04070B0002000202040802020101");
243 CU_ASSERT_STRING_EQUAL(
w,
"MULTIPOINT(1 1,0 0)");
254 cu_twkb_idlist(
"GEOMETRYCOLLECTION(POINT(1 1),POINT(0 0))",idlist, 0, 0, 0, 0);
256 CU_ASSERT_STRING_EQUAL(
s,
"07040204080100020201000000");
257 CU_ASSERT_STRING_EQUAL(
w,
"GEOMETRYCOLLECTION(POINT(1 1),POINT(0 0))");
271 CU_ASSERT_STRING_EQUAL(
s,
"07060D02040801020202020102020000");
272 CU_ASSERT_STRING_EQUAL(
w,
"GEOMETRYCOLLECTION(POINT(1 1),POINT(0 0))");
static void cu_twkb_idlist(char *wkt, int64_t *idlist, int8_t prec_xy, int8_t prec_z, int8_t prec_m, uint8_t variant)
static void test_twkb_out_polygon(void)
static void cu_twkb(char *wkt, int8_t prec_xy, int8_t prec_z, int8_t prec_m, uint8_t variant)
static int init_twkb_out_suite(void)
static void test_twkb_out_multipolygon(void)
static void test_twkb_out_multipoint(void)
void twkb_out_suite_setup(void)
static void test_twkb_out_point(void)
static void test_twkb_out_multilinestring(void)
static void test_twkb_out_idlist(void)
static void test_twkb_out_linestring(void)
static int clean_twkb_out_suite(void)
static void test_twkb_out_collection(void)
#define PG_ADD_TEST(suite, testfunc)
uint8_t * lwgeom_to_twkb_with_idlist(const LWGEOM *geom, int64_t *idlist, uint8_t variant, int8_t precision_xy, int8_t precision_z, int8_t precision_m, size_t *twkb_size)
Convert LWGEOM to a char* in TWKB format.
void lwgeom_free(LWGEOM *geom)
char * hexbytes_from_bytes(const uint8_t *bytes, size_t size)
#define LW_PARSER_CHECK_NONE
LWGEOM * lwgeom_from_twkb(const uint8_t *twkb, size_t twkb_size, char check)
WKB inputs must have a declared size, to prevent malformed WKB from reading off the end of the memory...
char * lwgeom_to_ewkt(const LWGEOM *lwgeom)
Return an alloced string.
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
uint8_t * lwgeom_to_twkb(const LWGEOM *geom, uint8_t variant, int8_t precision_xy, int8_t precision_z, int8_t precision_m, size_t *twkb_size)
void lwnotice(const char *fmt,...)
Write a notice out to the notice handler.