88 double initdistance = ( mode ==
DIST_MIN ? FLT_MAX : -1.0);
97 LWDEBUG(2,
"lw_dist2d_distanceline is called");
102 lwerror(
"Some unspecified error.");
109 LWDEBUG(3,
"didn't find geometries to measure between, returning null");
135 double initdistance = FLT_MAX;
142 LWDEBUG(2,
"lw_dist2d_distancepoint is called");
147 lwerror(
"Some unspecified error.");
152 LWDEBUG(3,
"didn't find geometries to measure between, returning null");
171 LWDEBUG(2,
"lwgeom_maxdistance2d is called");
185 LWDEBUG(2,
"lwgeom_maxdistance2d_tolerance is called");
194 lwerror(
"Some unspecified error.");
204 LWDEBUG(2,
"lwgeom_mindistance2d is called");
216 LWDEBUG(2,
"lwgeom_mindistance2d_tolerance is called");
225 lwerror(
"Some unspecified error.");
247 LWDEBUG(2,
"lw_dist2d_comp is called");
287 LWDEBUGF(2,
"lw_dist2d_comp is called with type1=%d, type2=%d", lwg1->
type, lwg2->
type);
291 LWDEBUG(3,
"First geometry is collection");
297 LWDEBUG(3,
"Second geometry is collection");
302 for ( i = 0; i < n1; i++ )
318 LWDEBUG(3,
"Found collection inside first geometry collection, recursing");
322 for ( j = 0; j < n2; j++ )
334 LWDEBUG(3,
"Found collection inside second geometry collection, recursing");
486 lwerror(
"unspecified error in function lw_dist2d_distribute_bruteforce");
500 LWDEBUG(2,
"lw_dist2d_check_overlap is called");
510 LWDEBUG(3,
"geometries bboxes did not overlap");
513 LWDEBUG(3,
"geometries bboxes overlap");
525 int type1 = lwg1->
type;
526 int type2 = lwg2->
type;
528 LWDEBUGF(2,
"lw_dist2d_distribute_fast is called with typ1=%d, type2=%d", lwg1->
type, lwg2->
type);
533 pa1 = ((
LWLINE *)lwg1)->points;
536 pa1 = ((
LWPOLY *)lwg1)->rings[0];
545 pa2 = ((
LWLINE *)lwg2)->points;
548 pa2 = ((
LWPOLY *)lwg2)->rings[0];
592 LWDEBUG(2,
"lw_dist2d_point_line is called");
616 LWDEBUG(2,
"lw_dist2d_point_poly called");
622 LWDEBUG(3,
"looking for maxdistance");
628 LWDEBUG(3,
"first point not inside outer-ring");
638 for ( i = 1; i < poly->
nrings; i++)
648 LWDEBUG(3,
" inside the polygon");
667 lwerror(
"lw_dist2d_point_curvepoly cannot calculate max distance");
681 for ( i = 1; i < poly->
nrings; i++)
691 LWDEBUG(3,
" inside the polygon");
711 LWDEBUG(2,
"lw_dist2d_line_line is called");
738 LWDEBUGF(2,
"lw_dist2d_line_poly called (%d rings)", poly->
nrings);
746 for (i=1; i<poly->
nrings; i++)
750 LWDEBUGF(3,
" distance from ring %d: %f, mindist: %f",
775 for (i=1; i<poly->
nrings; i++)
806 for ( i = 1; i < poly->
nrings; i++ )
815 for ( i=1; i < poly->
nrings; i++ )
849 LWDEBUG(2,
"lw_dist2d_poly_poly called");
872 for (i=1; i<poly1->
nrings; i++)
883 for (i=1; i<poly2->
nrings; i++)
913 lwerror(
"Unspecified error in function lw_dist2d_poly_poly");
964 lwerror(
"lw_curvering_getfirstpoint2d_cp: unknown type");
975 LWDEBUG(2,
"lw_dist2d_curvepoly_curvepoly called");
998 for (i = 1; i < poly1->
nrings; i++)
1009 for (i = 1; i < poly2->
nrings; i++)
1038 lwerror(
"Unspecified error in function lw_dist2d_curvepoly_curvepoly");
1055 LWDEBUG(2,
"lw_dist2d_pt_ptarray is called");
1087 LWDEBUG(2,
"lw_dist2d_pt_ptarrayarc is called");
1091 lwerror(
"lw_dist2d_pt_ptarrayarc called with non-arc input");
1097 lwerror(
"lw_dist2d_pt_ptarrayarc does not currently support DIST_MAX mode");
1106 for ( t=1; t<pa->
npoints; t += 2 )
1149 LWDEBUGF(4,
"maxdist_ptarray_ptarray; seg %i * seg %i, dist = %g\n",t,u,dl->
distance);
1150 LWDEBUGF(3,
" seg%d-seg%d dist: %f, mindist: %f",
1167 LWDEBUGF(4,
"mindist_ptarray_ptarray; seg %i * seg %i, dist = %g\n",t,u,dl->
distance);
1168 LWDEBUGF(3,
" seg%d-seg%d dist: %f, mindist: %f",
1197 lwerror(
"lw_dist2d_ptarray_ptarrayarc called with non-arc input");
1203 lwerror(
"lw_dist2d_ptarray_ptarrayarc does not currently support DIST_MAX mode");
1209 for ( t=1; t < pa->
npoints; t++ )
1213 for ( u=1; u < pb->
npoints; u += 2 )
1252 lwerror(
"lw_dist2d_ptarrayarc_ptarrayarc does not currently support DIST_MAX mode");
1258 for ( t=1; t < pa->
npoints; t += 2 )
1263 for ( u=1; u < pb->
npoints; u += 2 )
1294 int pt_in_arc, pt_in_seg;
1299 lwerror(
"lw_dist2d_seg_arc does not support maxdistance mode");
1309 if ( radius_C < 0.0 )
1315 lwerror(
"lw_dist2d_pt_seg failed in lw_dist2d_seg_arc");
1323 if ( dist_C_D < radius_C )
1329 dist_D_EF = sqrt(radius_C*radius_C - dist_C_D*dist_C_D);
1330 length_A = sqrt((A2->
x-A1->
x)*(A2->
x-A1->
x)+(A2->
y-A1->
y)*(A2->
y-A1->
y));
1333 E.
x = D.
x - (A2->
x-A1->
x) * dist_D_EF / length_A;
1334 E.
y = D.
y - (A2->
y-A1->
y) * dist_D_EF / length_A;
1336 F.
x = D.
x + (A2->
x-A1->
x) * dist_D_EF / length_A;
1337 F.
y = D.
y + (A2->
y-A1->
y) * dist_D_EF / length_A;
1344 if ( pt_in_arc && pt_in_seg )
1356 if ( pt_in_arc && pt_in_seg )
1368 else if ( dist_C_D == radius_C )
1375 if ( pt_in_arc && pt_in_seg )
1389 G.
x = C.
x + (D.
x-C.
x) * radius_C / dist_C_D;
1390 G.
y = C.
y + (D.
y-C.
y) * radius_C / dist_C_D;
1396 if ( pt_in_arc && pt_in_seg )
1408 if ( pt_in_arc & ! pt_in_seg )
1415 else if ( pt_in_seg && ! pt_in_arc )
1442 lwerror(
"lw_dist2d_pt_arc does not support maxdistance mode");
1452 if ( radius_A < 0.0 )
1468 X.
x = C.
x + (P->
x - C.
x) * radius_A / d;
1469 X.
y = C.
y + (P->
y - C.
y) * radius_A / d;
1487 const POINT2D *A3,
double radius_A,
1489 const POINT2D *B3,
double radius_B,
1498 double radius_A, radius_B, d;
1500 int pt_in_arc_A, pt_in_arc_B;
1503 lwerror(
"lw_dist2d_arc_arc only supports mindistance");
1520 if ( radius_A < 0 && radius_B < 0 )
1537 B1, B2, B3, radius_B,
1541 if ( radius_B > radius_A )
1546 tmp = B1; B1 = A1; A1 = tmp;
1547 tmp = B2; B2 = A2; A2 = tmp;
1548 tmp = B3; B3 = A3; A3 = tmp;
1549 TP = CB; CB = CA; CA = TP;
1550 td = radius_B; radius_B = radius_A; radius_A = td;
1554 if ( d == (radius_A + radius_B) )
1556 D.
x = CA.
x + (CB.
x - CA.
x) * radius_A / d;
1557 D.
y = CA.
y + (CB.
y - CA.
y) * radius_A / d;
1563 if ( pt_in_arc_A && pt_in_arc_B )
1573 else if ( d > (radius_A + radius_B) || d < (radius_A - radius_B) )
1580 XA.
x = CA.
x + (CB.
x - CA.
x) * radius_A / d;
1581 XA.
y = CA.
y + (CB.
y - CA.
y) * radius_A / d;
1582 XB.
x = CB.
x + (CA.
x - CB.
x) * radius_B / d;
1583 XB.
y = CB.
y + (CA.
y - CB.
y) * radius_B / d;
1590 if ( pt_in_arc_A && pt_in_arc_B )
1597 else if ( d < (radius_A + radius_B) )
1601 double a = (radius_A*radius_A - radius_B*radius_B + d*d) / (2*d);
1603 double h = sqrt(radius_A*radius_A - a*a);
1606 D.
x = CA.
x + (CB.
x - CA.
x) * a / d;
1607 D.
y = CA.
y + (CB.
y - CA.
y) * a / d;
1610 E.
x = D.
x + (D.
y - CA.
y) * h / a;
1611 E.
y = D.
y + (D.
x - CA.
x) * h / a;
1617 if ( pt_in_arc_A && pt_in_arc_B )
1619 dl->
p1 = dl->
p2 = E;
1625 F.
x = D.
x - (D.
y - CA.
y) * h / a;
1626 F.
y = D.
y - (D.
x - CA.
x) * h / a;
1632 if ( pt_in_arc_A && pt_in_arc_B )
1634 dl->
p1 = dl->
p2 = F;
1641 lwerror(
"lw_dist2d_arc_arc: arcs neither touch, intersect nor are disjoint! INCONCEIVABLE!");
1647 if ( pt_in_arc_A & ! pt_in_arc_B )
1655 else if ( pt_in_arc_B && ! pt_in_arc_A )
1676 const POINT2D *A3,
double radius_A,
1678 const POINT2D *B3,
double radius_B,
1682 double dist_sqr, shortest_sqr;
1687 if (radius_A == radius_B)
1728 proj.
x = CENTER->
x + (B1->
x - CENTER->
x) * radius_A / radius_B;
1729 proj.
y = CENTER->
y + (B1->
y - CENTER->
y) * radius_A / radius_B;
1735 dl->
distance = fabs(radius_A - radius_B);
1739 proj.
x = CENTER->
x + (B3->
x - CENTER->
x) * radius_A / radius_B;
1740 proj.
y = CENTER->
y + (B3->
y - CENTER->
y) * radius_A / radius_B;
1745 dl->
distance = fabs(radius_A - radius_B);
1753 proj.
x = CENTER->
x + (A1->
x - CENTER->
x) * radius_B / radius_A;
1754 proj.
y = CENTER->
y + (A1->
y - CENTER->
y) * radius_B / radius_A;
1759 dl->
distance = fabs(radius_A - radius_B);
1764 proj.
x = CENTER->
x + (A3->
x - CENTER->
x) * radius_B / radius_A;
1765 proj.
y = CENTER->
y + (A3->
y - CENTER->
y) * radius_B / radius_A;
1770 dl->
distance = fabs(radius_A - radius_B);
1781 if (dist_sqr < shortest_sqr)
1783 shortest_sqr = dist_sqr;
1789 if (dist_sqr < shortest_sqr)
1791 shortest_sqr = dist_sqr;
1797 if (dist_sqr < shortest_sqr)
1799 shortest_sqr = dist_sqr;
1819 double s_top, s_bot,
s;
1820 double r_top, r_bot,
r;
1822 LWDEBUGF(2,
"lw_dist2d_seg_seg [%g,%g]->[%g,%g] by [%g,%g]->[%g,%g]",
1823 A->
x,A->
y,B->
x,B->
y, C->
x,C->
y, D->
x, D->
y);
1826 if ( ( A->
x == B->
x) && (A->
y == B->
y) )
1832 if ( ( C->
x == D->
x) && (C->
y == D->
y) )
1859 r_top = (A->
y-C->
y)*(D->
x-C->
x) - (A->
x-C->
x)*(D->
y-C->
y);
1860 r_bot = (B->
x-A->
x)*(D->
y-C->
y) - (B->
y-A->
y)*(D->
x-C->
x);
1862 s_top = (A->
y-C->
y)*(B->
x-A->
x) - (A->
x-C->
x)*(B->
y-A->
y);
1863 s_bot = (B->
x-A->
x)*(D->
y-C->
y) - (B->
y-A->
y)*(D->
x-C->
x);
1865 if ( (r_bot==0) || (s_bot == 0) )
1881 if (((r<0) || (r>1) || (s<0) || (s>1)) || (dl->
mode ==
DIST_MAX))
1899 if (((A->
x==C->
x)&&(A->
y==C->
y))||((A->
x==D->
x)&&(A->
y==D->
y)))
1904 else if (((B->
x==C->
x)&&(B->
y==C->
y))||((B->
x==D->
x)&&(B->
y==D->
y)))
1911 theP.
x = A->
x+r*(B->
x-A->
x);
1912 theP.
y = A->
y+r*(B->
y-A->
y);
1921 lwerror(
"unspecified error in function lw_dist2d_seg_seg");
1948 float deltaX, deltaY, c1m, c2m;
1951 float min1X, max1X, max1Y, min1Y,min2X, max2X, max2Y, min2Y;
1960 LWDEBUG(2,
"lw_dist2d_fast_ptarray_ptarray is called");
1971 c1.
x = min1X + (max1X-min1X)/2;
1972 c1.
y = min1Y + (max1Y-min1Y)/2;
1973 c2.
x = min2X + (max2X-min2X)/2;
1974 c2.
y = min2Y + (max2Y-min2Y)/2;
1982 if ((deltaX*deltaX)<(deltaY*deltaY))
1985 for (t=0; t<n1; t++)
1988 thevalue = theP->
y - (k * theP->
x);
1993 for (t=0; t<n2; t++)
1996 thevalue = theP->
y - (k * theP->
x);
2001 c1m = c1.
y-(k*c1.
x);
2002 c2m = c2.
y-(k*c2.
x);
2011 for (t=0; t<n1; t++)
2014 thevalue = theP->
x - (k * theP->
y);
2019 for (t=0; t<n2; t++)
2022 thevalue = theP->
x - (k * theP->
y);
2027 c1m = c1.
x-(k*c1.
y);
2028 c2m = c2.
x-(k*c2.
y);
2075 int pnr1,pnr2,pnr3,pnr4, n1, n2, i, u,
r, twist;
2080 LWDEBUG(2,
"lw_dist2d_pre_seg_seg is called");
2087 for (i =(n1-1); i>=0; --i)
2092 if (((list2[0].themeasure-list1[i].themeasure)) > maxmeasure)
break;
2093 for (r=-1; r<=1; r +=2)
2095 pnr1 = list1[i].
pnr;
2100 if (( p1->
x == p01->
x) && (p1->
y == p01->
y)) pnr2 = (n1-1);
2104 else if (pnr1+r>(n1-1))
2107 if (( p1->
x == p01->
x) && (p1->
y == p01->
y)) pnr2 = 0;
2114 for (u=0; u<n2; ++u)
2116 if (((list2[u].themeasure-list1[i].themeasure)) >= maxmeasure)
break;
2117 pnr3 = list2[u].
pnr;
2122 if (( p3->
x == p02->
x) && (p3->
y == p02->
y)) pnr4 = (n2-1);
2134 if (( p3->
x == p02->
x) && (p3->
y == p02->
y)) pnr4 = 0;
2161 LWDEBUGF(2,
"lw_dist2d_selected_seg_seg [%g,%g]->[%g,%g] by [%g,%g]->[%g,%g]",
2162 A->
x,A->
y,B->
x,B->
y, C->
x,C->
y, D->
x, D->
y);
2165 if ( ( A->
x == B->
x) && (A->
y == B->
y) )
2171 if ( ( C->
x == D->
x) && (C->
y == D->
y) )
2210 if ( ( A->
x == B->
x) && (A->
y == B->
y) )
2229 r = ( (p->
x-A->
x) * (B->
x-A->
x) + (p->
y-A->
y) * (B->
y-A->
y) )/( (B->
x-A->
x)*(B->
x-A->
x) +(B->
y-A->
y)*(B->
y-A->
y) );
2266 c.
x=A->
x + r * (B->
x-A->
x);
2267 c.
y=A->
y + r * (B->
y-A->
y);
2283 double hside = thep2->
x - thep1->
x;
2284 double vside = thep2->
y - thep1->
y;
2285 double dist = sqrt ( hside*hside + vside*vside );
2319 double hside = p2->
x - p1->
x;
2320 double vside = p2->
y - p1->
y;
2322 return sqrt ( hside*hside + vside*vside );
2329 double hside = p2->
x - p1->
x;
2330 double vside = p2->
y - p1->
y;
2332 return hside*hside + vside*vside;
2347 if ( ( A->
x == B->
x) && (A->
y == B->
y) )
2365 r = ( (p->
x-A->
x) * (B->
x-A->
x) + (p->
y-A->
y) * (B->
y-A->
y) )/( (B->
x-A->
x)*(B->
x-A->
x) +(B->
y-A->
y)*(B->
y-A->
y) );
2381 s = ( (A->
y-p->
y)*(B->
x-A->
x)- (A->
x-p->
x)*(B->
y-A->
y) ) /
2382 ( (B->
x-A->
x)*(B->
x-A->
x) +(B->
y-A->
y)*(B->
y-A->
y) );
2385 (B->
x-A->
x)*(B->
x-A->
x) + (B->
y-A->
y)*(B->
y-A->
y)
2395 if ( ( A->
x == B->
x) && (A->
y == B->
y) )
2398 r = ( (p->
x-A->
x) * (B->
x-A->
x) + (p->
y-A->
y) * (B->
y-A->
y) )/( (B->
x-A->
x)*(B->
x-A->
x) +(B->
y-A->
y)*(B->
y-A->
y) );
2414 s = ( (A->
y-p->
y)*(B->
x-A->
x)- (A->
x-p->
x)*(B->
y-A->
y) ) /
2415 ( (B->
x-A->
x)*(B->
x-A->
x) +(B->
y-A->
y)*(B->
y-A->
y) );
2417 return s * s * ( (B->
x-A->
x)*(B->
x-A->
x) + (B->
y-A->
y)*(B->
y-A->
y) );
2431 if ( A->
y < B->
y ) *d=0.0;
2432 else if ( A->
y > B->
y ) *d=M_PI;
2439 if ( A->
x < B->
x ) *d=M_PI/2;
2440 else if ( A->
x > B->
x ) *d=M_PI+(M_PI/2);
2449 *d=atan(fabs(A->
x - B->
x) / fabs(A->
y - B->
y) );
2453 *d=atan(fabs(A->
y - B->
y) / fabs(A->
x - B->
x) )
2462 *d=atan(fabs(A->
x - B->
x) / fabs(A->
y - B->
y) )
2467 *d=atan(fabs(A->
y - B->
y) / fabs(A->
x - B->
x) )
double distance2d_sqr_pt_pt(const POINT2D *p1, const POINT2D *p2)
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_dist2d_line_curvepoly(LWLINE *line, LWCURVEPOLY *poly, DISTPTS *dl)
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_dist2d_circstring_circstring(LWCIRCSTRING *line1, LWCIRCSTRING *line2, DISTPTS *dl)
double lwgeom_maxdistance2d_tolerance(const LWGEOM *lw1, const LWGEOM *lw2, double tolerance)
Function handling max distance calculations and dfyllywithin calculations.
LWGEOM * lw_dist2d_distancepoint(const LWGEOM *lw1, const LWGEOM *lw2, int srid, int mode)
Function initializing closestpoint calculations.
int lw_dist2d_arc_arc_concentric(const POINT2D *A1, const POINT2D *A2, const POINT2D *A3, double radius_A, const POINT2D *B1, const POINT2D *B2, const POINT2D *B3, double radius_B, const POINT2D *CENTER, DISTPTS *dl)
int lw_dist2d_comp(const LWGEOM *lw1, const LWGEOM *lw2, DISTPTS *dl)
This function just deserializes geometries Bboxes is not checked here since it is the subgeometries b...
int lw_dist2d_circstring_poly(LWCIRCSTRING *circ, LWPOLY *poly, DISTPTS *dl)
int lw_dist2d_point_curvepoly(LWPOINT *point, LWCURVEPOLY *poly, DISTPTS *dl)
double distance2d_pt_seg(const POINT2D *p, const POINT2D *A, const POINT2D *B)
The old function nessecary for ptarray_segmentize2d in ptarray.c.
double distance2d_sqr_pt_seg(const POINT2D *p, const POINT2D *A, const POINT2D *B)
int lw_dist2d_recursive(const LWGEOM *lwg1, const LWGEOM *lwg2, DISTPTS *dl)
This is a recursive function delivering every possible combinatin of subgeometries.
int struct_cmp_by_measure(const void *a, const void *b)
int lw_dist2d_point_point(LWPOINT *point1, LWPOINT *point2, DISTPTS *dl)
point to point calculation
LWPOINT * lwpoint_make2d(int srid, double x, double y)
LWLINE * lwline_from_ptarray(int srid, uint32_t npoints, LWPOINT **points)
void lwgeom_free(LWGEOM *geom)
int lw_dist2d_circstring_curvepoly(LWCIRCSTRING *circ, LWCURVEPOLY *poly, DISTPTS *dl)
LWGEOM * lwgeom_closest_line(const LWGEOM *lw1, const LWGEOM *lw2)
#define LWDEBUG(level, msg)
#define POLYHEDRALSURFACETYPE
int lw_dist2d_point_poly(LWPOINT *point, LWPOLY *poly, DISTPTS *dl)
double lwgeom_mindistance2d(const LWGEOM *lw1, const LWGEOM *lw2)
Function initialazing min distance calculation.
LWGEOM * lwgeom_furthest_line(const LWGEOM *lw1, const LWGEOM *lw2)
int lw_dist2d_fast_ptarray_ptarray(POINTARRAY *l1, POINTARRAY *l2, DISTPTS *dl, GBOX *box1, GBOX *box2)
The new faster calculation comparing pointarray to another pointarray the arrays can come from both p...
int lw_dist2d_arc_arc(const POINT2D *A1, const POINT2D *A2, const POINT2D *A3, const POINT2D *B1, const POINT2D *B2, const POINT2D *B3, DISTPTS *dl)
int lw_dist2d_curvepoly_curvepoly(LWCURVEPOLY *poly1, LWCURVEPOLY *poly2, DISTPTS *dl)
int lw_dist2d_pre_seg_seg(POINTARRAY *l1, POINTARRAY *l2, LISTSTRUCT *list1, LISTSTRUCT *list2, double k, DISTPTS *dl)
preparation before lw_dist2d_seg_seg.
LWGEOM * lw_dist2d_distanceline(const LWGEOM *lw1, const LWGEOM *lw2, int srid, int mode)
Function initializing shortestline and longestline calculations.
int lwgeom_calculate_gbox(const LWGEOM *lwgeom, GBOX *gbox)
Calculate bounding box of a geometry, automatically taking into account whether it is cartesian or ge...
int p2d_same(const POINT2D *p1, const POINT2D *p2)
int lw_dist2d_poly_poly(LWPOLY *poly1, LWPOLY *poly2, DISTPTS *dl)
Function handling polygon to polygon calculation 1 if we are looking for maxdistance, just check the outer rings.
LWCURVEPOLY * lwcurvepoly_construct_from_lwpoly(LWPOLY *lwpoly)
Construct an equivalent curve polygon from a polygon.
static int lw_dist2d_is_collection(const LWGEOM *g)
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
const POINT2D * getPoint2d_cp(const POINTARRAY *pa, int n)
Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from...
LWGEOM * lwgeom_closest_point(const LWGEOM *lw1, const LWGEOM *lw2)
int azimuth_pt_pt(const POINT2D *A, const POINT2D *B, double *d)
Compute the azimuth of segment AB in radians.
#define LW_TRUE
Return types for functions with status returns.
int lw_dist2d_ptarray_ptarrayarc(const POINTARRAY *pa, const POINTARRAY *pb, DISTPTS *dl)
Test each segment of pa against each arc of pb for distance.
int lw_dist2d_pt_arc(const POINT2D *P, const POINT2D *A1, const POINT2D *A2, const POINT2D *A3, DISTPTS *dl)
int lw_dist2d_line_poly(LWLINE *line, LWPOLY *poly, DISTPTS *dl)
line to polygon calculation Brute force.
int lw_dist2d_point_circstring(LWPOINT *point, LWCIRCSTRING *circ, DISTPTS *dl)
int lw_dist2d_pt_seg(const POINT2D *p, const POINT2D *A, const POINT2D *B, DISTPTS *dl)
lw_dist2d_comp from p to line A->B This one is now sending every occation to lw_dist2d_pt_pt Before i...
int lw_dist2d_point_line(LWPOINT *point, LWLINE *line, DISTPTS *dl)
point to line calculation
int lw_dist2d_line_circstring(LWLINE *line1, LWCIRCSTRING *line2, DISTPTS *dl)
int lw_dist2d_pt_ptarrayarc(const POINT2D *p, const POINTARRAY *pa, DISTPTS *dl)
Search all the arcs of pointarray to see which one is closest to p1 Returns minimum distance between ...
int lw_dist2d_seg_seg(const POINT2D *A, const POINT2D *B, const POINT2D *C, const POINT2D *D, DISTPTS *dl)
Finds the shortest distance between two segments.
int lw_dist2d_pt_ptarray(const POINT2D *p, POINTARRAY *pa, DISTPTS *dl)
search all the segments of pointarray to see which one is closest to p1 Returns minimum distance betw...
double lwgeom_maxdistance2d(const LWGEOM *lw1, const LWGEOM *lw2)
Function initialazing max distance calculation.
int lw_dist2d_poly_curvepoly(LWPOLY *poly1, LWCURVEPOLY *curvepoly2, DISTPTS *dl)
int lw_dist2d_distribute_bruteforce(const LWGEOM *lwg1, const LWGEOM *lwg2, DISTPTS *dl)
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 lw_dist2d_selected_seg_seg(const POINT2D *A, const POINT2D *B, const POINT2D *C, const POINT2D *D, DISTPTS *dl)
This is the same function as lw_dist2d_seg_seg but without any calculations to determine intersection...
int lw_dist2d_check_overlap(LWGEOM *lwg1, LWGEOM *lwg2)
We have to check for overlapping bboxes.
int lw_dist2d_line_line(LWLINE *line1, LWLINE *line2, DISTPTS *dl)
line to line calculation
LWCOLLECTION * lwgeom_as_lwcollection(const LWGEOM *lwgeom)
double distance2d_pt_pt(const POINT2D *p1, const POINT2D *p2)
The old function nessecary for ptarray_segmentize2d in ptarray.c.
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
int lw_dist2d_ptarrayarc_ptarrayarc(const POINTARRAY *pa, const POINTARRAY *pb, DISTPTS *dl)
Test each arc of pa against each arc of pb for distance.
void lwgeom_add_bbox(LWGEOM *lwgeom)
Compute a bbox if not already computed.
LWGEOM * lwgeom_furthest_point(const LWGEOM *lw1, const LWGEOM *lw2)
static const POINT2D * lw_curvering_getfirstpoint2d_cp(LWGEOM *geom)
int lw_pt_in_seg(const POINT2D *P, const POINT2D *A1, const POINT2D *A2)
Returns true if P is between A1/A2.
int lw_dist2d_seg_arc(const POINT2D *A1, const POINT2D *A2, const POINT2D *B1, const POINT2D *B2, const POINT2D *B3, DISTPTS *dl)
Calculate the shortest distance between an arc and an edge.
int ptarray_contains_point(const POINTARRAY *pa, const POINT2D *pt)
Return 1 if the point is inside the POINTARRAY, -1 if it is outside, and 0 if it is on the boundary...
double lwgeom_mindistance2d_tolerance(const LWGEOM *lw1, const LWGEOM *lw2, double tolerance)
Function handling min distance calculations and dwithin calculations.
void * lwalloc(size_t size)
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members) ...
int lw_segment_side(const POINT2D *p1, const POINT2D *p2, const POINT2D *q)
lw_segment_side()
Structure used in distance-calculations.
void lw_dist2d_distpts_init(DISTPTS *dl, int mode)
int lwgeom_contains_point(const LWGEOM *geom, const POINT2D *pt)
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int srid, char hasz, char hasm)
int lw_dist2d_ptarray_ptarray(POINTARRAY *l1, POINTARRAY *l2, DISTPTS *dl)
test each segment of l1 against each segment of l2.
#define LWDEBUGF(level, msg,...)
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
int lw_dist2d_pt_pt(const POINT2D *thep1, const POINT2D *thep2, DISTPTS *dl)
Compares incomming points and stores the points closest to each other or most far away from each othe...
int lw_dist2d_distribute_fast(LWGEOM *lwg1, LWGEOM *lwg2, DISTPTS *dl)
Here the geometries are distributed for the new faster distance-calculations.