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

Definition at line 868 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().

869 {
870  LWGEOM *geom;
871  GSERIALIZED *g;
872  uint32_t type;
873  double *inspect; /* To poke right into the blob. */
874 
875  geom = lwgeom_from_wkt("POINT(0 0.2)", LW_PARSER_CHECK_NONE);
876  FLAGS_SET_GEODETIC(geom->flags, 1);
877  g = gserialized_from_lwgeom(geom, 1, 0);
878  type = gserialized_get_type(g);
879  CU_ASSERT_EQUAL( type, POINTTYPE );
880  inspect = (double*)g;
881  CU_ASSERT_EQUAL(inspect[3], 0.2);
882  lwgeom_free(geom);
883  lwfree(g);
884 
885  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);
886  FLAGS_SET_GEODETIC(geom->flags, 1);
887  g = gserialized_from_lwgeom(geom, 1, 0);
888  type = gserialized_get_type(g);
889  CU_ASSERT_EQUAL( type, POLYGONTYPE );
890  inspect = (double*)g;
891  CU_ASSERT_EQUAL(inspect[9], 2.5);
892  lwgeom_free(geom);
893  lwfree(g);
894 
895  geom = lwgeom_from_wkt("MULTILINESTRING((0 0, 1 1),(0 0.1, 1 1))", 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, MULTILINETYPE );
900  inspect = (double*)g;
901  CU_ASSERT_EQUAL(inspect[12], 0.1);
902  lwgeom_free(geom);
903  lwfree(g);
904 
905 }
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:56
void lwfree(void *mem)
Definition: lwutil.c:190
#define POLYGONTYPE
Definition: liblwgeom.h:62
uint8_t flags
Definition: liblwgeom.h:353
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1006
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition: lwin_wkt.c:844
#define FLAGS_SET_GEODETIC(flags, value)
Definition: liblwgeom.h:115
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:1706
GSERIALIZED * gserialized_from_lwgeom(LWGEOM *geom, int is_geodetic, size_t *size)
Allocate a new GSERIALIZED from an LWGEOM.
Definition: g_serialized.c:908
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:60
#define MULTILINETYPE
Definition: liblwgeom.h:64

Here is the call graph for this function:

Here is the caller graph for this function: