PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ do_geojson_test()

static void do_geojson_test ( const char *  exp,
char *  in,
char *  exp_srs 
)
static

Definition at line 21 of file cu_in_geojson.c.

22 {
23  LWGEOM *g;
24  char * h = NULL;
25  char * srs = NULL;
26  size_t size;
27 
28  g = lwgeom_from_geojson(in, &srs);
29  if ( ! g )
30  {
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  {
40  fprintf(stderr, "\nIn: %s\nExp: %s\nObt: %s\n", in, exp, h);
41  CU_ASSERT_STRING_EQUAL(h, exp);
42  }
43  else
44  {
45  CU_ASSERT_STRING_EQUAL(h, exp);
46  }
47 
48  if ( exp_srs )
49  {
50  if ( ! srs )
51  {
52  fprintf(stderr, "\nIn: %s\nExp: %s\nObt: (null)\n", in, exp_srs);
53  CU_ASSERT_EQUAL(srs, exp_srs);
54  }
55  else if (strcmp(srs, exp_srs))
56  {
57  fprintf(stderr, "\nIn: %s\nExp: %s\nObt: %s\n", in, exp_srs, srs);
58  CU_ASSERT_STRING_EQUAL(srs, exp_srs);
59  }
60  }
61  else if ( srs )
62  {
63  fprintf(stderr, "\nIn: %s\nExp: (null)\nObt: %s\n", in, srs);
64  CU_ASSERT_EQUAL(srs, exp_srs);
65  }
66 
67  lwgeom_free(g);
68  if ( h ) lwfree(h);
69  if ( srs ) lwfree(srs);
70 }
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:411
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1155
#define WKT_EXTENDED
Definition: liblwgeom.h:2186
void lwfree(void *mem)
Definition: lwutil.c:242
char * lwgeom_to_wkt(const LWGEOM *geom, uint8_t variant, int precision, size_t *size_out)
WKT emitter function.
Definition: lwout_wkt.c:708

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

Referenced by in_geojson_test_srid().

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