PostGIS  2.2.7dev-r@@SVN_REVISION@@
static void test_gserialized_from_lwgeom ( void  )
static

Definition at line 888 of file cu_geodetic.c.

References LWGEOM::flags, FLAGS_SET_GEODETIC, gserialized_from_lwgeom(), gserialized_get_type(), LW_PARSER_CHECK_NONE, lwfree(), lwgeom_free(), lwgeom_from_wkt(), MULTILINETYPE, POINTTYPE, and POLYGONTYPE.

Referenced by geodetic_suite_setup().

889 {
890  LWGEOM *geom;
891  GSERIALIZED *g;
892  uint32_t type;
893  double *inspect; /* To poke right into the blob. */
894 
895  geom = lwgeom_from_wkt("POINT(0 0.2)", LW_PARSER_CHECK_NONE);
896  FLAGS_SET_GEODETIC(geom->flags, 1);
897  g = gserialized_from_lwgeom(geom, 1, 0);
898  type = gserialized_get_type(g);
899  CU_ASSERT_EQUAL( type, POINTTYPE );
900  inspect = (double*)g;
901  CU_ASSERT_EQUAL(inspect[3], 0.2);
902  lwgeom_free(geom);
903  lwfree(g);
904 
905  geom = lwgeom_from_wkt("POLYGON((-1 -1, -1 2.5, 2 2, 2 -1, -1 -1), (0 0, 0 1, 1 1, 1 0, 0 0))", LW_PARSER_CHECK_NONE);
906  FLAGS_SET_GEODETIC(geom->flags, 1);
907  g = gserialized_from_lwgeom(geom, 1, 0);
908  type = gserialized_get_type(g);
909  CU_ASSERT_EQUAL( type, POLYGONTYPE );
910  inspect = (double*)g;
911  CU_ASSERT_EQUAL(inspect[9], 2.5);
912  lwgeom_free(geom);
913  lwfree(g);
914 
915  geom = lwgeom_from_wkt("MULTILINESTRING((0 0, 1 1),(0 0.1, 1 1))", LW_PARSER_CHECK_NONE);
916  FLAGS_SET_GEODETIC(geom->flags, 1);
917  g = gserialized_from_lwgeom(geom, 1, 0);
918  type = gserialized_get_type(g);
919  CU_ASSERT_EQUAL( type, MULTILINETYPE );
920  inspect = (double*)g;
921  CU_ASSERT_EQUAL(inspect[12], 0.1);
922  lwgeom_free(geom);
923  lwfree(g);
924 
925 }
uint32_t gserialized_get_type(const GSERIALIZED *s)
Extract the geometry type from the serialized form (it hides in the anonymous data area...
Definition: g_serialized.c:55
void lwfree(void *mem)
Definition: lwutil.c:214
#define POLYGONTYPE
Definition: liblwgeom.h:72
uint8_t flags
Definition: liblwgeom.h:381
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1050
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition: lwin_wkt.c:890
#define FLAGS_SET_GEODETIC(flags, value)
Definition: liblwgeom.h:133
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:1869
GSERIALIZED * gserialized_from_lwgeom(LWGEOM *geom, int is_geodetic, size_t *size)
Allocate a new GSERIALIZED from an LWGEOM.
Definition: g_serialized.c:906
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:70
#define MULTILINETYPE
Definition: liblwgeom.h:74

Here is the call graph for this function:

Here is the caller graph for this function: