The new faster calculation comparing pointarray to another pointarray the arrays can come from both polygons and linestrings.
The naming is not good but comes from that it compares a chosen selection of the points not all of them
2036{
2037
2038
2039 double k, thevalue;
2040 float deltaX, deltaY, c1m, c2m;
2043 float min1X, max1X, max1Y, min1Y, min2X, max2X, max2Y, min2Y;
2044 int t;
2047
2051
2052 LWDEBUG(2,
"lw_dist2d_fast_ptarray_ptarray is called");
2053
2062
2063 c1.
x = min1X + (max1X - min1X) / 2;
2064 c1.
y = min1Y + (max1Y - min1Y) / 2;
2065 c2.
x = min2X + (max2X - min2X) / 2;
2066 c2.
y = min2Y + (max2Y - min2Y) / 2;
2067
2068 deltaX = (c2.
x - c1.
x);
2069 deltaY = (c2.
y - c1.
y);
2070
2071
2072
2073
2074 if ((deltaX * deltaX) < (deltaY * deltaY))
2075 {
2076 k = -deltaX / deltaY;
2077 for (t = 0; t < n1; t++)
2078 {
2080 thevalue = theP->
y - (k * theP->
x);
2083 }
2084 for (t = 0; t < n2; t++)
2085 {
2087 thevalue = theP->
y - (k * theP->
x);
2090 }
2091 c1m = c1.
y - (k * c1.
x);
2092 c2m = c2.
y - (k * c2.
x);
2093 }
2094
2095
2096
2097
2098 else
2099 {
2100 k = -deltaY / deltaX;
2101 for (t = 0; t < n1; t++)
2102 {
2104 thevalue = theP->
x - (k * theP->
y);
2107
2108 }
2109 for (t = 0; t < n2; t++)
2110 {
2112 thevalue = theP->
x - (k * theP->
y);
2115
2116 }
2117 c1m = c1.
x - (k * c1.
y);
2118 c2m = c2.
x - (k * c2.
y);
2119 }
2120
2121
2124
2125 if (c1m < c2m)
2126 {
2128 {
2132 }
2133 }
2134 else
2135 {
2138 {
2142 }
2143 }
2147}
void * lwalloc(size_t size)
#define LW_TRUE
Return types for functions with status returns.
#define LWDEBUG(level, msg)
static const POINT2D * getPoint2d_cp(const POINTARRAY *pa, uint32_t n)
Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from.
int struct_cmp_by_measure(const void *a, const void *b)
int lw_dist2d_pre_seg_seg(POINTARRAY *l1, POINTARRAY *l2, LISTSTRUCT *list1, LISTSTRUCT *list2, double k, DISTPTS *dl)
preparation before lw_dist2d_seg_seg.