95 double x1, x2, y1, y2;
97 double initdistance = (mode ==
DIST_MIN ? FLT_MAX : -1.0);
106 LWDEBUG(2,
"lw_dist2d_distanceline is called");
111 lwerror(
"Some unspecified error.");
118 LWDEBUG(3,
"didn't find geometries to measure between, returning null");
144 double initdistance = FLT_MAX;
151 LWDEBUG(2,
"lw_dist2d_distancepoint is called");
156 lwerror(
"Some unspecified error.");
161 LWDEBUG(3,
"didn't find geometries to measure between, returning null");
179 LWDEBUG(2,
"lwgeom_maxdistance2d is called");
193 LWDEBUG(2,
"lwgeom_maxdistance2d_tolerance is called");
201 lwerror(
"Some unspecified error.");
222 LWDEBUG(2,
"lwgeom_mindistance2d_tolerance is called");
229 lwerror(
"Some unspecified error.");
281 assert(lwg1 && lwg2 && lwg1->
bbox && lwg2->
bbox);
306 LWDEBUGF(2,
"lw_dist2d_comp is called with type1=%d, type2=%d", lwg1->
type, lwg2->
type);
310 LWDEBUG(3,
"First geometry is collection");
316 LWDEBUG(3,
"Second geometry is collection");
321 for (i = 0; i < n1; i++)
336 LWDEBUG(3,
"Found collection inside first geometry collection, recursing");
341 for (j = 0; j < n2; j++)
352 LWDEBUG(3,
"Found collection inside second geometry collection, recursing");
553 int type1 = lwg1->
type;
554 int type2 = lwg2->
type;
556 LWDEBUGF(2,
"lw_dist2d_distribute_fast is called with typ1=%d, type2=%d", lwg1->
type, lwg2->
type);
561 pa1 = ((
LWLINE *)lwg1)->points;
564 pa1 = ((
LWPOLY *)lwg1)->rings[0];
576 pa2 = ((
LWLINE *)lwg2)->points;
579 pa2 = ((
LWPOLY *)lwg2)->rings[0];
669 for (uint32_t i = 1; i < poly->
nrings; i++)
684 lwerror(
"lw_dist2d_point_curvepoly cannot calculate max distance");
694 for (uint32_t i = 1; i < poly->
nrings; i++)
752 for (uint32_t i = 1; i < poly->
nrings; i++)
763 for (uint32_t i = 1; i < poly->
nrings; i++)
784 for (uint32_t i = 1; i < poly->
nrings; i++)
795 for (uint32_t i = 1; i < poly->
nrings; i++)
858 for (uint32_t i = 1; i < poly->
nrings; i++)
869 for (uint32_t i = 1; i < poly->
nrings; i++)
893 lwerror(
"lw_curvering_getfirstpoint2d_cp: unknown type");
920 for (uint32_t i = 1; i < poly->
nrings; i++)
931 for (uint32_t i = 1; i < poly->
nrings; i++)
967 LWDEBUG(2,
"lw_dist2d_poly_poly called");
987 for (uint32_t i = 1; i < poly1->
nrings; i++)
994 for (uint32_t i = 1; i < poly2->
nrings; i++)
1014 lwerror(
"Unspecified error in function lw_dist2d_poly_poly");
1071 for (uint32_t i = 1; i < poly1->
nrings; i++)
1078 for (uint32_t i = 1; i < poly2->
nrings; i++)
1098 lwerror(
"Unspecified error in function lw_dist2d_curvepoly_curvepoly");
1117 for (uint32_t t = 1; t < pa->
npoints; t++)
1145 LWDEBUG(2,
"lw_dist2d_pt_ptarrayarc is called");
1149 lwerror(
"lw_dist2d_pt_ptarrayarc called with non-arc input");
1155 lwerror(
"lw_dist2d_pt_ptarrayarc does not currently support DIST_MAX mode");
1164 for (t = 1; t < pa->
npoints; t += 2)
1199 for (t = 0; t < l1->
npoints; t++)
1202 for (u = 0; u < l2->
npoints; u++)
1212 for (t = 1; t < l1->
npoints; t++)
1216 for (u = 1; u < l2->
npoints; u++)
1249 lwerror(
"lw_dist2d_ptarray_ptarrayarc called with non-arc input");
1255 lwerror(
"lw_dist2d_ptarray_ptarrayarc does not currently support DIST_MAX mode");
1261 for (t = 1; t < pa->
npoints; t++)
1265 for (u = 1; u < pb->
npoints; u += 2)
1304 lwerror(
"lw_dist2d_ptarrayarc_ptarrayarc does not currently support DIST_MAX mode");
1310 for (t = 1; t < pa->
npoints; t += 2)
1315 for (u = 1; u < pb->
npoints; u += 2)
1351 int pt_in_arc, pt_in_seg;
1356 lwerror(
"lw_dist2d_seg_arc does not support maxdistance mode");
1372 lwerror(
"lw_dist2d_pt_seg failed in lw_dist2d_seg_arc");
1380 if (dist_C_D < radius_C)
1386 dist_D_EF = sqrt(radius_C * radius_C - dist_C_D * dist_C_D);
1387 length_A = sqrt((A2->
x - A1->
x) * (A2->
x - A1->
x) + (A2->
y - A1->
y) * (A2->
y - A1->
y));
1390 E.
x = D.
x - (A2->
x - A1->
x) * dist_D_EF / length_A;
1391 E.
y = D.
y - (A2->
y - A1->
y) * dist_D_EF / length_A;
1393 F.
x = D.
x + (A2->
x - A1->
x) * dist_D_EF / length_A;
1394 F.
y = D.
y + (A2->
y - A1->
y) * dist_D_EF / length_A;
1400 if (pt_in_arc && pt_in_seg)
1410 if (pt_in_arc && pt_in_seg)
1420 else if (dist_C_D == radius_C)
1427 if (pt_in_arc && pt_in_seg)
1439 G.
x = C.
x + (D.
x - C.
x) * radius_C / dist_C_D;
1440 G.
y = C.
y + (D.
y - C.
y) * radius_C / dist_C_D;
1446 if (pt_in_arc && pt_in_seg)
1457 if (pt_in_arc && !pt_in_seg)
1464 else if (pt_in_seg && !pt_in_arc)
1491 lwerror(
"lw_dist2d_pt_arc does not support maxdistance mode");
1515 X.
x = C.
x + (P->
x - C.
x) * radius_A / d;
1516 X.
y = C.
y + (P->
y - C.
y) * radius_A / d;
1582 double dir_x = center_A->
x - P->
x;
1583 double dir_y = center_A->
y - P->
y;
1584 double dist = sqrt(dir_x * dir_x + dir_y * dir_y);
1587 double unit_x = dir_x / dist;
1588 double unit_y = dir_y / dist;
1592 R.
x = center_A->
x + unit_x * radius_A;
1593 R.
y = center_A->
y + unit_y * radius_A;
1598 R.
x = center_A->
x - unit_x * radius_A;
1599 R.
y = center_A->
y - unit_y * radius_A;
1632 double dx = cB->
x - cA->
x;
1633 double dy = cB->
y - cA->
y;
1636 double d = sqrt(dx * dx + dy * dy);
1640 double a = (rA * rA - rB * rB + d * d) / (2.0 * d);
1643 double h_squared = rA * rA - a * a;
1647 if (h_squared < 0.0)
1650 double h = sqrt(h_squared);
1653 double Px = cA->
x + a * (dx / d);
1654 double Py = cA->
y + a * (dy / d);
1661 I[0].
x = Px - h * (dy / d);
1662 I[0].
y = Py + h * (dx / d);
1669 I[1].
x = Px + h * (dy / d);
1670 I[1].
y = Py - h * (dx / d);
1683 uint32_t ai = 0, bi = 0;
1685 double radius_A, radius_B, d;
1686 int is_disjoint, is_overlapping, is_contained, is_same_center;
1690 lwerror(
"lw_dist2d_arc_arc only supports mindistance");
1705 if (radius_A < 0 && radius_B < 0)
1718 is_disjoint = (d > (radius_A + radius_B));
1719 is_contained = (d < fabs(radius_A - radius_B));
1720 is_same_center =
p2d_same(¢er_A, ¢er_B);
1721 is_overlapping = ! (is_disjoint || is_contained || is_same_center);
1744 ¢er_A, radius_A,
1745 ¢er_B, radius_B,
1747 for (uint32_t i = 0; i < npoints; i++)
1769 if (is_disjoint || is_contained || is_overlapping)
1771 if (!is_same_center)
1776 ¢er_A, radius_A, ¢er_B,
1782 ¢er_B, radius_B, ¢er_A,
1789 ¢er_A, radius_A, B1,
1795 ¢er_A, radius_A, B3,
1801 ¢er_B, radius_B, A1,
1807 ¢er_B, radius_B, A3,
1815 for (uint32_t i = 0; i < ai; i++)
1816 for (uint32_t j = 0; j < bi; j++)
1831 double s_top, s_bot,
s;
1832 double r_top, r_bot,
r;
1835 if ((A->
x == B->
x) && (A->
y == B->
y))
1841 if ((C->
x == D->
x) && (C->
y == D->
y))
1869 r_top = (A->
y - C->
y) * (D->
x - C->
x) - (A->
x - C->
x) * (D->
y - C->
y);
1870 r_bot = (B->
x - A->
x) * (D->
y - C->
y) - (B->
y - A->
y) * (D->
x - C->
x);
1872 s_top = (A->
y - C->
y) * (B->
x - A->
x) - (A->
x - C->
x) * (B->
y - A->
y);
1873 s_bot = (B->
x - A->
x) * (D->
y - C->
y) - (B->
y - A->
y) * (D->
x - C->
x);
1875 if ((r_bot == 0) || (s_bot == 0))
1909 if (((A->
x == C->
x) && (A->
y == C->
y)) || ((A->
x == D->
x) && (A->
y == D->
y)))
1914 else if (((B->
x == C->
x) && (B->
y == C->
y)) || ((B->
x == D->
x) && (B->
y == D->
y)))
1921 theP.
x = A->
x +
r * (B->
x - A->
x);
1922 theP.
y = A->
y +
r * (B->
y - A->
y);
1951 float deltaX, deltaY, c1m, c2m;
1954 float min1X, max1X, max1Y, min1Y, min2X, max2X, max2Y, min2Y;
1963 LWDEBUG(2,
"lw_dist2d_fast_ptarray_ptarray is called");
1974 c1.
x = min1X + (max1X - min1X) / 2;
1975 c1.
y = min1Y + (max1Y - min1Y) / 2;
1976 c2.
x = min2X + (max2X - min2X) / 2;
1977 c2.
y = min2Y + (max2Y - min2Y) / 2;
1979 deltaX = (c2.
x - c1.
x);
1980 deltaY = (c2.
y - c1.
y);
1985 if ((deltaX * deltaX) < (deltaY * deltaY))
1987 k = -deltaX / deltaY;
1988 for (t = 0; t < n1; t++)
1991 thevalue = theP->
y - (k * theP->
x);
1995 for (t = 0; t < n2; t++)
1998 thevalue = theP->
y - (k * theP->
x);
2002 c1m = c1.
y - (k * c1.
x);
2003 c2m = c2.
y - (k * c2.
x);
2011 k = -deltaY / deltaX;
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);
2072 const POINT2D *p1, *p2, *p3, *p4, *p01, *p02;
2073 int pnr1, pnr2, pnr3, pnr4, n1, n2, i, u,
r, twist;
2078 LWDEBUG(2,
"lw_dist2d_pre_seg_seg is called");
2085 for (i = (n1 - 1); i >= 0; --i)
2089 if (((list2[0].themeasure - list1[i].themeasure)) > maxmeasure)
2093 for (
r = -1;
r <= 1;
r += 2)
2095 pnr1 = list1[i].
pnr;
2100 if ((p1->
x == p01->
x) && (p1->
y == p01->
y))
2107 else if (pnr1 +
r > (n1 - 1))
2110 if ((p1->
x == p01->
x) && (p1->
y == p01->
y))
2120 for (u = 0; u < n2; ++u)
2122 if (((list2[u].themeasure - list1[i].themeasure)) >= maxmeasure)
2124 pnr3 = list2[u].
pnr;
2129 if ((p3->
x == p02->
x) && (p3->
y == p02->
y))
2143 if (pnr3 >= (n2 - 1))
2146 if ((p3->
x == p02->
x) && (p3->
y == p02->
y))
2178 if ((A->
x == B->
x) && (A->
y == B->
y))
2184 if ((C->
x == D->
x) && (C->
y == D->
y))
2221 if ((A->
x == B->
x) && (A->
y == B->
y))
2239 r = ((p->
x - A->
x) * (B->
x - A->
x) + (p->
y - A->
y) * (B->
y - A->
y)) /
2240 ((B->
x - A->
x) * (B->
x - A->
x) + (B->
y - A->
y) * (B->
y - A->
y));
2258 if ((((A->
y - p->
y) * (B->
x - A->
x) == (A->
x - p->
x) * (B->
y - A->
y))) && (dl->
mode ==
DIST_MIN))
2265 c.
x = A->
x +
r * (B->
x - A->
x);
2266 c.
y = A->
y +
r * (B->
y - A->
y);
2276 double hside = thep2->
x - thep1->
x;
2277 double vside = thep2->
y - thep1->
y;
2278 double dist = sqrt(hside * hside + vside * vside);
2308 double hside = p2->
x - p1->
x;
2309 double vside = p2->
y - p1->
y;
2311 return hypot(hside, vside);
2319 if ((A->
x == B->
x) && (A->
y == B->
y))
2337 double ba_x = (B->
x - A->
x);
2338 double ba_y = (B->
y - A->
y);
2339 double ab_length_sqr = (ba_x * ba_x + ba_y * ba_y);
2340 double ca_x = (C->
x - A->
x);
2341 double ca_y = (C->
y - A->
y);
2342 double dot_ac_ab = (ca_x * ba_x + ca_y * ba_y);
2346 if (dot_ac_ab >= ab_length_sqr)
2359 double s_numerator = ca_x * ba_y - ca_y * ba_x;
2362 return s_numerator * s_numerator / ab_length_sqr;
2372 if (A->
x == B->
x && A->
y == B->
y)
2374 *d = fmod(2 * M_PI + M_PI / 2 - atan2(B->
y - A->
y, B->
x - A->
x), 2 * M_PI);
char result[OUT_DOUBLE_BUFFER_SIZE]
LWPOINT * lwpoint_make2d(int32_t srid, double x, double y)
LWLINE * lwline_from_ptarray(int32_t srid, uint32_t npoints, LWPOINT **points)
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
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int32_t srid, char hasz, char hasm)
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
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.
#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 ptarray_contains_point(const POINTARRAY *pa, const POINT2D *pt)
The following is based on the "Fast Winding Number Inclusion of a Point in a Polygon" algorithm by Da...
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_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.
static const POINT2D * getPoint2d_cp(const POINTARRAY *pa, uint32_t n)
Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from.
static double distance2d_sqr_pt_pt(const POINT2D *p1, const POINT2D *p2)
static int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
static double distance(double x1, double y1, double x2, double y2)
static uint32_t lw_dist2d_circle_circle_intersections(const POINT2D *cA, double rA, const POINT2D *cB, double rB, POINT2D *I)
Calculates the intersection points of two overlapping circles.
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,...
LWGEOM * lw_dist2d_distanceline(const LWGEOM *lw1, const LWGEOM *lw2, int32_t srid, int mode)
Function initializing shortestline and longestline calculations.
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)
static void lw_dist2d_distpts_set(DISTPTS *dl, double distance, 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.
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)
int lw_dist2d_tri_circstring(LWTRIANGLE *tri, LWCIRCSTRING *line, 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_line_tri(LWLINE *line, LWTRIANGLE *tri, DISTPTS *dl)
static int lw_dist2d_check_overlap(const LWGEOM *lwg1, const LWGEOM *lwg2)
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.
int lw_dist2d_point_line(LWPOINT *point, LWLINE *line, DISTPTS *dl)
point to line calculation
int lw_dist2d_tri_curvepoly(LWTRIANGLE *tri, LWCURVEPOLY *poly, DISTPTS *dl)
double lwgeom_mindistance2d_tolerance(const LWGEOM *lw1, const LWGEOM *lw2, double tolerance)
Function handling min distance calculations and dwithin 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)
LWGEOM * lwgeom_closest_line(const LWGEOM *lw1, const LWGEOM *lw2)
static const POINT2D * lw_curvering_getfirstpoint2d_cp(LWGEOM *geom)
int lw_dist2d_tri_tri(LWTRIANGLE *tri1, LWTRIANGLE *tri2, DISTPTS *dl)
int lw_dist2d_point_tri(LWPOINT *point, LWTRIANGLE *tri, DISTPTS *dl)
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.
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.
LWGEOM * lw_dist2d_distancepoint(const LWGEOM *lw1, const LWGEOM *lw2, int32_t srid, int mode)
Function initializing closestpoint calculations.
double distance2d_sqr_pt_seg(const POINT2D *C, const POINT2D *A, const POINT2D *B)
int lw_dist2d_distribute_fast(LWGEOM *lwg1, LWGEOM *lwg2, DISTPTS *dl)
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)
static int lw_dist2d_circle_intersections(const POINT2D *A1, const POINT2D *A2, const POINT2D *A3, const POINT2D *center_A, double radius_A, const POINT2D *P, POINT2D *I, uint32_t *ni)
Calculates the intersection points of a circle and line.
int lw_dist2d_tri_poly(LWTRIANGLE *tri, LWPOLY *poly, DISTPTS *dl)
int lw_dist2d_point_point(LWPOINT *point1, LWPOINT *point2, DISTPTS *dl)
point to point calculation
Structure used in distance-calculations.