PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ cu_twkb_in()

static void cu_twkb_in ( char *  wkt)
static

Definition at line 53 of file cu_in_twkb.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_twkb(), lwgeom_parse_wkt(), lwgeom_parser_result_free(), lwgeom_to_twkb(), struct_lwgeom_parser_result::message, precision, 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().

54 {
56  LWGEOM *g_a, *g_b;
57  uint8_t *twkb_a, *twkb_b;
58  size_t twkb_size_a, twkb_size_b;
59  /* int i; char *hex; */
60 
61  /* Turn WKT into geom */
63  if ( pr.errcode )
64  {
65  printf("ERROR: %s\n", pr.message);
66  printf("POSITION: %d\n", pr.errlocation);
67  exit(0);
68  }
69 
70  /* Get the geom */
71  g_a = pr.geom;
72 
73  /* Turn geom into TWKB */
74  twkb_a = lwgeom_to_twkb(g_a, variant, precision, precision, precision, &twkb_size_a);
75 
76  // printf("\n Size: %ld\n", twkb_size_a);
77 
78  /* Turn TWKB back into geom */
79  g_b = lwgeom_from_twkb(twkb_a, twkb_size_a, LW_PARSER_CHECK_NONE);
80 
81  // printf("\n Org: %s\n 1st: %s\n 2nd: %s\n", wkt, lwgeom_to_ewkt(g_a), lwgeom_to_ewkt(g_b));
82 
83  /* Turn geom to TWKB again */
84  twkb_b = lwgeom_to_twkb(g_b, variant, precision, precision, precision, &twkb_size_b);
85 
86  /* Turn TWKB into hex for comparisons */
87  if ( hex_a ) lwfree(hex_a);
88  if ( hex_b ) lwfree(hex_b);
89  hex_a = hexbytes_from_bytes(twkb_a, twkb_size_a);
90  hex_b = hexbytes_from_bytes(twkb_b, twkb_size_b);
91 
92  /* Clean up */
93  lwfree(twkb_a);
94  lwfree(twkb_b);
96  lwgeom_free(g_b);
97 }
uint8_t variant
Definition: cu_in_twkb.c:26
void lwfree(void *mem)
Definition: lwutil.c:244
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1099
void lwgeom_parser_result_free(LWGEOM_PARSER_RESULT *parser_result)
Definition: lwin_wkt.c:885
char * hexbytes_from_bytes(uint8_t *bytes, size_t size)
Definition: lwout_wkb.c:39
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:2013
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:2020
uint8_t precision
Definition: cu_in_twkb.c:25
char * hex_b
Definition: cu_in_twkb.c:24
LWGEOM * lwgeom_from_twkb(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:656
char * hex_a
Definition: cu_in_twkb.c:23
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)
Definition: lwout_twkb.c:615
unsigned char uint8_t
Definition: uthash.h:79
Here is the call graph for this function:
Here is the caller graph for this function: