PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ test_isclosed()

static void test_isclosed ( void  )
static

Definition at line 882 of file cu_algorithm.c.

883 {
884  LWGEOM *geom;
885 
886  /* LINESTRING */
887 
888  /* Not Closed on 2D */
889  geom = lwgeom_from_wkt("LINESTRING(1 2,3 4)", LW_PARSER_CHECK_NONE);
890  CU_ASSERT(!lwline_is_closed((LWLINE *) geom));
891  lwgeom_free(geom);
892 
893  /* Closed on 2D */
894  geom = lwgeom_from_wkt("LINESTRING(1 2,3 4,1 2)", LW_PARSER_CHECK_NONE);
895  CU_ASSERT(lwline_is_closed((LWLINE *) geom));
896  lwgeom_free(geom);
897 
898  /* Not closed on 3D */
899  geom = lwgeom_from_wkt("LINESTRING(1 2 3,4 5 6)", LW_PARSER_CHECK_NONE);
900  CU_ASSERT(!lwline_is_closed((LWLINE *) geom));
901  lwgeom_free(geom);
902 
903  /* Closed on 3D */
904  geom = lwgeom_from_wkt("LINESTRING(1 2 3,4 5 6,1 2 3)", LW_PARSER_CHECK_NONE);
905  CU_ASSERT(lwline_is_closed((LWLINE *) geom));
906  lwgeom_free(geom);
907 
908  /* Closed on 4D, even if M is not the same */
909  geom = lwgeom_from_wkt("LINESTRING(1 2 3 4,5 6 7 8,1 2 3 0)", LW_PARSER_CHECK_NONE);
910  CU_ASSERT(lwline_is_closed((LWLINE *) geom));
911  lwgeom_free(geom);
912 
913 
914  /* CIRCULARSTRING */
915 
916  /* Not Closed on 2D */
917  geom = lwgeom_from_wkt("CIRCULARSTRING(1 2,3 4,5 6)", LW_PARSER_CHECK_NONE);
918  CU_ASSERT(!lwcircstring_is_closed((LWCIRCSTRING *) geom));
919  lwgeom_free(geom);
920 
921  /* Closed on 2D */
922  geom = lwgeom_from_wkt("CIRCULARSTRING(1 2,3 4,1 2)", LW_PARSER_CHECK_NONE);
923  CU_ASSERT(lwcircstring_is_closed((LWCIRCSTRING *) geom));
924  lwgeom_free(geom);
925 
926  /* Not closed on 3D */
927  geom = lwgeom_from_wkt("CIRCULARSTRING(1 2 3,4 5 6,7 8 9)", LW_PARSER_CHECK_NONE);
928  CU_ASSERT(!lwcircstring_is_closed((LWCIRCSTRING *) geom));
929  lwgeom_free(geom);
930 
931  /* Closed on 3D */
932  geom = lwgeom_from_wkt("CIRCULARSTRING(1 2 3,4 5 6,1 2 3)", LW_PARSER_CHECK_NONE);
933  CU_ASSERT(lwcircstring_is_closed((LWCIRCSTRING *) geom));
934  lwgeom_free(geom);
935 
936  /* Closed on 4D, even if M is not the same */
937  geom = lwgeom_from_wkt("CIRCULARSTRING(1 2 3 4,5 6 7 8,1 2 3 0)", LW_PARSER_CHECK_NONE);
938  CU_ASSERT(lwcircstring_is_closed((LWCIRCSTRING *) geom));
939  lwgeom_free(geom);
940 
941 
942  /* COMPOUNDCURVE */
943 
944  /* Not Closed on 2D */
945  geom = lwgeom_from_wkt("COMPOUNDCURVE(CIRCULARSTRING(1 2,3 4,1 2),(1 2,7 8,5 6))", LW_PARSER_CHECK_NONE);
946  CU_ASSERT(!lwcompound_is_closed((LWCOMPOUND *) geom));
947  lwgeom_free(geom);
948 
949  geom = lwgeom_from_wkt("COMPOUNDCURVE((1 2,3 4,1 2),CIRCULARSTRING(1 2,7 8,5 6))", LW_PARSER_CHECK_NONE);
950  CU_ASSERT(!lwcompound_is_closed((LWCOMPOUND *) geom));
951  lwgeom_free(geom);
952 
953  /* Closed on 2D */
954  geom = lwgeom_from_wkt("COMPOUNDCURVE(CIRCULARSTRING(1 2,3 4,5 6), (5 6,7 8,1 2))", LW_PARSER_CHECK_NONE);
955  CU_ASSERT(lwcompound_is_closed((LWCOMPOUND *) geom));
956  lwgeom_free(geom);
957 
958  geom = lwgeom_from_wkt("COMPOUNDCURVE((1 2,3 4,5 6),CIRCULARSTRING(5 6,7 8,1 2))", LW_PARSER_CHECK_NONE);
959  CU_ASSERT(lwcompound_is_closed((LWCOMPOUND *) geom));
960  lwgeom_free(geom);
961 
962  /* Not Closed on 3D */
963  geom = lwgeom_from_wkt("COMPOUNDCURVE(CIRCULARSTRING(1 2 3,4 5 6,1 2 3),(1 2 3,7 8 9,10 11 12))", LW_PARSER_CHECK_NONE);
964  CU_ASSERT(!lwcompound_is_closed((LWCOMPOUND *) geom));
965  lwgeom_free(geom);
966 
967  geom = lwgeom_from_wkt("COMPOUNDCURVE((1 2 3,4 5 6,1 2 3),CIRCULARSTRING(1 2 3,7 8 9,10 11 12))", LW_PARSER_CHECK_NONE);
968  CU_ASSERT(!lwcompound_is_closed((LWCOMPOUND *) geom));
969  lwgeom_free(geom);
970 
971  /* Closed on 3D */
972  geom = lwgeom_from_wkt("COMPOUNDCURVE(CIRCULARSTRING(1 2 3,4 5 6,7 8 9),(7 8 9,10 11 12,1 2 3))", LW_PARSER_CHECK_NONE);
973  CU_ASSERT(lwcompound_is_closed((LWCOMPOUND *) geom));
974  lwgeom_free(geom);
975 
976  geom = lwgeom_from_wkt("COMPOUNDCURVE((1 2 3,4 5 6,7 8 9),CIRCULARSTRING(7 8 9,10 11 12,1 2 3))", LW_PARSER_CHECK_NONE);
977  CU_ASSERT(lwcompound_is_closed((LWCOMPOUND *) geom));
978  lwgeom_free(geom);
979 
980  /* Closed on 4D, even if M is not the same */
981  geom = lwgeom_from_wkt("COMPOUNDCURVE((1 2 3 4,5 6 7 8,9 10 11 12),CIRCULARSTRING(9 10 11 12,13 14 15 16,1 2 3 0))", LW_PARSER_CHECK_NONE);
982  CU_ASSERT(lwcompound_is_closed((LWCOMPOUND *) geom));
983  lwgeom_free(geom);
984 }
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
int lwcircstring_is_closed(const LWCIRCSTRING *curve)
Definition: lwcircstring.c:261
int lwline_is_closed(const LWLINE *line)
Definition: lwline.c:454
int lwcompound_is_closed(const LWCOMPOUND *curve)
Definition: lwcompound.c:35

References LW_PARSER_CHECK_NONE, lwcircstring_is_closed(), lwcompound_is_closed(), lwgeom_free(), lwgeom_from_wkt(), and lwline_is_closed().

Referenced by algorithms_suite_setup().

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