PostGIS  2.1.10dev-r@@SVN_REVISION@@
static void test_isclosed ( void  )
static

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

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

Here is the call graph for this function:

Here is the caller graph for this function: