31 #include "../postgis_config.h"
86 double x1, x2, y1, y2;
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");
170 LWDEBUG(2,
"lwgeom_maxdistance2d is called");
184 LWDEBUG(2,
"lwgeom_maxdistance2d_tolerance is called");
192 lwerror(
"Some unspecified error.");
213 LWDEBUG(2,
"lwgeom_mindistance2d_tolerance is called");
220 lwerror(
"Some unspecified error.");
281 LWDEBUGF(2,
"lw_dist2d_comp is called with type1=%d, type2=%d", lwg1->
type, lwg2->
type);
285 LWDEBUG(3,
"First geometry is collection");
291 LWDEBUG(3,
"Second geometry is collection");
296 for (i = 0; i < n1; i++)
309 LWDEBUG(3,
"Found collection inside first geometry collection, recursing");
314 for (j = 0; j < n2; j++)
323 LWDEBUG(3,
"Found collection inside second geometry collection, recursing");
353 LWDEBUG(2,
"Not below tolerance yet");
524 LWDEBUG(2,
"lw_dist2d_check_overlap is called");
534 LWDEBUG(3,
"geometries bboxes did not overlap");
537 LWDEBUG(3,
"geometries bboxes overlap");
546 int type1 = lwg1->
type;
547 int type2 = lwg2->
type;
549 LWDEBUGF(2,
"lw_dist2d_distribute_fast is called with typ1=%d, type2=%d", lwg1->
type, lwg2->
type);
554 pa1 = ((
LWLINE *)lwg1)->points;
557 pa1 = ((
LWPOLY *)lwg1)->rings[0];
569 pa2 = ((
LWLINE *)lwg2)->points;
572 pa2 = ((
LWPOLY *)lwg2)->rings[0];
664 for (uint32_t i = 1; i < poly->
nrings; i++)
681 lwerror(
"lw_dist2d_point_curvepoly cannot calculate max distance");
691 for (uint32_t i = 1; i < poly->
nrings; i++)
753 for (uint32_t i = 1; i < poly->
nrings; i++)
764 for (uint32_t i = 1; i < poly->
nrings; i++)
787 for (uint32_t i = 1; i < poly->
nrings; i++)
798 for (uint32_t i = 1; i < poly->
nrings; i++)
869 for (uint32_t i = 1; i < poly->
nrings; i++)
880 for (uint32_t i = 1; i < poly->
nrings; i++)
906 lwerror(
"lw_curvering_getfirstpoint2d_cp: unknown type");
935 for (uint32_t i = 1; i < poly->
nrings; i++)
946 for (uint32_t i = 1; i < poly->
nrings; i++)
986 LWDEBUG(2,
"lw_dist2d_poly_poly called");
1006 for (uint32_t i = 1; i < poly1->
nrings; i++)
1013 for (uint32_t i = 1; i < poly2->
nrings; i++)
1037 lwerror(
"Unspecified error in function lw_dist2d_poly_poly");
1094 for (uint32_t i = 1; i < poly1->
nrings; i++)
1101 for (uint32_t i = 1; i < poly2->
nrings; i++)
1125 lwerror(
"Unspecified error in function lw_dist2d_curvepoly_curvepoly");
1141 LWDEBUG(2,
"lw_dist2d_pt_ptarray enter");
1146 LWDEBUGF(2,
"lw_dist2d_pt_ptarray: distance from first point ? : %.15g", dl->
distance);
1148 for (uint32_t t = 1; t < pa->
npoints; t++)
1155 LWDEBUGF(2,
"lw_dist2d_pt_ptarray: distance from seg %u ? : %.15g", t, dl->
distance);
1178 LWDEBUG(2,
"lw_dist2d_pt_ptarrayarc is called");
1182 lwerror(
"lw_dist2d_pt_ptarrayarc called with non-arc input");
1188 lwerror(
"lw_dist2d_pt_ptarrayarc does not currently support DIST_MAX mode");
1197 for (t = 1; t < pa->
npoints; t += 2)
1232 for (t = 0; t < l1->
npoints; t++)
1235 for (u = 0; u < l2->
npoints; u++)
1245 for (t = 1; t < l1->
npoints; t++)
1249 for (u = 1; u < l2->
npoints; u++)
1282 lwerror(
"lw_dist2d_ptarray_ptarrayarc called with non-arc input");
1288 lwerror(
"lw_dist2d_ptarray_ptarrayarc does not currently support DIST_MAX mode");
1294 for (t = 1; t < pa->
npoints; t++)
1298 for (u = 1; u < pb->
npoints; u += 2)
1337 lwerror(
"lw_dist2d_ptarrayarc_ptarrayarc does not currently support DIST_MAX mode");
1343 for (t = 1; t < pa->
npoints; t += 2)
1348 for (u = 1; u < pb->
npoints; u += 2)
1384 int pt_in_arc, pt_in_seg;
1389 lwerror(
"lw_dist2d_seg_arc does not support maxdistance mode");
1405 lwerror(
"lw_dist2d_pt_seg failed in lw_dist2d_seg_arc");
1413 if (dist_C_D < radius_C)
1419 dist_D_EF = sqrt(radius_C * radius_C - dist_C_D * dist_C_D);
1420 length_A = sqrt((A2->
x - A1->
x) * (A2->
x - A1->
x) + (A2->
y - A1->
y) * (A2->
y - A1->
y));
1423 E.
x = D.
x - (A2->
x - A1->
x) * dist_D_EF / length_A;
1424 E.
y = D.
y - (A2->
y - A1->
y) * dist_D_EF / length_A;
1426 F.
x = D.
x + (A2->
x - A1->
x) * dist_D_EF / length_A;
1427 F.
y = D.
y + (A2->
y - A1->
y) * dist_D_EF / length_A;
1433 if (pt_in_arc && pt_in_seg)
1445 if (pt_in_arc && pt_in_seg)
1457 else if (dist_C_D == radius_C)
1464 if (pt_in_arc && pt_in_seg)
1478 G.
x = C.
x + (D.
x - C.
x) * radius_C / dist_C_D;
1479 G.
y = C.
y + (D.
y - C.
y) * radius_C / dist_C_D;
1485 if (pt_in_arc && pt_in_seg)
1496 if (pt_in_arc && !pt_in_seg)
1503 else if (pt_in_seg && !pt_in_arc)
1530 lwerror(
"lw_dist2d_pt_arc does not support maxdistance mode");
1556 X.
x = C.
x + (P->
x - C.
x) * radius_A / d;
1557 X.
y = C.
y + (P->
y - C.
y) * radius_A / d;
1595 double radius_A, radius_B, d;
1597 int pt_in_arc_A, pt_in_arc_B;
1600 lwerror(
"lw_dist2d_arc_arc only supports mindistance");
1617 if (radius_A < 0 && radius_B < 0)
1636 if (radius_B > radius_A)
1654 radius_B = radius_A;
1659 if (d == (radius_A + radius_B))
1661 D.
x = CA.
x + (CB.
x - CA.
x) * radius_A / d;
1662 D.
y = CA.
y + (CB.
y - CA.
y) * radius_A / d;
1668 if (pt_in_arc_A && pt_in_arc_B)
1678 else if (d > (radius_A + radius_B) || d < (radius_A - radius_B) )
1685 XA.
x = CA.
x + (CB.
x - CA.
x) * radius_A / d;
1686 XA.
y = CA.
y + (CB.
y - CA.
y) * radius_A / d;
1687 XB.
x = CB.
x + (CA.
x - CB.
x) * radius_B / d;
1688 XB.
y = CB.
y + (CA.
y - CB.
y) * radius_B / d;
1695 if (pt_in_arc_A && pt_in_arc_B)
1702 else if (d < (radius_A + radius_B))
1706 double a = (radius_A * radius_A - radius_B * radius_B + d * d) / (2 * d);
1708 double h = sqrt(radius_A * radius_A - a * a);
1711 D.
x = CA.
x + (CB.
x - CA.
x) * a / d;
1712 D.
y = CA.
y + (CB.
y - CA.
y) * a / d;
1715 E.
x = D.
x + (D.
y - CA.
y) * h / a;
1716 E.
y = D.
y + (D.
x - CA.
x) * h / a;
1722 if (pt_in_arc_A && pt_in_arc_B)
1724 dl->
p1 = dl->
p2 = E;
1730 F.
x = D.
x - (D.
y - CA.
y) * h / a;
1731 F.
y = D.
y - (D.
x - CA.
x) * h / a;
1737 if (pt_in_arc_A && pt_in_arc_B)
1739 dl->
p1 = dl->
p2 = F;
1746 lwerror(
"lw_dist2d_arc_arc: arcs neither touch, intersect nor are disjoint! INCONCEIVABLE!");
1752 if (pt_in_arc_A && !pt_in_arc_B)
1760 else if (pt_in_arc_B && !pt_in_arc_A)
1792 double dist_sqr, shortest_sqr;
1797 if (radius_A == radius_B)
1838 proj.
x = CENTER->
x + (B1->
x - CENTER->
x) * radius_A / radius_B;
1839 proj.
y = CENTER->
y + (B1->
y - CENTER->
y) * radius_A / radius_B;
1845 dl->
distance = fabs(radius_A - radius_B);
1849 proj.
x = CENTER->
x + (B3->
x - CENTER->
x) * radius_A / radius_B;
1850 proj.
y = CENTER->
y + (B3->
y - CENTER->
y) * radius_A / radius_B;
1855 dl->
distance = fabs(radius_A - radius_B);
1863 proj.
x = CENTER->
x + (A1->
x - CENTER->
x) * radius_B / radius_A;
1864 proj.
y = CENTER->
y + (A1->
y - CENTER->
y) * radius_B / radius_A;
1869 dl->
distance = fabs(radius_A - radius_B);
1874 proj.
x = CENTER->
x + (A3->
x - CENTER->
x) * radius_B / radius_A;
1875 proj.
y = CENTER->
y + (A3->
y - CENTER->
y) * radius_B / radius_A;
1880 dl->
distance = fabs(radius_A - radius_B);
1891 if (dist_sqr < shortest_sqr)
1893 shortest_sqr = dist_sqr;
1899 if (dist_sqr < shortest_sqr)
1901 shortest_sqr = dist_sqr;
1907 if (dist_sqr < shortest_sqr)
1909 shortest_sqr = dist_sqr;
1929 double s_top, s_bot,
s;
1930 double r_top, r_bot,
r;
1933 if ((A->
x == B->
x) && (A->
y == B->
y))
1939 if ((C->
x == D->
x) && (C->
y == D->
y))
1967 r_top = (A->
y - C->
y) * (D->
x - C->
x) - (A->
x - C->
x) * (D->
y - C->
y);
1968 r_bot = (B->
x - A->
x) * (D->
y - C->
y) - (B->
y - A->
y) * (D->
x - C->
x);
1970 s_top = (A->
y - C->
y) * (B->
x - A->
x) - (A->
x - C->
x) * (B->
y - A->
y);
1971 s_bot = (B->
x - A->
x) * (D->
y - C->
y) - (B->
y - A->
y) * (D->
x - C->
x);
1973 if ((r_bot == 0) || (s_bot == 0))
2007 if (((A->
x == C->
x) && (A->
y == C->
y)) || ((A->
x == D->
x) && (A->
y == D->
y)))
2012 else if (((B->
x == C->
x) && (B->
y == C->
y)) || ((B->
x == D->
x) && (B->
y == D->
y)))
2019 theP.
x = A->
x +
r * (B->
x - A->
x);
2020 theP.
y = A->
y +
r * (B->
y - A->
y);
2051 float deltaX, deltaY, c1m, c2m;
2054 float min1X, max1X, max1Y, min1Y, min2X, max2X, max2Y, min2Y;
2063 LWDEBUG(2,
"lw_dist2d_fast_ptarray_ptarray is called");
2074 c1.
x = min1X + (max1X - min1X) / 2;
2075 c1.
y = min1Y + (max1Y - min1Y) / 2;
2076 c2.
x = min2X + (max2X - min2X) / 2;
2077 c2.
y = min2Y + (max2Y - min2Y) / 2;
2079 deltaX = (c2.
x - c1.
x);
2080 deltaY = (c2.
y - c1.
y);
2085 if ((deltaX * deltaX) < (deltaY * deltaY))
2087 k = -deltaX / deltaY;
2088 for (t = 0; t < n1; t++)
2091 thevalue = theP->
y - (k * theP->
x);
2095 for (t = 0; t < n2; t++)
2098 thevalue = theP->
y - (k * theP->
x);
2102 c1m = c1.
y - (k * c1.
x);
2103 c2m = c2.
y - (k * c2.
x);
2111 k = -deltaY / deltaX;
2112 for (t = 0; t < n1; t++)
2115 thevalue = theP->
x - (k * theP->
y);
2120 for (t = 0; t < n2; t++)
2123 thevalue = theP->
x - (k * theP->
y);
2128 c1m = c1.
x - (k * c1.
y);
2129 c2m = c2.
x - (k * c2.
y);
2172 const POINT2D *p1, *p2, *p3, *p4, *p01, *p02;
2173 int pnr1, pnr2, pnr3, pnr4, n1, n2, i, u,
r, twist;
2178 LWDEBUG(2,
"lw_dist2d_pre_seg_seg is called");
2185 for (i = (n1 - 1); i >= 0; --i)
2189 if (((list2[0].themeasure - list1[i].themeasure)) > maxmeasure)
2193 for (
r = -1;
r <= 1;
r += 2)
2195 pnr1 = list1[i].
pnr;
2200 if ((p1->
x == p01->
x) && (p1->
y == p01->
y))
2207 else if (pnr1 +
r > (n1 - 1))
2210 if ((p1->
x == p01->
x) && (p1->
y == p01->
y))
2220 for (u = 0; u < n2; ++u)
2222 if (((list2[u].themeasure - list1[i].themeasure)) >= maxmeasure)
2224 pnr3 = list2[u].
pnr;
2229 if ((p3->
x == p02->
x) && (p3->
y == p02->
y))
2243 if (pnr3 >= (n2 - 1))
2246 if ((p3->
x == p02->
x) && (p3->
y == p02->
y))
2278 if ((A->
x == B->
x) && (A->
y == B->
y))
2284 if ((C->
x == D->
x) && (C->
y == D->
y))
2320 LWDEBUG(2,
"lw_dist2d_pt_seg called");
2323 if ((A->
x == B->
x) && (A->
y == B->
y))
2325 LWDEBUG(2,
"lw_dist2d_pt_seg found first and last segment points being the same");
2345 r = ((p->
x - A->
x) * (B->
x - A->
x) + (p->
y - A->
y) * (B->
y - A->
y)) /
2346 ((B->
x - A->
x) * (B->
x - A->
x) + (B->
y - A->
y) * (B->
y - A->
y));
2348 LWDEBUGF(2,
"lw_dist2d_pt_seg found r = %.15g",
r);
2366 if ((((A->
y - p->
y) * (B->
x - A->
x) == (A->
x - p->
x) * (B->
y - A->
y))) && (dl->
mode ==
DIST_MIN))
2383 double s = ((A->
y - p->
y) * (B->
x - A->
x) - (A->
x - p->
x) * (B->
y - A->
y)) /
2384 ((B->
x - A->
x) * (B->
x - A->
x) + (B->
y - A->
y) * (B->
y - A->
y));
2386 double dist = fabs(
s) * sqrt(((B->
x - A->
x) * (B->
x - A->
x) + (B->
y - A->
y) * (B->
y - A->
y)));
2392 c.
x = A->
x +
r * (B->
x - A->
x);
2393 c.
y = A->
y +
r * (B->
y - A->
y);
2415 double hside = thep2->
x - thep1->
x;
2416 double vside = thep2->
y - thep1->
y;
2417 double dist = sqrt(hside * hside + vside * vside);
2447 double hside = p2->
x - p1->
x;
2448 double vside = p2->
y - p1->
y;
2450 return hypot(hside, vside);
2458 if ((A->
x == B->
x) && (A->
y == B->
y))
2476 double ba_x = (B->
x - A->
x);
2477 double ba_y = (B->
y - A->
y);
2478 double ab_length_sqr = (ba_x * ba_x + ba_y * ba_y);
2479 double ca_x = (C->
x - A->
x);
2480 double ca_y = (C->
y - A->
y);
2481 double dot_ac_ab = (ca_x * ba_x + ca_y * ba_y);
2485 if (dot_ac_ab >= ab_length_sqr)
2498 double s_numerator = ca_x * ba_y - ca_y * ba_x;
2501 return s_numerator * s_numerator / ab_length_sqr;
2511 if (A->
x == B->
x && A->
y == B->
y)
2513 *d = fmod(2 * M_PI + M_PI / 2 - atan2(B->
y - A->
y, B->
x - A->
x), 2 * M_PI);
2524 const double TWOPI = 2.0 * M_PI;
2527 int orbits = floor(azimuth / TWOPI);
2528 azimuth -= TWOPI * orbits;
2530 slope = TWOPI - azimuth + M_PI_2;
2531 if (slope > 0 && slope > TWOPI) slope -= TWOPI;
2532 if (slope < 0 && slope < -TWOPI) slope += TWOPI;
2551 double dx = (B->
x - A->
x) * prop;
2552 double dy = (B->
y - A->
y) * prop;
2553 double dz = (B->
z - A->
z) * prop;
2554 double dm = (B->
m - A->
m) * prop;
2557 if (isfinite(dz)) R->
z = B->
z + dz;
2558 if (isfinite(dm)) R->
m = B->
m + dm;
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.
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...
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)
Return LW_INSIDE if the point is inside the POINTARRAY, LW_OUTSIDE if it is outside,...
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 void lwerror(const char *fmt,...) __attribute__((format(printf
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)
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)
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)
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)
int project_pt(const POINT2D *P, double distance, double azimuth, POINT2D *R)
Azimuth is angle in radians from vertical axis.
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.
int project_pt_pt(const POINT4D *A, const POINT4D *B, double distance, POINT4D *R)
Azimuth is angle in radians from vertical axis.
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)
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
int lw_dist2d_check_overlap(LWGEOM *lwg1, LWGEOM *lwg2)
Structure used in distance-calculations.