PostGIS  2.5.7dev-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  uint8_t *wkb_a, *wkb_b;
67  size_t wkb_size_a, wkb_size_b;
68  /* int i; char *hex; */
69 
70  if ( hex_a ) free(hex_a);
71  if ( hex_b ) free(hex_b);
72 
73  /* Turn WKT into geom */
75  if ( pr.errcode )
76  {
77  printf("ERROR: %s\n", pr.message);
78  printf("POSITION: %d\n", pr.errlocation);
79  exit(0);
80  }
81 
82  /* Get the geom */
83  g_a = pr.geom;
84 
85  /* Turn geom into WKB */
86  wkb_a = lwgeom_to_wkb(g_a, WKB_NDR | WKB_EXTENDED, &wkb_size_a);
87 
88  /* Turn WKB back into geom */
89  g_b = lwgeom_from_wkb(wkb_a, wkb_size_a, LW_PARSER_CHECK_NONE);
90 
91  /* Turn geom to WKB again */
92  wkb_b = lwgeom_to_wkb(g_b, WKB_NDR | WKB_EXTENDED, &wkb_size_b);
93 
94  /* Turn geoms into WKB for comparisons */
95  hex_a = hexbytes_from_bytes(wkb_a, wkb_size_a);
96  hex_b = hexbytes_from_bytes(wkb_b, wkb_size_b);
97 
98  /* Clean up */
99  lwfree(wkb_a);
100  lwfree(wkb_b);
102  lwgeom_free(g_b);
103 }
static char * hex_a
Definition: cu_in_wkb.c:23
static char * hex_b
Definition: cu_in_wkb.c:24
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1144
char * hexbytes_from_bytes(const uint8_t *bytes, size_t size)
Definition: lwout_wkb.c:39
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:2005
int lwgeom_parse_wkt(LWGEOM_PARSER_RESULT *parser_result, char *wktstr, int parse_flags)
Parse a WKT geometry string into an LWGEOM structure.
uint8_t * lwgeom_to_wkb(const LWGEOM *geom, uint8_t variant, size_t *size_out)
Convert LWGEOM to a char* in WKB format.
Definition: lwout_wkb.c:764
void lwfree(void *mem)
Definition: lwutil.c:244
#define WKB_EXTENDED
Definition: liblwgeom.h:2068
#define WKB_NDR
Definition: liblwgeom.h:2069
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:789
void lwgeom_parser_result_free(LWGEOM_PARSER_RESULT *parser_result)
Definition: lwin_wkt.c:885
void free(void *)
Parser result structure: returns the result of attempting to convert (E)WKT/(E)WKB to LWGEOM.
Definition: liblwgeom.h:2013
unsigned char uint8_t
Definition: uthash.h:79

References 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(), struct_lwgeom_parser_result::message, 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: