PostGIS  3.0.0dev-r@@SVN_REVISION@@

◆ test_lwgeom_same()

static void test_lwgeom_same ( void  )
static

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

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