PostGIS  2.1.10dev-r@@SVN_REVISION@@
static void cu_wkb_in ( char *  wkt)
static

Definition at line 63 of file cu_in_wkb.c.

References 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_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().

64 {
66  LWGEOM *g_a, *g_b;
67  uint8_t *wkb_a, *wkb_b;
68  size_t wkb_size_a, wkb_size_b;
69  /* int i; char *hex; */
70 
71  if ( hex_a ) free(hex_a);
72  if ( hex_b ) free(hex_b);
73 
74  /* Turn WKT into geom */
76  if ( pr.errcode )
77  {
78  printf("ERROR: %s\n", pr.message);
79  printf("POSITION: %d\n", pr.errlocation);
80  exit(0);
81  }
82 
83  /* Get the geom */
84  g_a = pr.geom;
85 
86  /* Turn geom into WKB */
87  wkb_a = lwgeom_to_wkb(g_a, WKB_NDR | WKB_EXTENDED, &wkb_size_a);
88 
89  /* Turn WKB back into geom */
90  g_b = lwgeom_from_wkb(wkb_a, wkb_size_a, LW_PARSER_CHECK_NONE);
91 
92  /* Turn geom to WKB again */
93  wkb_b = lwgeom_to_wkb(g_b, WKB_NDR | WKB_EXTENDED, &wkb_size_b);
94 
95  /* Turn geoms into WKB for comparisons */
96  hex_a = hexbytes_from_bytes(wkb_a, wkb_size_a);
97  hex_b = hexbytes_from_bytes(wkb_b, wkb_size_b);
98 
99  /* Clean up */
100  lwfree(wkb_a);
101  lwfree(wkb_b);
103  lwgeom_free(g_b);
104 }
#define WKB_NDR
Definition: liblwgeom.h:1770
void lwfree(void *mem)
Definition: lwutil.c:190
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1006
void lwgeom_parser_result_free(LWGEOM_PARSER_RESULT *parser_result)
Definition: lwin_wkt.c:825
char * hexbytes_from_bytes(uint8_t *bytes, size_t size)
Definition: lwout_wkb.c:23
char * hex_a
Definition: cu_in_wkb.c:24
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:1706
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:692
int lwgeom_parse_wkt(LWGEOM_PARSER_RESULT *parser_result, char *wktstr, int parse_flags)
Parse a WKT geometry string into an LWGEOM structure.
Parser result structure: returns the result of attempting to convert (E)WKT/(E)WKB to LWGEOM...
Definition: liblwgeom.h:1713
#define WKB_EXTENDED
Definition: liblwgeom.h:1769
char * hex_b
Definition: cu_in_wkb.c:25
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:728

Here is the call graph for this function:

Here is the caller graph for this function: