PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ cu_wkb_in()

static void cu_wkb_in ( char *  wkt)
static

Definition at line 62 of file cu_in_wkb.c.

63 {
65  LWGEOM *g_a, *g_b;
66  lwvarlena_t *wkb_a, *wkb_b;
67  /* int i; char *hex; */
68 
69  if ( hex_a ) free(hex_a);
70  if ( hex_b ) free(hex_b);
71 
72  /* Turn WKT into geom */
74  if ( pr.errcode )
75  {
76  printf("ERROR: %s\n", pr.message);
77  printf("POSITION: %d\n", pr.errlocation);
78  exit(0);
79  }
80 
81  /* Get the geom */
82  g_a = pr.geom;
83 
84  /* Turn geom into WKB */
86 
87  /* Turn WKB back into geom */
88  g_b = lwgeom_from_wkb((uint8_t *)wkb_a->data, LWSIZE_GET(wkb_a->size) - LWVARHDRSZ, LW_PARSER_CHECK_NONE);
89 
90  /* Turn geom to WKB again */
92 
93  /* Turn geoms into WKB for comparisons */
94  hex_a = hexbytes_from_bytes((uint8_t *)wkb_a->data, LWSIZE_GET(wkb_a->size) - LWVARHDRSZ);
95  hex_b = hexbytes_from_bytes((uint8_t *)wkb_b->data, LWSIZE_GET(wkb_b->size) - LWVARHDRSZ);
96 
97  /* Clean up */
98  lwfree(wkb_a);
99  lwfree(wkb_b);
101  lwgeom_free(g_b);
102 }
static char * hex_a
Definition: cu_in_wkb.c:23
static char * hex_b
Definition: cu_in_wkb.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
#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.
void lwfree(void *mem)
Definition: lwutil.c:242
#define WKB_EXTENDED
Definition: liblwgeom.h:2177
#define WKB_NDR
Definition: liblwgeom.h:2178
LWGEOM * lwgeom_from_wkb(const uint8_t *wkb, const size_t wkb_size, const char check)
WKB inputs must have a declared size, to prevent malformed WKB from reading off the end of the memory...
Definition: lwin_wkb.c:834
lwvarlena_t * lwgeom_to_wkb_varlena(const LWGEOM *geom, uint8_t variant)
Definition: lwout_wkb.c:851
void lwgeom_parser_result_free(LWGEOM_PARSER_RESULT *parser_result)
Definition: lwin_wkt.c:886
void free(void *)
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, free(), struct_lwgeom_parser_result::geom, hex_a, hex_b, hexbytes_from_bytes(), LW_PARSER_CHECK_NONE, lwfree(), lwgeom_free(), lwgeom_from_wkb(), lwgeom_parse_wkt(), lwgeom_parser_result_free(), lwgeom_to_wkb_varlena(), LWSIZE_GET, LWVARHDRSZ, struct_lwgeom_parser_result::message, lwvarlena_t::size, WKB_EXTENDED, and WKB_NDR.

Referenced by test_wkb_in_circularstring(), test_wkb_in_collection(), test_wkb_in_compoundcurve(), test_wkb_in_curvpolygon(), test_wkb_in_linestring(), test_wkb_in_multipoint(), test_wkb_in_multipolygon(), test_wkb_in_point(), and test_wkb_in_polygon().

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