PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ test_isclosed()

static void test_isclosed ( void  )
static

Definition at line 803 of file cu_algorithm.c.

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().

804 {
805  LWGEOM *geom;
806 
807  /* LINESTRING */
808 
809  /* Not Closed on 2D */
810  geom = lwgeom_from_wkt("LINESTRING(1 2,3 4)", LW_PARSER_CHECK_NONE);
811  CU_ASSERT(!lwline_is_closed((LWLINE *) geom));
812  lwgeom_free(geom);
813 
814  /* Closed on 2D */
815  geom = lwgeom_from_wkt("LINESTRING(1 2,3 4,1 2)", LW_PARSER_CHECK_NONE);
816  CU_ASSERT(lwline_is_closed((LWLINE *) geom));
817  lwgeom_free(geom);
818 
819  /* Not closed on 3D */
820  geom = lwgeom_from_wkt("LINESTRING(1 2 3,4 5 6)", LW_PARSER_CHECK_NONE);
821  CU_ASSERT(!lwline_is_closed((LWLINE *) geom));
822  lwgeom_free(geom);
823 
824  /* Closed on 3D */
825  geom = lwgeom_from_wkt("LINESTRING(1 2 3,4 5 6,1 2 3)", LW_PARSER_CHECK_NONE);
826  CU_ASSERT(lwline_is_closed((LWLINE *) geom));
827  lwgeom_free(geom);
828 
829  /* Closed on 4D, even if M is not the same */
830  geom = lwgeom_from_wkt("LINESTRING(1 2 3 4,5 6 7 8,1 2 3 0)", LW_PARSER_CHECK_NONE);
831  CU_ASSERT(lwline_is_closed((LWLINE *) geom));
832  lwgeom_free(geom);
833 
834 
835  /* CIRCULARSTRING */
836 
837  /* Not Closed on 2D */
838  geom = lwgeom_from_wkt("CIRCULARSTRING(1 2,3 4,5 6)", LW_PARSER_CHECK_NONE);
839  CU_ASSERT(!lwcircstring_is_closed((LWCIRCSTRING *) geom));
840  lwgeom_free(geom);
841 
842  /* Closed on 2D */
843  geom = lwgeom_from_wkt("CIRCULARSTRING(1 2,3 4,1 2)", LW_PARSER_CHECK_NONE);
844  CU_ASSERT(lwcircstring_is_closed((LWCIRCSTRING *) geom));
845  lwgeom_free(geom);
846 
847  /* Not closed on 3D */
848  geom = lwgeom_from_wkt("CIRCULARSTRING(1 2 3,4 5 6,7 8 9)", LW_PARSER_CHECK_NONE);
849  CU_ASSERT(!lwcircstring_is_closed((LWCIRCSTRING *) geom));
850  lwgeom_free(geom);
851 
852  /* Closed on 3D */
853  geom = lwgeom_from_wkt("CIRCULARSTRING(1 2 3,4 5 6,1 2 3)", LW_PARSER_CHECK_NONE);
854  CU_ASSERT(lwcircstring_is_closed((LWCIRCSTRING *) geom));
855  lwgeom_free(geom);
856 
857  /* Closed on 4D, even if M is not the same */
858  geom = lwgeom_from_wkt("CIRCULARSTRING(1 2 3 4,5 6 7 8,1 2 3 0)", LW_PARSER_CHECK_NONE);
859  CU_ASSERT(lwcircstring_is_closed((LWCIRCSTRING *) geom));
860  lwgeom_free(geom);
861 
862 
863  /* COMPOUNDCURVE */
864 
865  /* Not Closed on 2D */
866  geom = lwgeom_from_wkt("COMPOUNDCURVE(CIRCULARSTRING(1 2,3 4,1 2),(1 2,7 8,5 6))", LW_PARSER_CHECK_NONE);
867  CU_ASSERT(!lwcompound_is_closed((LWCOMPOUND *) geom));
868  lwgeom_free(geom);
869 
870  geom = lwgeom_from_wkt("COMPOUNDCURVE((1 2,3 4,1 2),CIRCULARSTRING(1 2,7 8,5 6))", LW_PARSER_CHECK_NONE);
871  CU_ASSERT(!lwcompound_is_closed((LWCOMPOUND *) geom));
872  lwgeom_free(geom);
873 
874  /* Closed on 2D */
875  geom = lwgeom_from_wkt("COMPOUNDCURVE(CIRCULARSTRING(1 2,3 4,5 6), (5 6,7 8,1 2))", LW_PARSER_CHECK_NONE);
876  CU_ASSERT(lwcompound_is_closed((LWCOMPOUND *) geom));
877  lwgeom_free(geom);
878 
879  geom = lwgeom_from_wkt("COMPOUNDCURVE((1 2,3 4,5 6),CIRCULARSTRING(5 6,7 8,1 2))", LW_PARSER_CHECK_NONE);
880  CU_ASSERT(lwcompound_is_closed((LWCOMPOUND *) geom));
881  lwgeom_free(geom);
882 
883  /* Not Closed on 3D */
884  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);
885  CU_ASSERT(!lwcompound_is_closed((LWCOMPOUND *) geom));
886  lwgeom_free(geom);
887 
888  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);
889  CU_ASSERT(!lwcompound_is_closed((LWCOMPOUND *) geom));
890  lwgeom_free(geom);
891 
892  /* Closed on 3D */
893  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);
894  CU_ASSERT(lwcompound_is_closed((LWCOMPOUND *) geom));
895  lwgeom_free(geom);
896 
897  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);
898  CU_ASSERT(lwcompound_is_closed((LWCOMPOUND *) geom));
899  lwgeom_free(geom);
900 
901  /* Closed on 4D, even if M is not the same */
902  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);
903  CU_ASSERT(lwcompound_is_closed((LWCOMPOUND *) geom));
904  lwgeom_free(geom);
905 }
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1099
int lwcompound_is_closed(const LWCOMPOUND *curve)
Definition: lwcompound.c:35
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition: lwin_wkt.c:904
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:2013
int lwcircstring_is_closed(const LWCIRCSTRING *curve)
Definition: lwcircstring.c:268
int lwline_is_closed(const LWLINE *line)
Definition: lwline.c:468
Here is the call graph for this function:
Here is the caller graph for this function: