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");
504 LWDEBUG(2,
"lw_dist2d_check_overlap is called");
514 LWDEBUG(3,
"geometries bboxes did not overlap");
517 LWDEBUG(3,
"geometries bboxes overlap");
529 int type1 = lwg1->
type;
530 int type2 = lwg2->
type;
532 LWDEBUGF(2,
"lw_dist2d_distribute_fast is called with typ1=%d, type2=%d", lwg1->
type, lwg2->
type);
537 pa1 = ((
LWLINE *)lwg1)->points;
540 pa1 = ((
LWPOLY *)lwg1)->rings[0];
549 pa2 = ((
LWLINE *)lwg2)->points;
552 pa2 = ((
LWPOLY *)lwg2)->rings[0];
596 LWDEBUG(2,
"lw_dist2d_point_line is called");
620 LWDEBUG(2,
"lw_dist2d_point_poly called");
626 LWDEBUG(3,
"looking for maxdistance");
632 LWDEBUG(3,
"first point not inside outer-ring");
642 for ( i = 1; i < poly->
nrings; i++)
652 LWDEBUG(3,
" inside the polygon");
671 lwerror(
"lw_dist2d_point_curvepoly cannot calculate max distance");
685 for ( i = 1; i < poly->
nrings; i++)
695 LWDEBUG(3,
" inside the polygon");
715 LWDEBUG(2,
"lw_dist2d_line_line is called");
742 LWDEBUGF(2,
"lw_dist2d_line_poly called (%d rings)", poly->
nrings);
750 for (i=1; i<poly->
nrings; i++)
754 LWDEBUGF(3,
" distance from ring %d: %f, mindist: %f",
779 for (i=1; i<poly->
nrings; i++)
810 for ( i = 1; i < poly->
nrings; i++ )
819 for ( i=1; i < poly->
nrings; i++ )
853 LWDEBUG(2,
"lw_dist2d_poly_poly called");
876 for (i=1; i<poly1->
nrings; i++)
887 for (i=1; i<poly2->
nrings; i++)
917 lwerror(
"Unspecified error in function lw_dist2d_poly_poly");
968 lwerror(
"lw_curvering_getfirstpoint2d_cp: unknown type");
979 LWDEBUG(2,
"lw_dist2d_curvepoly_curvepoly called");
1002 for (i = 1; i < poly1->
nrings; i++)
1013 for (i = 1; i < poly2->
nrings; i++)
1042 lwerror(
"Unspecified error in function lw_dist2d_curvepoly_curvepoly");
1059 LWDEBUG(2,
"lw_dist2d_pt_ptarray is called");
1091 LWDEBUG(2,
"lw_dist2d_pt_ptarrayarc is called");
1095 lwerror(
"lw_dist2d_pt_ptarrayarc called with non-arc input");
1101 lwerror(
"lw_dist2d_pt_ptarrayarc does not currently support DIST_MAX mode");
1110 for ( t=1; t<pa->
npoints; t += 2 )
1153 LWDEBUGF(4,
"maxdist_ptarray_ptarray; seg %i * seg %i, dist = %g\n",t,u,dl->
distance);
1154 LWDEBUGF(3,
" seg%d-seg%d dist: %f, mindist: %f",
1171 LWDEBUGF(4,
"mindist_ptarray_ptarray; seg %i * seg %i, dist = %g\n",t,u,dl->
distance);
1172 LWDEBUGF(3,
" seg%d-seg%d dist: %f, mindist: %f",
1201 lwerror(
"lw_dist2d_ptarray_ptarrayarc called with non-arc input");
1207 lwerror(
"lw_dist2d_ptarray_ptarrayarc does not currently support DIST_MAX mode");
1213 for ( t=1; t < pa->
npoints; t++ )
1217 for ( u=1; u < pb->
npoints; u += 2 )
1256 lwerror(
"lw_dist2d_ptarrayarc_ptarrayarc does not currently support DIST_MAX mode");
1262 for ( t=1; t < pa->
npoints; t += 2 )
1267 for ( u=1; u < pb->
npoints; u += 2 )
1298 int pt_in_arc, pt_in_seg;
1303 lwerror(
"lw_dist2d_seg_arc does not support maxdistance mode");
1313 if ( radius_C < 0.0 )
1319 lwerror(
"lw_dist2d_pt_seg failed in lw_dist2d_seg_arc");
1327 if ( dist_C_D < radius_C )
1333 dist_D_EF = sqrt(radius_C*radius_C - dist_C_D*dist_C_D);
1334 length_A = sqrt((A2->
x-A1->
x)*(A2->
x-A1->
x)+(A2->
y-A1->
y)*(A2->
y-A1->
y));
1337 E.
x = D.
x - (A2->
x-A1->
x) * dist_D_EF / length_A;
1338 E.
y = D.
y - (A2->
y-A1->
y) * dist_D_EF / length_A;
1340 F.
x = D.
x + (A2->
x-A1->
x) * dist_D_EF / length_A;
1341 F.
y = D.
y + (A2->
y-A1->
y) * dist_D_EF / length_A;
1348 if ( pt_in_arc && pt_in_seg )
1360 if ( pt_in_arc && pt_in_seg )
1372 else if ( dist_C_D == radius_C )
1379 if ( pt_in_arc && pt_in_seg )
1393 G.
x = C.
x + (D.
x-C.
x) * radius_C / dist_C_D;
1394 G.
y = C.
y + (D.
y-C.
y) * radius_C / dist_C_D;
1400 if ( pt_in_arc && pt_in_seg )
1412 if (pt_in_arc && !pt_in_seg)
1419 else if (pt_in_seg && !pt_in_arc)
1446 lwerror(
"lw_dist2d_pt_arc does not support maxdistance mode");
1456 if ( radius_A < 0.0 )
1472 X.
x = C.
x + (P->
x - C.
x) * radius_A / d;
1473 X.
y = C.
y + (P->
y - C.
y) * radius_A / d;
1491 const POINT2D *A3,
double radius_A,
1493 const POINT2D *B3,
double radius_B,
1502 double radius_A, radius_B, d;
1504 int pt_in_arc_A, pt_in_arc_B;
1507 lwerror(
"lw_dist2d_arc_arc only supports mindistance");
1524 if ( radius_A < 0 && radius_B < 0 )
1541 B1, B2, B3, radius_B,
1545 if ( radius_B > radius_A )
1550 tmp = B1; B1 = A1; A1 = tmp;
1551 tmp = B2; B2 = A2; A2 = tmp;
1552 tmp = B3; B3 = A3; A3 = tmp;
1553 TP = CB; CB = CA; CA = TP;
1554 td = radius_B; radius_B = radius_A; radius_A = td;
1558 if ( d == (radius_A + radius_B) )
1560 D.
x = CA.
x + (CB.
x - CA.
x) * radius_A / d;
1561 D.
y = CA.
y + (CB.
y - CA.
y) * radius_A / d;
1567 if ( pt_in_arc_A && pt_in_arc_B )
1577 else if ( d > (radius_A + radius_B) || d < (radius_A - radius_B) )
1584 XA.
x = CA.
x + (CB.
x - CA.
x) * radius_A / d;
1585 XA.
y = CA.
y + (CB.
y - CA.
y) * radius_A / d;
1586 XB.
x = CB.
x + (CA.
x - CB.
x) * radius_B / d;
1587 XB.
y = CB.
y + (CA.
y - CB.
y) * radius_B / d;
1594 if ( pt_in_arc_A && pt_in_arc_B )
1601 else if ( d < (radius_A + radius_B) )
1605 double a = (radius_A*radius_A - radius_B*radius_B + d*d) / (2*d);
1607 double h = sqrt(radius_A*radius_A - a*a);
1610 D.
x = CA.
x + (CB.
x - CA.
x) * a / d;
1611 D.
y = CA.
y + (CB.
y - CA.
y) * a / d;
1614 E.
x = D.
x + (D.
y - CA.
y) * h / a;
1615 E.
y = D.
y + (D.
x - CA.
x) * h / a;
1621 if ( pt_in_arc_A && pt_in_arc_B )
1623 dl->
p1 = dl->
p2 = E;
1629 F.
x = D.
x - (D.
y - CA.
y) * h / a;
1630 F.
y = D.
y - (D.
x - CA.
x) * h / a;
1636 if ( pt_in_arc_A && pt_in_arc_B )
1638 dl->
p1 = dl->
p2 = F;
1645 lwerror(
"lw_dist2d_arc_arc: arcs neither touch, intersect nor are disjoint! INCONCEIVABLE!");
1651 if (pt_in_arc_A && !pt_in_arc_B)
1659 else if ( pt_in_arc_B && ! pt_in_arc_A )
1680 const POINT2D *A3,
double radius_A,
1682 const POINT2D *B3,
double radius_B,
1686 double dist_sqr, shortest_sqr;
1691 if (radius_A == radius_B)
1732 proj.
x = CENTER->
x + (B1->
x - CENTER->
x) * radius_A / radius_B;
1733 proj.
y = CENTER->
y + (B1->
y - CENTER->
y) * radius_A / radius_B;
1739 dl->
distance = fabs(radius_A - radius_B);
1743 proj.
x = CENTER->
x + (B3->
x - CENTER->
x) * radius_A / radius_B;
1744 proj.
y = CENTER->
y + (B3->
y - CENTER->
y) * radius_A / radius_B;
1749 dl->
distance = fabs(radius_A - radius_B);
1757 proj.
x = CENTER->
x + (A1->
x - CENTER->
x) * radius_B / radius_A;
1758 proj.
y = CENTER->
y + (A1->
y - CENTER->
y) * radius_B / radius_A;
1763 dl->
distance = fabs(radius_A - radius_B);
1768 proj.
x = CENTER->
x + (A3->
x - CENTER->
x) * radius_B / radius_A;
1769 proj.
y = CENTER->
y + (A3->
y - CENTER->
y) * radius_B / radius_A;
1774 dl->
distance = fabs(radius_A - radius_B);
1785 if (dist_sqr < shortest_sqr)
1787 shortest_sqr = dist_sqr;
1793 if (dist_sqr < shortest_sqr)
1795 shortest_sqr = dist_sqr;
1801 if (dist_sqr < shortest_sqr)
1803 shortest_sqr = dist_sqr;
1823 double s_top, s_bot,
s;
1824 double r_top, r_bot,
r;
1826 LWDEBUGF(2,
"lw_dist2d_seg_seg [%g,%g]->[%g,%g] by [%g,%g]->[%g,%g]",
1827 A->
x,A->
y,B->
x,B->
y, C->
x,C->
y, D->
x, D->
y);
1830 if ( ( A->
x == B->
x) && (A->
y == B->
y) )
1836 if ( ( C->
x == D->
x) && (C->
y == D->
y) )
1863 r_top = (A->
y-C->
y)*(D->
x-C->
x) - (A->
x-C->
x)*(D->
y-C->
y);
1864 r_bot = (B->
x-A->
x)*(D->
y-C->
y) - (B->
y-A->
y)*(D->
x-C->
x);
1866 s_top = (A->
y-C->
y)*(B->
x-A->
x) - (A->
x-C->
x)*(B->
y-A->
y);
1867 s_bot = (B->
x-A->
x)*(D->
y-C->
y) - (B->
y-A->
y)*(D->
x-C->
x);
1869 if ( (r_bot==0) || (s_bot == 0) )
1903 if (((A->
x==C->
x)&&(A->
y==C->
y))||((A->
x==D->
x)&&(A->
y==D->
y)))
1908 else if (((B->
x==C->
x)&&(B->
y==C->
y))||((B->
x==D->
x)&&(B->
y==D->
y)))
1915 theP.
x = A->
x+
r*(B->
x-A->
x);
1916 theP.
y = A->
y+
r*(B->
y-A->
y);
1949 float deltaX, deltaY, c1m, c2m;
1952 float min1X, max1X, max1Y, min1Y,min2X, max2X, max2Y, min2Y;
1961 LWDEBUG(2,
"lw_dist2d_fast_ptarray_ptarray is called");
1972 c1.
x = min1X + (max1X-min1X)/2;
1973 c1.
y = min1Y + (max1Y-min1Y)/2;
1974 c2.
x = min2X + (max2X-min2X)/2;
1975 c2.
y = min2Y + (max2Y-min2Y)/2;
1983 if ((deltaX*deltaX)<(deltaY*deltaY))
1986 for (t=0; t<n1; t++)
1989 thevalue = theP->
y - (k * theP->
x);
1994 for (t=0; t<n2; t++)
1997 thevalue = theP->
y - (k * theP->
x);
2002 c1m = c1.
y-(k*c1.
x);
2003 c2m = c2.
y-(k*c2.
x);
2012 for (t=0; t<n1; t++)
2015 thevalue = theP->
x - (k * theP->
y);
2020 for (t=0; t<n2; t++)
2023 thevalue = theP->
x - (k * theP->
y);
2028 c1m = c1.
x-(k*c1.
y);
2029 c2m = c2.
x-(k*c2.
y);
2075 const POINT2D *p1, *p2, *p3, *p4, *p01, *p02;
2076 int pnr1,pnr2,pnr3,pnr4, n1, n2, i, u,
r, twist;
2081 LWDEBUG(2,
"lw_dist2d_pre_seg_seg is called");
2088 for (i =(n1-1); i>=0; --i)
2093 if (((list2[0].themeasure-list1[i].themeasure)) > maxmeasure)
break;
2094 for (
r=-1;
r<=1;
r +=2)
2096 pnr1 = list1[i].
pnr;
2101 if (( p1->
x == p01->
x) && (p1->
y == p01->
y)) pnr2 = (n1-1);
2105 else if (pnr1+
r>(n1-1))
2108 if (( p1->
x == p01->
x) && (p1->
y == p01->
y)) pnr2 = 0;
2115 for (u=0; u<n2; ++u)
2117 if (((list2[u].themeasure-list1[i].themeasure)) >= maxmeasure)
break;
2118 pnr3 = list2[u].
pnr;
2123 if (( p3->
x == p02->
x) && (p3->
y == p02->
y)) pnr4 = (n2-1);
2135 if (( p3->
x == p02->
x) && (p3->
y == p02->
y)) pnr4 = 0;
2162 LWDEBUGF(2,
"lw_dist2d_selected_seg_seg [%g,%g]->[%g,%g] by [%g,%g]->[%g,%g]",
2163 A->
x,A->
y,B->
x,B->
y, C->
x,C->
y, D->
x, D->
y);
2166 if ( ( A->
x == B->
x) && (A->
y == B->
y) )
2172 if ( ( C->
x == D->
x) && (C->
y == D->
y) )
2211 if ( ( A->
x == B->
x) && (A->
y == B->
y) )
2230 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) );
2267 c.
x=A->
x +
r * (B->
x-A->
x);
2268 c.
y=A->
y +
r * (B->
y-A->
y);
2284 double hside = thep2->
x - thep1->
x;
2285 double vside = thep2->
y - thep1->
y;
2286 double dist = sqrt ( hside*hside + vside*vside );
2316 double hside = p2->
x - p1->
x;
2317 double vside = p2->
y - p1->
y;
2319 return hypot(hside, vside);
2325 double hside = p2->
x - p1->
x;
2326 double vside = p2->
y - p1->
y;
2328 return hside * hside + vside * vside;
2337 if ( ( A->
x == B->
x) && (A->
y == B->
y) )
2355 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) );
2371 s = ( (A->
y-p->
y)*(B->
x-A->
x)- (A->
x-p->
x)*(B->
y-A->
y) ) /
2372 ( (B->
x-A->
x)*(B->
x-A->
x) +(B->
y-A->
y)*(B->
y-A->
y) );
2375 (B->
x-A->
x)*(B->
x-A->
x) + (B->
y-A->
y)*(B->
y-A->
y)
2385 if ( ( A->
x == B->
x) && (A->
y == B->
y) )
2388 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) );
2404 s = ( (A->
y-p->
y)*(B->
x-A->
x)- (A->
x-p->
x)*(B->
y-A->
y) ) /
2405 ( (B->
x-A->
x)*(B->
x-A->
x) +(B->
y-A->
y)*(B->
y-A->
y) );
2407 return s *
s * ( (B->
x-A->
x)*(B->
x-A->
x) + (B->
y-A->
y)*(B->
y-A->
y) );
2421 if ( A->
y < B->
y ) *d=0.0;
2422 else if ( A->
y > B->
y ) *d=M_PI;
2429 if ( A->
x < B->
x ) *d=M_PI/2;
2430 else if ( A->
x > B->
x ) *d=M_PI+(M_PI/2);
2439 *d=atan(fabs(A->
x - B->
x) / fabs(A->
y - B->
y) );
2443 *d=atan(fabs(A->
y - B->
y) / fabs(A->
x - B->
x) )
2452 *d=atan(fabs(A->
x - B->
x) / fabs(A->
y - B->
y) )
2457 *d=atan(fabs(A->
y - B->
y) / fabs(A->
x - B->
x) )
LWPOINT * lwpoint_make2d(int srid, double x, double y)
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int srid, char hasz, char hasm)
void lwgeom_free(LWGEOM *geom)
LWCURVEPOLY * lwcurvepoly_construct_from_lwpoly(LWPOLY *lwpoly)
Construct an equivalent curve polygon from a polygon.
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
#define POLYHEDRALSURFACETYPE
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
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...
LWLINE * lwline_from_ptarray(int srid, uint32_t npoints, LWPOINT **points)
void * lwalloc(size_t size)
LWCOLLECTION * lwgeom_as_lwcollection(const LWGEOM *lwgeom)
#define LW_TRUE
Return types for functions with status returns.
void lwgeom_add_bbox(LWGEOM *lwgeom)
Compute a bbox if not already computed.
const POINT2D * getPoint2d_cp(const POINTARRAY *pa, uint32_t n)
Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from.
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 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.
int lw_pt_in_seg(const POINT2D *P, const POINT2D *A1, const POINT2D *A2)
Returns true if P is between A1/A2.
int lwgeom_contains_point(const LWGEOM *geom, const POINT2D *pt)
int lw_segment_side(const POINT2D *p1, const POINT2D *p2, const POINT2D *q)
lw_segment_side()
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)
#define LWDEBUG(level, msg)
#define LWDEBUGF(level, msg,...)
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
int lw_dist2d_circstring_curvepoly(LWCIRCSTRING *circ, LWCURVEPOLY *poly, DISTPTS *dl)
int struct_cmp_by_measure(const void *a, const void *b)
int lw_dist2d_line_curvepoly(LWLINE *line, LWCURVEPOLY *poly, DISTPTS *dl)
double distance2d_pt_pt(const POINT2D *p1, const POINT2D *p2)
LWGEOM * lwgeom_closest_point(const LWGEOM *lw1, const LWGEOM *lw2)
double lwgeom_maxdistance2d(const LWGEOM *lw1, const LWGEOM *lw2)
Function initializing max distance calculation.
int lw_dist2d_line_circstring(LWLINE *line1, LWCIRCSTRING *line2, DISTPTS *dl)
int lw_dist2d_poly_poly(LWPOLY *poly1, LWPOLY *poly2, DISTPTS *dl)
Function handling polygon to polygon calculation 1 if we are looking for maxdistance,...
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_pt_arc(const POINT2D *P, const POINT2D *A1, const POINT2D *A2, const POINT2D *A3, DISTPTS *dl)
double distance2d_sqr_pt_pt(const POINT2D *p1, const POINT2D *p2)
int lw_dist2d_pre_seg_seg(POINTARRAY *l1, POINTARRAY *l2, LISTSTRUCT *list1, LISTSTRUCT *list2, double k, DISTPTS *dl)
preparation before lw_dist2d_seg_seg.
int azimuth_pt_pt(const POINT2D *A, const POINT2D *B, double *d)
Compute the azimuth of segment AB in radians.
LWGEOM * lw_dist2d_distanceline(const LWGEOM *lw1, const LWGEOM *lw2, int srid, int mode)
Function initializing shortestline and longestline calculations.
int lw_dist2d_point_curvepoly(LWPOINT *point, LWCURVEPOLY *poly, DISTPTS *dl)
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 occasion to lw_dist2d_pt_pt Before i...
int lw_dist2d_circstring_poly(LWCIRCSTRING *circ, LWPOLY *poly, DISTPTS *dl)
LWGEOM * lwgeom_furthest_point(const LWGEOM *lw1, const LWGEOM *lw2)
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_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...
int lw_dist2d_recursive(const LWGEOM *lwg1, const LWGEOM *lwg2, DISTPTS *dl)
This is a recursive function delivering every possible combination of subgeometries.
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_curvepoly_curvepoly(LWCURVEPOLY *poly1, LWCURVEPOLY *poly2, DISTPTS *dl)
int lw_dist2d_poly_curvepoly(LWPOLY *poly1, LWCURVEPOLY *curvepoly2, DISTPTS *dl)
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.
double distance2d_pt_seg(const POINT2D *p, const POINT2D *A, const POINT2D *B)
int lw_dist2d_point_line(LWPOINT *point, LWLINE *line, DISTPTS *dl)
point to line calculation
double lwgeom_mindistance2d_tolerance(const LWGEOM *lw1, const LWGEOM *lw2, double tolerance)
Function handling min distance calculations and dwithin calculations.
LWGEOM * lw_dist2d_distancepoint(const LWGEOM *lw1, const LWGEOM *lw2, int srid, int mode)
Function initializing closestpoint calculations.
void lw_dist2d_distpts_init(DISTPTS *dl, int mode)
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...
static int lw_dist2d_is_collection(const LWGEOM *g)
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_line_line(LWLINE *line1, LWLINE *line2, DISTPTS *dl)
line to line calculation
LWGEOM * lwgeom_closest_line(const LWGEOM *lw1, const LWGEOM *lw2)
static const POINT2D * lw_curvering_getfirstpoint2d_cp(LWGEOM *geom)
double lwgeom_mindistance2d(const LWGEOM *lw1, const LWGEOM *lw2)
Function initializing min distance calculation.
int lw_dist2d_ptarray_ptarray(POINTARRAY *l1, POINTARRAY *l2, DISTPTS *dl)
test each segment of l1 against each segment of l2.
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.
double distance2d_sqr_pt_seg(const POINT2D *p, const POINT2D *A, const POINT2D *B)
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_line_poly(LWLINE *line, LWPOLY *poly, DISTPTS *dl)
line to polygon calculation Brute force.
int lw_dist2d_distribute_bruteforce(const LWGEOM *lwg1, const LWGEOM *lwg2, DISTPTS *dl)
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.
LWGEOM * lwgeom_furthest_line(const LWGEOM *lw1, const LWGEOM *lw2)
double lwgeom_maxdistance2d_tolerance(const LWGEOM *lw1, const LWGEOM *lw2, double tolerance)
Function handling max distance calculations and dfullywithin calculations.
int lw_dist2d_distribute_fast(LWGEOM *lwg1, LWGEOM *lwg2, DISTPTS *dl)
Here the geometries are distributed for the new faster distance-calculations.
int lw_dist2d_pt_pt(const POINT2D *thep1, const POINT2D *thep2, DISTPTS *dl)
Compares incoming points and stores the points closest to each other or most far away from each other...
int lw_dist2d_circstring_circstring(LWCIRCSTRING *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_point_poly(LWPOINT *point, LWPOLY *poly, DISTPTS *dl)
int lw_dist2d_point_point(LWPOINT *point1, LWPOINT *point2, DISTPTS *dl)
point to point calculation
int lw_dist2d_check_overlap(LWGEOM *lwg1, LWGEOM *lwg2)
We have to check for overlapping bboxes.
Structure used in distance-calculations.