PostGIS  2.1.10dev-r@@SVN_REVISION@@
static void do_geojson_test ( const char *  exp,
char *  in,
char *  exp_srs,
int  precision,
int  has_bbox 
)
static

Definition at line 22 of file cu_in_geojson.c.

References cu_error_msg, lwfree(), lwgeom_free(), lwgeom_from_geojson(), lwgeom_to_wkt(), and WKT_EXTENDED.

Referenced by in_geojson_test_bbox(), in_geojson_test_geoms(), and in_geojson_test_srid().

23 {
24  LWGEOM *g;
25  char * h = NULL;
26  char * srs = NULL;
27  size_t size;
28 
29  g = lwgeom_from_geojson(in, &srs);
30  if ( ! g ) {
31  fprintf(stderr, "\nIn: %s\nExp: %s\nObt: %s\n", in, exp, cu_error_msg);
32  CU_ASSERT(g != NULL);
33  return;
34  }
35 
36  h = lwgeom_to_wkt(g, WKT_EXTENDED, 15, &size);
37 
38  if (strcmp(h, exp)) {
39  fprintf(stderr, "\nIn: %s\nExp: %s\nObt: %s\n", in, exp, h);
40  CU_ASSERT_STRING_EQUAL(h, exp);
41  }
42 
43  if ( exp_srs ) {
44  if ( ! srs ) {
45  fprintf(stderr, "\nIn: %s\nExp: %s\nObt: (null)\n", in, exp_srs);
46  CU_ASSERT_EQUAL(srs, exp_srs);
47  }
48  else if (strcmp(srs, exp_srs)) {
49  fprintf(stderr, "\nIn: %s\nExp: %s\nObt: %s\n", in, exp_srs, srs);
50  CU_ASSERT_STRING_EQUAL(srs, exp_srs);
51  }
52  } else if ( srs ) {
53  fprintf(stderr, "\nIn: %s\nExp: (null)\nObt: %s\n", in, srs);
54  CU_ASSERT_EQUAL(srs, exp_srs);
55  }
56 
57  lwgeom_free(g);
58  if ( h ) lwfree(h);
59  if ( srs ) lwfree(srs);
60 }
char * lwgeom_to_wkt(const LWGEOM *geom, uint8_t variant, int precision, size_t *size_out)
WKT emitter function.
Definition: lwout_wkt.c:655
void lwfree(void *mem)
Definition: lwutil.c:190
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1006
#define WKT_EXTENDED
Definition: liblwgeom.h:1778
char cu_error_msg[MAX_CUNIT_ERROR_LENGTH+1]
LWGEOM * lwgeom_from_geojson(const char *geojson, char **srs)
Create an LWGEOM object from a GeoJSON representation.
Definition: lwin_geojson.c:510

Here is the call graph for this function:

Here is the caller graph for this function: