PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ cu_twkb_in()

static void cu_twkb_in ( char *  wkt)
static

Definition at line 53 of file cu_in_twkb.c.

54 {
56  LWGEOM *g_a, *g_b;
57  /* int i; char *hex; */
58 
59  /* Turn WKT into geom */
61  if ( pr.errcode )
62  {
63  printf("ERROR: %s\n", pr.message);
64  printf("POSITION: %d\n", pr.errlocation);
65  exit(0);
66  }
67 
68  /* Get the geom */
69  g_a = pr.geom;
70 
71  /* Turn geom into TWKB */
73 
74  // printf("\n Size: %ld\n", twkb_size_a);
75 
76  /* Turn TWKB back into geom */
77  g_b = lwgeom_from_twkb((uint8_t *)twkb_a->data, LWSIZE_GET(twkb_a->size) - LWVARHDRSZ, LW_PARSER_CHECK_NONE);
78 
79  // printf("\n Org: %s\n 1st: %s\n 2nd: %s\n", wkt, lwgeom_to_ewkt(g_a), lwgeom_to_ewkt(g_b));
80 
81  /* Turn geom to TWKB again */
83 
84  /* Turn TWKB into hex for comparisons */
85  if ( hex_a ) lwfree(hex_a);
86  if ( hex_b ) lwfree(hex_b);
87  hex_a = hexbytes_from_bytes((uint8_t *)twkb_a->data, LWSIZE_GET(twkb_a->size) - LWVARHDRSZ);
88  hex_b = hexbytes_from_bytes((uint8_t *)twkb_b->data, LWSIZE_GET(twkb_b->size) - LWVARHDRSZ);
89 
90  /* Clean up */
91  lwfree(twkb_a);
92  lwfree(twkb_b);
94  lwgeom_free(g_b);
95 }
static char * hex_a
Definition: cu_in_twkb.c:23
static uint8_t variant
Definition: cu_in_twkb.c:26
static uint8_t precision
Definition: cu_in_twkb.c:25
static char * hex_b
Definition: cu_in_twkb.c:24
#define LWVARHDRSZ
Definition: liblwgeom.h:311
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1155
char * hexbytes_from_bytes(const uint8_t *bytes, size_t size)
Definition: lwout_wkb.c:40
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:2114
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...
Definition: lwin_twkb.c:654
#define LWSIZE_GET(varsize)
Macro for reading the size from the GSERIALIZED size attribute.
Definition: liblwgeom.h:324
int lwgeom_parse_wkt(LWGEOM_PARSER_RESULT *parser_result, char *wktstr, int parse_flags)
Parse a WKT geometry string into an LWGEOM structure.
lwvarlena_t * lwgeom_to_twkb(const LWGEOM *geom, uint8_t variant, int8_t precision_xy, int8_t precision_z, int8_t precision_m)
Definition: lwout_twkb.c:636
void lwfree(void *mem)
Definition: lwutil.c:242
void lwgeom_parser_result_free(LWGEOM_PARSER_RESULT *parser_result)
Definition: lwin_wkt.c:886
uint32_t size
Definition: liblwgeom.h:307
char data[]
Definition: liblwgeom.h:308
Parser result structure: returns the result of attempting to convert (E)WKT/(E)WKB to LWGEOM.
Definition: liblwgeom.h:2122

References lwvarlena_t::data, struct_lwgeom_parser_result::errcode, struct_lwgeom_parser_result::errlocation, struct_lwgeom_parser_result::geom, hex_a, hex_b, hexbytes_from_bytes(), LW_PARSER_CHECK_NONE, lwfree(), lwgeom_free(), lwgeom_from_twkb(), lwgeom_parse_wkt(), lwgeom_parser_result_free(), lwgeom_to_twkb(), LWSIZE_GET, LWVARHDRSZ, struct_lwgeom_parser_result::message, precision, lwvarlena_t::size, and variant.

Referenced by test_twkb_in_collection(), test_twkb_in_linestring(), test_twkb_in_multilinestring(), test_twkb_in_multipoint(), test_twkb_in_multipolygon(), test_twkb_in_point(), test_twkb_in_polygon(), and test_twkb_in_precision().

Here is the call graph for this function:
Here is the caller graph for this function: