extern int getPoint2d_p(const POINTARRAY *pa, int n, POINT2D *point);
/**
-* Returns a pointer into the POINTARRAY serialized_ptlist,
+* Returns a POINT2D pointer into the POINTARRAY serialized_ptlist,
* suitable for reading from. This is very high performance
* and declared const because you aren't allowed to muck with the
* values, only read them.
*/
extern const POINT2D* getPoint2d_cp(const POINTARRAY *pa, int n);
+/**
+* Returns a POINT3DZ pointer into the POINTARRAY serialized_ptlist,
+* suitable for reading from. This is very high performance
+* and declared const because you aren't allowed to muck with the
+* values, only read them.
+*/
+extern const POINT3DZ* getPoint3dz_cp(const POINTARRAY *pa, int n);
+
/*
* set point N to the given value
* NOTE that the pointarray can be of any
{
int cn = 0; /* the crossing number counter */
int i;
- POINT2D v1, v2;
+ const POINT2D *v1, *v2;
+ const POINT2D *first, *last;
- POINT2D first, last;
-
- getPoint2d_p(ring, 0, &first);
- getPoint2d_p(ring, ring->npoints-1, &last);
- if ( memcmp(&first, &last, sizeof(POINT2D)) )
+ first = getPoint2d_cp(ring, 0);
+ last = getPoint2d_cp(ring, ring->npoints-1);
+ if ( memcmp(first, last, sizeof(POINT2D)) )
{
lwerror("pt_in_ring_2d: V[n] != V[0] (%g %g != %g %g)",
- first.x, first.y, last.x, last.y);
+ first->x, first->y, last->x, last->y);
return LW_FALSE;
}
/* printPA(ring); */
/* loop through all edges of the polygon */
- getPoint2d_p(ring, 0, &v1);
+ v1 = getPoint2d_cp(ring, 0);
for (i=0; i<ring->npoints-1; i++)
{
double vt;
- getPoint2d_p(ring, i+1, &v2);
+ v2 = getPoint2d_cp(ring, i+1);
/* edge from vertex i to vertex i+1 */
if
(
/* an upward crossing */
- ((v1.y <= p->y) && (v2.y > p->y))
+ ((v1->y <= p->y) && (v2->y > p->y))
/* a downward crossing */
- || ((v1.y > p->y) && (v2.y <= p->y))
+ || ((v1->y > p->y) && (v2->y <= p->y))
)
{
- vt = (double)(p->y - v1.y) / (v2.y - v1.y);
+ vt = (double)(p->y - v1->y) / (v2->y - v1->y);
- /* P.x <intersect */
- if (p->x < v1.x + vt * (v2.x - v1.x))
+ /* P->x <intersect */
+ if (p->x < v1->x + vt * (v2->x - v1->x))
{
- /* a valid crossing of y=p.y right of p.x */
+ /* a valid crossing of y=p->y right of p->x */
++cn;
}
}
return (const POINT2D*)getPoint_internal(pa, n);
}
+const POINT3DZ*
+getPoint3dz_cp(const POINTARRAY *pa, int n)
+{
+ if ( ! pa ) return 0;
+
+ if ( ! FLAGS_GET_Z(pa->flags) )
+ {
+ lwerror("getPoint3dz_cp: no Z coordinates in point array");
+ return 0; /*error */
+ }
+
+ if ( (n<0) || (n>=pa->npoints))
+ {
+ lwerror("getPoint3dz_cp: point offset out of range");
+ return 0; /*error */
+ }
+
+ return (const POINT3DZ*)getPoint_internal(pa, n);
+}
+
+
/*
* set point N to the given value
ptarray_to_GEOSCoordSeq(const POINTARRAY *pa)
{
uint32_t dims = 2;
- uint32_t size, i;
- POINT3DZ p;
+ uint32_t i;
+ const POINT3DZ *p3d;
+ const POINT2D *p2d;
GEOSCoordSeq sq;
- if ( FLAGS_GET_Z(pa->flags) ) dims = 3;
- size = pa->npoints;
+ if ( FLAGS_GET_Z(pa->flags) )
+ dims = 3;
- sq = GEOSCoordSeq_create(size, dims);
- if ( ! sq ) lwerror("Error creating GEOS Coordinate Sequence");
+ if ( ! (sq = GEOSCoordSeq_create(pa->npoints, dims)) )
+ lwerror("Error creating GEOS Coordinate Sequence");
- for (i=0; i<size; i++)
+ for ( i=0; i < pa->npoints; i++ )
{
- getPoint3dz_p(pa, i, &p);
+ if ( dims == 3 )
+ {
+ p3d = getPoint3dz_cp(pa, i);
+ p2d = (const POINT2D *)p3d;
+ }
+ else
+ {
+ p2d = getPoint2d_cp(pa, i);
+ }
- LWDEBUGF(4, "Point: %g,%g,%g", p.x, p.y, p.z);
+ LWDEBUGF(4, "Point: %g,%g,%g", p2d->x, p2d->y, p3d->z);
#if POSTGIS_GEOS_VERSION < 33
/* Make sure we don't pass any infinite values down into GEOS */
/* GEOS 3.3+ is supposed to handle this stuff OK */
- if ( isinf(p.x) || isinf(p.y) || (dims == 3 && isinf(p.z)) )
+ if ( isinf(p2d->x) || isinf(p2d->y) || (dims == 3 && isinf(p3d->z)) )
lwerror("Infinite coordinate value found in geometry.");
- if ( isnan(p.x) || isnan(p.y) || (dims == 3 && isnan(p.z)) )
+ if ( isnan(p2d->x) || isnan(p2d->y) || (dims == 3 && isnan(p3d->z)) )
lwerror("NaN coordinate value found in geometry.");
#endif
- GEOSCoordSeq_setX(sq, i, p.x);
- GEOSCoordSeq_setY(sq, i, p.y);
- if ( dims == 3 ) GEOSCoordSeq_setZ(sq, i, p.z);
+ GEOSCoordSeq_setX(sq, i, p2d->x);
+ GEOSCoordSeq_setY(sq, i, p2d->y);
+
+ if ( dims == 3 )
+ GEOSCoordSeq_setZ(sq, i, p3d->z);
}
return sq;
}
{
for (i=0; i<pa->npoints; i++)
{
- POINT2D pt;
- getPoint2d_p(pa, i, &pt);
+ const POINT2D *pt;
+ pt = getPoint2d_cp(pa, i);
- lwprint_double(pt.x, precision, x, BUFSIZE);
- trim_trailing_zeros(x);
- lwprint_double(pt.y, precision, y, BUFSIZE);
- trim_trailing_zeros(y);
+ lwprint_double(pt->x, precision, x, BUFSIZE);
+ trim_trailing_zeros(x);
+ lwprint_double(pt->y, precision, y, BUFSIZE);
+ trim_trailing_zeros(y);
if ( i ) ptr += sprintf(ptr, ",");
ptr += sprintf(ptr, "[%s,%s]", x, y);
{
for (i=0; i<pa->npoints; i++)
{
- POINT4D pt;
- getPoint4d_p(pa, i, &pt);
-
- lwprint_double(pt.x, precision, x, BUFSIZE);
- trim_trailing_zeros(x);
- lwprint_double(pt.y, precision, y, BUFSIZE);
- trim_trailing_zeros(y);
- lwprint_double(pt.z, precision, z, BUFSIZE);
- trim_trailing_zeros(z);
+ const POINT3DZ *pt;
+ pt = getPoint3dz_cp(pa, i);
+
+ lwprint_double(pt->x, precision, x, BUFSIZE);
+ trim_trailing_zeros(x);
+ lwprint_double(pt->y, precision, y, BUFSIZE);
+ trim_trailing_zeros(y);
+ lwprint_double(pt->z, precision, z, BUFSIZE);
+ trim_trailing_zeros(z);
if ( i ) ptr += sprintf(ptr, ",");
ptr += sprintf(ptr, "[%s,%s,%s]", x, y, z);
{
for (i=0; i<pa->npoints; i++)
{
- POINT2D pt;
- getPoint2d_p(pa, i, &pt);
+ const POINT2D *pt;
+ pt = getPoint2d_cp(pa, i);
- if (fabs(pt.x) < OUT_MAX_DOUBLE)
- sprintf(x, "%.*f", precision, pt.x);
+ if (fabs(pt->x) < OUT_MAX_DOUBLE)
+ sprintf(x, "%.*f", precision, pt->x);
else
- sprintf(x, "%g", pt.x);
+ sprintf(x, "%g", pt->x);
trim_trailing_zeros(x);
- if (fabs(pt.y) < OUT_MAX_DOUBLE)
- sprintf(y, "%.*f", precision, pt.y);
+ if (fabs(pt->y) < OUT_MAX_DOUBLE)
+ sprintf(y, "%.*f", precision, pt->y);
else
- sprintf(y, "%g", pt.y);
+ sprintf(y, "%g", pt->y);
trim_trailing_zeros(y);
if ( i ) ptr += sprintf(ptr, " ");
{
for (i=0; i<pa->npoints; i++)
{
- POINT4D pt;
- getPoint4d_p(pa, i, &pt);
+ const POINT3DZ *pt;
+ pt = getPoint3dz_cp(pa, i);
- if (fabs(pt.x) < OUT_MAX_DOUBLE)
- sprintf(x, "%.*f", precision, pt.x);
+ if (fabs(pt->x) < OUT_MAX_DOUBLE)
+ sprintf(x, "%.*f", precision, pt->x);
else
- sprintf(x, "%g", pt.x);
+ sprintf(x, "%g", pt->x);
trim_trailing_zeros(x);
- if (fabs(pt.y) < OUT_MAX_DOUBLE)
- sprintf(y, "%.*f", precision, pt.y);
+ if (fabs(pt->y) < OUT_MAX_DOUBLE)
+ sprintf(y, "%.*f", precision, pt->y);
else
- sprintf(y, "%g", pt.y);
+ sprintf(y, "%g", pt->y);
trim_trailing_zeros(y);
- if (fabs(pt.z) < OUT_MAX_DOUBLE)
- sprintf(z, "%.*f", precision, pt.z);
+ if (fabs(pt->z) < OUT_MAX_DOUBLE)
+ sprintf(z, "%.*f", precision, pt->z);
else
- sprintf(z, "%g", pt.z);
+ sprintf(z, "%g", pt->z);
trim_trailing_zeros(z);
if ( i ) ptr += sprintf(ptr, " ");
{
for (i=0; i<pa->npoints; i++)
{
- POINT2D pt;
- getPoint2d_p(pa, i, &pt);
+ const POINT2D *pt;
+ pt = getPoint2d_cp(pa, i);
- if (fabs(pt.x) < OUT_MAX_DOUBLE)
- sprintf(x, "%.*f", precision, pt.x);
+ if (fabs(pt->x) < OUT_MAX_DOUBLE)
+ sprintf(x, "%.*f", precision, pt->x);
else
- sprintf(x, "%g", pt.x);
+ sprintf(x, "%g", pt->x);
trim_trailing_zeros(x);
- if (fabs(pt.y) < OUT_MAX_DOUBLE)
- sprintf(y, "%.*f", precision, pt.y);
+ if (fabs(pt->y) < OUT_MAX_DOUBLE)
+ sprintf(y, "%.*f", precision, pt->y);
else
- sprintf(y, "%g", pt.y);
+ sprintf(y, "%g", pt->y);
trim_trailing_zeros(y);
if ( i ) ptr += sprintf(ptr, " ");
{
for (i=0; i<pa->npoints; i++)
{
- POINT4D pt;
- getPoint4d_p(pa, i, &pt);
+ const POINT3DZ *pt;
+ pt = getPoint3dz_cp(pa, i);
- if (fabs(pt.x) < OUT_MAX_DOUBLE)
- sprintf(x, "%.*f", precision, pt.x);
+ if (fabs(pt->x) < OUT_MAX_DOUBLE)
+ sprintf(x, "%.*f", precision, pt->x);
else
- sprintf(x, "%g", pt.x);
+ sprintf(x, "%g", pt->x);
trim_trailing_zeros(x);
- if (fabs(pt.y) < OUT_MAX_DOUBLE)
- sprintf(y, "%.*f", precision, pt.y);
+ if (fabs(pt->y) < OUT_MAX_DOUBLE)
+ sprintf(y, "%.*f", precision, pt->y);
else
- sprintf(y, "%g", pt.y);
+ sprintf(y, "%g", pt->y);
trim_trailing_zeros(y);
- if (fabs(pt.z) < OUT_MAX_DOUBLE)
- sprintf(z, "%.*f", precision, pt.z);
+ if (fabs(pt->z) < OUT_MAX_DOUBLE)
+ sprintf(z, "%.*f", precision, pt->z);
else
- sprintf(z, "%g", pt.z);
+ sprintf(z, "%g", pt->z);
trim_trailing_zeros(z);
if ( i ) ptr += sprintf(ptr, " ");
int
lw_dist2d_point_point(LWPOINT *point1, LWPOINT *point2, DISTPTS *dl)
{
- POINT2D p1;
- POINT2D p2;
+ const POINT2D *p1, *p2;
- getPoint2d_p(point1->point, 0, &p1);
- getPoint2d_p(point2->point, 0, &p2);
+ p1 = getPoint2d_cp(point1->point, 0);
+ p2 = getPoint2d_cp(point2->point, 0);
- return lw_dist2d_pt_pt(&p1, &p2,dl);
+ return lw_dist2d_pt_pt(p1, p2, dl);
}
/**
lw_dist2d_ptarray_ptarray(POINTARRAY *l1, POINTARRAY *l2,DISTPTS *dl)
{
int t,u;
- POINT2D start, end;
- POINT2D start2, end2;
+ const POINT2D *start, *end;
+ const POINT2D *start2, *end2;
int twist = dl->twisted;
LWDEBUGF(2, "lw_dist2d_ptarray_ptarray called (points: %d-%d)",l1->npoints, l2->npoints);
{
for (t=0; t<l1->npoints; t++) /*for each segment in L1 */
{
- getPoint2d_p(l1, t, &start);
+ start = getPoint2d_cp(l1, t);
for (u=0; u<l2->npoints; u++) /*for each segment in L2 */
{
- getPoint2d_p(l2, u, &start2);
- lw_dist2d_pt_pt(&start,&start2,dl);
+ start2 = getPoint2d_cp(l2, u);
+ lw_dist2d_pt_pt(start, start2, dl);
LWDEBUGF(4, "maxdist_ptarray_ptarray; seg %i * seg %i, dist = %g\n",t,u,dl->distance);
LWDEBUGF(3, " seg%d-seg%d dist: %f, mindist: %f",
t, u, dl->distance, dl->tolerance);
}
else
{
- getPoint2d_p(l1, 0, &start);
+ start = getPoint2d_cp(l1, 0);
for (t=1; t<l1->npoints; t++) /*for each segment in L1 */
{
- getPoint2d_p(l1, t, &end);
- getPoint2d_p(l2, 0, &start2);
+ end = getPoint2d_cp(l1, t);
+ start2 = getPoint2d_cp(l2, 0);
for (u=1; u<l2->npoints; u++) /*for each segment in L2 */
{
- getPoint2d_p(l2, u, &end2);
+ end2 = getPoint2d_cp(l2, u);
dl->twisted=twist;
- lw_dist2d_seg_seg(&start, &end, &start2, &end2,dl);
+ lw_dist2d_seg_seg(start, end, start2, end2, dl);
LWDEBUGF(4, "mindist_ptarray_ptarray; seg %i * seg %i, dist = %g\n",t,u,dl->distance);
LWDEBUGF(3, " seg%d-seg%d dist: %f, mindist: %f",
t, u, dl->distance, dl->tolerance);
double k, thevalue;
float deltaX, deltaY, c1m, c2m;
- POINT2D theP,c1, c2;
+ POINT2D c1, c2;
+ const POINT2D *theP;
float min1X, max1X, max1Y, min1Y,min2X, max2X, max2Y, min2Y;
int t;
int n1 = l1->npoints;
k = -deltaX/deltaY;
for (t=0; t<n1; t++) /*for each segment in L1 */
{
- getPoint2d_p(l1, t, &theP);
- thevalue = theP.y-(k*theP.x);
+ theP = getPoint2d_cp(l1, t);
+ thevalue = theP->y - (k * theP->x);
list1[t].themeasure=thevalue;
list1[t].pnr=t;
}
for (t=0; t<n2; t++) /*for each segment in L2*/
{
- getPoint2d_p(l2, t, &theP);
- thevalue = theP.y-(k*theP.x);
+ theP = getPoint2d_cp(l2, t);
+ thevalue = theP->y - (k * theP->x);
list2[t].themeasure=thevalue;
list2[t].pnr=t;
k = -deltaY/deltaX;
for (t=0; t<n1; t++) /*for each segment in L1 */
{
- getPoint2d_p(l1, t, &theP);
- thevalue = theP.x-(k*theP.y);
+ theP = getPoint2d_cp(l1, t);
+ thevalue = theP->x - (k * theP->y);
list1[t].themeasure=thevalue;
list1[t].pnr=t;
/* lwnotice("l1 %d, measure=%f",t,thevalue ); */
}
for (t=0; t<n2; t++) /*for each segment in L2*/
{
- getPoint2d_p(l2, t, &theP);
-
- thevalue = theP.x-(k*theP.y);
+ theP = getPoint2d_cp(l2, t);
+ thevalue = theP->x - (k * theP->y);
list2[t].themeasure=thevalue;
list2[t].pnr=t;
/* lwnotice("l2 %d, measure=%f",t,thevalue ); */
int
lw_dist2d_pre_seg_seg(POINTARRAY *l1, POINTARRAY *l2,LISTSTRUCT *list1, LISTSTRUCT *list2,double k, DISTPTS *dl)
{
- POINT2D p1, p2, p3, p4, p01, p02;
+ const POINT2D *p1, *p2, *p3, *p4, *p01, *p02;
int pnr1,pnr2,pnr3,pnr4, n1, n2, i, u, r, twist;
double maxmeasure;
n1= l1->npoints;
LWDEBUG(2, "lw_dist2d_pre_seg_seg is called");
- getPoint2d_p(l1, list1[0].pnr, &p1);
- getPoint2d_p(l2, list2[0].pnr, &p3);
- lw_dist2d_pt_pt(&p1, &p3,dl);
+ p1 = getPoint2d_cp(l1, list1[0].pnr);
+ p3 = getPoint2d_cp(l2, list2[0].pnr);
+ lw_dist2d_pt_pt(p1, p3, dl);
maxmeasure = sqrt(dl->distance*dl->distance + (dl->distance*dl->distance*k*k));
twist = dl->twisted; /*to keep the incomming order between iterations*/
for (i =(n1-1); i>=0; --i)
for (r=-1; r<=1; r +=2) /*because we are not iterating in the original pointorder we have to check the segment before and after every point*/
{
pnr1 = list1[i].pnr;
- getPoint2d_p(l1, pnr1, &p1);
+ p1 = getPoint2d_cp(l1, pnr1);
if (pnr1+r<0)
{
- getPoint2d_p(l1, (n1-1), &p01);
- if (( p1.x == p01.x) && (p1.y == p01.y)) pnr2 = (n1-1);
+ p01 = getPoint2d_cp(l1, (n1-1));
+ if (( p1->x == p01->x) && (p1->y == p01->y)) pnr2 = (n1-1);
else pnr2 = pnr1; /* if it is a line and the last and first point is not the same we avoid the edge between start and end this way*/
}
else if (pnr1+r>(n1-1))
{
- getPoint2d_p(l1, 0, &p01);
- if (( p1.x == p01.x) && (p1.y == p01.y)) pnr2 = 0;
+ p01 = getPoint2d_cp(l1, 0);
+ if (( p1->x == p01->x) && (p1->y == p01->y)) pnr2 = 0;
else pnr2 = pnr1; /* if it is a line and the last and first point is not the same we avoid the edge between start and end this way*/
}
else pnr2 = pnr1+r;
- getPoint2d_p(l1, pnr2, &p2);
+ p2 = getPoint2d_cp(l1, pnr2);
for (u=0; u<n2; ++u)
{
if (((list2[u].themeasure-list1[i].themeasure)) >= maxmeasure) break;
pnr3 = list2[u].pnr;
- getPoint2d_p(l2, pnr3, &p3);
+ p3 = getPoint2d_cp(l2, pnr3);
if (pnr3==0)
{
- getPoint2d_p(l2, (n2-1), &p02);
- if (( p3.x == p02.x) && (p3.y == p02.y)) pnr4 = (n2-1);
+ p02 = getPoint2d_cp(l2, (n2-1));
+ if (( p3->x == p02->x) && (p3->y == p02->y)) pnr4 = (n2-1);
else pnr4 = pnr3; /* if it is a line and the last and first point is not the same we avoid the edge between start and end this way*/
}
else pnr4 = pnr3-1;
- getPoint2d_p(l2, pnr4, &p4);
+ p4 = getPoint2d_cp(l2, pnr4);
dl->twisted=twist;
- if (!lw_dist2d_selected_seg_seg(&p1, &p2, &p3, &p4, dl)) return LW_FALSE;
+ if (!lw_dist2d_selected_seg_seg(p1, p2, p3, p4, dl)) return LW_FALSE;
if (pnr3>=(n2-1))
{
- getPoint2d_p(l2, 0, &p02);
- if (( p3.x == p02.x) && (p3.y == p02.y)) pnr4 = 0;
+ p02 = getPoint2d_cp(l2, 0);
+ if (( p3->x == p02->x) && (p3->y == p02->y)) pnr4 = 0;
else pnr4 = pnr3; /* if it is a line and the last and first point is not the same we avoid the edge between start and end this way*/
}
else pnr4 = pnr3+1;
- getPoint2d_p(l2, pnr4, &p4);
+ p4 = getPoint2d_cp(l2, pnr4);
dl->twisted=twist; /*we reset the "twist" for each iteration*/
- if (!lw_dist2d_selected_seg_seg(&p1, &p2, &p3, &p4, dl)) return LW_FALSE;
+ if (!lw_dist2d_selected_seg_seg(p1, p2, p3, p4, dl)) return LW_FALSE;
maxmeasure = sqrt(dl->distance*dl->distance + (dl->distance*dl->distance*k*k));/*here we "translate" the found mindistance so it can be compared to our "z"-values*/
}
already know they do not intersect
*/
int
-lw_dist2d_selected_seg_seg(POINT2D *A, POINT2D *B, POINT2D *C, POINT2D *D, DISTPTS *dl)
+lw_dist2d_selected_seg_seg(const POINT2D *A, const POINT2D *B, const POINT2D *C, const POINT2D *D, DISTPTS *dl)
{
LWDEBUGF(2, "lw_dist2d_selected_seg_seg [%g,%g]->[%g,%g] by [%g,%g]->[%g,%g]",
A->x,A->y,B->x,B->y, C->x,C->y, D->x, D->y);
* New faster distance calculations
*/
int lw_dist2d_pre_seg_seg(POINTARRAY *l1, POINTARRAY *l2,LISTSTRUCT *list1, LISTSTRUCT *list2,double k, DISTPTS *dl);
-int lw_dist2d_selected_seg_seg(POINT2D *A, POINT2D *B, POINT2D *C, POINT2D *D, DISTPTS *dl);
+int lw_dist2d_selected_seg_seg(const POINT2D *A, const POINT2D *B, const POINT2D *C, const POINT2D *D, DISTPTS *dl);
int struct_cmp_by_measure(const void *a, const void *b);
int lw_dist2d_fast_ptarray_ptarray(POINTARRAY *l1,POINTARRAY *l2, DISTPTS *dl, GBOX *box1, GBOX *box2);
double tlen, plen;
int t, seg=-1;
POINT4D start4d, end4d, projtmp;
- POINT2D start, end, proj, p;
+ POINT2D proj, p;
+ const POINT2D *start, *end;
/* Initialize our 2D copy of the input parameter */
p.x = p4d->x;
if ( ! proj4d ) proj4d = &projtmp;
- getPoint2d_p(pa, 0, &start);
+ start = getPoint2d_cp(pa, 0);
for (t=1; t<pa->npoints; t++)
{
double dist;
- getPoint2d_p(pa, t, &end);
- dist = distance2d_pt_seg(&p, &start, &end);
+ end = getPoint2d_cp(pa, t);
+ dist = distance2d_pt_seg(&p, start, end);
if (t==1 || dist < mindist )
{
LWDEBUGF(3, "Closest segment:%d, npoints:%d", seg, pa->npoints);
/* For robustness, force 1 when closest point == endpoint */
- if ( (seg >= (pa->npoints-2)) && p2d_same(&proj, &end) )
+ if ( (seg >= (pa->npoints-2)) && p2d_same(&proj, end) )
{
return 1.0;
}
if ( tlen == 0 ) return 0;
plen=0;
- getPoint2d_p(pa, 0, &start);
+ start = getPoint2d_cp(pa, 0);
for (t=0; t<seg; t++, start=end)
{
- getPoint2d_p(pa, t+1, &end);
- plen += distance2d_pt_pt(&start, &end);
+ end = getPoint2d_cp(pa, t+1);
+ plen += distance2d_pt_pt(start, end);
LWDEBUGF(4, "Segment %d made plen %g", t, plen);
}
- plen+=distance2d_pt_pt(&proj, &start);
+ plen+=distance2d_pt_pt(&proj, start);
LWDEBUGF(3, "plen %g, tlen %g", plen, tlen);
ptarray_dp_findsplit(POINTARRAY *pts, int p1, int p2, int *split, double *dist)
{
int k;
- POINT2D pa, pb;
- const POINT2D* pk;
+ const POINT2D *pk, *pa, *pb;
double tmp, d;
LWDEBUG(4, "function called");
if (p1 + 1 < p2)
{
- getPoint2d_p(pts, p1, &pa);
- getPoint2d_p(pts, p2, &pb);
+ pa = getPoint2d_cp(pts, p1);
+ pb = getPoint2d_cp(pts, p2);
LWDEBUGF(4, "P%d(%f,%f) to P%d(%f,%f)",
- p1, pa.x, pa.y, p2, pb.x, pb.y);
+ p1, pa->x, pa->y, p2, pb->x, pb->y);
for (k=p1+1; k<p2; k++)
{
LWDEBUGF(4, "P%d(%f,%f)", k, pk->x, pk->y);
/* distance computation */
- tmp = distance2d_sqr_pt_seg(pk, &pa, &pb);
+ tmp = distance2d_sqr_pt_seg(pk, pa, pb);
if (tmp > d)
{