846{
847 int wn = 0;
848 uint32_t i;
849 int side;
854
855
857 {
858 lwerror(
"ptarrayarc_contains_point called with even number of points");
860 }
861
862
864 {
865 lwerror(
"ptarrayarc_contains_point called too-short pointarray");
867 }
868
869
872 if ( check_closed && !
p2d_same(seg1, seg3) )
873 {
874 lwerror(
"ptarrayarc_contains_point called on unclosed ring");
876 }
877
879 {
880 double radius, d;
883
884
887
888
893 else if ( d < radius )
895 else
897 }
899 {
901 }
902
903
905 for ( i=1; i < pa->
npoints; i += 2 )
906 {
909
910
913
914
916 {
917 seg1 = seg3;
918 continue;
919 }
920
921
924 {
925 seg1 = seg3;
926 continue;
927 }
928
929
930 if ( (pt->
x > gbox.
xmax || pt->
x < gbox.
xmin) &&
932 {
933 seg1 = seg3;
934 continue;
935 }
936
938
939
940 if ( (side == 0) &&
lw_pt_in_arc(pt, seg1, seg2, seg3) )
941 {
943 }
944
945
946 if ( side < 0 && (seg1->
y <= pt->
y) && (pt->
y < seg3->
y) )
947 {
948 wn++;
949 }
950
951
952 if ( side > 0 && (seg3->
y <= pt->
y) && (pt->
y < seg1->
y) )
953 {
954 wn--;
955 }
956
957
958 if ( pt->
x <= gbox.
xmax && pt->
x >= gbox.
xmin )
959 {
963
964
965 if ( d == radius )
967
968
969 if ( d < radius )
970 {
971
972 if ( side < 0 )
973 wn++;
974
975 if ( side > 0 )
976 wn--;
977 }
978 }
979
980 seg1 = seg3;
981 }
982
983
984 if ( winding_number )
985 *winding_number = wn;
986
987
988 if (wn == 0)
989 {
991 }
992
993
995}
int lw_arc_calculate_gbox_cartesian_2d(const POINT2D *A1, const POINT2D *A2, const POINT2D *A3, GBOX *gbox)
double distance2d_pt_pt(const POINT2D *p1, const POINT2D *p2)
#define LW_INSIDE
Constants for point-in-polygon return values.
double lw_arc_center(const POINT2D *p1, const POINT2D *p2, const POINT2D *p3, POINT2D *result)
Determines the center of the circle defined by the three given points.
int lw_arc_side(const POINT2D *A1, const POINT2D *A2, const POINT2D *A3, const POINT2D *Q)
int lw_arc_is_pt(const POINT2D *A1, const POINT2D *A2, const POINT2D *A3)
Returns true if arc A is actually a point (all vertices are the same) .
int lw_pt_in_arc(const POINT2D *P, const POINT2D *A1, const POINT2D *A2, const POINT2D *A3)
Returns true if P is on the same side of the plane partition defined by A1/A3 as A2 is.
int p2d_same(const POINT2D *p1, const POINT2D *p2)
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
static const POINT2D * getPoint2d_cp(const POINTARRAY *pa, uint32_t n)
Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from.