PostGIS  2.5.0beta1dev-r@@SVN_REVISION@@

◆ test_lwgeom_check_geodetic()

static void test_lwgeom_check_geodetic ( void  )
static

Definition at line 800 of file cu_geodetic.c.

References LW_FALSE, LW_TRUE, lwfree(), lwgeom_check_geodetic(), lwgeom_free(), and lwgeom_over_gserialized().

Referenced by geodetic_suite_setup().

801 {
802  LWGEOM *geom;
803  int i = 0;
804 
805  char ewkt[][512] =
806  {
807  "POINT(0 0.2)",
808  "LINESTRING(-1 -1,-1 2.5,2 2,2 -1)",
809  "SRID=1;MULTILINESTRING((-1 -1,-1 2.5,2 2,2 -1),(-1 -1,-1 2.5,2 2,2 -1),(-1 -1,-1 2.5,2 2,2 -1),(-1 -1,-1 2.5,2 2,2 -1))",
810  "POLYGON((-1 -1,-1 2.5,2 2,2 -1,-1 -1),(0 0,0 1,1 1,1 0,0 0))",
811  "SRID=4326;MULTIPOLYGON(((-1 -1,-1 2.5,2 2,2 -1,-1 -1),(0 0,0 1,1 1,1 0,0 0),(-0.5 -0.5,-0.5 -0.4,-0.4 -0.4,-0.4 -0.5,-0.5 -0.5)),((-1 -1,-1 2.5,2 2,2 -1,-1 -1),(0 0,0 1,1 1,1 0,0 0),(-0.5 -0.5,-0.5 -0.4,-0.4 -0.4,-0.4 -0.5,-0.5 -0.5)))",
812  "SRID=4326;GEOMETRYCOLLECTION(POINT(0 1),POLYGON((-1 -1,-1 2.5,2 2,2 -1,-1 -1),(0 0,0 1,1 1,1 0,0 0)),MULTIPOLYGON(((-1 -1,-1 2.5,2 2,2 -1,-1 -1),(0 0,0 1,1 1,1 0,0 0),(-0.5 -0.5,-0.5 -0.4,-0.4 -0.4,-0.4 -0.5,-0.5 -0.5))))",
813  "POINT(0 220.2)",
814  "LINESTRING(-1 -1,-1231 2.5,2 2,2 -1)",
815  "SRID=1;MULTILINESTRING((-1 -131,-1 2.5,2 2,2 -1),(-1 -1,-1 2.5,2 2,2 -1),(-1 -1,-1 2.5,2 2,2 -1),(-1 -1,-1 2.5,2 2,2 -1))",
816  "POLYGON((-1 -1,-1 2.5,2 2,2 -133,-1 -1),(0 0,0 1,1 1,1 0,0 0))",
817  "SRID=4326;MULTIPOLYGON(((-1 -1,-1 2.5,211 2,2 -1,-1 -1),(0 0,0 1,1 1,1 0,0 0),(-0.5 -0.5,-0.5 -0.4,-0.4 -0.4,-0.4 -0.5,-0.5 -0.5)),((-1 -1,-1 2.5,2 2,2 -1,-1 -1),(0 0,0 1,1 1,1 0,0 0),(-0.5 -0.5,-0.5 -0.4,-0.4 -0.4,-0.4 -0.5,-0.5 -0.5)))",
818  "SRID=4326;GEOMETRYCOLLECTION(POINT(0 1),POLYGON((-1 -1,-1111 2.5,2 2,2 -1,-1 -1),(0 0,0 1,1 1,1 0,0 0)),MULTIPOLYGON(((-1 -1,-1 2.5,2 2,2 -1,-1 -1),(0 0,0 1,1 1,1 0,0 0),(-0.5 -0.5,-0.5 -0.4,-0.4 -0.4,-0.4 -0.5,-0.5 -0.5))))",
819  };
820 
821  for ( i = 0; i < 6; i++ )
822  {
823  GSERIALIZED *g;
824  geom = lwgeom_over_gserialized(ewkt[i], &g);
825  CU_ASSERT_EQUAL(lwgeom_check_geodetic(geom), LW_TRUE);
826  lwgeom_free(geom);
827  lwfree(g);
828  }
829 
830  for ( i = 6; i < 12; i++ )
831  {
832  GSERIALIZED *g;
833  //char *out_ewkt;
834  geom = lwgeom_over_gserialized(ewkt[i], &g);
835  CU_ASSERT_EQUAL(lwgeom_check_geodetic(geom), LW_FALSE);
836  //out_ewkt = lwgeom_to_ewkt(geom);
837  //printf("%s\n", out_ewkt);
838  lwgeom_free(geom);
839  lwfree(g);
840  }
841 
842 }
void lwfree(void *mem)
Definition: lwutil.c:244
int lwgeom_check_geodetic(const LWGEOM *geom)
Check that coordinates of LWGEOM are all within the geodetic range (-180, -90, 180, 90)
Definition: lwgeodetic.c:3043
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1144
#define LW_FALSE
Definition: liblwgeom.h:76
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:75
static LWGEOM * lwgeom_over_gserialized(char *wkt, GSERIALIZED **g)
Definition: cu_geodetic.c:789
Here is the call graph for this function:
Here is the caller graph for this function: