PostGIS  2.3.8dev-r@@SVN_REVISION@@

◆ test_lwgeom_same()

static void test_lwgeom_same ( void  )
static

Definition at line 854 of file cu_libgeom.c.

References LW_PARSER_CHECK_NONE, lwgeom_add_bbox(), lwgeom_free(), lwgeom_from_wkt(), and lwgeom_same().

Referenced by libgeom_suite_setup().

855 {
856  LWGEOM *geom, *geom2;
857 
858  geom = lwgeom_from_wkt("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))", LW_PARSER_CHECK_NONE);
859  CU_ASSERT( lwgeom_same(geom, geom) );
860  lwgeom_add_bbox(geom);
861  CU_ASSERT( lwgeom_same(geom, geom) );
862  lwgeom_free(geom);
863 
864  geom = lwgeom_from_wkt("MULTIPOLYGON(((0 0, 10 0, 10 10, 0 10, 0 0)))", LW_PARSER_CHECK_NONE);
865  CU_ASSERT( lwgeom_same(geom, geom) );
866  lwgeom_add_bbox(geom);
867  CU_ASSERT( lwgeom_same(geom, geom) );
868  lwgeom_free(geom);
869 
870  geom = lwgeom_from_wkt("LINESTRING(0 0, 2 0)", LW_PARSER_CHECK_NONE);
871  CU_ASSERT( lwgeom_same(geom, geom) );
872  lwgeom_add_bbox(geom);
873  CU_ASSERT( lwgeom_same(geom, geom) );
874  lwgeom_free(geom);
875 
876  geom = lwgeom_from_wkt("MULTILINESTRING((0 0, 2 0))", LW_PARSER_CHECK_NONE);
877  CU_ASSERT( lwgeom_same(geom, geom) );
878  lwgeom_add_bbox(geom);
879  CU_ASSERT( lwgeom_same(geom, geom) );
880  lwgeom_free(geom);
881 
882  geom = lwgeom_from_wkt("POINT(0 0)", LW_PARSER_CHECK_NONE);
883  CU_ASSERT( lwgeom_same(geom, geom) );
884  lwgeom_add_bbox(geom);
885  CU_ASSERT( lwgeom_same(geom, geom) );
886  lwgeom_free(geom);
887 
888  geom = lwgeom_from_wkt("MULTIPOINT((0 0),(4 5))", LW_PARSER_CHECK_NONE);
889  CU_ASSERT( lwgeom_same(geom, geom) );
890  lwgeom_add_bbox(geom);
891  CU_ASSERT( lwgeom_same(geom, geom) );
892  lwgeom_free(geom);
893 
894  geom = lwgeom_from_wkt("POINT EMPTY", LW_PARSER_CHECK_NONE);
895  CU_ASSERT( lwgeom_same(geom, geom) );
896  lwgeom_add_bbox(geom);
897  CU_ASSERT( lwgeom_same(geom, geom) );
898  lwgeom_free(geom);
899 
900  geom = lwgeom_from_wkt("LINESTRING EMPTY", LW_PARSER_CHECK_NONE);
901  CU_ASSERT( lwgeom_same(geom, geom) );
902  lwgeom_add_bbox(geom);
903  CU_ASSERT( lwgeom_same(geom, geom) );
904  lwgeom_free(geom);
905 
906  geom = lwgeom_from_wkt("POLYGON EMPTY", LW_PARSER_CHECK_NONE);
907  CU_ASSERT( lwgeom_same(geom, geom) );
908  lwgeom_free(geom);
909 
910  geom = lwgeom_from_wkt("MULTIPOINT EMPTY", LW_PARSER_CHECK_NONE);
911  CU_ASSERT( lwgeom_same(geom, geom) );
912  lwgeom_free(geom);
913 
914  geom = lwgeom_from_wkt("MULTILINESTRING EMPTY", LW_PARSER_CHECK_NONE);
915  CU_ASSERT( lwgeom_same(geom, geom) );
916  lwgeom_free(geom);
917 
918  geom = lwgeom_from_wkt("MULTIPOLYGON EMPTY", LW_PARSER_CHECK_NONE);
919  CU_ASSERT( lwgeom_same(geom, geom) );
920  lwgeom_free(geom);
921 
922  geom = lwgeom_from_wkt("GEOMETRYCOLLECTION(GEOMETRYCOLLECTION EMPTY, POINT EMPTY, LINESTRING EMPTY, POLYGON EMPTY, MULTIPOINT EMPTY, MULTILINESTRING EMPTY, MULTIPOLYGON EMPTY, GEOMETRYCOLLECTION(MULTIPOLYGON EMPTY))", LW_PARSER_CHECK_NONE);
923  CU_ASSERT( lwgeom_same(geom, geom) );
924  lwgeom_free(geom);
925 
926  geom = lwgeom_from_wkt("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))", LW_PARSER_CHECK_NONE);
927  geom2 = lwgeom_from_wkt("GEOMETRYCOLLECTION(GEOMETRYCOLLECTION EMPTY, POINT EMPTY, LINESTRING EMPTY, POLYGON EMPTY, MULTIPOINT EMPTY, MULTILINESTRING EMPTY, MULTIPOLYGON EMPTY, GEOMETRYCOLLECTION(MULTIPOLYGON EMPTY))", LW_PARSER_CHECK_NONE);
928  CU_ASSERT( ! lwgeom_same(geom, geom2) );
929  lwgeom_free(geom);
930  lwgeom_free(geom2);
931 
932  geom = lwgeom_from_wkt("POINT(0 0)", LW_PARSER_CHECK_NONE);
933  geom2 = lwgeom_from_wkt("MULTIPOINT((0 0))", LW_PARSER_CHECK_NONE);
934  CU_ASSERT( ! lwgeom_same(geom, geom2) );
935  lwgeom_free(geom);
936  lwgeom_free(geom2);
937 
938  geom = lwgeom_from_wkt("POINT EMPTY", LW_PARSER_CHECK_NONE);
939  geom2 = lwgeom_from_wkt("POINT Z EMPTY", LW_PARSER_CHECK_NONE);
940  CU_ASSERT( ! lwgeom_same(geom, geom2) );
941  lwgeom_free(geom);
942  lwgeom_free(geom2);
943 
944 }
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1063
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition: lwin_wkt.c:904
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:1985
char lwgeom_same(const LWGEOM *lwgeom1, const LWGEOM *lwgeom2)
geom1 same as geom2 iff
Definition: lwgeom.c:508
void lwgeom_add_bbox(LWGEOM *lwgeom)
Compute a bbox if not already computed.
Definition: lwgeom.c:612
Here is the call graph for this function:
Here is the caller graph for this function: