PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ test_lwgeom_same()

static void test_lwgeom_same ( void  )
static

Definition at line 878 of file cu_libgeom.c.

879 {
880  LWGEOM *geom, *geom2;
881 
882  geom = lwgeom_from_wkt("POLYGON((0 0, 10 0, 10 10, 0 10, 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("MULTIPOLYGON(((0 0, 10 0, 10 10, 0 10, 0 0)))", 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("LINESTRING(0 0, 2 0)", 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("MULTILINESTRING((0 0, 2 0))", 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("POINT(0 0)", LW_PARSER_CHECK_NONE);
907  CU_ASSERT( lwgeom_same(geom, geom) );
908  lwgeom_add_bbox(geom);
909  CU_ASSERT( lwgeom_same(geom, geom) );
910  lwgeom_free(geom);
911 
912  geom = lwgeom_from_wkt("MULTIPOINT((0 0),(4 5))", LW_PARSER_CHECK_NONE);
913  CU_ASSERT( lwgeom_same(geom, geom) );
914  lwgeom_add_bbox(geom);
915  CU_ASSERT( lwgeom_same(geom, geom) );
916  lwgeom_free(geom);
917 
918  geom = lwgeom_from_wkt("POINT EMPTY", LW_PARSER_CHECK_NONE);
919  CU_ASSERT( lwgeom_same(geom, geom) );
920  lwgeom_add_bbox(geom);
921  CU_ASSERT( lwgeom_same(geom, geom) );
922  lwgeom_free(geom);
923 
924  geom = lwgeom_from_wkt("LINESTRING EMPTY", LW_PARSER_CHECK_NONE);
925  CU_ASSERT( lwgeom_same(geom, geom) );
926  lwgeom_add_bbox(geom);
927  CU_ASSERT( lwgeom_same(geom, geom) );
928  lwgeom_free(geom);
929 
930  geom = lwgeom_from_wkt("POLYGON EMPTY", LW_PARSER_CHECK_NONE);
931  CU_ASSERT( lwgeom_same(geom, geom) );
932  lwgeom_free(geom);
933 
934  geom = lwgeom_from_wkt("MULTIPOINT EMPTY", LW_PARSER_CHECK_NONE);
935  CU_ASSERT( lwgeom_same(geom, geom) );
936  lwgeom_free(geom);
937 
938  geom = lwgeom_from_wkt("MULTILINESTRING EMPTY", LW_PARSER_CHECK_NONE);
939  CU_ASSERT( lwgeom_same(geom, geom) );
940  lwgeom_free(geom);
941 
942  geom = lwgeom_from_wkt("MULTIPOLYGON EMPTY", LW_PARSER_CHECK_NONE);
943  CU_ASSERT( lwgeom_same(geom, geom) );
944  lwgeom_free(geom);
945 
946  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);
947  CU_ASSERT( lwgeom_same(geom, geom) );
948  lwgeom_free(geom);
949 
950  geom = lwgeom_from_wkt("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))", LW_PARSER_CHECK_NONE);
951  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);
952  CU_ASSERT( ! lwgeom_same(geom, geom2) );
953  lwgeom_free(geom);
954  lwgeom_free(geom2);
955 
956  geom = lwgeom_from_wkt("POINT(0 0)", LW_PARSER_CHECK_NONE);
957  geom2 = lwgeom_from_wkt("MULTIPOINT((0 0))", LW_PARSER_CHECK_NONE);
958  CU_ASSERT( ! lwgeom_same(geom, geom2) );
959  lwgeom_free(geom);
960  lwgeom_free(geom2);
961 
962  geom = lwgeom_from_wkt("POINT EMPTY", LW_PARSER_CHECK_NONE);
963  geom2 = lwgeom_from_wkt("POINT Z EMPTY", LW_PARSER_CHECK_NONE);
964  CU_ASSERT( ! lwgeom_same(geom, geom2) );
965  lwgeom_free(geom);
966  lwgeom_free(geom2);
967 
968 }
char lwgeom_same(const LWGEOM *lwgeom1, const LWGEOM *lwgeom2)
geom1 same as geom2 iff
Definition: lwgeom.c:582
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1144
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:2005
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition: lwin_wkt.c:904
void lwgeom_add_bbox(LWGEOM *lwgeom)
Compute a bbox if not already computed.
Definition: lwgeom.c:686

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

Referenced by libgeom_suite_setup().

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