PostGIS 3.0.6dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ 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
44 if ( exp_srs )
45 {
46 if ( ! srs )
47 {
48 fprintf(stderr, "\nIn: %s\nExp: %s\nObt: (null)\n", in, exp_srs);
49 CU_ASSERT_EQUAL(srs, exp_srs);
50 }
51 else if (strcmp(srs, exp_srs))
52 {
53 fprintf(stderr, "\nIn: %s\nExp: %s\nObt: %s\n", in, exp_srs, srs);
54 CU_ASSERT_STRING_EQUAL(srs, exp_srs);
55 }
56 }
57 else if ( srs )
58 {
59 fprintf(stderr, "\nIn: %s\nExp: (null)\nObt: %s\n", in, srs);
60 CU_ASSERT_EQUAL(srs, exp_srs);
61 }
62
63 lwgeom_free(g);
64 if ( h ) lwfree(h);
65 if ( srs ) lwfree(srs);
66}
char cu_error_msg[MAX_CUNIT_ERROR_LENGTH+1]
void lwgeom_free(LWGEOM *geom)
Definition lwgeom.c:1138
#define WKT_EXTENDED
Definition liblwgeom.h:2132
char * lwgeom_to_wkt(const LWGEOM *geom, uint8_t variant, int precision, size_t *size_out)
WKT emitter function.
Definition lwout_wkt.c:676
void lwfree(void *mem)
Definition lwutil.c:242
LWGEOM * lwgeom_from_geojson(const char *geojson, char **srs)
Create an LWGEOM object from a GeoJSON representation.

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

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