27 return fmax(
tol(ic1),
tol(ic2));
32 return (-tolerance <= x) && (x <= tolerance);
39 return (-tolerance <= diff) && (diff <= tolerance);
45 return x <= (y + tolerance);
51 return (x + tolerance) >= y;
59 auto compressed_coords =
reinterpret_cast<const int32_t*
>(data);
67 auto double_coords =
reinterpret_cast<const double*
>(data);
68 return double_coords[index];
126 auto decompressed_transformed_coord_x =
128 return decompressed_transformed_coord_x;
138 auto decompressed_transformed_coord_y =
140 return decompressed_transformed_coord_y;
145 const auto compressed_coords =
reinterpret_cast<const int32_t*
>(data);
146 return compressed_coords[index];
193 double dotprod = (px - l1x) * (l2x - l1x) + (py - l1y) * (l2y - l1y);
194 double k = dotprod / (length * length);
195 k = fmax(0.0, fmin(1.0, k));
196 double projx = l1x + k * (l2x - l1x);
197 double projy = l1y + k * (l2y - l1y);
220 double dotprod = (px - l1x) * (l2x - l1x) + (py - l1y) * (l2y - l1y);
221 double k = dotprod / (length * length);
222 k = fmax(0.0, fmin(1.0, k));
223 double projx = l1x + k * (l2x - l1x);
224 double projy = l1y + k * (l2y - l1y);
236 return (
tol_le(qx, fmax(px, rx)) &&
tol_ge(qx, fmin(px, rx)) &&
241 orientation(
double px,
double py,
double qx,
double qy,
double rx,
double ry) {
242 auto val = ((qy - py) * (rx - qx) - (qx - px) * (ry - qy));
262 auto o1 =
orientation(l11x, l11y, l12x, l12y, l21x, l21y);
263 auto o2 =
orientation(l11x, l11y, l12x, l12y, l22x, l22y);
264 auto o3 =
orientation(l21x, l21y, l22x, l22y, l11x, l11y);
265 auto o4 =
orientation(l21x, l21y, l22x, l22y, l12x, l12y);
268 if (o1 != o2 && o3 != o4) {
274 if (o1 == 0 &&
on_segment(l11x, l11y, l21x, l21y, l12x, l12y)) {
279 if (o2 == 0 &&
on_segment(l11x, l11y, l22x, l22y, l12x, l12y)) {
284 if (o3 == 0 &&
on_segment(l21x, l21y, l11x, l11y, l22x, l22y)) {
289 if (o4 == 0 &&
on_segment(l21x, l21y, l12x, l12y, l22x, l22y)) {
306 double e1x =
coord_x(l, 0, ic1, isr1, osr);
307 double e1y =
coord_y(l, 1, ic1, isr1, osr);
308 for (int64_t
i = 2;
i < lnum_coords;
i += 2) {
309 double e2x =
coord_x(l,
i, ic1, isr1, osr);
310 double e2y =
coord_y(l,
i + 1, ic1, isr1, osr);
322 int32_t ring_num_coords,
330 double e1x =
coord_x(ring, ring_num_coords - 2, ic1, isr1, osr);
331 double e1y =
coord_y(ring, ring_num_coords - 1, ic1, isr1, osr);
332 double e2x =
coord_x(ring, 0, ic1, isr1, osr);
333 double e2y =
coord_y(ring, 1, ic1, isr1, osr);
338 ring, ring_num_coords, l1x, l1y, l2x, l2y, ic1, isr1, osr);
351 double e1x =
coord_x(l, 0, ic1, isr1, osr);
352 double e1y =
coord_y(l, 1, ic1, isr1, osr);
353 for (int64_t
i = 2;
i < lnum_coords;
i += 2) {
354 double e2x =
coord_x(l,
i, ic1, isr1, osr);
355 double e2y =
coord_y(l,
i + 1, ic1, isr1, osr);
382 return fmin(dist12, dist21);
402 return fmin(dist12, dist21);
407 int32_t ring_num_coords,
416 double min_distance = 0.0;
418 double re1x =
coord_x(ring, ring_num_coords - 2, ic1, isr1, osr);
419 double re1y =
coord_y(ring, ring_num_coords - 1, ic1, isr1, osr);
420 for (
auto i = 0;
i < ring_num_coords;
i += 2) {
421 double re2x =
coord_x(ring,
i, ic1, isr1, osr);
422 double re2y =
coord_y(ring,
i + 1, ic1, isr1, osr);
424 double le1x =
coord_x(l, 0, ic2, isr2, osr);
425 double le1y =
coord_y(l, 1, ic2, isr2, osr);
426 for (
auto j = 2;
j < lnum_coords;
j += 2) {
427 double le2x =
coord_x(l,
j, ic2, isr2, osr);
428 double le2y =
coord_y(l,
j + 1, ic2, isr2, osr);
431 if ((
i == 0 &&
j == 2) || min_distance > distance) {
432 min_distance = distance;
436 if (min_distance <= threshold) {
452 int32_t ring1_num_coords,
454 int32_t ring2_num_coords,
461 double min_distance = 0.0;
463 double e11x =
coord_x(ring1, ring1_num_coords - 2, ic1, isr1, osr);
464 double e11y =
coord_y(ring1, ring1_num_coords - 1, ic1, isr1, osr);
465 for (
auto i = 0;
i < ring1_num_coords;
i += 2) {
466 double e12x =
coord_x(ring1,
i, ic1, isr1, osr);
467 double e12y =
coord_y(ring1,
i + 1, ic1, isr1, osr);
469 double e21x =
coord_x(ring2, ring2_num_coords - 2, ic2, isr2, osr);
470 double e21y =
coord_y(ring2, ring2_num_coords - 1, ic2, isr2, osr);
471 for (
auto j = 0;
j < ring2_num_coords;
j += 2) {
472 double e22x =
coord_x(ring2,
j, ic2, isr2, osr);
473 double e22y =
coord_y(ring2,
j + 1, ic2, isr2, osr);
476 if ((
i == 0 &&
j == 0) || min_distance > distance) {
477 min_distance = distance;
481 if (min_distance <= threshold) {
499 template <
typename T>
501 is_left(
const T lx0,
const T ly0,
const T lx1,
const T ly1,
const T px,
const T py) {
502 return ((lx1 - lx0) * (py - ly0) - (px - lx0) * (ly1 - ly0));
505 template <
typename T>
508 if constexpr (!std::is_floating_point<T>::value) {
511 return (-tolerance <= x) && (x <= tolerance);
529 template <
typename T, EdgeBehavior TEdgeBehavior>
531 const int32_t poly_num_coords,
539 constexpr
bool include_point_on_edge =
542 auto get_x_coord = [=](
const auto data,
const auto index) ->
T {
543 if constexpr (std::is_floating_point<T>::value) {
544 return coord_x(data, index, ic1, isr1, osr);
551 auto get_y_coord = [=](
const auto data,
const auto index) ->
T {
552 if constexpr (std::is_floating_point<T>::value) {
553 return coord_y(data, index, ic1, isr1, osr);
560 DEBUG_STMT(printf(
"Poly num coords: %d\n", poly_num_coords));
561 const int64_t num_edges = poly_num_coords / 2;
563 int64_t e0_index = 0;
564 T e0x = get_x_coord(poly, e0_index * 2);
565 T e0y = get_y_coord(poly, (e0_index * 2) + 1);
570 for (int64_t edge = 1; edge <= num_edges; edge++) {
573 e1_index = edge % num_edges;
574 e1x = get_x_coord(poly, e1_index * 2);
575 e1y = get_y_coord(poly, (e1_index * 2) + 1);
577 DEBUG_STMT(printf(
"edge 0: %ld : %f, %f\n", e0_index, (
double)e0x, (
double)e0y));
578 DEBUG_STMT(printf(
"edge 1: %ld : %f, %f\n", e1_index, (
double)e1x, (
double)e1y));
580 auto get_epsilon = [=]() ->
T {
581 if constexpr (std::is_floating_point<T>::value) {
582 const T edge_vec_magnitude =
583 (e1x - e0x) * (e1x - e0x) + (e1y - e0y) * (e1y - e0y);
584 return 0.003 * edge_vec_magnitude;
591 const T epsilon = get_epsilon();
592 DEBUG_STMT(printf(
"using epsilon value %e\n", (
double)epsilon));
594 if constexpr (include_point_on_edge) {
595 const T xp = (px - e1x) * (e0y - e1y) - (py - e1y) * (e0x - e1x);
596 const T pt_vec_magnitude = (px - e0x) * (px - e0x) + (py - e0y) * (py - e0y);
597 const T edge_vec_magnitude = (e1x - e0x) * (e1x - e0x) + (e1y - e0y) * (e1y - e0y);
598 if (
tol_zero_template(xp, epsilon) && (pt_vec_magnitude <= edge_vec_magnitude)) {
599 DEBUG_STMT(printf(
"point is on edge: %e && %e <= %e\n",
601 (
double)pt_vec_magnitude,
602 (
double)edge_vec_magnitude));
603 return include_point_on_edge;
611 const auto is_left_val =
is_left(e0x, e0y, e1x, e1y, px, py);
612 DEBUG_STMT(printf(
"Left val %f and tol zero left val %d\n",
617 return include_point_on_edge;
618 }
else if (is_left_val >
T(0)) {
624 }
else if (e1y <= py) {
627 const auto is_left_val =
is_left(e0x, e0y, e1x, e1y, px, py);
628 DEBUG_STMT(printf(
"Left val %f and tol zero left val %d\n",
633 return include_point_on_edge;
634 }
else if (is_left_val <
T(0)) {
665 const int32_t poly_num_coords,
673 bool horizontal_edge =
false;
674 bool yray_intersects =
false;
676 double e1x =
coord_x(poly, poly_num_coords - 2, ic1, isr1, osr);
677 double e1y =
coord_y(poly, poly_num_coords - 1, ic1, isr1, osr);
678 for (int64_t
i = 0;
i < poly_num_coords;
i += 2) {
679 double e2x =
coord_x(poly,
i, ic1, isr1, osr);
680 double e2y =
coord_y(poly,
i + 1, ic1, isr1, osr);
694 horizontal_edge = (xray_touch != 0) &&
tol_eq(py, e1y) &&
tol_eq(py, e2y);
698 double xray = fmax(e2x, e1x) + 1.0;
713 if (xray_touch == 0) {
720 xray_touch = (e1y > py) ? 1 : -1;
725 if (xray_touch > 0) {
751 if (!yray_intersects) {
752 double yray = fmin(e2y, e1y) - 1.0;
769 if (!yray_intersects) {
780 int32_t poly_num_coords,
789 double l1x =
coord_x(l, 0, ic2, isr2, osr);
790 double l1y =
coord_y(l, 1, ic2, isr2, osr);
797 for (int32_t
i = 2;
i < lnum_coords;
i += 2) {
798 double l2x =
coord_x(l,
i, ic2, isr2, osr);
799 double l2y =
coord_y(l,
i + 1, ic2, isr2, osr);
810 const int64_t bounds_size,
827 int64_t bounds1_size,
829 int64_t bounds2_size) {
833 bounds1, bounds1_size, bounds2[0], bounds2[1]) &&
835 bounds1, bounds1_size, bounds2[2], bounds2[3]));
839 int64_t bounds1_size,
841 int64_t bounds2_size) {
845 bounds1, bounds1_size, bounds2[0], bounds2[1]) ||
847 bounds1, bounds1_size, bounds2[2], bounds2[3]) ||
849 bounds1, bounds1_size, bounds2[0], bounds2[3]) ||
851 bounds1, bounds1_size, bounds2[2], bounds2[1]));
855 int64_t bounds1_size,
857 int64_t bounds2_size) {
860 if (bounds1[2] < bounds2[0] ||
861 bounds1[0] > bounds2[2] ||
862 bounds1[3] < bounds2[1] ||
863 bounds1[1] > bounds2[3]) {
874 int64_t bounds2_size,
882 auto px =
coord_x(p1, 0, ic1, isr1, osr);
883 auto py =
coord_y(p1, 1, ic1, isr1, osr);
899 int64_t bounds1_size,
902 int64_t bounds2_size,
935 double ST_X_Point(int8_t* p, int64_t psize, int32_t ic, int32_t isr, int32_t osr) {
936 return coord_x(p, 0, ic, isr, osr);
940 double ST_Y_Point(int8_t* p, int64_t psize, int32_t ic, int32_t isr, int32_t osr) {
941 return coord_y(p, 1, ic, isr, osr);
952 if (lindex < 0 || lindex > l_num_points) {
953 lindex = l_num_points;
955 return coord_x(l, 2 * (lindex - 1), ic, isr, osr);
966 if (lindex < 0 || lindex > l_num_points) {
967 lindex = l_num_points;
969 return coord_y(l, 2 * (lindex - 1) + 1, ic, isr, osr);
973 double ST_XMin(int8_t* coords, int64_t size, int32_t ic, int32_t isr, int32_t osr) {
976 for (int32_t
i = 0;
i < num_coords;
i += 2) {
977 double x =
coord_x(coords,
i, ic, isr, osr);
978 if (
i == 0 || x < xmin) {
986 double ST_YMin(int8_t* coords, int64_t size, int32_t ic, int32_t isr, int32_t osr) {
989 for (int32_t
i = 1;
i < num_coords;
i += 2) {
990 double y =
coord_y(coords,
i, ic, isr, osr);
991 if (
i == 1 || y < ymin) {
999 double ST_XMax(int8_t* coords, int64_t size, int32_t ic, int32_t isr, int32_t osr) {
1002 for (int32_t
i = 0;
i < num_coords;
i += 2) {
1003 double x =
coord_x(coords,
i, ic, isr, osr);
1004 if (
i == 0 || x > xmax) {
1012 double ST_YMax(int8_t* coords, int64_t size, int32_t ic, int32_t isr, int32_t osr) {
1015 for (int32_t
i = 1;
i < num_coords;
i += 2) {
1016 double y =
coord_y(coords,
i, ic, isr, osr);
1017 if (
i == 1 || y > ymax) {
1054 bool check_closed) {
1057 double length = 0.0;
1059 double l0x =
coord_x(l, 0, ic, isr, osr);
1060 double l0y =
coord_y(l, 1, ic, isr, osr);
1063 for (int32_t
i = 2;
i < l_num_coords;
i += 2) {
1067 l2y =
coord_y(l,
i + 1, ic, isr, osr);
1105 int32_t* poly_ring_sizes,
1106 int64_t poly_num_rings,
1110 if (poly_num_rings <= 0) {
1114 auto exterior_ring_num_coords = poly_ring_sizes[0] * 2;
1117 return length_linestring(poly, exterior_ring_coords_size, ic, isr, osr,
false,
true);
1123 int32_t* poly_ring_sizes,
1124 int64_t poly_num_rings,
1128 if (poly_num_rings <= 0) {
1132 auto exterior_ring_num_coords = poly_ring_sizes[0] * 2;
1135 return length_linestring(poly, exterior_ring_coords_size, ic, isr, osr,
true,
true);
1139 int64_t mpoly_coords_size,
1140 int32_t* mpoly_ring_sizes,
1141 int64_t mpoly_num_rings,
1142 int32_t* mpoly_poly_sizes,
1143 int64_t mpoly_num_polys,
1148 if (mpoly_num_polys <= 0 || mpoly_num_rings <= 0) {
1152 double perimeter = 0.0;
1155 auto next_poly_coords = mpoly_coords;
1156 auto next_poly_ring_sizes = mpoly_ring_sizes;
1158 for (
auto poly = 0; poly < mpoly_num_polys; poly++) {
1159 auto poly_coords = next_poly_coords;
1160 auto poly_ring_sizes = next_poly_ring_sizes;
1161 auto poly_num_rings = mpoly_poly_sizes[poly];
1163 int32_t poly_num_coords = 0;
1164 for (
auto ring = 0; ring < poly_num_rings; ring++) {
1165 poly_num_coords += 2 * *next_poly_ring_sizes++;
1168 next_poly_coords += poly_coords_size;
1170 auto exterior_ring_num_coords = poly_ring_sizes[0] * 2;
1174 poly_coords, exterior_ring_coords_size, ic, isr, osr, geodesic,
true);
1182 int64_t mpoly_coords_size,
1183 int32_t* mpoly_ring_sizes,
1184 int64_t mpoly_num_rings,
1185 int32_t* mpoly_poly_sizes,
1186 int64_t mpoly_num_polys,
1204 int64_t mpoly_coords_size,
1205 int32_t* mpoly_ring_sizes,
1206 int64_t mpoly_num_rings,
1207 int32_t* mpoly_poly_sizes,
1208 int64_t mpoly_num_polys,
1234 return (x1 * y2 - x2 * y1 + x3 * y1 - x1 * y3 + x2 * y3 - x3 * y2) / 2.0;
1244 if (ring_num_coords < 6) {
1250 double x1 =
coord_x(ring, 0, ic, isr, osr);
1251 double y1 =
coord_y(ring, 1, ic, isr, osr);
1252 double x2 =
coord_x(ring, 2, ic, isr, osr);
1253 double y2 =
coord_y(ring, 3, ic, isr, osr);
1254 for (int32_t
i = 4;
i < ring_num_coords;
i += 2) {
1255 double x3 =
coord_x(ring,
i, ic, isr, osr);
1256 double y3 =
coord_y(ring,
i + 1, ic, isr, osr);
1265 int64_t poly_coords_size,
1266 int32_t* poly_ring_sizes,
1267 int64_t poly_num_rings,
1271 if (poly_num_rings <= 0) {
1276 auto ring_coords = poly_coords;
1281 for (
auto r = 0;
r < poly_num_rings;
r++) {
1283 area +=
area_ring(ring_coords, ring_coords_size, ic, isr, osr);
1285 ring_coords += ring_coords_size;
1292 int64_t poly_coords_size,
1293 int32_t* poly_ring_sizes,
1294 int64_t poly_num_rings,
1299 poly_coords, poly_coords_size, poly_ring_sizes, poly_num_rings, ic, isr, osr);
1304 int64_t poly_coords_size,
1305 int32_t* poly_ring_sizes,
1306 int64_t poly_num_rings,
1311 poly_coords, poly_coords_size, poly_ring_sizes, poly_num_rings, ic, isr, osr);
1316 int64_t mpoly_coords_size,
1317 int32_t* mpoly_ring_sizes,
1318 int64_t mpoly_num_rings,
1319 int32_t* mpoly_poly_sizes,
1320 int64_t mpoly_num_polys,
1324 if (mpoly_num_rings <= 0 || mpoly_num_polys <= 0) {
1331 auto next_poly_coords = mpoly_coords;
1332 auto next_poly_ring_sizes = mpoly_ring_sizes;
1334 for (
auto poly = 0; poly < mpoly_num_polys; poly++) {
1335 auto poly_coords = next_poly_coords;
1336 auto poly_ring_sizes = next_poly_ring_sizes;
1337 auto poly_num_rings = mpoly_poly_sizes[poly];
1339 int32_t poly_num_coords = 0;
1340 for (
auto ring = 0; ring < poly_num_rings; ring++) {
1341 poly_num_coords += 2 * *next_poly_ring_sizes++;
1344 next_poly_coords += poly_coords_size;
1347 poly_coords, poly_coords_size, poly_ring_sizes, poly_num_rings, ic, isr, osr);
1354 int64_t mpoly_coords_size,
1355 int32_t* mpoly_ring_sizes,
1356 int64_t mpoly_num_rings,
1357 int32_t* mpoly_poly_sizes,
1358 int64_t mpoly_num_polys,
1396 return coord_y(p, 1, ic, isr, osr);
1398 return coord_x(p, 0, ic, isr, osr);
1406 double* linestring_centroid_sum) {
1409 double segment_midpoint_x = (x1 + x2) / 2.0;
1410 double segment_midpoint_y = (y1 + y2) / 2.0;
1411 linestring_centroid_sum[0] += ldist * segment_midpoint_x;
1412 linestring_centroid_sum[1] += ldist * segment_midpoint_y;
1422 double* total_length,
1423 double* linestring_centroid_sum,
1424 int64_t* num_points,
1425 double* point_centroid_sum) {
1427 double length = 0.0;
1428 double l0x =
coord_x(l, 0, ic, isr, osr);
1429 double l0y =
coord_y(l, 1, ic, isr, osr);
1432 for (int32_t
i = 2;
i < l_num_coords;
i += 2) {
1436 l2y =
coord_y(l,
i + 1, ic, isr, osr);
1439 if (l_num_coords > 4 && closed) {
1443 *total_length += length;
1444 if (length == 0.0 && l_num_coords > 0) {
1446 point_centroid_sum[0] += l0x;
1447 point_centroid_sum[1] += l0y;
1459 double length = 0.0;
1460 double linestring_centroid_sum[2] = {0.0, 0.0};
1461 int64_t num_points = 0;
1462 double point_centroid_sum[2] = {0.0, 0.0};
1470 &linestring_centroid_sum[0],
1472 &point_centroid_sum[0]);
1473 double linestring_centroid[2] = {0.0, 0.0};
1475 linestring_centroid[0] = linestring_centroid_sum[0] / length;
1476 linestring_centroid[1] = linestring_centroid_sum[1] / length;
1477 }
else if (num_points > 0) {
1478 linestring_centroid[0] = point_centroid_sum[0] / num_points;
1479 linestring_centroid[1] = point_centroid_sum[1] / num_points;
1482 return linestring_centroid[1];
1484 return linestring_centroid[0];
1494 double* total_area2,
1496 double cx = x1 + x2 + x3;
1497 double cy = y1 + y2 + y3;
1498 double area2 = x1 * y2 - x2 * y1 + x3 * y1 - x1 * y3 + x2 * y3 - x3 * y2;
1499 cg3[0] += sign * area2 * cx;
1500 cg3[1] += sign * area2 * cy;
1501 *total_area2 += sign * area2;
1511 double* total_area2,
1513 double* total_length,
1514 double* linestring_centroid_sum,
1515 int64_t* num_points,
1516 double* point_centroid_sum) {
1519 if (ring_num_coords < 6) {
1523 double x1 =
coord_x(ring, 0, ic, isr, osr);
1524 double y1 =
coord_y(ring, 1, ic, isr, osr);
1525 double x2 =
coord_x(ring, 2, ic, isr, osr);
1526 double y2 =
coord_y(ring, 3, ic, isr, osr);
1527 for (int32_t
i = 4;
i < ring_num_coords;
i += 2) {
1528 double x3 =
coord_x(ring,
i, ic, isr, osr);
1529 double y3 =
coord_y(ring,
i + 1, ic, isr, osr);
1542 linestring_centroid_sum,
1544 point_centroid_sum);
1549 int64_t poly_coords_size,
1550 int32_t* poly_ring_sizes,
1551 int64_t poly_num_rings,
1555 double* total_area2,
1557 double* total_length,
1558 double* linestring_centroid_sum,
1559 int64_t* num_points,
1560 double* point_centroid_sum) {
1561 if (poly_num_rings <= 0) {
1565 auto ring_coords = poly_coords;
1567 for (
auto r = 0;
r < poly_num_rings;
r++) {
1570 double sign = (
r == 0) ? 1.0 : -1.0;
1580 linestring_centroid_sum,
1582 point_centroid_sum);
1584 ring_coords += ring_coords_size;
1591 int64_t poly_coords_size,
1592 int32_t* poly_ring_sizes,
1593 int64_t poly_num_rings,
1598 if (poly_num_rings <= 0) {
1601 double total_area2 = 0.0;
1602 double cg3[2] = {0.0, 0.0};
1603 double total_length = 0.0;
1604 double linestring_centroid_sum[2] = {0.0, 0.0};
1605 int64_t num_points = 0;
1606 double point_centroid_sum[2] = {0.0, 0.0};
1617 &linestring_centroid_sum[0],
1619 &point_centroid_sum[0]);
1621 double x1 =
coord_x(poly_coords, 0, ic, isr, osr);
1622 double y1 =
coord_y(poly_coords, 1, ic, isr, osr);
1623 double poly_centroid[2] = {x1, y1};
1624 if (total_area2 != 0.0) {
1625 poly_centroid[0] = cg3[0] / 3 / total_area2;
1626 poly_centroid[1] = cg3[1] / 3 / total_area2;
1627 }
else if (total_length > 0.0) {
1629 poly_centroid[0] = linestring_centroid_sum[0] / total_length;
1630 poly_centroid[1] = linestring_centroid_sum[1] / total_length;
1631 }
else if (num_points > 0) {
1633 poly_centroid[0] = point_centroid_sum[0] / num_points;
1634 poly_centroid[1] = point_centroid_sum[1] / num_points;
1638 return poly_centroid[1];
1640 return poly_centroid[0];
1645 int64_t mpoly_coords_size,
1646 int32_t* mpoly_ring_sizes,
1647 int64_t mpoly_num_rings,
1648 int32_t* mpoly_poly_sizes,
1649 int64_t mpoly_num_polys,
1654 if (mpoly_num_rings <= 0 || mpoly_num_polys <= 0) {
1658 double total_area2 = 0.0;
1659 double cg3[2] = {0.0, 0.0};
1660 double total_length = 0.0;
1661 double linestring_centroid_sum[2] = {0.0, 0.0};
1662 int64_t num_points = 0;
1663 double point_centroid_sum[2] = {0.0, 0.0};
1666 auto next_poly_coords = mpoly_coords;
1667 auto next_poly_ring_sizes = mpoly_ring_sizes;
1669 for (
auto poly = 0; poly < mpoly_num_polys; poly++) {
1670 auto poly_coords = next_poly_coords;
1671 auto poly_ring_sizes = next_poly_ring_sizes;
1672 auto poly_num_rings = mpoly_poly_sizes[poly];
1674 int32_t poly_num_coords = 0;
1675 for (
auto ring = 0; ring < poly_num_rings; ring++) {
1676 poly_num_coords += 2 * *next_poly_ring_sizes++;
1679 next_poly_coords += poly_coords_size;
1691 &linestring_centroid_sum[0],
1693 &point_centroid_sum[0]);
1696 double x1 =
coord_x(mpoly_coords, 0, ic, isr, osr);
1697 double y1 =
coord_y(mpoly_coords, 1, ic, isr, osr);
1698 double mpoly_centroid[2] = {x1, y1};
1699 if (total_area2 != 0.0) {
1700 mpoly_centroid[0] = cg3[0] / 3 / total_area2;
1701 mpoly_centroid[1] = cg3[1] / 3 / total_area2;
1702 }
else if (total_length > 0.0) {
1704 mpoly_centroid[0] = linestring_centroid_sum[0] / total_length;
1705 mpoly_centroid[1] = linestring_centroid_sum[1] / total_length;
1706 }
else if (num_points > 0) {
1708 mpoly_centroid[0] = point_centroid_sum[0] / num_points;
1709 mpoly_centroid[1] = point_centroid_sum[1] / num_points;
1713 return mpoly_centroid[1];
1715 return mpoly_centroid[0];
1719 int32_t
ST_NPoints(int8_t* coords, int64_t coords_sz, int32_t ic) {
1721 return static_cast<int32_t
>(num_pts / 2);
1725 int32_t
ST_NRings(int32_t* poly_ring_sizes, int64_t poly_num_rings) {
1726 return static_cast<int32_t
>(poly_num_rings);
1743 double p1x =
coord_x(p1, 0, ic1, isr1, osr);
1744 double p1y =
coord_y(p1, 1, ic1, isr1, osr);
1745 double p2x =
coord_x(p2, 0, ic2, isr2, osr);
1746 double p2y =
coord_y(p2, 1, ic2, isr2, osr);
1760 double p1x =
coord_x(p1, 0, ic1, isr1, osr);
1761 double p1y =
coord_y(p1, 1, ic1, isr1, osr);
1762 double p2x =
coord_x(p2, 0, ic2, isr2, osr);
1763 double p2y =
coord_y(p2, 1, ic2, isr2, osr);
1777 double p1x =
coord_x(p1, 0, ic1, 4326, 4326);
1778 double p1y =
coord_y(p1, 1, ic1, 4326, 4326);
1779 double p2x =
coord_x(p2, 0, ic2, 4326, 4326);
1780 double p2y =
coord_y(p2, 1, ic2, 4326, 4326);
1796 double px =
coord_x(p, 0, ic1, 4326, 4326);
1797 double py =
coord_y(p, 1, ic1, 4326, 4326);
1799 if (lindex < 0 || lindex > lpoints) {
1802 double lx =
coord_x(l, 2 * (lindex - 1), ic2, 4326, 4326);
1803 double ly =
coord_y(l, 2 * (lindex - 1) + 1, ic2, 4326, 4326);
1820 p, psize, l, lsize, lindex, ic2, isr2, ic1, isr1, osr);
1837 if (l1index < 0 || l1index > l1points) {
1840 double l1x =
coord_x(l1, 2 * (l1index - 1), ic1, 4326, 4326);
1841 double l1y =
coord_y(l1, 2 * (l1index - 1) + 1, ic1, 4326, 4326);
1843 if (l2index < 0 || l2index > l2points) {
1846 double l2x =
coord_x(l2, 2 * (l2index - 1), ic2, 4326, 4326);
1847 double l2y =
coord_y(l2, 2 * (l2index - 1) + 1, ic2, 4326, 4326);
1863 double px =
coord_x(p, 0, ic1, isr1, osr);
1864 double py =
coord_y(p, 1, ic1, isr1, osr);
1867 auto l_num_points = l_num_coords / 2;
1869 if (lindex < 0 || lindex > l_num_points) {
1870 lindex = l_num_points;
1872 double lx =
coord_x(l, 2 * (lindex - 1), ic2, isr2, osr);
1873 double ly =
coord_y(l, 2 * (lindex - 1) + 1, ic2, isr2, osr);
1877 double l1x =
coord_x(l, 0, ic2, isr2, osr);
1878 double l1y =
coord_y(l, 1, ic2, isr2, osr);
1879 double l2x =
coord_x(l, 2, ic2, isr2, osr);
1880 double l2y =
coord_y(l, 3, ic2, isr2, osr);
1883 for (int32_t
i = 4;
i < l_num_coords;
i += 2) {
1886 l2x =
coord_x(l,
i, ic2, isr2, osr);
1887 l2y =
coord_y(l,
i + 1, ic2, isr2, osr);
1892 if (dist <= threshold) {
1896 if (l_num_coords > 4 && check_closed) {
1898 l1x =
coord_x(l, 0, ic2, isr2, osr);
1899 l1y =
coord_y(l, 1, ic2, isr2, osr);
1921 p, psize, l, lsize, lindex, ic1, isr1, ic2, isr2, osr,
true, threshold);
1938 auto l_num_points = l_num_coords / 2;
1939 if (lindex < 0 || lindex > l_num_points) {
1940 lindex = l_num_points;
1942 double px =
coord_x(p, 0, ic1, isr1, osr);
1943 double py =
coord_y(p, 1, ic1, isr1, osr);
1944 double lx =
coord_x(l, 2 * (lindex - 1), ic2, isr2, osr);
1945 double ly =
coord_y(l, 2 * (lindex - 1) + 1, ic2, isr2, osr);
1950 p, psize, l, lsize, lindex, ic1, isr1, ic2, isr2, osr,
false, threshold);
1958 int32_t* poly_ring_sizes,
1959 int64_t poly_num_rings,
1967 if (poly_num_rings > 0) {
1968 exterior_ring_num_coords = poly_ring_sizes[0] * 2;
1972 double px =
coord_x(p, 0, ic1, isr1, osr);
1973 double py =
coord_y(p, 1, ic1, isr1, osr);
1979 exterior_ring_coords_size,
1990 poly += exterior_ring_coords_size;
1992 for (
auto r = 1;
r < poly_num_rings;
r++) {
1993 auto interior_ring_num_coords = poly_ring_sizes[
r] * 2;
1994 auto interior_ring_coords_size =
2001 interior_ring_coords_size,
2010 poly += interior_ring_coords_size;
2018 int8_t* mpoly_coords,
2019 int64_t mpoly_coords_size,
2020 int32_t* mpoly_ring_sizes,
2021 int64_t mpoly_num_rings,
2022 int32_t* mpoly_poly_sizes,
2023 int64_t mpoly_num_polys,
2030 if (mpoly_num_polys <= 0) {
2033 double min_distance = 0.0;
2036 auto next_poly_coords = mpoly_coords;
2037 auto next_poly_ring_sizes = mpoly_ring_sizes;
2039 for (
auto poly = 0; poly < mpoly_num_polys; poly++) {
2040 auto poly_coords = next_poly_coords;
2041 auto poly_ring_sizes = next_poly_ring_sizes;
2042 auto poly_num_rings = mpoly_poly_sizes[poly];
2044 int32_t poly_num_coords = 0;
2045 for (
auto ring = 0; ring < poly_num_rings; ring++) {
2046 poly_num_coords += 2 * *next_poly_ring_sizes++;
2049 next_poly_coords += poly_coords_size;
2062 if (poly == 0 || min_distance > distance) {
2063 min_distance = distance;
2068 if (min_distance <= threshold) {
2074 return min_distance;
2090 p, psize, l, lsize, lindex, ic2, isr2, ic1, isr1, osr, threshold);
2109 auto l1_num_points = l1_num_coords / 2;
2110 if (l1index < 0 || l1index > l1_num_points) {
2111 l1index = l1_num_points;
2116 p, psize, l2, l2size, l2index, ic1, isr1, ic2, isr2, osr, threshold);
2122 auto l2_num_points = l2_num_coords / 2;
2123 if (l2index < 0 || l2index > l2_num_points) {
2124 l2index = l2_num_points;
2129 p, psize, l1, l1size, l1index, ic2, isr2, ic1, isr1, osr, threshold);
2132 double threshold_squared = threshold * threshold;
2133 double dist_squared = 0.0;
2134 double l11x =
coord_x(l1, 0, ic1, isr1, osr);
2135 double l11y =
coord_y(l1, 1, ic1, isr1, osr);
2136 for (int32_t i1 = 2; i1 < l1_num_coords; i1 += 2) {
2137 double l12x =
coord_x(l1, i1, ic1, isr1, osr);
2138 double l12y =
coord_y(l1, i1 + 1, ic1, isr1, osr);
2140 double l21x =
coord_x(l2, 0, ic2, isr2, osr);
2141 double l21y =
coord_y(l2, 1, ic2, isr2, osr);
2142 for (int32_t i2 = 2; i2 < l2_num_coords; i2 += 2) {
2143 double l22x =
coord_x(l2, i2, ic2, isr2, osr);
2144 double l22y =
coord_y(l2, i2 + 1, ic2, isr2, osr);
2150 double ldist_squared = ldist * ldist;
2152 if (i1 == 2 && i2 == 2) {
2153 dist_squared = ldist_squared;
2155 }
else if (dist_squared > ldist_squared) {
2156 dist_squared = ldist_squared;
2161 if (dist_squared <= threshold_squared) {
2164 return sqrt(dist_squared);
2174 return sqrt(dist_squared);
2181 int8_t* poly_coords,
2182 int64_t poly_coords_size,
2183 int32_t* poly_ring_sizes,
2184 int64_t poly_num_rings,
2192 auto lnum_points = lnum_coords / 2;
2193 if (lindex < 0 || lindex > lnum_points) {
2194 lindex = lnum_points;
2212 return min_distance;
2218 if (min_distance <= threshold) {
2219 return min_distance;
2225 auto poly_ring_coords = poly_coords;
2226 for (
auto r = 0;
r < poly_num_rings;
r++) {
2227 int64_t poly_ring_num_coords = poly_ring_sizes[
r] * 2;
2230 poly_ring_num_coords,
2239 if (min_distance > distance) {
2240 min_distance = distance;
2244 if (min_distance <= threshold) {
2245 return min_distance;
2252 return min_distance;
2259 int8_t* mpoly_coords,
2260 int64_t mpoly_coords_size,
2261 int32_t* mpoly_ring_sizes,
2262 int64_t mpoly_num_rings,
2263 int32_t* mpoly_poly_sizes,
2264 int64_t mpoly_num_polys,
2274 auto lnum_points = lnum_coords / 2;
2277 if (lindex < 0 || lindex > lnum_points) {
2278 lindex = lnum_points;
2298 double min_distance = 0.0;
2301 auto next_poly_coords = mpoly_coords;
2302 auto next_poly_ring_sizes = mpoly_ring_sizes;
2304 for (
auto poly = 0; poly < mpoly_num_polys; poly++) {
2305 auto poly_coords = next_poly_coords;
2306 auto poly_ring_sizes = next_poly_ring_sizes;
2307 auto poly_num_rings = mpoly_poly_sizes[poly];
2309 int32_t poly_num_coords = 0;
2310 for (
auto ring = 0; ring < poly_num_rings; ring++) {
2311 poly_num_coords += 2 * *next_poly_ring_sizes++;
2314 next_poly_coords += poly_coords_size;
2328 if (poly == 0 || min_distance > distance) {
2329 min_distance = distance;
2334 if (min_distance <= threshold) {
2335 return min_distance;
2340 return min_distance;
2345 int64_t poly_coords_size,
2346 int32_t* poly_ring_sizes,
2347 int64_t poly_num_rings,
2372 int64_t poly_coords_size,
2373 int32_t* poly_ring_sizes,
2374 int64_t poly_num_rings,
2401 int64_t poly1_coords_size,
2402 int32_t* poly1_ring_sizes,
2403 int64_t poly1_num_rings,
2404 int8_t* poly2_coords,
2405 int64_t poly2_coords_size,
2406 int32_t* poly2_ring_sizes,
2407 int64_t poly2_num_rings,
2415 auto poly2_first_point_coords = poly2_coords;
2421 poly2_first_point_coords,
2422 poly2_first_point_coords_size,
2433 if (min_distance <= threshold) {
2434 return min_distance;
2447 auto poly1_ring_coords = poly1_coords;
2448 for (
auto r1 = 0; r1 < poly1_num_rings; r1++) {
2449 int64_t poly1_ring_num_coords = poly1_ring_sizes[r1] * 2;
2451 auto poly2_ring_coords = poly2_coords;
2452 for (
auto r2 = 0; r2 < poly2_num_rings; r2++) {
2453 int64_t poly2_ring_num_coords = poly2_ring_sizes[r2] * 2;
2456 poly1_ring_num_coords,
2458 poly2_ring_num_coords,
2465 if (min_distance > distance) {
2466 min_distance = distance;
2470 if (min_distance <= threshold) {
2471 return min_distance;
2481 return min_distance;
2486 int64_t poly1_coords_size,
2487 int32_t* poly1_ring_sizes,
2488 int64_t poly1_num_rings,
2489 int8_t* mpoly_coords,
2490 int64_t mpoly_coords_size,
2491 int32_t* mpoly_ring_sizes,
2492 int64_t mpoly_num_rings,
2493 int32_t* mpoly_poly_sizes,
2494 int64_t mpoly_num_polys,
2501 double min_distance = 0.0;
2504 auto next_poly_coords = mpoly_coords;
2505 auto next_poly_ring_sizes = mpoly_ring_sizes;
2507 for (
auto poly = 0; poly < mpoly_num_polys; poly++) {
2508 auto poly_coords = next_poly_coords;
2509 auto poly_ring_sizes = next_poly_ring_sizes;
2510 auto poly_num_rings = mpoly_poly_sizes[poly];
2512 int32_t poly_num_coords = 0;
2513 for (
auto ring = 0; ring < poly_num_rings; ring++) {
2514 poly_num_coords += 2 * *next_poly_ring_sizes++;
2517 next_poly_coords += poly_coords_size;
2532 if (poly == 0 || min_distance > distance) {
2533 min_distance = distance;
2538 if (min_distance <= threshold) {
2544 return min_distance;
2549 int64_t mpoly_coords_size,
2550 int32_t* mpoly_ring_sizes,
2551 int64_t mpoly_num_rings,
2552 int32_t* mpoly_poly_sizes,
2553 int64_t mpoly_num_polys,
2580 int64_t mpoly_coords_size,
2581 int32_t* mpoly_ring_sizes,
2582 int64_t mpoly_num_rings,
2583 int32_t* mpoly_poly_sizes,
2584 int64_t mpoly_num_polys,
2613 int64_t mpoly_coords_size,
2614 int32_t* mpoly_ring_sizes,
2615 int64_t mpoly_num_rings,
2616 int32_t* mpoly_poly_sizes,
2617 int64_t mpoly_num_polys,
2618 int8_t* poly1_coords,
2619 int64_t poly1_coords_size,
2620 int32_t* poly1_ring_sizes,
2621 int64_t poly1_num_rings,
2648 int64_t mpoly1_coords_size,
2649 int32_t* mpoly1_ring_sizes,
2650 int64_t mpoly1_num_rings,
2651 int32_t* mpoly1_poly_sizes,
2652 int64_t mpoly1_num_polys,
2653 int8_t* mpoly2_coords,
2654 int64_t mpoly2_coords_size,
2655 int32_t* mpoly2_ring_sizes,
2656 int64_t mpoly2_num_rings,
2657 int32_t* mpoly2_poly_sizes,
2658 int64_t mpoly2_num_polys,
2665 double min_distance = 0.0;
2669 auto next_poly_coords = mpoly1_coords;
2670 auto next_poly_ring_sizes = mpoly1_ring_sizes;
2672 for (
auto poly = 0; poly < mpoly1_num_polys; poly++) {
2673 auto poly_coords = next_poly_coords;
2674 auto poly_ring_sizes = next_poly_ring_sizes;
2675 auto poly_num_rings = mpoly1_poly_sizes[poly];
2677 int32_t poly_num_coords = 0;
2678 for (
auto ring = 0; ring < poly_num_rings; ring++) {
2679 poly_num_coords += 2 * *next_poly_ring_sizes++;
2682 next_poly_coords += poly_coords_size;
2699 if (poly == 0 || min_distance > distance) {
2700 min_distance = distance;
2705 if (min_distance <= threshold) {
2711 return min_distance;
2728 double distance_within) {
2730 p1, p1size, p2, p2size, ic1, isr1, ic2, isr2, osr) <=
2731 distance_within * distance_within;
2740 int64_t l2bounds_size,
2747 double distance_within) {
2751 p1, p1size, ic1, isr1, l2bounds, l2bounds_size, isr2, osr, distance_within)) {
2757 const double threshold = distance_within;
2759 p1, p1size, l2, l2size, l2index, ic1, isr1, ic2, isr2, osr, threshold) <=
2766 int8_t* poly_coords,
2767 int64_t poly_coords_size,
2768 int32_t* poly_ring_sizes,
2769 int64_t poly_num_rings,
2770 double* poly_bounds,
2771 int64_t poly_bounds_size,
2777 double distance_within) {
2793 const double threshold = distance_within;
2805 threshold) <= distance_within;
2811 int8_t* mpoly_coords,
2812 int64_t mpoly_coords_size,
2813 int32_t* mpoly_ring_sizes,
2814 int64_t mpoly_num_rings,
2815 int32_t* mpoly_poly_sizes,
2816 int64_t mpoly_num_polys,
2817 double* mpoly_bounds,
2818 int64_t mpoly_bounds_size,
2824 double distance_within) {
2840 const double threshold = distance_within;
2854 threshold) <= distance_within;
2861 int64_t l1bounds_size,
2866 int64_t l2bounds_size,
2873 double distance_within) {
2874 if (l1bounds && l2bounds) {
2889 const double threshold = distance_within;
2901 threshold) <= distance_within;
2908 int64_t l1bounds_size,
2910 int8_t* poly_coords,
2911 int64_t poly_coords_size,
2912 int32_t* poly_ring_sizes,
2913 int64_t poly_num_rings,
2914 double* poly_bounds,
2915 int64_t poly_bounds_size,
2921 double distance_within) {
2922 if (l1bounds && poly_bounds) {
2937 const double threshold = distance_within;
2950 threshold) <= distance_within;
2957 int64_t l1bounds_size,
2959 int8_t* mpoly_coords,
2960 int64_t mpoly_coords_size,
2961 int32_t* mpoly_ring_sizes,
2962 int64_t mpoly_num_rings,
2963 int32_t* mpoly_poly_sizes,
2964 int64_t mpoly_num_polys,
2965 double* mpoly_bounds,
2966 int64_t mpoly_bounds_size,
2972 double distance_within) {
2973 if (l1bounds && mpoly_bounds) {
2988 const double threshold = distance_within;
3003 threshold) <= distance_within;
3008 int64_t poly1_coords_size,
3009 int32_t* poly1_ring_sizes,
3010 int64_t poly1_num_rings,
3011 double* poly1_bounds,
3012 int64_t poly1_bounds_size,
3013 int8_t* poly2_coords,
3014 int64_t poly2_coords_size,
3015 int32_t* poly2_ring_sizes,
3016 int64_t poly2_num_rings,
3017 double* poly2_bounds,
3018 int64_t poly2_bounds_size,
3024 double distance_within) {
3025 if (poly1_bounds && poly2_bounds) {
3040 const double threshold = distance_within;
3054 threshold) <= distance_within;
3059 int64_t poly_coords_size,
3060 int32_t* poly_ring_sizes,
3061 int64_t poly_num_rings,
3062 double* poly_bounds,
3063 int64_t poly_bounds_size,
3064 int8_t* mpoly_coords,
3065 int64_t mpoly_coords_size,
3066 int32_t* mpoly_ring_sizes,
3067 int64_t mpoly_num_rings,
3068 int32_t* mpoly_poly_sizes,
3069 int64_t mpoly_num_polys,
3070 double* mpoly_bounds,
3071 int64_t mpoly_bounds_size,
3077 double distance_within) {
3078 if (poly_bounds && mpoly_bounds) {
3093 const double threshold = distance_within;
3109 threshold) <= distance_within;
3114 int64_t mpoly1_coords_size,
3115 int32_t* mpoly1_ring_sizes,
3116 int64_t mpoly1_num_rings,
3117 int32_t* mpoly1_poly_sizes,
3118 int64_t mpoly1_num_polys,
3119 double* mpoly1_bounds,
3120 int64_t mpoly1_bounds_size,
3121 int8_t* mpoly2_coords,
3122 int64_t mpoly2_coords_size,
3123 int32_t* mpoly2_ring_sizes,
3124 int64_t mpoly2_num_rings,
3125 int32_t* mpoly2_poly_sizes,
3126 int64_t mpoly2_num_polys,
3127 double* mpoly2_bounds,
3128 int64_t mpoly2_bounds_size,
3134 double distance_within) {
3135 if (mpoly1_bounds && mpoly2_bounds) {
3150 const double threshold = distance_within;
3168 threshold) <= distance_within;
3186 if (length1 > length2) {
3202 bool check_closed) {
3204 double px =
coord_x(p, 0, ic1, isr1, osr);
3205 double py =
coord_y(p, 1, ic1, isr1, osr);
3208 auto l_num_points = l_num_coords / 2;
3210 if (lindex < 0 || lindex > l_num_points) {
3211 lindex = l_num_points;
3213 double lx =
coord_x(l, 2 * (lindex - 1), ic2, isr2, osr);
3214 double ly =
coord_y(l, 2 * (lindex - 1) + 1, ic2, isr2, osr);
3218 double l1x =
coord_x(l, 0, ic2, isr2, osr);
3219 double l1y =
coord_y(l, 1, ic2, isr2, osr);
3220 double l2x =
coord_x(l, 2, ic2, isr2, osr);
3221 double l2y =
coord_y(l, 3, ic2, isr2, osr);
3224 for (int32_t
i = 4;
i < l_num_coords;
i += 2) {
3227 l2x =
coord_x(l,
i, ic2, isr2, osr);
3228 l2y =
coord_y(l,
i + 1, ic2, isr2, osr);
3230 if (max_dist < ldist) {
3234 if (l_num_coords > 4 && check_closed) {
3236 l1x =
coord_x(l, 0, ic2, isr2, osr);
3237 l1y =
coord_y(l, 1, ic2, isr2, osr);
3239 if (max_dist < ldist) {
3258 p, psize, l, lsize, lindex, ic1, isr1, ic2, isr2, osr,
false);
3273 p, psize, l, lsize, lindex, ic2, isr2, ic1, isr1, osr,
false);
3292 double p1x =
coord_x(p1, 0, ic1, isr1, osr);
3293 double p1y =
coord_y(p1, 1, ic1, isr1, osr);
3294 double p2x =
coord_x(p2, 0, ic2, isr2, osr);
3295 double p2y =
coord_y(p2, 1, ic2, isr2, osr);
3296 double tolerance =
tol(ic1, ic2);
3297 return tol_eq(p1x, p2x, tolerance) &&
tol_eq(p1y, p2y, tolerance);
3306 int64_t lbounds_size,
3313 double px =
coord_x(p, 0, ic1, isr1, osr);
3314 double py =
coord_y(p, 1, ic1, isr1, osr);
3318 tol_eq(py, lbounds[3])) {
3324 for (
int i = 0;
i < l_num_coords;
i += 2) {
3325 double lx =
coord_x(l,
i, ic2, isr2, osr);
3326 double ly =
coord_y(l,
i + 1, ic2, isr2, osr);
3338 int8_t* poly_coords,
3339 int64_t poly_coords_size,
3340 int32_t* poly_ring_sizes,
3341 int64_t poly_num_rings,
3342 double* poly_bounds,
3343 int64_t poly_bounds_size,
3350 if (poly_num_rings > 0) {
3351 exterior_ring_num_coords = poly_ring_sizes[0] * 2;
3358 exterior_ring_coords_size,
3373 int64_t lbounds_size,
3383 p, psize, l, lsize, li, ic2, isr2, ic1, isr1, osr, 0.0));
3390 int64_t l1bounds_size,
3395 int64_t l2bounds_size,
3402 if (l1i != 0 || l2i != 0) {
3405 l1, l1size, l1i, l2, l2size, l2i, ic1, isr1, ic2, isr2, osr, 0.0));
3419 int64_t lbounds_size,
3421 int8_t* poly_coords,
3422 int64_t poly_coords_size,
3423 int32_t* poly_ring_sizes,
3424 int64_t poly_num_rings,
3425 double* poly_bounds,
3426 int64_t poly_bounds_size,
3436 template <
typename T, EdgeBehavior TEdgeBehavior>
3438 const int64_t poly_coords_size,
3439 const int32_t* poly_ring_sizes,
3440 const int64_t poly_num_rings,
3441 const double* poly_bounds,
3442 const int64_t poly_bounds_size,
3444 const int64_t psize,
3449 const int32_t osr) {
3454 coord_x(p, 0, ic2, isr2, osr),
3455 coord_y(p, 1, ic2, isr2, osr))) {
3456 DEBUG_STMT(printf(
"Bounding box does not contain point, exiting.\n"));
3461 auto get_x_coord = [=]() ->
T {
3462 if constexpr (std::is_floating_point<T>::value) {
3463 return coord_x(p, 0, ic2, isr2, osr);
3470 auto get_y_coord = [=]() ->
T {
3471 if constexpr (std::is_floating_point<T>::value) {
3472 return coord_y(p, 1, ic2, isr2, osr);
3479 const T px = get_x_coord();
3480 const T py = get_y_coord();
3481 DEBUG_STMT(printf(
"pt: %f, %f\n", (
double)px, (
double)py));
3484 auto exterior_ring_num_coords =
3485 poly_num_rings > 0 ? poly_ring_sizes[0] * 2 : poly_num_coords;
3487 auto poly = poly_coords;
3488 if (point_in_polygon_winding_number<T, TEdgeBehavior>(
3489 poly, exterior_ring_num_coords, px, py, ic1, isr1, osr)) {
3493 for (
auto r = 1;
r < poly_num_rings;
r++) {
3494 const int64_t interior_ring_num_coords = poly_ring_sizes[
r] * 2;
3495 if (point_in_polygon_winding_number<T, TEdgeBehavior>(
3496 poly, interior_ring_num_coords, px, py, ic1, isr1, osr)) {
3507 const int64_t poly_coords_size,
3508 const int32_t* poly_ring_sizes,
3509 const int64_t poly_num_rings,
3510 const double* poly_bounds,
3511 const int64_t poly_bounds_size,
3513 const int64_t psize,
3518 const int32_t osr) {
3519 return Contains_Polygon_Point_Impl<double, EdgeBehavior::kExcludePointOnEdge>(
3536 const int64_t poly_coords_size,
3537 const int32_t* poly_ring_sizes,
3538 const int64_t poly_num_rings,
3539 const double* poly_bounds,
3540 const int64_t poly_bounds_size,
3542 const int64_t psize,
3547 const int32_t osr) {
3548 return Contains_Polygon_Point_Impl<int64_t, EdgeBehavior::kExcludePointOnEdge>(
3566 int64_t poly_coords_size,
3567 int32_t* poly_ring_sizes,
3568 int64_t poly_num_rings,
3569 double* poly_bounds,
3570 int64_t poly_bounds_size,
3574 int64_t lbounds_size,
3581 if (poly_num_rings > 1) {
3587 auto lnum_points = lnum_coords / 2;
3590 if (li < 0 || li > lnum_points) {
3593 double lx =
coord_x(l, 2 * (li - 1), ic2, isr2, osr);
3594 double ly =
coord_y(l, 2 * (li - 1) + 1, ic2, isr2, osr);
3602 return point_in_polygon_winding_number<double, EdgeBehavior::kIncludePointOnEdge>(
3603 poly_coords, poly_num_coords, lx, ly, ic1, isr1, osr);
3607 if (poly_bounds && lbounds) {
3608 if (!
box_contains_box(poly_bounds, poly_bounds_size, lbounds, lbounds_size)) {
3614 poly_coords, poly_num_coords, l, lnum_coords, ic1, isr1, ic2, isr2, osr);
3619 int64_t poly1_coords_size,
3620 int32_t* poly1_ring_sizes,
3621 int64_t poly1_num_rings,
3622 double* poly1_bounds,
3623 int64_t poly1_bounds_size,
3624 int8_t* poly2_coords,
3625 int64_t poly2_coords_size,
3626 int32_t* poly2_ring_sizes,
3627 int64_t poly2_num_rings,
3628 double* poly2_bounds,
3629 int64_t poly2_bounds_size,
3637 if (poly1_num_rings > 1) {
3641 if (poly1_bounds && poly2_bounds) {
3643 poly1_bounds, poly1_bounds_size, poly2_bounds, poly2_bounds_size)) {
3648 int64_t poly2_exterior_ring_coords_size = poly2_coords_size;
3649 if (poly2_num_rings > 0) {
3650 poly2_exterior_ring_coords_size =
3660 poly2_exterior_ring_coords_size,
3671 template <
typename T, EdgeBehavior TEdgeBehavior>
3673 const int8_t* mpoly_coords,
3674 const int64_t mpoly_coords_size,
3675 const int32_t* mpoly_ring_sizes,
3676 const int64_t mpoly_num_rings,
3677 const int32_t* mpoly_poly_sizes,
3678 const int64_t mpoly_num_polys,
3679 const double* mpoly_bounds,
3680 const int64_t mpoly_bounds_size,
3682 const int64_t psize,
3687 const int32_t osr) {
3688 if (mpoly_num_polys <= 0) {
3697 coord_x(p, 0, ic2, isr2, osr),
3698 coord_y(p, 1, ic2, isr2, osr))) {
3705 auto next_poly_coords = mpoly_coords;
3706 auto next_poly_ring_sizes = mpoly_ring_sizes;
3708 for (
auto poly = 0; poly < mpoly_num_polys; poly++) {
3709 const auto poly_coords = next_poly_coords;
3710 const auto poly_ring_sizes = next_poly_ring_sizes;
3711 const auto poly_num_rings = mpoly_poly_sizes[poly];
3713 int32_t poly_num_coords = 0;
3714 for (
auto ring = 0; ring < poly_num_rings; ring++) {
3715 poly_num_coords += 2 * *next_poly_ring_sizes++;
3718 next_poly_coords += poly_coords_size;
3720 if (Contains_Polygon_Point_Impl<T, TEdgeBehavior>(poly_coords,
3742 int64_t mpoly_coords_size,
3743 int32_t* mpoly_ring_sizes,
3744 int64_t mpoly_num_rings,
3745 int32_t* mpoly_poly_sizes,
3746 int64_t mpoly_num_polys,
3747 double* mpoly_bounds,
3748 int64_t mpoly_bounds_size,
3756 return Contains_MultiPolygon_Point_Impl<double, EdgeBehavior::kExcludePointOnEdge>(
3775 int64_t mpoly_coords_size,
3776 int32_t* mpoly_ring_sizes,
3777 int64_t mpoly_num_rings,
3778 int32_t* mpoly_poly_sizes,
3779 int64_t mpoly_num_polys,
3780 double* mpoly_bounds,
3781 int64_t mpoly_bounds_size,
3789 return Contains_MultiPolygon_Point_Impl<int64_t, EdgeBehavior::kExcludePointOnEdge>(
3809 int64_t mpoly_coords_size,
3810 int32_t* mpoly_ring_sizes,
3811 int64_t mpoly_num_rings,
3812 int32_t* mpoly_poly_sizes,
3813 int64_t mpoly_num_polys,
3814 double* mpoly_bounds,
3815 int64_t mpoly_bounds_size,
3819 int64_t lbounds_size,
3826 if (mpoly_num_polys <= 0) {
3831 auto lnum_points = lnum_coords / 2;
3834 if (li < 0 || li > lnum_points) {
3837 double lx =
coord_x(l, 2 * (li - 1), ic2, isr2, osr);
3838 double ly =
coord_y(l, 2 * (li - 1) + 1, ic2, isr2, osr);
3864 if (mpoly_bounds && lbounds) {
3865 if (!
box_contains_box(mpoly_bounds, mpoly_bounds_size, lbounds, lbounds_size)) {
3871 auto next_poly_coords = mpoly_coords;
3872 auto next_poly_ring_sizes = mpoly_ring_sizes;
3874 for (
auto poly = 0; poly < mpoly_num_polys; poly++) {
3875 auto poly_coords = next_poly_coords;
3876 auto poly_ring_sizes = next_poly_ring_sizes;
3877 auto poly_num_rings = mpoly_poly_sizes[poly];
3879 int32_t poly_num_coords = 0;
3880 for (
auto ring = 0; ring < poly_num_rings; ring++) {
3881 poly_num_coords += 2 * *next_poly_ring_sizes++;
3884 next_poly_coords += poly_coords_size;
3933 int64_t lbounds_size,
3940 double px =
coord_x(p, 0, ic1, isr1, osr);
3941 double py =
coord_y(p, 1, ic1, isr1, osr);
3944 auto lnum_points = lnum_coords / 2;
3947 if (li < 0 || li > lnum_points) {
3962 p, psize, l, lsize, li, ic1, isr1, ic2, isr2, osr, 0.0));
3970 int32_t* poly_ring_sizes,
3971 int64_t poly_num_rings,
3972 double* poly_bounds,
3973 int64_t poly_bounds_size,
3979 return Contains_Polygon_Point_Impl<double, EdgeBehavior::kIncludePointOnEdge>(
3998 int8_t* mpoly_coords,
3999 int64_t mpoly_coords_size,
4000 int32_t* mpoly_ring_sizes,
4001 int64_t mpoly_num_rings,
4002 int32_t* mpoly_poly_sizes,
4003 int64_t mpoly_num_polys,
4004 double* mpoly_bounds,
4005 int64_t mpoly_bounds_size,
4032 int64_t lbounds_size,
4042 p, psize, l, lsize, lbounds, lbounds_size, li, ic2, isr2, ic1, isr1, osr);
4049 int64_t l1bounds_size,
4054 int64_t l2bounds_size,
4062 auto l2num_points = l2num_coords / 2;
4065 if (l2i < 0 || l2i > l2num_points) {
4071 l1, l1size, l1bounds, l1bounds_size, l1i, p2, p2size, ic1, isr1, ic2, isr2, osr);
4074 auto l1num_points = l1num_coords / 2;
4077 if (l1i < 0 || l1i > l1num_points) {
4083 l2, l2size, l2bounds, l2bounds_size, l2i, p1, p1size, ic2, isr2, ic1, isr1, osr);
4086 if (l1bounds && l2bounds) {
4093 l1, l1size, l1i, l2, l2size, l2i, ic1, isr1, ic2, isr2, osr, 0.0));
4100 int64_t lbounds_size,
4104 int32_t* poly_ring_sizes,
4105 int64_t poly_num_rings,
4106 double* poly_bounds,
4107 int64_t poly_bounds_size,
4114 auto lnum_points = lnum_coords / 2;
4117 if (li < 0 || li > lnum_points) {
4122 return Contains_Polygon_Point_Impl<double, EdgeBehavior::kIncludePointOnEdge>(
4138 if (lbounds && poly_bounds) {
4139 if (!
box_overlaps_box(lbounds, lbounds_size, poly_bounds, poly_bounds_size)) {
4170 int64_t lbounds_size,
4172 int8_t* mpoly_coords,
4173 int64_t mpoly_coords_size,
4174 int32_t* mpoly_ring_sizes,
4175 int64_t mpoly_num_rings,
4176 int32_t* mpoly_poly_sizes,
4177 int64_t mpoly_num_polys,
4178 double* mpoly_bounds,
4179 int64_t mpoly_bounds_size,
4186 auto lnum_points = lnum_coords / 2;
4189 if (li < 0 || li > lnum_points) {
4211 if (lbounds && mpoly_bounds) {
4212 if (!
box_overlaps_box(lbounds, lbounds_size, mpoly_bounds, mpoly_bounds_size)) {
4244 int32_t* poly_ring_sizes,
4245 int64_t poly_num_rings,
4246 double* poly_bounds,
4247 int64_t poly_bounds_size,
4255 return Contains_Polygon_Point_Impl<double, EdgeBehavior::kIncludePointOnEdge>(
4274 int32_t* poly_ring_sizes,
4275 int64_t poly_num_rings,
4276 double* poly_bounds,
4277 int64_t poly_bounds_size,
4281 int64_t lbounds_size,
4308 int64_t poly1_coords_size,
4309 int32_t* poly1_ring_sizes,
4310 int64_t poly1_num_rings,
4311 double* poly1_bounds,
4312 int64_t poly1_bounds_size,
4313 int8_t* poly2_coords,
4314 int64_t poly2_coords_size,
4315 int32_t* poly2_ring_sizes,
4316 int64_t poly2_num_rings,
4317 double* poly2_bounds,
4318 int64_t poly2_bounds_size,
4324 if (poly1_bounds && poly2_bounds) {
4326 poly1_bounds, poly1_bounds_size, poly2_bounds, poly2_bounds_size)) {
4349 int64_t poly_coords_size,
4350 int32_t* poly_ring_sizes,
4351 int64_t poly_num_rings,
4352 double* poly_bounds,
4353 int64_t poly_bounds_size,
4354 int8_t* mpoly_coords,
4355 int64_t mpoly_coords_size,
4356 int32_t* mpoly_ring_sizes,
4357 int64_t mpoly_num_rings,
4358 int32_t* mpoly_poly_sizes,
4359 int64_t mpoly_num_polys,
4360 double* mpoly_bounds,
4361 int64_t mpoly_bounds_size,
4367 if (poly_bounds && mpoly_bounds) {
4369 poly_bounds, poly_bounds_size, mpoly_bounds, mpoly_bounds_size)) {
4394 int64_t mpoly_coords_size,
4395 int32_t* mpoly_ring_sizes,
4396 int64_t mpoly_num_rings,
4397 int32_t* mpoly_poly_sizes,
4398 int64_t mpoly_num_polys,
4399 double* mpoly_bounds,
4400 int64_t mpoly_bounds_size,
4408 return Contains_MultiPolygon_Point_Impl<double, EdgeBehavior::kIncludePointOnEdge>(
4428 int64_t mpoly_coords_size,
4429 int32_t* mpoly_ring_sizes,
4430 int64_t mpoly_num_rings,
4431 int32_t* mpoly_poly_sizes,
4432 int64_t mpoly_num_polys,
4433 double* mpoly_bounds,
4434 int64_t mpoly_bounds_size,
4438 int64_t lbounds_size,
4467 int64_t mpoly_coords_size,
4468 int32_t* mpoly_ring_sizes,
4469 int64_t mpoly_num_rings,
4470 int32_t* mpoly_poly_sizes,
4471 int64_t mpoly_num_polys,
4472 double* mpoly_bounds,
4473 int64_t mpoly_bounds_size,
4474 int8_t* poly_coords,
4475 int64_t poly_coords_size,
4476 int32_t* poly_ring_sizes,
4477 int64_t poly_num_rings,
4478 double* poly_bounds,
4479 int64_t poly_bounds_size,
4508 int64_t mpoly1_coords_size,
4509 int32_t* mpoly1_ring_sizes,
4510 int64_t mpoly1_num_rings,
4511 int32_t* mpoly1_poly_sizes,
4512 int64_t mpoly1_num_polys,
4513 double* mpoly1_bounds,
4514 int64_t mpoly1_bounds_size,
4515 int8_t* mpoly2_coords,
4516 int64_t mpoly2_coords_size,
4517 int32_t* mpoly2_ring_sizes,
4518 int64_t mpoly2_num_rings,
4519 int32_t* mpoly2_poly_sizes,
4520 int64_t mpoly2_num_polys,
4521 double* mpoly2_bounds,
4522 int64_t mpoly2_bounds_size,
4528 if (mpoly1_bounds && mpoly2_bounds) {
4530 mpoly1_bounds, mpoly1_bounds_size, mpoly2_bounds, mpoly2_bounds_size)) {
4565 return reinterpret_cast<int64_t
>(bounds);
4570 return render_group;
4586 const int64_t psize,
4590 const double min_lon,
4591 const double max_lon,
4592 const int32_t img_width,
4593 const double min_width) {
4594 const double const1 = 0.017453292519943295769236907684886;
4595 const double const2 = 6372797.560856;
4598 double t1 = sinf(meters / (2.0 * const2));
4599 double t2 = cosf(const1 * lat);
4600 const double newlon = lon - (2.0 * asinf(t1 / t2)) / const1;
4605 const double domain_diff = max_domain_x - min_domain_x;
4606 t1 = ((t1 - min_domain_x) / domain_diff) *
static_cast<double>(img_width);
4607 t2 = ((t2 - min_domain_x) / domain_diff) *
static_cast<double>(img_width);
4610 const double sz = fabs(t1 - t2);
4611 return (sz < min_width ? min_width : sz);
4617 const int64_t psize,
4621 const double min_lat,
4622 const double max_lat,
4623 const int32_t img_height,
4624 const double min_height) {
4625 const double const1 = 0.017453292519943295769236907684886;
4626 const double const2 = 6372797.560856;
4628 const double latdiff = meters / (const1 * const2);
4629 const double newlat =
4630 (lat < 0) ? lat + latdiff : lat - latdiff;
4633 const double min_domain_y =
transform_coord(min_lat, isr, osr,
false);
4634 const double max_domain_y =
transform_coord(max_lat, isr, osr,
false);
4635 const double domain_diff = max_domain_y - min_domain_y;
4636 t1 = ((t1 - min_domain_y) / domain_diff) *
static_cast<double>(img_height);
4637 t2 = ((t2 - min_domain_y) / domain_diff) *
static_cast<double>(img_height);
4640 const double sz = fabs(t1 - t2);
4641 return (sz < min_height ? min_height : sz);
4645 const int64_t psize,
4647 const double min_lon,
4648 const double max_lon,
4649 const double min_lat,
4650 const double max_lat) {
4653 return !(lon < min_lon || lon > max_lon || lat < min_lat || lat > max_lat);
4657 const int64_t psize,
4659 const double meters,
4660 const double min_lon,
4661 const double max_lon,
4662 const double min_lat,
4663 const double max_lat) {
4664 const double const1 = 0.017453292519943295769236907684886;
4665 const double const2 = 6372797.560856;
4668 const double latdiff = meters / (const1 * const2);
4669 const double t1 = sinf(meters / (2.0 * const2));
4670 const double t2 = cosf(const1 * lat);
4671 const double londiff = (2.0 * asinf(t1 / t2)) / const1;
4672 return !(lon + londiff < min_lon || lon - londiff > max_lon ||
4673 lat + latdiff < min_lat || lat - latdiff > max_lat);
EXTENSION_NOINLINE double ST_Distance_LineString_LineString_Geodesic(int8_t *l1, int64_t l1size, int32_t l1index, int8_t *l2, int64_t l2size, int32_t l2index, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
EXTENSION_NOINLINE double convert_meters_to_pixel_width(const double meters, int8_t *p, const int64_t psize, const int32_t ic, const int32_t isr, const int32_t osr, const double min_lon, const double max_lon, const int32_t img_width, const double min_width)
EXTENSION_INLINE bool ST_Intersects_Point_Polygon(int8_t *p, int64_t psize, int8_t *poly, int64_t polysize, int32_t *poly_ring_sizes, int64_t poly_num_rings, double *poly_bounds, int64_t poly_bounds_size, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
DEVICE ALWAYS_INLINE double length_linestring(int8_t *l, int64_t lsize, int32_t ic, int32_t isr, int32_t osr, bool geodesic, bool check_closed)
EXTENSION_NOINLINE double ST_Distance_Point_Point(int8_t *p1, int64_t p1size, int8_t *p2, int64_t p2size, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
EXTENSION_NOINLINE double ST_X_Point(int8_t *p, int64_t psize, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE bool on_segment(double px, double py, double qx, double qy, double rx, double ry)
EXTENSION_INLINE bool ST_DWithin_MultiPolygon_MultiPolygon(int8_t *mpoly1_coords, int64_t mpoly1_coords_size, int32_t *mpoly1_ring_sizes, int64_t mpoly1_num_rings, int32_t *mpoly1_poly_sizes, int64_t mpoly1_num_polys, double *mpoly1_bounds, int64_t mpoly1_bounds_size, int8_t *mpoly2_coords, int64_t mpoly2_coords_size, int32_t *mpoly2_ring_sizes, int64_t mpoly2_num_rings, int32_t *mpoly2_poly_sizes, int64_t mpoly2_num_polys, double *mpoly2_bounds, int64_t mpoly2_bounds_size, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double distance_within)
DEVICE ALWAYS_INLINE double transform_coord(const double coord, const int32_t isr, const int32_t osr, const bool x)
EXTENSION_NOINLINE double ST_Centroid_LineString(int8_t *coords, int64_t coords_sz, int32_t ic, int32_t isr, int32_t osr, bool ycoord)
EXTENSION_INLINE bool ST_Intersects_MultiPolygon_Polygon(int8_t *mpoly_coords, int64_t mpoly_coords_size, int32_t *mpoly_ring_sizes, int64_t mpoly_num_rings, int32_t *mpoly_poly_sizes, int64_t mpoly_num_polys, double *mpoly_bounds, int64_t mpoly_bounds_size, int8_t *poly_coords, int64_t poly_coords_size, int32_t *poly_ring_sizes, int64_t poly_num_rings, double *poly_bounds, int64_t poly_bounds_size, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
DEVICE ALWAYS_INLINE double area_polygon(int8_t *poly_coords, int64_t poly_coords_size, int32_t *poly_ring_sizes, int64_t poly_num_rings, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE bool box_dwithin_box(double *bounds1, int64_t bounds1_size, int32_t isr1, double *bounds2, int64_t bounds2_size, int32_t isr2, int32_t osr, double distance)
EXTENSION_NOINLINE bool ST_Contains_Point_Point(int8_t *p1, int64_t p1size, int8_t *p2, int64_t p2size, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
EXTENSION_NOINLINE double ST_Perimeter_Polygon(int8_t *poly, int64_t polysize, int32_t *poly_ring_sizes, int64_t poly_num_rings, int32_t ic, int32_t isr, int32_t osr)
EXTENSION_NOINLINE bool ST_Contains_LineString_Polygon(int8_t *l, int64_t lsize, double *lbounds, int64_t lbounds_size, int32_t li, int8_t *poly_coords, int64_t poly_coords_size, int32_t *poly_ring_sizes, int64_t poly_num_rings, double *poly_bounds, int64_t poly_bounds_size, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
EXTENSION_INLINE int32_t OmniSci_Geo_PolyRenderGroup(int32_t render_group)
DEVICE ALWAYS_INLINE bool centroid_add_triangle(double x1, double y1, double x2, double y2, double x3, double y3, double sign, double *total_area2, double *cg3)
EXTENSION_NOINLINE double ST_XMax(int8_t *coords, int64_t size, int32_t ic, int32_t isr, int32_t osr)
EXTENSION_INLINE bool ST_DWithin_Point_Polygon(int8_t *p, int64_t psize, int8_t *poly_coords, int64_t poly_coords_size, int32_t *poly_ring_sizes, int64_t poly_num_rings, double *poly_bounds, int64_t poly_bounds_size, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double distance_within)
EXTENSION_NOINLINE bool ST_Intersects_LineString_MultiPolygon(int8_t *l, int64_t lsize, double *lbounds, int64_t lbounds_size, int32_t li, int8_t *mpoly_coords, int64_t mpoly_coords_size, int32_t *mpoly_ring_sizes, int64_t mpoly_num_rings, int32_t *mpoly_poly_sizes, int64_t mpoly_num_polys, double *mpoly_bounds, int64_t mpoly_bounds_size, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
EXTENSION_NOINLINE double ST_Distance_Point_MultiPolygon(int8_t *p, int64_t psize, int8_t *mpoly_coords, int64_t mpoly_coords_size, int32_t *mpoly_ring_sizes, int64_t mpoly_num_rings, int32_t *mpoly_poly_sizes, int64_t mpoly_num_polys, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double threshold)
EXTENSION_NOINLINE bool ST_Intersects_Polygon_Polygon(int8_t *poly1_coords, int64_t poly1_coords_size, int32_t *poly1_ring_sizes, int64_t poly1_num_rings, double *poly1_bounds, int64_t poly1_bounds_size, int8_t *poly2_coords, int64_t poly2_coords_size, int32_t *poly2_ring_sizes, int64_t poly2_num_rings, double *poly2_bounds, int64_t poly2_bounds_size, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
EXTENSION_NOINLINE bool is_point_size_in_view(int8_t *p, const int64_t psize, const int32_t ic, const double meters, const double min_lon, const double max_lon, const double min_lat, const double max_lat)
DEVICE double distance_point_line(double px, double py, double l1x, double l1y, double l2x, double l2y)
EXTENSION_NOINLINE double ST_X_LineString(int8_t *l, int64_t lsize, int32_t lindex, int32_t ic, int32_t isr, int32_t osr)
EXTENSION_INLINE double ST_YMin_Bounds(double *bounds, int64_t size, int32_t isr, int32_t osr)
EXTENSION_NOINLINE double ST_YMax(int8_t *coords, int64_t size, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE int32_t compressed_coord(const int8_t *data, const int32_t index)
EXTENSION_INLINE double ST_XMin_Bounds(double *bounds, int64_t size, int32_t isr, int32_t osr)
EXTENSION_NOINLINE bool ST_cContains_Polygon_Point(const int8_t *poly_coords, const int64_t poly_coords_size, const int32_t *poly_ring_sizes, const int64_t poly_num_rings, const double *poly_bounds, const int64_t poly_bounds_size, const int8_t *p, const int64_t psize, const int32_t ic1, const int32_t isr1, const int32_t ic2, const int32_t isr2, const int32_t osr)
DEVICE ALWAYS_INLINE T is_left(const T lx0, const T ly0, const T lx1, const T ly1, const T px, const T py)
DEVICE ALWAYS_INLINE bool Contains_MultiPolygon_Point_Impl(const int8_t *mpoly_coords, const int64_t mpoly_coords_size, const int32_t *mpoly_ring_sizes, const int64_t mpoly_num_rings, const int32_t *mpoly_poly_sizes, const int64_t mpoly_num_polys, const double *mpoly_bounds, const int64_t mpoly_bounds_size, const int8_t *p, const int64_t psize, const int32_t ic1, const int32_t isr1, const int32_t ic2, const int32_t isr2, const int32_t osr)
DEVICE ALWAYS_INLINE double perimeter_multipolygon(int8_t *mpoly_coords, int64_t mpoly_coords_size, int32_t *mpoly_ring_sizes, int64_t mpoly_num_rings, int32_t *mpoly_poly_sizes, int64_t mpoly_num_polys, int32_t ic, int32_t isr, int32_t osr, bool geodesic)
DEVICE ALWAYS_INLINE double max_distance_point_linestring(int8_t *p, int64_t psize, int8_t *l, int64_t lsize, int32_t lindex, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, bool check_closed)
DEVICE double decompress_lattitude_coord_geoint32(const int32_t compressed)
EXTENSION_NOINLINE double ST_Area_Polygon(int8_t *poly_coords, int64_t poly_coords_size, int32_t *poly_ring_sizes, int64_t poly_num_rings, int32_t ic, int32_t isr, int32_t osr)
EXTENSION_NOINLINE double ST_Distance_LineString_MultiPolygon(int8_t *l, int64_t lsize, int32_t lindex, int8_t *mpoly_coords, int64_t mpoly_coords_size, int32_t *mpoly_ring_sizes, int64_t mpoly_num_rings, int32_t *mpoly_poly_sizes, int64_t mpoly_num_polys, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double threshold)
EXTENSION_NOINLINE bool ST_Contains_MultiPolygon_LineString(int8_t *mpoly_coords, int64_t mpoly_coords_size, int32_t *mpoly_ring_sizes, int64_t mpoly_num_rings, int32_t *mpoly_poly_sizes, int64_t mpoly_num_polys, double *mpoly_bounds, int64_t mpoly_bounds_size, int8_t *l, int64_t lsize, double *lbounds, int64_t lbounds_size, int32_t li, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
DEVICE ALWAYS_INLINE double area_triangle(double x1, double y1, double x2, double y2, double x3, double y3)
EXTENSION_INLINE double ST_Distance_Polygon_LineString(int8_t *poly_coords, int64_t poly_coords_size, int32_t *poly_ring_sizes, int64_t poly_num_rings, int8_t *l, int64_t lsize, int32_t li, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double threshold)
EXTENSION_INLINE bool ST_DWithin_Polygon_Polygon(int8_t *poly1_coords, int64_t poly1_coords_size, int32_t *poly1_ring_sizes, int64_t poly1_num_rings, double *poly1_bounds, int64_t poly1_bounds_size, int8_t *poly2_coords, int64_t poly2_coords_size, int32_t *poly2_ring_sizes, int64_t poly2_num_rings, double *poly2_bounds, int64_t poly2_bounds_size, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double distance_within)
EXTENSION_NOINLINE double ST_XMin(int8_t *coords, int64_t size, int32_t ic, int32_t isr, int32_t osr)
EXTENSION_INLINE double ST_Distance_LineString_Point(int8_t *l, int64_t lsize, int32_t lindex, int8_t *p, int64_t psize, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double threshold)
EXTENSION_NOINLINE bool ST_Contains_Polygon_LineString(int8_t *poly_coords, int64_t poly_coords_size, int32_t *poly_ring_sizes, int64_t poly_num_rings, double *poly_bounds, int64_t poly_bounds_size, int8_t *l, int64_t lsize, double *lbounds, int64_t lbounds_size, int32_t li, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
EXTENSION_INLINE bool ST_Intersects_Polygon_Point(int8_t *poly, int64_t polysize, int32_t *poly_ring_sizes, int64_t poly_num_rings, double *poly_bounds, int64_t poly_bounds_size, int8_t *p, int64_t psize, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
EXTENSION_NOINLINE double ST_Distance_Point_Polygon(int8_t *p, int64_t psize, int8_t *poly, int64_t polysize, int32_t *poly_ring_sizes, int64_t poly_num_rings, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double threshold)
EXTENSION_NOINLINE double ST_Distance_Point_Point_Squared(int8_t *p1, int64_t p1size, int8_t *p2, int64_t p2size, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
EXTENSION_INLINE bool ST_DWithin_Point_Point(int8_t *p1, int64_t p1size, int8_t *p2, int64_t p2size, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double distance_within)
EXTENSION_NOINLINE double ST_Y_Point(int8_t *p, int64_t psize, int32_t ic, int32_t isr, int32_t osr)
EXTENSION_NOINLINE double ST_Perimeter_MultiPolygon_Geodesic(int8_t *mpoly_coords, int64_t mpoly_coords_size, int32_t *mpoly_ring_sizes, int64_t mpoly_num_rings, int32_t *mpoly_poly_sizes, int64_t mpoly_num_polys, int32_t ic, int32_t isr, int32_t osr)
EXTENSION_NOINLINE double convert_meters_to_pixel_height(const double meters, int8_t *p, const int64_t psize, const int32_t ic, const int32_t isr, const int32_t osr, const double min_lat, const double max_lat, const int32_t img_height, const double min_height)
#define TOLERANCE_GEOINT32
EXTENSION_INLINE bool ST_DWithin_LineString_MultiPolygon(int8_t *l1, int64_t l1size, double *l1bounds, int64_t l1bounds_size, int32_t l1index, int8_t *mpoly_coords, int64_t mpoly_coords_size, int32_t *mpoly_ring_sizes, int64_t mpoly_num_rings, int32_t *mpoly_poly_sizes, int64_t mpoly_num_polys, double *mpoly_bounds, int64_t mpoly_bounds_size, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double distance_within)
EXTENSION_NOINLINE double ST_Y_LineString(int8_t *l, int64_t lsize, int32_t lindex, int32_t ic, int32_t isr, int32_t osr)
DEVICE double max_distance_point_line(double px, double py, double l1x, double l1y, double l2x, double l2y)
EXTENSION_INLINE int32_t MapD_GeoPolyRenderGroup(int32_t render_group)
EXTENSION_NOINLINE bool Point_Overlaps_Box(double *bounds, int64_t bounds_size, double px, double py)
EXTENSION_INLINE int64_t OmniSci_Geo_PolyBoundsPtr(double *bounds, int64_t size)
EXTENSION_NOINLINE double ST_Distance_Point_LineString(int8_t *p, int64_t psize, int8_t *l, int64_t lsize, int32_t lindex, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double threshold)
EXTENSION_NOINLINE bool ST_Intersects_LineString_Linestring(int8_t *l1, int64_t l1size, double *l1bounds, int64_t l1bounds_size, int32_t l1i, int8_t *l2, int64_t l2size, double *l2bounds, int64_t l2bounds_size, int32_t l2i, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
#define EXTENSION_NOINLINE
EXTENSION_INLINE bool ST_Intersects_Polygon_LineString(int8_t *poly, int64_t polysize, int32_t *poly_ring_sizes, int64_t poly_num_rings, double *poly_bounds, int64_t poly_bounds_size, int8_t *l, int64_t lsize, double *lbounds, int64_t lbounds_size, int32_t li, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
EXTENSION_NOINLINE double ST_Distance_Polygon_MultiPolygon(int8_t *poly1_coords, int64_t poly1_coords_size, int32_t *poly1_ring_sizes, int64_t poly1_num_rings, int8_t *mpoly_coords, int64_t mpoly_coords_size, int32_t *mpoly_ring_sizes, int64_t mpoly_num_rings, int32_t *mpoly_poly_sizes, int64_t mpoly_num_polys, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double threshold)
EXTENSION_NOINLINE double ST_Distance_Polygon_Polygon(int8_t *poly1_coords, int64_t poly1_coords_size, int32_t *poly1_ring_sizes, int64_t poly1_num_rings, int8_t *poly2_coords, int64_t poly2_coords_size, int32_t *poly2_ring_sizes, int64_t poly2_num_rings, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double threshold)
EXTENSION_INLINE double ST_Distance_MultiPolygon_Point(int8_t *mpoly_coords, int64_t mpoly_coords_size, int32_t *mpoly_ring_sizes, int64_t mpoly_num_rings, int32_t *mpoly_poly_sizes, int64_t mpoly_num_polys, int8_t *p, int64_t psize, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double threshold)
EXTENSION_NOINLINE bool ST_Contains_Polygon_Point(const int8_t *poly_coords, const int64_t poly_coords_size, const int32_t *poly_ring_sizes, const int64_t poly_num_rings, const double *poly_bounds, const int64_t poly_bounds_size, const int8_t *p, const int64_t psize, const int32_t ic1, const int32_t isr1, const int32_t ic2, const int32_t isr2, const int32_t osr)
DEVICE ALWAYS_INLINE int16_t orientation(double px, double py, double qx, double qy, double rx, double ry)
DEVICE double distance_line_line_squared(double l11x, double l11y, double l12x, double l12y, double l21x, double l21y, double l22x, double l22y)
EXTENSION_NOINLINE double ST_Centroid_MultiPolygon(int8_t *mpoly_coords, int64_t mpoly_coords_size, int32_t *mpoly_ring_sizes, int64_t mpoly_num_rings, int32_t *mpoly_poly_sizes, int64_t mpoly_num_polys, int32_t ic, int32_t isr, int32_t osr, bool ycoord)
EXTENSION_NOINLINE double ST_YMin(int8_t *coords, int64_t size, int32_t ic, int32_t isr, int32_t osr)
EXTENSION_INLINE bool ST_Intersects_LineString_Point(int8_t *l, int64_t lsize, double *lbounds, int64_t lbounds_size, int32_t li, int8_t *p, int64_t psize, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
DEVICE ALWAYS_INLINE double area_ring(int8_t *ring, int64_t ringsize, int32_t ic, int32_t isr, int32_t osr)
EXTENSION_INLINE bool ST_DWithin_Polygon_MultiPolygon(int8_t *poly_coords, int64_t poly_coords_size, int32_t *poly_ring_sizes, int64_t poly_num_rings, double *poly_bounds, int64_t poly_bounds_size, int8_t *mpoly_coords, int64_t mpoly_coords_size, int32_t *mpoly_ring_sizes, int64_t mpoly_num_rings, int32_t *mpoly_poly_sizes, int64_t mpoly_num_polys, double *mpoly_bounds, int64_t mpoly_bounds_size, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double distance_within)
EXTENSION_NOINLINE bool ST_cContains_MultiPolygon_Point(int8_t *mpoly_coords, int64_t mpoly_coords_size, int32_t *mpoly_ring_sizes, int64_t mpoly_num_rings, int32_t *mpoly_poly_sizes, int64_t mpoly_num_polys, double *mpoly_bounds, int64_t mpoly_bounds_size, int8_t *p, int64_t psize, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
EXTENSION_INLINE double ST_Area_Polygon_Geodesic(int8_t *poly_coords, int64_t poly_coords_size, int32_t *poly_ring_sizes, int64_t poly_num_rings, int32_t ic, int32_t isr, int32_t osr)
EXTENSION_NOINLINE bool ST_Intersects_LineString_Polygon(int8_t *l, int64_t lsize, double *lbounds, int64_t lbounds_size, int32_t li, int8_t *poly, int64_t polysize, int32_t *poly_ring_sizes, int64_t poly_num_rings, double *poly_bounds, int64_t poly_bounds_size, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
DEVICE ALWAYS_INLINE bool box_overlaps_box(double *bounds1, int64_t bounds1_size, double *bounds2, int64_t bounds2_size)
EXTENSION_INLINE int64_t MapD_GeoPolyBoundsPtr(double *bounds, int64_t size)
EXTENSION_INLINE bool ST_Intersects_Point_MultiPolygon(int8_t *p, int64_t psize, int8_t *mpoly_coords, int64_t mpoly_coords_size, int32_t *mpoly_ring_sizes, int64_t mpoly_num_rings, int32_t *mpoly_poly_sizes, int64_t mpoly_num_polys, double *mpoly_bounds, int64_t mpoly_bounds_size, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
EXTENSION_INLINE double ST_Distance_MultiPolygon_Polygon(int8_t *mpoly_coords, int64_t mpoly_coords_size, int32_t *mpoly_ring_sizes, int64_t mpoly_num_rings, int32_t *mpoly_poly_sizes, int64_t mpoly_num_polys, int8_t *poly1_coords, int64_t poly1_coords_size, int32_t *poly1_ring_sizes, int64_t poly1_num_rings, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double threshold)
DEVICE bool linestring_intersects_line(int8_t *l, int32_t lnum_coords, double l1x, double l1y, double l2x, double l2y, int32_t ic1, int32_t isr1, int32_t osr)
EXTENSION_NOINLINE double ST_Centroid_Polygon(int8_t *poly_coords, int64_t poly_coords_size, int32_t *poly_ring_sizes, int64_t poly_num_rings, int32_t ic, int32_t isr, int32_t osr, bool ycoord)
#define TOLERANCE_DEFAULT
EXTENSION_NOINLINE double ST_Distance_LineString_LineString(int8_t *l1, int64_t l1size, int32_t l1index, int8_t *l2, int64_t l2size, int32_t l2index, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double threshold)
EXTENSION_INLINE double ST_Distance_LineString_Point_Geodesic(int8_t *l, int64_t lsize, int32_t lindex, int8_t *p, int64_t psize, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
DEVICE bool line_intersects_line(double l11x, double l11y, double l12x, double l12y, double l21x, double l21y, double l22x, double l22y)
EXTENSION_NOINLINE double ST_Area_MultiPolygon(int8_t *mpoly_coords, int64_t mpoly_coords_size, int32_t *mpoly_ring_sizes, int64_t mpoly_num_rings, int32_t *mpoly_poly_sizes, int64_t mpoly_num_polys, int32_t ic, int32_t isr, int32_t osr)
EXTENSION_NOINLINE bool ST_Intersects_Polygon_MultiPolygon(int8_t *poly_coords, int64_t poly_coords_size, int32_t *poly_ring_sizes, int64_t poly_num_rings, double *poly_bounds, int64_t poly_bounds_size, int8_t *mpoly_coords, int64_t mpoly_coords_size, int32_t *mpoly_ring_sizes, int64_t mpoly_num_rings, int32_t *mpoly_poly_sizes, int64_t mpoly_num_polys, double *mpoly_bounds, int64_t mpoly_bounds_size, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
DEVICE ALWAYS_INLINE bool tol_zero_template(const T x, const T tolerance=TOLERANCE_DEFAULT)
EXTENSION_NOINLINE bool is_point_in_view(int8_t *p, const int64_t psize, const int32_t ic, const double min_lon, const double max_lon, const double min_lat, const double max_lat)
EXTENSION_INLINE bool ST_Contains_LineString_Point(int8_t *l, int64_t lsize, double *lbounds, int64_t lbounds_size, int32_t li, int8_t *p, int64_t psize, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
EXTENSION_NOINLINE bool ST_Contains_LineString_LineString(int8_t *l1, int64_t l1size, double *l1bounds, int64_t l1bounds_size, int32_t l1i, int8_t *l2, int64_t l2size, double *l2bounds, int64_t l2bounds_size, int32_t l2i, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
EXTENSION_INLINE bool ST_DWithin_LineString_Polygon(int8_t *l1, int64_t l1size, double *l1bounds, int64_t l1bounds_size, int32_t l1index, int8_t *poly_coords, int64_t poly_coords_size, int32_t *poly_ring_sizes, int64_t poly_num_rings, double *poly_bounds, int64_t poly_bounds_size, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double distance_within)
DEVICE ALWAYS_INLINE double decompress_coord(const int8_t *data, const int32_t index, const int32_t ic, const bool x)
DEVICE ALWAYS_INLINE bool centroid_add_polygon(int8_t *poly_coords, int64_t poly_coords_size, int32_t *poly_ring_sizes, int64_t poly_num_rings, int32_t ic, int32_t isr, int32_t osr, double *total_area2, double *cg3, double *total_length, double *linestring_centroid_sum, int64_t *num_points, double *point_centroid_sum)
EXTENSION_NOINLINE bool ST_Contains_Point_Polygon(int8_t *p, int64_t psize, int8_t *poly_coords, int64_t poly_coords_size, int32_t *poly_ring_sizes, int64_t poly_num_rings, double *poly_bounds, int64_t poly_bounds_size, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
EXTENSION_NOINLINE double ST_Distance_Point_Point_Geodesic(int8_t *p1, int64_t p1size, int8_t *p2, int64_t p2size, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
EXTENSION_NOINLINE double ST_MaxDistance_Point_LineString(int8_t *p, int64_t psize, int8_t *l, int64_t lsize, int32_t lindex, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
DEVICE ALWAYS_INLINE bool box_contains_point(const double *bounds, const int64_t bounds_size, const double px, const double py)
DEVICE double distance_ring_ring(int8_t *ring1, int32_t ring1_num_coords, int8_t *ring2, int32_t ring2_num_coords, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double threshold)
EXTENSION_NOINLINE double ST_Length_LineString(int8_t *coords, int64_t coords_sz, int32_t ic, int32_t isr, int32_t osr)
DEVICE double decompress_longitude_coord_geoint32(const int32_t compressed)
EXTENSION_NOINLINE double ST_Perimeter_MultiPolygon(int8_t *mpoly_coords, int64_t mpoly_coords_size, int32_t *mpoly_ring_sizes, int64_t mpoly_num_rings, int32_t *mpoly_poly_sizes, int64_t mpoly_num_polys, int32_t ic, int32_t isr, int32_t osr)
EXTENSION_INLINE bool ST_Intersects_Point_Point(int8_t *p1, int64_t p1size, int8_t *p2, int64_t p2size, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
DEVICE ALWAYS_INLINE bool tol_le(const double x, const double y, const double tolerance=TOLERANCE_DEFAULT)
DEVICE ALWAYS_INLINE bool centroid_add_segment(double x1, double y1, double x2, double y2, double *length, double *linestring_centroid_sum)
EXTENSION_INLINE double ST_Area_MultiPolygon_Geodesic(int8_t *mpoly_coords, int64_t mpoly_coords_size, int32_t *mpoly_ring_sizes, int64_t mpoly_num_rings, int32_t *mpoly_poly_sizes, int64_t mpoly_num_polys, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE bool tol_zero(const double x, const double tolerance=TOLERANCE_DEFAULT)
EXTENSION_INLINE int32_t ST_NRings(int32_t *poly_ring_sizes, int64_t poly_num_rings)
DEVICE ALWAYS_INLINE bool centroid_add_linestring(int8_t *l, int64_t lsize, int32_t ic, int32_t isr, int32_t osr, bool closed, double *total_length, double *linestring_centroid_sum, int64_t *num_points, double *point_centroid_sum)
EXTENSION_NOINLINE double ST_Perimeter_Polygon_Geodesic(int8_t *poly, int64_t polysize, int32_t *poly_ring_sizes, int64_t poly_num_rings, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE double distance_point_point_squared(double p1x, double p1y, double p2x, double p2y)
EXTENSION_INLINE double ST_Distance_MultiPolygon_LineString(int8_t *mpoly_coords, int64_t mpoly_coords_size, int32_t *mpoly_ring_sizes, int64_t mpoly_num_rings, int32_t *mpoly_poly_sizes, int64_t mpoly_num_polys, int8_t *l, int64_t lsize, int32_t lindex, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double threshold)
DEVICE bool linestring_intersects_linestring(int8_t *l, int32_t lnum_coords, double l1x, double l1y, double l2x, double l2y, int32_t ic1, int32_t isr1, int32_t osr)
EXTENSION_INLINE bool ST_Intersects_MultiPolygon_MultiPolygon(int8_t *mpoly1_coords, int64_t mpoly1_coords_size, int32_t *mpoly1_ring_sizes, int64_t mpoly1_num_rings, int32_t *mpoly1_poly_sizes, int64_t mpoly1_num_polys, double *mpoly1_bounds, int64_t mpoly1_bounds_size, int8_t *mpoly2_coords, int64_t mpoly2_coords_size, int32_t *mpoly2_ring_sizes, int64_t mpoly2_num_rings, int32_t *mpoly2_poly_sizes, int64_t mpoly2_num_polys, double *mpoly2_bounds, int64_t mpoly2_bounds_size, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
EXTENSION_NOINLINE double distance_in_meters(const double fromlon, const double fromlat, const double tolon, const double tolat)
Computes the distance, in meters, between two WGS-84 positions.
EXTENSION_NOINLINE double ST_Length_LineString_Geodesic(int8_t *coords, int64_t coords_sz, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE bool tol_ge(const double x, const double y, const double tolerance=TOLERANCE_DEFAULT)
EXTENSION_NOINLINE double ST_Distance_Point_LineString_Geodesic(int8_t *p, int64_t psize, int8_t *l, int64_t lsize, int32_t lindex, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
DEVICE ALWAYS_INLINE double distance_point_linestring(int8_t *p, int64_t psize, int8_t *l, int64_t lsize, int32_t lindex, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, bool check_closed, double threshold)
DEVICE ALWAYS_INLINE bool polygon_contains_point(const int8_t *poly, const int32_t poly_num_coords, const double px, const double py, const int32_t ic1, const int32_t isr1, const int32_t osr)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(const int32_t ic)
DEVICE ALWAYS_INLINE double transform_coord_y(const double coord, const int32_t isr, const int32_t osr)
#define TOLERANCE_DEFAULT_SQUARED
EXTENSION_NOINLINE double ST_Distance_MultiPolygon_MultiPolygon(int8_t *mpoly1_coords, int64_t mpoly1_coords_size, int32_t *mpoly1_ring_sizes, int64_t mpoly1_num_rings, int32_t *mpoly1_poly_sizes, int64_t mpoly1_num_polys, int8_t *mpoly2_coords, int64_t mpoly2_coords_size, int32_t *mpoly2_ring_sizes, int64_t mpoly2_num_rings, int32_t *mpoly2_poly_sizes, int64_t mpoly2_num_polys, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double threshold)
EXTENSION_NOINLINE bool ST_Contains_Polygon_Polygon(int8_t *poly1_coords, int64_t poly1_coords_size, int32_t *poly1_ring_sizes, int64_t poly1_num_rings, double *poly1_bounds, int64_t poly1_bounds_size, int8_t *poly2_coords, int64_t poly2_coords_size, int32_t *poly2_ring_sizes, int64_t poly2_num_rings, double *poly2_bounds, int64_t poly2_bounds_size, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
EXTENSION_INLINE bool ST_DWithin_LineString_LineString(int8_t *l1, int64_t l1size, double *l1bounds, int64_t l1bounds_size, int32_t l1index, int8_t *l2, int64_t l2size, double *l2bounds, int64_t l2bounds_size, int32_t l2index, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double distance_within)
DEVICE ALWAYS_INLINE bool point_in_polygon_winding_number(const int8_t *poly, const int32_t poly_num_coords, const T px, const T py, const int32_t ic1, const int32_t isr1, const int32_t osr)
EXTENSION_INLINE bool ST_DWithin_Point_LineString(int8_t *p1, int64_t p1size, int8_t *l2, int64_t l2size, double *l2bounds, int64_t l2bounds_size, int32_t l2index, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double distance_within)
EXTENSION_INLINE double ST_Distance_Polygon_Point(int8_t *poly_coords, int64_t poly_coords_size, int32_t *poly_ring_sizes, int64_t poly_num_rings, int8_t *p, int64_t psize, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double threshold)
DEVICE double distance_point_line_squared(double px, double py, double l1x, double l1y, double l2x, double l2y)
#define COMPRESSION_GEOINT32
EXTENSION_NOINLINE double ST_MaxDistance_LineString_Point(int8_t *l, int64_t lsize, int32_t lindex, int8_t *p, int64_t psize, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
DEVICE ALWAYS_INLINE double coord_y(const int8_t *data, const int32_t index, const int32_t ic, const int32_t isr, const int32_t osr)
DEVICE ALWAYS_INLINE double tol(int32_t ic)
DEVICE double distance_line_line(double l11x, double l11y, double l12x, double l12y, double l21x, double l21y, double l22x, double l22y)
DEVICE bool polygon_contains_linestring(int8_t *poly, int32_t poly_num_coords, int8_t *l, int64_t lnum_coords, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
EXTENSION_NOINLINE double ST_Centroid_Point(int8_t *p, int64_t psize, int32_t ic, int32_t isr, int32_t osr, bool ycoord)
DEVICE ALWAYS_INLINE bool Contains_Polygon_Point_Impl(const int8_t *poly_coords, const int64_t poly_coords_size, const int32_t *poly_ring_sizes, const int64_t poly_num_rings, const double *poly_bounds, const int64_t poly_bounds_size, const int8_t *p, const int64_t psize, const int32_t ic1, const int32_t isr1, const int32_t ic2, const int32_t isr2, const int32_t osr)
EXTENSION_NOINLINE double ST_Distance_LineString_Polygon(int8_t *l, int64_t lsize, int32_t lindex, int8_t *poly_coords, int64_t poly_coords_size, int32_t *poly_ring_sizes, int64_t poly_num_rings, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double threshold)
EXTENSION_NOINLINE bool ST_Contains_MultiPolygon_Point(int8_t *mpoly_coords, int64_t mpoly_coords_size, int32_t *mpoly_ring_sizes, int64_t mpoly_num_rings, int32_t *mpoly_poly_sizes, int64_t mpoly_num_polys, double *mpoly_bounds, int64_t mpoly_bounds_size, int8_t *p, int64_t psize, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
EXTENSION_INLINE bool ST_Intersects_MultiPolygon_Point(int8_t *mpoly_coords, int64_t mpoly_coords_size, int32_t *mpoly_ring_sizes, int64_t mpoly_num_rings, int32_t *mpoly_poly_sizes, int64_t mpoly_num_polys, double *mpoly_bounds, int64_t mpoly_bounds_size, int8_t *p, int64_t psize, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
DEVICE bool ring_intersects_line(int8_t *ring, int32_t ring_num_coords, double l1x, double l1y, double l2x, double l2y, int32_t ic1, int32_t isr1, int32_t osr)
DEVICE double distance_ring_linestring(int8_t *ring, int32_t ring_num_coords, int8_t *l, int32_t lnum_coords, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double threshold)
EXTENSION_INLINE bool ST_Intersects_MultiPolygon_LineString(int8_t *mpoly_coords, int64_t mpoly_coords_size, int32_t *mpoly_ring_sizes, int64_t mpoly_num_rings, int32_t *mpoly_poly_sizes, int64_t mpoly_num_polys, double *mpoly_bounds, int64_t mpoly_bounds_size, int8_t *l, int64_t lsize, double *lbounds, int64_t lbounds_size, int32_t li, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
EXTENSION_INLINE int32_t ST_NPoints(int8_t *coords, int64_t coords_sz, int32_t ic)
EXTENSION_NOINLINE double conv_4326_900913_y(const double y)
EXTENSION_NOINLINE double conv_4326_900913_x(const double x)
DEVICE ALWAYS_INLINE bool tol_eq(const double x, const double y, const double tolerance=TOLERANCE_DEFAULT)
DEVICE ALWAYS_INLINE bool box_contains_box_vertex(double *bounds1, int64_t bounds1_size, double *bounds2, int64_t bounds2_size)
DEVICE ALWAYS_INLINE bool box_contains_box(double *bounds1, int64_t bounds1_size, double *bounds2, int64_t bounds2_size)
DEVICE ALWAYS_INLINE bool point_dwithin_box(int8_t *p1, int64_t p1size, int32_t ic1, int32_t isr1, double *bounds2, int64_t bounds2_size, int32_t isr2, int32_t osr, double distance)
EXTENSION_NOINLINE double ST_Distance_Point_ClosedLineString(int8_t *p, int64_t psize, int8_t *l, int64_t lsize, int32_t lindex, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double threshold)
DEVICE ALWAYS_INLINE double coord_x(const int8_t *data, const int32_t index, const int32_t ic, const int32_t isr, const int32_t osr)
EXTENSION_INLINE double ST_YMax_Bounds(double *bounds, int64_t size, int32_t isr, int32_t osr)
EXTENSION_INLINE double ST_XMax_Bounds(double *bounds, int64_t size, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE double transform_coord_x(const double coord, const int32_t isr, const int32_t osr)
EXTENSION_INLINE bool ST_DWithin_Point_MultiPolygon(int8_t *p, int64_t psize, int8_t *mpoly_coords, int64_t mpoly_coords_size, int32_t *mpoly_ring_sizes, int64_t mpoly_num_rings, int32_t *mpoly_poly_sizes, int64_t mpoly_num_polys, double *mpoly_bounds, int64_t mpoly_bounds_size, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double distance_within)
EXTENSION_NOINLINE bool ST_Contains_Point_LineString(int8_t *p, int64_t psize, int8_t *l, int64_t lsize, double *lbounds, int64_t lbounds_size, int32_t li, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
EXTENSION_NOINLINE bool ST_Intersects_Point_LineString(int8_t *p, int64_t psize, int8_t *l, int64_t lsize, double *lbounds, int64_t lbounds_size, int32_t li, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
DEVICE ALWAYS_INLINE double distance_point_point(double p1x, double p1y, double p2x, double p2y)
DEVICE ALWAYS_INLINE bool centroid_add_ring(int8_t *ring, int64_t ringsize, int32_t ic, int32_t isr, int32_t osr, double sign, double *total_area2, double *cg3, double *total_length, double *linestring_centroid_sum, int64_t *num_points, double *point_centroid_sum)