LSEG seg;
if (point_inside(pt, poly->npts, poly->p) != 0)
- {
-#ifdef GEODEBUG
- printf("dist_ppoly_internal- point inside of polygon\n");
-#endif
return 0.0;
- }
/* initialize distance with segment between first and last points */
seg.p[0].x = poly->p[0].x;
seg.p[1].x = poly->p[poly->npts - 1].x;
seg.p[1].y = poly->p[poly->npts - 1].y;
result = lseg_closept_point(NULL, &seg, pt);
-#ifdef GEODEBUG
- printf("dist_ppoly_internal- segment 0/n distance is %f\n", result);
-#endif
/* check distances for other segments */
for (i = 0; i < poly->npts - 1; i++)
seg.p[1].x = poly->p[i + 1].x;
seg.p[1].y = poly->p[i + 1].y;
d = lseg_closept_point(NULL, &seg, pt);
-#ifdef GEODEBUG
- printf("dist_ppoly_internal- segment %d distance is %f\n", (i + 1), d);
-#endif
if (d < result)
result = d;
}
if (j >= npts)
j = 0;
if (!point_eq_point(&p2[j], &p1[ii]))
- {
-#ifdef GEODEBUG
- printf("plist_same- %d failed forward match with %d\n", j, ii);
-#endif
break;
- }
}
-#ifdef GEODEBUG
- printf("plist_same- ii = %d/%d after forward match\n", ii, npts);
-#endif
if (ii == npts)
return true;
if (j < 0)
j = (npts - 1);
if (!point_eq_point(&p2[j], &p1[ii]))
- {
-#ifdef GEODEBUG
- printf("plist_same- %d failed reverse match with %d\n", j, ii);
-#endif
break;
- }
}
-#ifdef GEODEBUG
- printf("plist_same- ii = %d/%d after reverse match\n", ii, npts);
-#endif
if (ii == npts)
return true;
}