OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ExtensionFunctionsGeo.hpp File Reference
#include "Geospatial/Compression.h"
#include "Geospatial/CompressionRuntime.h"
#include "Geospatial/Types.h"
#include "Geospatial/Utm.h"
#include <iomanip>
#include <string>
#include "Shared/likely.h"
+ Include dependency graph for ExtensionFunctionsGeo.hpp:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  anonymous_namespace{ExtensionFunctionsGeo.hpp}::CoordData
 
struct  anonymous_namespace{ExtensionFunctionsGeo.hpp}::Point2D
 

Namespaces

 anonymous_namespace{ExtensionFunctionsGeo.hpp}
 

Macros

#define DEBUG_STMT(x)
 

Enumerations

enum  anonymous_namespace{ExtensionFunctionsGeo.hpp}::Coords { anonymous_namespace{ExtensionFunctionsGeo.hpp}::None = 0, anonymous_namespace{ExtensionFunctionsGeo.hpp}::Y, anonymous_namespace{ExtensionFunctionsGeo.hpp}::X, anonymous_namespace{ExtensionFunctionsGeo.hpp}::XY }
 
enum  EdgeBehavior { EdgeBehavior::kIncludePointOnEdge, EdgeBehavior::kExcludePointOnEdge }
 

Functions

DEVICE ALWAYS_INLINE double tol (int32_t ic)
 
DEVICE ALWAYS_INLINE double tol (const int32_t ic1, const int32_t ic2)
 
DEVICE ALWAYS_INLINE bool tol_zero (const double x, const double tolerance=TOLERANCE_DEFAULT)
 
DEVICE ALWAYS_INLINE bool tol_eq (const double x, const double y, const double tolerance=TOLERANCE_DEFAULT)
 
DEVICE ALWAYS_INLINE bool tol_le (const double x, const double y, const double tolerance=TOLERANCE_DEFAULT)
 
DEVICE ALWAYS_INLINE bool tol_ge (const double x, const double y, const double tolerance=TOLERANCE_DEFAULT)
 
template<Coords C>
DEVICE ALWAYS_INLINE double decompress_coord (const int8_t *data, const int32_t x_index, const int32_t ic)
 
DEVICE ALWAYS_INLINE int32_t compression_unit_size (const int32_t ic)
 
template<Coords C>
DEVICE ALWAYS_INLINE Point2D conv_4326_900913 (const Point2D point)
 
template<Coords C>
DEVICE ALWAYS_INLINE Point2D conv_4326_utm (const Point2D point, const int32_t utm_srid)
 
template<Coords C>
DEVICE ALWAYS_INLINE Point2D conv_utm_4326 (const Point2D point, const int32_t utm_srid)
 
template<Coords C>
DEVICE ALWAYS_INLINE Point2D transform_point (const Point2D point, const int32_t isr, const int32_t osr)
 
DEVICE ALWAYS_INLINE bool x_and_y_are_dependent (const int32_t isr, const int32_t osr)
 
DEVICE ALWAYS_INLINE Point2D get_point (const int8_t *data, const int32_t x_index, const int32_t ic, const int32_t isr, const int32_t osr)
 
template<Coords C>
DEVICE ALWAYS_INLINE Point2D coord (const int8_t *data, const int32_t x_index, const int32_t ic, const int32_t isr, const int32_t osr)
 
DEVICE ALWAYS_INLINE int32_t compressed_coord (const int8_t *data, const int32_t index)
 
DEVICE ALWAYS_INLINE double distance_point_point_squared (double p1x, double p1y, double p2x, double p2y)
 
DEVICE ALWAYS_INLINE double distance_point_point (double p1x, double p1y, double p2x, double p2y)
 
DEVICE double distance_point_line (double px, double py, double l1x, double l1y, double l2x, double l2y)
 
DEVICE double distance_point_line_squared (double px, double py, double l1x, double l1y, double l2x, double l2y)
 
DEVICE ALWAYS_INLINE bool on_segment (double px, double py, double qx, double qy, double rx, double ry)
 
DEVICE ALWAYS_INLINE int16_t orientation (double px, double py, double qx, double qy, double rx, double ry)
 
DEVICE bool line_intersects_line (double l11x, double l11y, double l12x, double l12y, double l21x, double l21y, double l22x, double l22y)
 
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)
 
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 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)
 
DEVICE double distance_line_line (double l11x, double l11y, double l12x, double l12y, double l21x, double l21y, double l22x, double l22y)
 
DEVICE double distance_line_line_squared (double l11x, double l11y, double l12x, double l12y, double l21x, double l21y, double l22x, double l22y)
 
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)
 
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)
 
template<typename T >
DEVICE ALWAYS_INLINEis_left (const T lx0, const T ly0, const T lx1, const T ly1, const T px, const T py)
 
template<typename T >
DEVICE ALWAYS_INLINE bool tol_zero_template (const T x, const T tolerance=TOLERANCE_DEFAULT)
 
template<typename T , EdgeBehavior TEdgeBehavior>
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)
 
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 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)
 
DEVICE ALWAYS_INLINE bool box_contains_point (const double *bounds, const int64_t bounds_size, const double px, const double py)
 
EXTENSION_NOINLINE bool Point_Overlaps_Box (double *bounds, int64_t bounds_size, double px, double py)
 
DEVICE ALWAYS_INLINE bool box_contains_box (double *bounds1, int64_t bounds1_size, double *bounds2, int64_t bounds2_size)
 
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_overlaps_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)
 
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)
 
DEVICE ALWAYS_INLINE CoordData trim_linestring_to_buffered_box (int8_t *l1, int64_t l1size, int32_t ic1, int32_t isr1, double *bounds2, int64_t bounds2_size, int32_t isr2, int32_t osr, double distance)
 
EXTENSION_NOINLINE double ST_X_Point (int8_t *p, int64_t psize, int32_t ic, int32_t isr, int32_t osr)
 
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_XMin (int8_t *coords, int64_t size, int32_t ic, int32_t isr, int32_t osr)
 
EXTENSION_NOINLINE double ST_YMin (int8_t *coords, int64_t size, int32_t ic, int32_t isr, int32_t osr)
 
EXTENSION_NOINLINE double ST_XMax (int8_t *coords, int64_t size, int32_t ic, 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)
 
EXTENSION_INLINE double ST_XMin_Bounds (double *bounds, int64_t size, int32_t isr, int32_t osr)
 
EXTENSION_INLINE double ST_YMin_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)
 
EXTENSION_INLINE double ST_YMax_Bounds (double *bounds, int64_t size, int32_t isr, int32_t osr)
 
DEVICE ALWAYS_INLINE double length_linestring (int8_t *l, int32_t lsize, int32_t ic, int32_t isr, int32_t osr, bool geodesic, bool check_closed)
 
EXTENSION_NOINLINE double ST_Length_LineString (int8_t *coords, int64_t coords_sz, int32_t ic, int32_t isr, int32_t osr)
 
EXTENSION_NOINLINE double ST_Length_LineString_Geodesic (int8_t *coords, int64_t coords_sz, int32_t ic, int32_t isr, int32_t osr)
 
EXTENSION_NOINLINE double ST_Length_MultiLineString (int8_t *coords, int64_t coords_sz, int8_t *linestring_sizes_in, int64_t linestring_sizes_sz, int32_t ic, int32_t isr, int32_t osr)
 
EXTENSION_NOINLINE double ST_Perimeter_Polygon (int8_t *poly, int32_t polysize, int8_t *poly_ring_sizes, int32_t poly_num_rings, int32_t ic, int32_t isr, int32_t osr)
 
EXTENSION_NOINLINE double ST_Perimeter_Polygon_Geodesic (int8_t *poly, int32_t polysize, int8_t *poly_ring_sizes_in, int32_t poly_num_rings, int32_t ic, int32_t isr, int32_t osr)
 
DEVICE ALWAYS_INLINE double perimeter_multipolygon (int8_t *mpoly_coords, int32_t mpoly_coords_size, int8_t *mpoly_ring_sizes_in, int32_t mpoly_num_rings, int8_t *mpoly_poly_sizes, int32_t mpoly_num_polys, int32_t ic, int32_t isr, int32_t osr, bool geodesic)
 
EXTENSION_NOINLINE double ST_Perimeter_MultiPolygon (int8_t *mpoly_coords, int32_t mpoly_coords_size, int8_t *mpoly_ring_sizes, int32_t mpoly_num_rings, int8_t *mpoly_poly_sizes, int32_t mpoly_num_polys, int32_t ic, int32_t isr, int32_t osr)
 
EXTENSION_NOINLINE double ST_Perimeter_MultiPolygon_Geodesic (int8_t *mpoly_coords, int32_t mpoly_coords_size, int8_t *mpoly_ring_sizes, int32_t mpoly_num_rings, int8_t *mpoly_poly_sizes, int32_t mpoly_num_polys, int32_t ic, int32_t isr, int32_t osr)
 
DEVICE ALWAYS_INLINE double area_triangle (double x1, double y1, double x2, double y2, double x3, double y3)
 
DEVICE ALWAYS_INLINE double area_ring (int8_t *ring, int64_t ringsize, int32_t ic, int32_t isr, int32_t osr)
 
DEVICE ALWAYS_INLINE double area_polygon (int8_t *poly_coords, int32_t poly_coords_size, int8_t *poly_ring_sizes_in, int32_t poly_num_rings, int32_t ic, int32_t isr, int32_t osr)
 
EXTENSION_NOINLINE double ST_Area_Polygon (int8_t *poly_coords, int32_t poly_coords_size, int8_t *poly_ring_sizes, int32_t poly_num_rings, int32_t ic, int32_t isr, int32_t osr)
 
EXTENSION_NOINLINE double ST_Area_MultiPolygon (int8_t *mpoly_coords, int32_t mpoly_coords_size, int8_t *mpoly_ring_sizes, int32_t mpoly_num_rings, int8_t *mpoly_poly_sizes_in, int32_t mpoly_num_polys, int32_t ic, int32_t isr, int32_t osr)
 
EXTENSION_NOINLINE void ST_Centroid_Point (int8_t *p, int32_t psize, int32_t ic, int32_t isr, int32_t osr, double *point_centroid)
 
EXTENSION_NOINLINE void ST_Centroid_MultiPoint (int8_t *mp, int32_t mpsize, int32_t ic, int32_t isr, int32_t osr, double *multipoint_centroid)
 
DEVICE ALWAYS_INLINE bool centroid_add_segment (double x1, double y1, double x2, double y2, double *length, double *linestring_centroid_sum)
 
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 void ST_Centroid_LineString (int8_t *coords, int32_t coords_sz, int32_t ic, int32_t isr, int32_t osr, double *linestring_centroid)
 
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)
 
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)
 
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 void ST_Centroid_Polygon (int8_t *poly_coords, int32_t poly_coords_size, int32_t *poly_ring_sizes, int32_t poly_num_rings, int32_t ic, int32_t isr, int32_t osr, double *poly_centroid)
 
EXTENSION_NOINLINE void ST_Centroid_MultiPolygon (int8_t *mpoly_coords, int32_t mpoly_coords_size, int32_t *mpoly_ring_sizes, int32_t mpoly_num_rings, int32_t *mpoly_poly_sizes, int32_t mpoly_num_polys, int32_t ic, int32_t isr, int32_t osr, double *mpoly_centroid)
 
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_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_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_Distance_Point_LineString_Geodesic (int8_t *p, int64_t psize, int8_t *l, int64_t lsize, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
 
EXTENSION_INLINE double ST_Distance_LineString_Point_Geodesic (int8_t *l, int64_t lsize, 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_MultiPoint (int8_t *p, int64_t psize, int8_t *mp, int64_t mpsize, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double threshold)
 
EXTENSION_NOINLINE double ST_Distance_Point_MultiPoint_Squared (int8_t *p, int64_t psize, int8_t *mp, int64_t mpsize, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double threshold)
 
DEVICE ALWAYS_INLINE double distance_point_linestring (int8_t *p, int64_t psize, int8_t *l, int64_t lsize, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, bool check_closed, double threshold)
 
EXTENSION_NOINLINE double ST_Distance_Point_ClosedLineString (int8_t *p, int64_t psize, int8_t *l, int64_t lsize, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double threshold)
 
EXTENSION_NOINLINE double ST_Distance_Point_LineString (int8_t *p, int64_t psize, int8_t *l, int64_t lsize, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double threshold)
 
DEVICE ALWAYS_INLINE double distance_point_multilinestring (int8_t *p, int64_t psize, int8_t *mls, int64_t mls_size, int32_t *mls_ls_sizes, int64_t mls_ls_num, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double threshold)
 
EXTENSION_NOINLINE double ST_Distance_Point_MultiLineString (int8_t *p, int64_t psize, int8_t *mls, int64_t mls_size, int32_t *mls_ls_sizes, int64_t mls_ls_num, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double threshold)
 
DEVICE ALWAYS_INLINE double 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)
 
DEVICE ALWAYS_INLINE double 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 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_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_INLINE double ST_Distance_MultiPoint_Polygon (int8_t *mp, int64_t mpsize, 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_INLINE double ST_Distance_MultiPoint_MultiPolygon (int8_t *mp, int64_t mpsize, 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_INLINE double ST_Distance_Polygon_MultiPoint (int8_t *poly, int64_t polysize, int32_t *poly_ring_sizes, int64_t poly_num_rings, int8_t *mp, int64_t mpsize, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double threshold)
 
EXTENSION_INLINE double ST_Distance_MultiPolygon_MultiPoint (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 *mp, int64_t mpsize, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double threshold)
 
EXTENSION_INLINE double ST_Distance_MultiPoint_Point (int8_t *mp, int64_t mpsize, int8_t *p, int64_t psize, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double threshold)
 
EXTENSION_INLINE double ST_Distance_MultiPoint_Point_Squared (int8_t *mp, int64_t mpsize, 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 double ST_Distance_MultiPoint_MultiPoint (int8_t *mp1, int64_t mp1size, int8_t *mp2, int64_t mp2size, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double threshold)
 
EXTENSION_NOINLINE double ST_Distance_MultiPoint_MultiPoint_Squared (int8_t *mp1, int64_t mp1size, int8_t *mp2, int64_t mp2size, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double threshold)
 
EXTENSION_INLINE double ST_Distance_MultiPoint_LineString (int8_t *mp, int64_t mpsize, int8_t *l, int64_t lsize, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double threshold)
 
EXTENSION_INLINE double ST_Distance_MultiPoint_MultiLineString (int8_t *mp, int64_t mpsize, int8_t *mls, int64_t mls_size, int32_t *mls_ls_sizes, int64_t mls_ls_num, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double threshold)
 
EXTENSION_INLINE double ST_Distance_LineString_Point (int8_t *l, int64_t lsize, int8_t *p, int64_t psize, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double threshold)
 
EXTENSION_INLINE double ST_Distance_LineString_MultiPoint (int8_t *l, int64_t lsize, int8_t *mp, int64_t mpsize, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double threshold)
 
EXTENSION_INLINE double ST_Distance_MultiLineString_MultiPoint (int8_t *mls, int64_t mls_size, int32_t *mls_ls_sizes, int64_t mls_ls_num, int8_t *mp, int64_t mpsize, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double threshold)
 
EXTENSION_NOINLINE double ST_Distance_LineString_LineString (int8_t *l1, int64_t l1size, int8_t *l2, int64_t l2size, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double threshold)
 
EXTENSION_NOINLINE double ST_Distance_LineString_Polygon (int8_t *l, int64_t lsize, 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 double ST_Distance_LineString_MultiPolygon (int8_t *l, int64_t lsize, 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_INLINE double ST_Distance_MultiLineString_Point (int8_t *mls, int64_t mls_size, int32_t *mls_ls_sizes, int64_t mls_ls_num, int8_t *p, int64_t psize, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double threshold)
 
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)
 
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 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_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_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_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 ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double threshold)
 
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)
 
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 double ST_Distance_MultiLineString_MultiLineString (int8_t *mls1, int64_t mls1size, int32_t *mls1_ls_sizes, int64_t mls1_ls_num, int8_t *mls2, int64_t mls2size, int32_t *mls2_ls_sizes, int64_t mls2_ls_num, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double threshold)
 
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_INLINE bool ST_DWithin_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, double distance_within)
 
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 ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double distance_within)
 
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_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_INLINE bool ST_DWithin_LineString_LineString (int8_t *l1, int64_t l1size, double *l1bounds, int64_t l1bounds_size, int8_t *l2, int64_t l2size, double *l2bounds, int64_t l2bounds_size, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double distance_within)
 
EXTENSION_INLINE bool ST_DWithin_LineString_Polygon (int8_t *l1, int64_t l1size, double *l1bounds, int64_t l1bounds_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, double distance_within)
 
EXTENSION_INLINE bool ST_DWithin_LineString_MultiPolygon (int8_t *l1, int64_t l1size, double *l1bounds, int64_t l1bounds_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_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_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_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 double max_distance_point_line (double px, double py, double l1x, double l1y, double l2x, double l2y)
 
DEVICE ALWAYS_INLINE double max_distance_point_linestring (int8_t *p, int64_t psize, int8_t *l, int64_t lsize, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, bool check_closed)
 
EXTENSION_NOINLINE double ST_MaxDistance_Point_LineString (int8_t *p, int64_t psize, int8_t *l, int64_t lsize, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
 
EXTENSION_NOINLINE double ST_MaxDistance_LineString_Point (int8_t *l, int64_t lsize, 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_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 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 ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
 
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_INLINE bool ST_Contains_LineString_Point (int8_t *l, int64_t lsize, double *lbounds, int64_t lbounds_size, 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_Polygon (int8_t *l, int64_t lsize, double *lbounds, int64_t lbounds_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)
 
template<typename T , EdgeBehavior TEdgeBehavior>
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 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)
 
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)
 
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 ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
 
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)
 
template<typename T , EdgeBehavior TEdgeBehavior>
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)
 
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_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_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 ic1, int32_t isr1, int32_t ic2, int32_t isr2, 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)
 
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 ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
 
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)
 
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 bool ST_Intersects_LineString_Point (int8_t *l, int64_t lsize, double *lbounds, int64_t lbounds_size, 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_Intersects_LineString_Linestring (int8_t *l1, int64_t l1size, double *l1bounds, int64_t l1bounds_size, int8_t *l2, int64_t l2size, double *l2bounds, int64_t l2bounds_size, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
 
EXTENSION_NOINLINE bool ST_Intersects_LineString_Polygon (int8_t *l, int64_t lsize, double *lbounds, int64_t lbounds_size, 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)
 
EXTENSION_NOINLINE bool ST_Intersects_LineString_MultiPolygon (int8_t *l, int64_t lsize, double *lbounds, int64_t lbounds_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)
 
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_INLINE bool ST_cIntersects_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_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 ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
 
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 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)
 
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)
 
EXTENSION_INLINE bool ST_cIntersects_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_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 ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
 
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)
 
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_INLINE int64_t HeavyDB_Geo_PolyBoundsPtr (double *bounds, int64_t size)
 
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_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)
 
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_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)
 
Geospatial::GeoPoint to_Geospatial_GeoPoint (GeoPoint &p)
 
Geospatial::GeoMultiPoint to_Geospatial_GeoMultiPoint (GeoMultiPoint &mp)
 
Geospatial::GeoLineString to_Geospatial_GeoLineString (GeoLineString &l)
 
Geospatial::GeoMultiLineString to_Geospatial_GeoMultiLineString (GeoMultiLineString &ml)
 
Geospatial::GeoPolygon to_Geospatial_GeoPolygon (GeoPolygon &p)
 
Geospatial::GeoMultiPolygon to_Geospatial_GeoMultiPolygon (GeoMultiPolygon &mp)
 
EXTENSION_NOINLINE TextEncodingNone ST_AsText__GeoPoint__cpu_ (RowFunctionManager &mgr, GeoPoint &p)
 
EXTENSION_NOINLINE TextEncodingNone ST_AsText__GeoMultiPoint__cpu_ (RowFunctionManager &mgr, GeoMultiPoint &mp)
 
EXTENSION_NOINLINE TextEncodingNone ST_AsText__GeoLineString__cpu_ (RowFunctionManager &mgr, GeoLineString &l)
 
EXTENSION_NOINLINE TextEncodingNone ST_AsText__GeoMultiLineString__cpu_ (RowFunctionManager &mgr, GeoMultiLineString &ml)
 
EXTENSION_NOINLINE TextEncodingNone ST_AsText__GeoPolygon__cpu_ (RowFunctionManager &mgr, GeoPolygon &p)
 
EXTENSION_NOINLINE TextEncodingNone ST_AsText__GeoMultiPolygon__cpu_ (RowFunctionManager &mgr, GeoMultiPolygon &mp)
 
EXTENSION_NOINLINE TextEncodingNone ST_AsWkt__GeoPoint__cpu_ (RowFunctionManager &mgr, GeoPoint &p)
 
EXTENSION_NOINLINE TextEncodingNone ST_AsWkt__GeoMultiPoint__cpu_ (RowFunctionManager &mgr, GeoMultiPoint &p)
 
EXTENSION_NOINLINE TextEncodingNone ST_AsWkt__GeoLineString__cpu_ (RowFunctionManager &mgr, GeoLineString &p)
 
EXTENSION_NOINLINE TextEncodingNone ST_AsWkt__GeoMultiLineString__cpu_ (RowFunctionManager &mgr, GeoMultiLineString &p)
 
EXTENSION_NOINLINE TextEncodingNone ST_AsWkt__GeoPolygon__cpu_ (RowFunctionManager &mgr, GeoPolygon &p)
 
EXTENSION_NOINLINE TextEncodingNone ST_AsWkt__GeoMultiPolygon__cpu_ (RowFunctionManager &mgr, GeoMultiPolygon &p)
 
template<typename T >
ALWAYS_INLINE std::string __wkb_to_str (T &geometry)
 
EXTENSION_NOINLINE TextEncodingNone ST_AsBinary__GeoPoint__cpu_ (RowFunctionManager &mgr, GeoPoint &p)
 
EXTENSION_NOINLINE TextEncodingNone ST_AsBinary__GeoMultiPoint__cpu_ (RowFunctionManager &mgr, GeoMultiPoint &mp)
 
EXTENSION_NOINLINE TextEncodingNone ST_AsBinary__GeoLineString__cpu_ (RowFunctionManager &mgr, GeoLineString &l)
 
EXTENSION_NOINLINE TextEncodingNone ST_AsBinary__GeoMultiLineString__cpu_ (RowFunctionManager &mgr, GeoMultiLineString &ml)
 
EXTENSION_NOINLINE TextEncodingNone ST_AsBinary__GeoPolygon__cpu_ (RowFunctionManager &mgr, GeoPolygon &p)
 
EXTENSION_NOINLINE TextEncodingNone ST_AsBinary__GeoMultiPolygon__cpu_ (RowFunctionManager &mgr, GeoMultiPolygon &mp)
 
EXTENSION_NOINLINE TextEncodingNone ST_AsWkb__GeoPoint__cpu_ (RowFunctionManager &mgr, GeoPoint &p)
 
EXTENSION_NOINLINE TextEncodingNone ST_AsWkb__GeoMultiPoint__cpu_ (RowFunctionManager &mgr, GeoMultiPoint &p)
 
EXTENSION_NOINLINE TextEncodingNone ST_AsWkb__GeoLineString__cpu_ (RowFunctionManager &mgr, GeoLineString &p)
 
EXTENSION_NOINLINE TextEncodingNone ST_AsWkb__GeoMultiLineString__cpu_ (RowFunctionManager &mgr, GeoMultiLineString &p)
 
EXTENSION_NOINLINE TextEncodingNone ST_AsWkb__GeoPolygon__cpu_ (RowFunctionManager &mgr, GeoPolygon &p)
 
EXTENSION_NOINLINE TextEncodingNone ST_AsWkb__GeoMultiPolygon__cpu_ (RowFunctionManager &mgr, GeoMultiPolygon &p)
 

Macro Definition Documentation

#define DEBUG_STMT (   x)

Enumeration Type Documentation

enum EdgeBehavior
strong
Enumerator
kIncludePointOnEdge 
kExcludePointOnEdge 

Definition at line 571 of file ExtensionFunctionsGeo.hpp.

Function Documentation

template<typename T >
ALWAYS_INLINE std::string __wkb_to_str ( T &  geometry)

Definition at line 5296 of file ExtensionFunctionsGeo.hpp.

Referenced by ST_AsBinary__GeoLineString__cpu_(), ST_AsBinary__GeoMultiLineString__cpu_(), ST_AsBinary__GeoMultiPoint__cpu_(), ST_AsBinary__GeoMultiPolygon__cpu_(), ST_AsBinary__GeoPoint__cpu_(), and ST_AsBinary__GeoPolygon__cpu_().

5296  {
5297  std::vector<uint8_t> bytes;
5298 
5299  bool ok = geometry.getWkb(bytes);
5300  if (!ok) {
5301  return std::string();
5302  }
5303 
5304  std::ostringstream ss;
5305  for (auto b : bytes) {
5306  ss << std::setfill('0') << std::setw(2) << std::hex << static_cast<int>(b);
5307  }
5308  return ss.str();
5309 }

+ Here is the caller graph for this function:

DEVICE ALWAYS_INLINE double area_polygon ( int8_t *  poly_coords,
int32_t  poly_coords_size,
int8_t *  poly_ring_sizes_in,
int32_t  poly_num_rings,
int32_t  ic,
int32_t  isr,
int32_t  osr 
)

Definition at line 1381 of file ExtensionFunctionsGeo.hpp.

References area_ring(), and compression_unit_size().

Referenced by ST_Area_MultiPolygon(), and ST_Area_Polygon().

1387  {
1388  if (poly_num_rings <= 0) {
1389  return 0.0;
1390  }
1391 
1392  double area = 0.0;
1393  auto ring_coords = poly_coords;
1394  auto poly_ring_sizes = reinterpret_cast<int32_t*>(poly_ring_sizes_in);
1395 
1396  // Add up the areas of all rings.
1397  // External ring is CCW, open - positive area.
1398  // Internal rings (holes) are CW, open - negative areas.
1399  for (auto r = 0; r < poly_num_rings; r++) {
1400  auto ring_coords_size = poly_ring_sizes[r] * 2 * compression_unit_size(ic);
1401  area += area_ring(ring_coords, ring_coords_size, ic, isr, osr);
1402  // Advance to the next ring.
1403  ring_coords += ring_coords_size;
1404  }
1405  return area;
1406 }
DEVICE ALWAYS_INLINE double area_ring(int8_t *ring, int64_t ringsize, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(const int32_t ic)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

DEVICE ALWAYS_INLINE double area_ring ( int8_t *  ring,
int64_t  ringsize,
int32_t  ic,
int32_t  isr,
int32_t  osr 
)

Definition at line 1358 of file ExtensionFunctionsGeo.hpp.

References area_triangle(), compression_unit_size(), and get_point().

Referenced by area_polygon().

1362  {
1363  auto ring_num_coords = ringsize / compression_unit_size(ic);
1364 
1365  if (ring_num_coords < 6) {
1366  return 0.0;
1367  }
1368 
1369  double area = 0.0;
1370 
1371  Point2D p1 = get_point(ring, 0, ic, isr, osr);
1372  Point2D p2 = get_point(ring, 2, ic, isr, osr);
1373  for (int32_t i = 4; i < ring_num_coords; i += 2) {
1374  Point2D p3 = get_point(ring, i, ic, isr, osr);
1375  area += area_triangle(p1.x, p1.y, p2.x, p2.y, p3.x, p3.y);
1376  p2 = p3;
1377  }
1378  return area;
1379 }
DEVICE ALWAYS_INLINE double area_triangle(double x1, double y1, double x2, double y2, double x3, double y3)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(const int32_t ic)
DEVICE ALWAYS_INLINE Point2D get_point(const int8_t *data, const int32_t x_index, const int32_t ic, const int32_t isr, const int32_t osr)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

DEVICE ALWAYS_INLINE double area_triangle ( double  x1,
double  y1,
double  x2,
double  y2,
double  x3,
double  y3 
)

Definition at line 1349 of file ExtensionFunctionsGeo.hpp.

Referenced by area_ring().

1354  {
1355  return (x1 * y2 - x2 * y1 + x3 * y1 - x1 * y3 + x2 * y3 - x3 * y2) / 2.0;
1356 }

+ Here is the caller graph for this function:

DEVICE ALWAYS_INLINE bool box_contains_box ( double *  bounds1,
int64_t  bounds1_size,
double *  bounds2,
int64_t  bounds2_size 
)

Definition at line 878 of file ExtensionFunctionsGeo.hpp.

References box_contains_point().

Referenced by ST_Contains_MultiPolygon_LineString(), ST_Contains_Polygon_LineString(), and ST_Contains_Polygon_Polygon().

881  {
882  // TODO: mixed spatial references
883  return (
885  bounds1, bounds1_size, bounds2[0], bounds2[1]) && // box1 <- box2: xmin, ymin
887  bounds1, bounds1_size, bounds2[2], bounds2[3])); // box1 <- box2: xmax, ymax
888 }
DEVICE ALWAYS_INLINE bool box_contains_point(const double *bounds, const int64_t bounds_size, const double px, const double py)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

DEVICE ALWAYS_INLINE bool box_contains_box_vertex ( double *  bounds1,
int64_t  bounds1_size,
double *  bounds2,
int64_t  bounds2_size 
)

Definition at line 890 of file ExtensionFunctionsGeo.hpp.

References box_contains_point().

893  {
894  // TODO: mixed spatial references
895  return (
897  bounds1, bounds1_size, bounds2[0], bounds2[1]) || // box1 <- box2: xmin, ymin
899  bounds1, bounds1_size, bounds2[2], bounds2[3]) || // box1 <- box2: xmax, ymax
901  bounds1, bounds1_size, bounds2[0], bounds2[3]) || // box1 <- box2: xmin, ymax
903  bounds1, bounds1_size, bounds2[2], bounds2[1])); // box1 <- box2: xmax, ymin
904 }
DEVICE ALWAYS_INLINE bool box_contains_point(const double *bounds, const int64_t bounds_size, const double px, const double py)

+ Here is the call graph for this function:

DEVICE ALWAYS_INLINE bool box_contains_point ( const double *  bounds,
const int64_t  bounds_size,
const double  px,
const double  py 
)

Definition at line 861 of file ExtensionFunctionsGeo.hpp.

References tol_ge(), and tol_le().

Referenced by box_contains_box(), box_contains_box_vertex(), Contains_MultiPolygon_Point_Impl(), Contains_Polygon_Point_Impl(), Point_Overlaps_Box(), and ST_Intersects_Point_LineString().

864  {
865  // TODO: mixed spatial references
866  return (tol_ge(px, bounds[0]) && tol_ge(py, bounds[1]) && tol_le(px, bounds[2]) &&
867  tol_le(py, bounds[3]));
868 }
DEVICE ALWAYS_INLINE bool tol_le(const double x, const double y, const double tolerance=TOLERANCE_DEFAULT)
DEVICE ALWAYS_INLINE bool tol_ge(const double x, const double y, const double tolerance=TOLERANCE_DEFAULT)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 
)

Definition at line 946 of file ExtensionFunctionsGeo.hpp.

Referenced by ST_DWithin_LineString_LineString(), ST_DWithin_LineString_MultiPolygon(), ST_DWithin_LineString_Polygon(), ST_DWithin_MultiPolygon_MultiPolygon(), ST_DWithin_Polygon_MultiPolygon(), and ST_DWithin_Polygon_Polygon().

953  {
954  // TODO: tolerance
955 
956  // Bounds come in corresponding input spatial references.
957  // For example, here the first bounding box may come in 4326, second in 900913:
958  // ST_DWithin(ST_Transform(linestring4326, 900913), linestring900913, 10)
959  // Distance is given in osr spatial reference units, in this case 10 meters.
960  // Bounds should be converted to osr before calculations, if isr != osr.
961 
962  // TODO: revise all other functions that process bounds
963 
964  Point2D const lb1 = transform_point<XY>({bounds1[0], bounds1[1]}, isr1, osr);
965  Point2D const rt1 = transform_point<XY>({bounds1[2], bounds1[3]}, isr1, osr);
966  Point2D const lb2 = transform_point<XY>({bounds2[0], bounds2[1]}, isr2, osr);
967  Point2D const rt2 = transform_point<XY>({bounds2[2], bounds2[3]}, isr2, osr);
968  if (
969  // box1 is left of box2: box1.xmax + distance < box2.xmin
970  rt1.x + distance < lb2.x ||
971  // box1 is right of box2: box1.xmin - distance > box2.xmax
972  lb1.x - distance > rt2.x ||
973  // box1 is below box2: box1.ymax + distance < box2.ymin
974  rt1.y + distance < lb2.y ||
975  // box1 is above box2: box1.ymin - distance > box1.ymax
976  lb1.y - distance > rt2.y) {
977  return false;
978  }
979  return true;
980 }

+ Here is the caller graph for this function:

DEVICE ALWAYS_INLINE bool box_overlaps_box ( double *  bounds1,
int64_t  bounds1_size,
double *  bounds2,
int64_t  bounds2_size 
)

Definition at line 906 of file ExtensionFunctionsGeo.hpp.

Referenced by ST_Intersects_LineString_Linestring(), ST_Intersects_LineString_MultiPolygon(), ST_Intersects_LineString_Polygon(), ST_Intersects_MultiPolygon_MultiPolygon(), ST_Intersects_Polygon_MultiPolygon(), and ST_Intersects_Polygon_Polygon().

909  {
910  // TODO: tolerance
911  // TODO: mixed spatial references
912  if (bounds1[2] < bounds2[0] || // box1 is left of box2: box1.xmax < box2.xmin
913  bounds1[0] > bounds2[2] || // box1 is right of box2: box1.xmin > box2.xmax
914  bounds1[3] < bounds2[1] || // box1 is below box2: box1.ymax < box2.ymin
915  bounds1[1] > bounds2[3]) { // box1 is above box2: box1.ymin > box1.ymax
916  return false;
917  }
918  return true;
919 }

+ Here is the caller graph for this function:

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 
)

Definition at line 1527 of file ExtensionFunctionsGeo.hpp.

References centroid_add_segment(), compression_unit_size(), and get_point().

Referenced by centroid_add_ring(), and ST_Centroid_LineString().

1536  {
1537  auto l_num_coords = lsize / compression_unit_size(ic);
1538  double length = 0.0;
1539  Point2D const l0 = get_point(l, 0, ic, isr, osr);
1540  Point2D l2 = l0;
1541  for (int32_t i = 2; i < l_num_coords; i += 2) {
1542  Point2D const l1 = l2;
1543  l2 = get_point(l, i, ic, isr, osr);
1544  centroid_add_segment(l1.x, l1.y, l2.x, l2.y, &length, linestring_centroid_sum);
1545  }
1546  if (l_num_coords > 4 && closed) {
1547  // Also add the closing segment between the last and the first points
1548  centroid_add_segment(l2.x, l2.y, l0.x, l0.y, &length, linestring_centroid_sum);
1549  }
1550  *total_length += length;
1551  if (length == 0.0 && l_num_coords > 0) {
1552  *num_points += 1;
1553  point_centroid_sum[0] += l0.x;
1554  point_centroid_sum[1] += l0.y;
1555  }
1556  return true;
1557 }
DEVICE ALWAYS_INLINE bool centroid_add_segment(double x1, double y1, double x2, double y2, double *length, double *linestring_centroid_sum)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(const int32_t ic)
DEVICE ALWAYS_INLINE Point2D get_point(const int8_t *data, const int32_t x_index, const int32_t ic, const int32_t isr, const int32_t osr)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 
)

Definition at line 1646 of file ExtensionFunctionsGeo.hpp.

References centroid_add_ring(), and compression_unit_size().

Referenced by ST_Centroid_MultiPolygon(), and ST_Centroid_Polygon().

1658  {
1659  if (poly_num_rings <= 0) {
1660  return false;
1661  }
1662 
1663  auto ring_coords = poly_coords;
1664 
1665  for (auto r = 0; r < poly_num_rings; r++) {
1666  auto ring_coords_size = poly_ring_sizes[r] * 2 * compression_unit_size(ic);
1667  // Shape - positive area, holes - negative areas
1668  double sign = (r == 0) ? 1.0 : -1.0;
1669  centroid_add_ring(ring_coords,
1670  ring_coords_size,
1671  ic,
1672  isr,
1673  osr,
1674  sign,
1675  total_area2,
1676  cg3,
1677  total_length,
1678  linestring_centroid_sum,
1679  num_points,
1680  point_centroid_sum);
1681  // Advance to the next ring.
1682  ring_coords += ring_coords_size;
1683  }
1684  return true;
1685 }
DEVICE ALWAYS_INLINE int32_t compression_unit_size(const int32_t ic)
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)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 
)

Definition at line 1607 of file ExtensionFunctionsGeo.hpp.

References centroid_add_linestring(), centroid_add_triangle(), compression_unit_size(), and get_point().

Referenced by centroid_add_polygon().

1618  {
1619  auto ring_num_coords = ringsize / compression_unit_size(ic);
1620 
1621  if (ring_num_coords < 6) {
1622  return false;
1623  }
1624 
1625  Point2D p1 = get_point(ring, 0, ic, isr, osr);
1626  Point2D p2 = get_point(ring, 2, ic, isr, osr);
1627  for (int32_t i = 4; i < ring_num_coords; i += 2) {
1628  Point2D p3 = get_point(ring, i, ic, isr, osr);
1629  centroid_add_triangle(p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, sign, total_area2, cg3);
1630  p2 = p3;
1631  }
1632 
1634  ringsize,
1635  ic,
1636  isr,
1637  osr,
1638  true, // closed
1639  total_length,
1640  linestring_centroid_sum,
1641  num_points,
1642  point_centroid_sum);
1643  return true;
1644 }
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)
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)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(const int32_t ic)
DEVICE ALWAYS_INLINE Point2D get_point(const int8_t *data, const int32_t x_index, const int32_t ic, const int32_t isr, const int32_t osr)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

DEVICE ALWAYS_INLINE bool centroid_add_segment ( double  x1,
double  y1,
double  x2,
double  y2,
double *  length,
double *  linestring_centroid_sum 
)

Definition at line 1512 of file ExtensionFunctionsGeo.hpp.

References distance_point_point().

Referenced by centroid_add_linestring().

1517  {
1518  double ldist = distance_point_point(x1, y1, x2, y2);
1519  *length += ldist;
1520  double segment_midpoint_x = (x1 + x2) / 2.0;
1521  double segment_midpoint_y = (y1 + y2) / 2.0;
1522  linestring_centroid_sum[0] += ldist * segment_midpoint_x;
1523  linestring_centroid_sum[1] += ldist * segment_midpoint_y;
1524  return true;
1525 }
DEVICE ALWAYS_INLINE double distance_point_point(double p1x, double p1y, double p2x, double p2y)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 
)

Definition at line 1589 of file ExtensionFunctionsGeo.hpp.

Referenced by centroid_add_ring().

1597  {
1598  double cx = x1 + x2 + x3;
1599  double cy = y1 + y2 + y3;
1600  double area2 = x1 * y2 - x2 * y1 + x3 * y1 - x1 * y3 + x2 * y3 - x3 * y2;
1601  cg3[0] += sign * area2 * cx;
1602  cg3[1] += sign * area2 * cy;
1603  *total_area2 += sign * area2;
1604  return true;
1605 }

+ Here is the caller graph for this function:

DEVICE ALWAYS_INLINE int32_t compressed_coord ( const int8_t *  data,
const int32_t  index 
)

Definition at line 226 of file ExtensionFunctionsGeo.hpp.

Referenced by Geospatial::compress_latitude_coord_geoint32(), Geospatial::compress_longitude_coord_geoint32(), Contains_Polygon_Point_Impl(), decompress_coord(), and point_in_polygon_winding_number().

226  {
227  const auto compressed_coords = reinterpret_cast<const int32_t*>(data);
228  return compressed_coords[index];
229 }

+ Here is the caller graph for this function:

DEVICE ALWAYS_INLINE int32_t compression_unit_size ( const int32_t  ic)

Definition at line 105 of file ExtensionFunctionsGeo.hpp.

References COMPRESSION_GEOINT32.

Referenced by area_polygon(), area_ring(), centroid_add_linestring(), centroid_add_polygon(), centroid_add_ring(), Contains_MultiPolygon_Point_Impl(), Contains_Polygon_Point_Impl(), distance_point_linestring(), distance_point_multilinestring(), distance_point_multipolygon(), distance_point_polygon(), length_linestring(), max_distance_point_linestring(), perimeter_multipolygon(), ST_Area_MultiPolygon(), ST_Centroid_MultiPoint(), ST_Centroid_MultiPolygon(), ST_Contains_MultiPolygon_LineString(), ST_Contains_Point_LineString(), ST_Contains_Point_Polygon(), ST_Contains_Polygon_LineString(), ST_Contains_Polygon_Polygon(), ST_Distance_LineString_LineString(), ST_Distance_LineString_MultiPolygon(), ST_Distance_LineString_Polygon(), ST_Distance_MultiPoint_LineString(), ST_Distance_MultiPoint_MultiLineString(), ST_Distance_MultiPoint_MultiPoint(), ST_Distance_MultiPoint_MultiPoint_Squared(), ST_Distance_MultiPoint_MultiPolygon(), ST_Distance_MultiPoint_Polygon(), ST_Distance_MultiPolygon_MultiPolygon(), ST_Distance_Point_LineString_Geodesic(), ST_Distance_Point_MultiPoint(), ST_Distance_Point_MultiPoint_Squared(), ST_Distance_Polygon_MultiPolygon(), ST_Distance_Polygon_Polygon(), ST_DWithin_LineString_MultiPolygon(), ST_DWithin_LineString_Polygon(), ST_Length_MultiLineString(), ST_Perimeter_Polygon(), ST_Perimeter_Polygon_Geodesic(), ST_XMax(), ST_XMin(), ST_YMax(), ST_YMin(), and trim_linestring_to_buffered_box().

105  {
106  if (ic == COMPRESSION_GEOINT32) {
107  return 4;
108  }
109  return 8;
110 }
#define COMPRESSION_GEOINT32

+ Here is the caller graph for this function:

template<typename T , EdgeBehavior TEdgeBehavior>
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 
)

Definition at line 4187 of file ExtensionFunctionsGeo.hpp.

References box_contains_point(), compression_unit_size(), and get_point().

4202  {
4203  if (mpoly_num_polys <= 0) {
4204  return false;
4205  }
4206 
4207  // TODO: mpoly_bounds could contain individual bounding boxes too:
4208  // first two points - box for the entire multipolygon, then a pair for each polygon
4209  if (mpoly_bounds) {
4210  Point2D const pt = get_point(p, 0, ic2, isr2, osr);
4211  if (!box_contains_point(mpoly_bounds, mpoly_bounds_size, pt.x, pt.y)) {
4212  return false;
4213  }
4214  }
4215 
4216  // Set specific poly pointers as we move through the coords/ringsizes/polyrings
4217  // arrays.
4218  auto next_poly_coords = mpoly_coords;
4219  auto next_poly_ring_sizes = mpoly_ring_sizes;
4220 
4221  for (auto poly = 0; poly < mpoly_num_polys; poly++) {
4222  const auto poly_coords = next_poly_coords;
4223  const auto poly_ring_sizes = next_poly_ring_sizes;
4224  const auto poly_num_rings = mpoly_poly_sizes[poly];
4225  // Count number of coords in all of poly's rings, advance ring size pointer.
4226  int32_t poly_num_coords = 0;
4227  for (auto ring = 0; ring < poly_num_rings; ring++) {
4228  poly_num_coords += 2 * *next_poly_ring_sizes++;
4229  }
4230  const auto poly_coords_size = poly_num_coords * compression_unit_size(ic1);
4231  next_poly_coords += poly_coords_size;
4232  // TODO: pass individual bounding boxes for each polygon
4233  if (Contains_Polygon_Point_Impl<T, TEdgeBehavior>(poly_coords,
4234  poly_coords_size,
4235  poly_ring_sizes,
4236  poly_num_rings,
4237  nullptr,
4238  0,
4239  p,
4240  psize,
4241  ic1,
4242  isr1,
4243  ic2,
4244  isr2,
4245  osr)) {
4246  return true;
4247  }
4248  }
4249 
4250  return false;
4251 }
DEVICE ALWAYS_INLINE bool box_contains_point(const double *bounds, const int64_t bounds_size, const double px, const double py)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(const int32_t ic)
DEVICE ALWAYS_INLINE Point2D get_point(const int8_t *data, const int32_t x_index, const int32_t ic, const int32_t isr, const int32_t osr)

+ Here is the call graph for this function:

template<typename T , EdgeBehavior TEdgeBehavior>
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 
)

Definition at line 3974 of file ExtensionFunctionsGeo.hpp.

References box_contains_point(), compressed_coord(), compression_unit_size(), DEBUG_STMT, get_point(), and heavydb.dtypes::T.

3986  {
3987  if (poly_bounds) {
3988  // TODO: codegen
3989  Point2D const pt = get_point(p, 0, ic2, isr2, osr);
3990  if (!box_contains_point(poly_bounds, poly_bounds_size, pt.x, pt.y)) {
3991  DEBUG_STMT(printf("Bounding box does not contain point, exiting.\n"));
3992  return false;
3993  }
3994  }
3995 
3996  auto get_x_coord = [=]() -> T {
3997  if constexpr (std::is_floating_point<T>::value) {
3998  return get_point(p, 0, ic2, isr2, osr).x;
3999  } else {
4000  return compressed_coord(p, 0);
4001  }
4002  return T{}; // https://stackoverflow.com/a/64561686/2700898
4003  };
4004 
4005  auto get_y_coord = [=]() -> T {
4006  if constexpr (std::is_floating_point<T>::value) {
4007  return get_point(p, 0, ic2, isr2, osr).y;
4008  } else {
4009  return compressed_coord(p, 1);
4010  }
4011  return T{}; // https://stackoverflow.com/a/64561686/2700898
4012  };
4013 
4014  const T px = get_x_coord();
4015  const T py = get_y_coord();
4016  DEBUG_STMT(printf("pt: %f, %f\n", (double)px, (double)py));
4017 
4018  const auto poly_num_coords = poly_coords_size / compression_unit_size(ic1);
4019  auto exterior_ring_num_coords =
4020  poly_num_rings > 0 ? poly_ring_sizes[0] * 2 : poly_num_coords;
4021 
4022  auto poly = poly_coords;
4023  if (point_in_polygon_winding_number<T, TEdgeBehavior>(
4024  poly, exterior_ring_num_coords, px, py, ic1, isr1, osr)) {
4025  // Inside exterior ring
4026  poly += exterior_ring_num_coords * compression_unit_size(ic1);
4027  // Check that none of the polygon's holes contain that point
4028  for (auto r = 1; r < poly_num_rings; r++) {
4029  const int64_t interior_ring_num_coords = poly_ring_sizes[r] * 2;
4030  if (point_in_polygon_winding_number<T, TEdgeBehavior>(
4031  poly, interior_ring_num_coords, px, py, ic1, isr1, osr)) {
4032  return false;
4033  }
4034  poly += interior_ring_num_coords * compression_unit_size(ic1);
4035  }
4036  return true;
4037  }
4038  return false;
4039 }
DEVICE ALWAYS_INLINE int32_t compressed_coord(const int8_t *data, const int32_t index)
#define DEBUG_STMT(x)
DEVICE ALWAYS_INLINE bool box_contains_point(const double *bounds, const int64_t bounds_size, const double px, const double py)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(const int32_t ic)
DEVICE ALWAYS_INLINE Point2D get_point(const int8_t *data, const int32_t x_index, const int32_t ic, const int32_t isr, const int32_t osr)

+ Here is the call graph for this function:

template<Coords C>
DEVICE ALWAYS_INLINE Point2D conv_4326_900913 ( const Point2D  point)

Definition at line 113 of file ExtensionFunctionsGeo.hpp.

References conv_4326_900913_x(), conv_4326_900913_y(), anonymous_namespace{ExtensionFunctionsGeo.hpp}::X, and anonymous_namespace{ExtensionFunctionsGeo.hpp}::Y.

113  {
114  Point2D retval;
115  if constexpr (static_cast<bool>(C & Coords::X)) {
116  retval.x = conv_4326_900913_x(point.x);
117  }
118  if constexpr (static_cast<bool>(C & Coords::Y)) {
119  retval.y = conv_4326_900913_y(point.y);
120  }
121  return retval;
122 }
EXTENSION_NOINLINE double conv_4326_900913_y(const double y)
EXTENSION_NOINLINE double conv_4326_900913_x(const double x)

+ Here is the call graph for this function:

template<Coords C>
DEVICE ALWAYS_INLINE Point2D conv_4326_utm ( const Point2D  point,
const int32_t  utm_srid 
)

Definition at line 125 of file ExtensionFunctionsGeo.hpp.

References Transform4326ToUTM::calculateX(), Transform4326ToUTM::calculateY(), anonymous_namespace{ExtensionFunctionsGeo.hpp}::X, and anonymous_namespace{ExtensionFunctionsGeo.hpp}::Y.

125  {
126  Point2D retval;
127  Transform4326ToUTM const utm(utm_srid, point.x, point.y);
128  if constexpr (static_cast<bool>(C & Coords::X)) {
129  retval.x = utm.calculateX();
130  }
131  if constexpr (static_cast<bool>(C & Coords::Y)) {
132  retval.y = utm.calculateY();
133  }
134  return retval;
135 }

+ Here is the call graph for this function:

template<Coords C>
DEVICE ALWAYS_INLINE Point2D conv_utm_4326 ( const Point2D  point,
const int32_t  utm_srid 
)

Definition at line 138 of file ExtensionFunctionsGeo.hpp.

References TransformUTMTo4326::calculateX(), TransformUTMTo4326::calculateY(), anonymous_namespace{ExtensionFunctionsGeo.hpp}::X, and anonymous_namespace{ExtensionFunctionsGeo.hpp}::Y.

138  {
139  Point2D retval;
140  TransformUTMTo4326 const wgs84(utm_srid, point.x, point.y);
141  if constexpr (static_cast<bool>(C & Coords::X)) {
142  retval.x = wgs84.calculateX();
143  }
144  if constexpr (static_cast<bool>(C & Coords::Y)) {
145  retval.y = wgs84.calculateY();
146  }
147  return retval;
148 }

+ Here is the call graph for this function:

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 
)

Definition at line 5033 of file ExtensionFunctionsGeo.hpp.

Referenced by com.mapd.calcite.parser.HeavyDBSqlOperatorTable::addUDF().

5042  {
5043  const double const1 = 0.017453292519943295769236907684886;
5044  const double const2 = 6372797.560856;
5045  const auto lat = decompress_coord<Y>(p, 0, ic);
5046  const double latdiff = meters / (const1 * const2);
5047  const double newlat =
5048  (lat < 0) ? lat + latdiff : lat - latdiff; // assumes a lat range of [-90, 90]
5049  double t1 = transform_point<Y>({{}, lat}, isr, osr).y;
5050  double t2 = transform_point<Y>({{}, newlat}, isr, osr).y;
5051  const double min_domain_y = transform_point<Y>({{}, min_lat}, isr, osr).y;
5052  const double max_domain_y = transform_point<Y>({{}, max_lat}, isr, osr).y;
5053  const double domain_diff = max_domain_y - min_domain_y;
5054  t1 = ((t1 - min_domain_y) / domain_diff) * static_cast<double>(img_height);
5055  t2 = ((t2 - min_domain_y) / domain_diff) * static_cast<double>(img_height);
5056 
5057  // TODO(croot): need to account for edge cases, such as getting close to the poles.
5058  const double sz = fabs(t1 - t2);
5059  return (sz < min_height ? min_height : sz);
5060 }

+ Here is the caller graph for this function:

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 
)

Definition at line 5001 of file ExtensionFunctionsGeo.hpp.

Referenced by com.mapd.calcite.parser.HeavyDBSqlOperatorTable::addUDF().

5010  {
5011  const double const1 = 0.017453292519943295769236907684886;
5012  const double const2 = 6372797.560856;
5013  const auto lon = decompress_coord<X>(p, 0, ic);
5014  const auto lat = decompress_coord<Y>(p, 0, ic);
5015  double t1 = sinf(meters / (2.0 * const2));
5016  double t2 = cosf(const1 * lat);
5017  const double newlon = lon - (2.0 * asinf(t1 / t2)) / const1;
5018  t1 = transform_point<X>({lon, {}}, isr, osr).x;
5019  t2 = transform_point<X>({newlon, {}}, isr, osr).x;
5020  const double min_domain_x = transform_point<X>({min_lon, {}}, isr, osr).x;
5021  const double max_domain_x = transform_point<X>({max_lon, {}}, isr, osr).x;
5022  const double domain_diff = max_domain_x - min_domain_x;
5023  t1 = ((t1 - min_domain_x) / domain_diff) * static_cast<double>(img_width);
5024  t2 = ((t2 - min_domain_x) / domain_diff) * static_cast<double>(img_width);
5025 
5026  // TODO(croot): need to account for edge cases, such as getting close to the poles.
5027  const double sz = fabs(t1 - t2);
5028  return (sz < min_width ? min_width : sz);
5029 }

+ Here is the caller graph for this function:

template<Coords C>
DEVICE ALWAYS_INLINE Point2D coord ( const int8_t *  data,
const int32_t  x_index,
const int32_t  ic,
const int32_t  isr,
const int32_t  osr 
)

Definition at line 205 of file ExtensionFunctionsGeo.hpp.

References anonymous_namespace{ExtensionFunctionsGeo.hpp}::X, x_and_y_are_dependent(), and anonymous_namespace{ExtensionFunctionsGeo.hpp}::Y.

Referenced by Geospatial::compress_coords().

209  {
210  Point2D decompressed;
211  static_assert(C == Coords::X || C == Coords::Y, "Use get_point() instead of XY.");
212  if (x_and_y_are_dependent(isr, osr)) {
213  decompressed = {decompress_coord<X>(data, x_index, ic),
214  decompress_coord<Y>(data, x_index, ic)};
215  } else {
216  if constexpr (C == Coords::X) {
217  decompressed.x = decompress_coord<X>(data, x_index, ic);
218  } else {
219  decompressed.y = decompress_coord<Y>(data, x_index, ic);
220  }
221  }
222  return transform_point<C>(decompressed, isr, osr);
223 }
DEVICE ALWAYS_INLINE bool x_and_y_are_dependent(const int32_t isr, const int32_t osr)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<Coords C>
DEVICE ALWAYS_INLINE double decompress_coord ( const int8_t *  data,
const int32_t  x_index,
const int32_t  ic 
)

Definition at line 87 of file ExtensionFunctionsGeo.hpp.

References compressed_coord(), COMPRESSION_GEOINT32, Geospatial::decompress_latitude_coord_geoint32(), Geospatial::decompress_longitude_coord_geoint32(), anonymous_namespace{ExtensionFunctionsGeo.hpp}::X, and anonymous_namespace{ExtensionFunctionsGeo.hpp}::Y.

89  {
90  static_assert(C == Coords::X || C == Coords::Y);
91  const int32_t adjusted_index = x_index + (C == Coords::Y);
92  if (ic == COMPRESSION_GEOINT32) {
93  auto compressed_coords = reinterpret_cast<const int32_t*>(data);
94  auto compressed_coord = compressed_coords[adjusted_index];
95  if constexpr (C == Coords::X) {
97  } else {
99  }
100  }
101  auto double_coords = reinterpret_cast<const double*>(data);
102  return double_coords[adjusted_index];
103 }
DEVICE double decompress_latitude_coord_geoint32(const int32_t compressed)
DEVICE ALWAYS_INLINE int32_t compressed_coord(const int8_t *data, const int32_t index)
DEVICE double decompress_longitude_coord_geoint32(const int32_t compressed)
#define COMPRESSION_GEOINT32

+ Here is the call graph for this function:

DEVICE double distance_line_line ( double  l11x,
double  l11y,
double  l12x,
double  l12y,
double  l21x,
double  l21y,
double  l22x,
double  l22y 
)

Definition at line 441 of file ExtensionFunctionsGeo.hpp.

References distance_point_line(), and line_intersects_line().

Referenced by distance_ring_linestring(), distance_ring_ring(), and ST_Distance_LineString_LineString().

448  {
449  if (line_intersects_line(l11x, l11y, l12x, l12y, l21x, l21y, l22x, l22y)) {
450  return 0.0;
451  }
452  double dist12 = fmin(distance_point_line(l11x, l11y, l21x, l21y, l22x, l22y),
453  distance_point_line(l12x, l12y, l21x, l21y, l22x, l22y));
454  double dist21 = fmin(distance_point_line(l21x, l21y, l11x, l11y, l12x, l12y),
455  distance_point_line(l22x, l22y, l11x, l11y, l12x, l12y));
456  return fmin(dist12, dist21);
457 }
DEVICE double distance_point_line(double px, double py, double l1x, double l1y, double l2x, double l2y)
DEVICE bool line_intersects_line(double l11x, double l11y, double l12x, double l12y, double l21x, double l21y, double l22x, double l22y)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

DEVICE double distance_line_line_squared ( double  l11x,
double  l11y,
double  l12x,
double  l12y,
double  l21x,
double  l21y,
double  l22x,
double  l22y 
)

Definition at line 461 of file ExtensionFunctionsGeo.hpp.

References distance_point_line_squared(), and line_intersects_line().

468  {
469  if (line_intersects_line(l11x, l11y, l12x, l12y, l21x, l21y, l22x, l22y)) {
470  return 0.0;
471  }
472  double dist12 = fmin(distance_point_line_squared(l11x, l11y, l21x, l21y, l22x, l22y),
473  distance_point_line_squared(l12x, l12y, l21x, l21y, l22x, l22y));
474  double dist21 = fmin(distance_point_line_squared(l21x, l21y, l11x, l11y, l12x, l12y),
475  distance_point_line_squared(l22x, l22y, l11x, l11y, l12x, l12y));
476  return fmin(dist12, dist21);
477 }
DEVICE bool line_intersects_line(double l11x, double l11y, double l12x, double l12y, double l21x, double l21y, double l22x, double l22y)
DEVICE double distance_point_line_squared(double px, double py, double l1x, double l1y, double l2x, double l2y)

+ Here is the call graph for this function:

DEVICE double distance_point_line ( double  px,
double  py,
double  l1x,
double  l1y,
double  l2x,
double  l2y 
)

Definition at line 258 of file ExtensionFunctionsGeo.hpp.

References distance_point_point(), and tol_zero().

Referenced by distance_line_line(), distance_point_linestring(), and polygon_contains_point().

263  {
264  double length = distance_point_point(l1x, l1y, l2x, l2y);
265  if (tol_zero(length)) {
266  return distance_point_point(px, py, l1x, l1y);
267  }
268 
269  // Find projection of point P onto the line segment AB:
270  // Line containing that segment: A + k * (B - A)
271  // Projection of point P onto the line touches it at
272  // k = dot(P-A,B-A) / length^2
273  // AB segment is represented by k = [0,1]
274  // Clamping k to [0,1] will give the shortest distance from P to AB segment
275  double dotprod = (px - l1x) * (l2x - l1x) + (py - l1y) * (l2y - l1y);
276  double k = dotprod / (length * length);
277  k = fmax(0.0, fmin(1.0, k));
278  double projx = l1x + k * (l2x - l1x);
279  double projy = l1y + k * (l2y - l1y);
280  return distance_point_point(px, py, projx, projy);
281 }
DEVICE ALWAYS_INLINE bool tol_zero(const double x, const double tolerance=TOLERANCE_DEFAULT)
DEVICE ALWAYS_INLINE double distance_point_point(double p1x, double p1y, double p2x, double p2y)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

DEVICE double distance_point_line_squared ( double  px,
double  py,
double  l1x,
double  l1y,
double  l2x,
double  l2y 
)

Definition at line 285 of file ExtensionFunctionsGeo.hpp.

References distance_point_point_squared(), tol_zero(), and TOLERANCE_DEFAULT_SQUARED.

Referenced by distance_line_line_squared().

290  {
291  double length = distance_point_point_squared(l1x, l1y, l2x, l2y);
292  if (tol_zero(length, TOLERANCE_DEFAULT_SQUARED)) {
293  return distance_point_point_squared(px, py, l1x, l1y);
294  }
295 
296  // Find projection of point P onto the line segment AB:
297  // Line containing that segment: A + k * (B - A)
298  // Projection of point P onto the line touches it at
299  // k = dot(P-A,B-A) / length^2
300  // AB segment is represented by k = [0,1]
301  // Clamping k to [0,1] will give the shortest distance from P to AB segment
302  double dotprod = (px - l1x) * (l2x - l1x) + (py - l1y) * (l2y - l1y);
303  double k = dotprod / (length * length);
304  k = fmax(0.0, fmin(1.0, k));
305  double projx = l1x + k * (l2x - l1x);
306  double projy = l1y + k * (l2y - l1y);
307  return distance_point_point_squared(px, py, projx, projy);
308 }
DEVICE ALWAYS_INLINE bool tol_zero(const double x, const double tolerance=TOLERANCE_DEFAULT)
DEVICE ALWAYS_INLINE double distance_point_point_squared(double p1x, double p1y, double p2x, double p2y)
#define TOLERANCE_DEFAULT_SQUARED

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

DEVICE ALWAYS_INLINE double distance_point_linestring ( int8_t *  p,
int64_t  psize,
int8_t *  l,
int64_t  lsize,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr,
bool  check_closed,
double  threshold 
)

Definition at line 1947 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size(), distance_point_line(), and get_point().

Referenced by distance_point_multilinestring(), ST_Distance_MultiPoint_LineString(), ST_Distance_Point_ClosedLineString(), and ST_Distance_Point_LineString().

1957  {
1958  Point2D pt = get_point(p, 0, ic1, isr1, osr);
1959 
1960  auto l_num_coords = lsize / compression_unit_size(ic2);
1961 
1962  Point2D l1 = get_point(l, 0, ic2, isr2, osr);
1963  Point2D l2 = get_point(l, 2, ic2, isr2, osr);
1964 
1965  double dist = distance_point_line(pt.x, pt.y, l1.x, l1.y, l2.x, l2.y);
1966  for (int32_t i = 4; i < l_num_coords; i += 2) {
1967  l1 = l2; // advance one point
1968  l2 = get_point(l, i, ic2, isr2, osr);
1969  double ldist = distance_point_line(pt.x, pt.y, l1.x, l1.y, l2.x, l2.y);
1970  if (dist > ldist) {
1971  dist = ldist;
1972  }
1973  if (dist <= threshold) {
1974  return dist;
1975  }
1976  }
1977  if (l_num_coords > 4 && check_closed) {
1978  // Also check distance to the closing edge between the first and the last points
1979  l1 = get_point(l, 0, ic2, isr2, osr);
1980  double ldist = distance_point_line(pt.x, pt.y, l1.x, l1.y, l2.x, l2.y);
1981  if (dist > ldist) {
1982  dist = ldist;
1983  }
1984  }
1985  return dist;
1986 }
DEVICE double distance_point_line(double px, double py, double l1x, double l1y, double l2x, double l2y)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(const int32_t ic)
DEVICE ALWAYS_INLINE Point2D get_point(const int8_t *data, const int32_t x_index, const int32_t ic, const int32_t isr, const int32_t osr)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

DEVICE ALWAYS_INLINE double distance_point_multilinestring ( int8_t *  p,
int64_t  psize,
int8_t *  mls,
int64_t  mls_size,
int32_t *  mls_ls_sizes,
int64_t  mls_ls_num,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr,
double  threshold 
)

Definition at line 2018 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size(), distance_point_linestring(), and tol_zero().

Referenced by ST_Distance_MultiPoint_MultiLineString(), and ST_Distance_Point_MultiLineString().

2029  {
2030  if (mls_ls_num <= 0) {
2031  return 0.0;
2032  }
2033  double min_distance = 0.0;
2034 
2035  auto next_linestring_coords = mls;
2036 
2037  for (auto l = 0; l < mls_ls_num; l++) {
2038  auto linestring_coords = next_linestring_coords;
2039  auto linestring_num_points = mls_ls_sizes[l];
2040  auto linestring_num_coords = 2 * linestring_num_points;
2041  auto linestring_coords_size = linestring_num_coords * compression_unit_size(ic2);
2042  next_linestring_coords += linestring_coords_size;
2043  double distance = distance_point_linestring(p,
2044  psize,
2045  linestring_coords,
2046  linestring_coords_size,
2047  ic1,
2048  isr1,
2049  ic2,
2050  isr2,
2051  osr,
2052  false,
2053  threshold);
2054  if (l == 0 || min_distance > distance) {
2055  min_distance = distance;
2056  if (tol_zero(min_distance)) {
2057  min_distance = 0.0;
2058  break;
2059  }
2060  if (min_distance <= threshold) {
2061  break;
2062  }
2063  }
2064  }
2065 
2066  return min_distance;
2067 }
DEVICE ALWAYS_INLINE bool tol_zero(const double x, const double tolerance=TOLERANCE_DEFAULT)
DEVICE ALWAYS_INLINE double distance_point_linestring(int8_t *p, int64_t psize, int8_t *l, int64_t lsize, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, bool check_closed, double threshold)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(const int32_t ic)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

DEVICE ALWAYS_INLINE double 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 
)

Definition at line 2148 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size(), distance_point_polygon(), and tol_zero().

Referenced by ST_Distance_MultiPoint_MultiPolygon(), and ST_Distance_Point_MultiPolygon().

2161  {
2162  if (mpoly_num_polys <= 0) {
2163  return 0.0;
2164  }
2165  double min_distance = 0.0;
2166 
2167  // Set specific poly pointers as we move through the coords/ringsizes/polyrings arrays.
2168  auto next_poly_coords = mpoly_coords;
2169  auto next_poly_ring_sizes = mpoly_ring_sizes;
2170 
2171  for (auto poly = 0; poly < mpoly_num_polys; poly++) {
2172  auto poly_coords = next_poly_coords;
2173  auto poly_ring_sizes = next_poly_ring_sizes;
2174  auto poly_num_rings = mpoly_poly_sizes[poly];
2175  // Count number of coords in all of poly's rings, advance ring size pointer.
2176  int32_t poly_num_coords = 0;
2177  for (auto ring = 0; ring < poly_num_rings; ring++) {
2178  poly_num_coords += 2 * *next_poly_ring_sizes++;
2179  }
2180  auto poly_coords_size = poly_num_coords * compression_unit_size(ic2);
2181  next_poly_coords += poly_coords_size;
2182  double distance = distance_point_polygon(p,
2183  psize,
2184  poly_coords,
2185  poly_coords_size,
2186  poly_ring_sizes,
2187  poly_num_rings,
2188  ic1,
2189  isr1,
2190  ic2,
2191  isr2,
2192  osr,
2193  threshold);
2194  if (poly == 0 || min_distance > distance) {
2195  min_distance = distance;
2196  if (tol_zero(min_distance)) {
2197  min_distance = 0.0;
2198  break;
2199  }
2200  if (min_distance <= threshold) {
2201  break;
2202  }
2203  }
2204  }
2205 
2206  return min_distance;
2207 }
DEVICE ALWAYS_INLINE double 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)
DEVICE ALWAYS_INLINE bool tol_zero(const double x, const double tolerance=TOLERANCE_DEFAULT)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(const int32_t ic)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

DEVICE ALWAYS_INLINE double distance_point_point ( double  p1x,
double  p1y,
double  p2x,
double  p2y 
)

Definition at line 248 of file ExtensionFunctionsGeo.hpp.

References distance_point_point_squared().

Referenced by centroid_add_segment(), distance_point_line(), length_linestring(), max_distance_point_line(), ST_Distance_MultiPoint_MultiPoint(), ST_Distance_Point_MultiPoint(), and ST_Distance_Point_Point().

251  {
252  auto d2 = distance_point_point_squared(p1x, p1y, p2x, p2y);
253  return sqrt(d2);
254 }
DEVICE ALWAYS_INLINE double distance_point_point_squared(double p1x, double p1y, double p2x, double p2y)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

DEVICE ALWAYS_INLINE double distance_point_point_squared ( double  p1x,
double  p1y,
double  p2x,
double  p2y 
)

Definition at line 232 of file ExtensionFunctionsGeo.hpp.

References tol_zero(), and TOLERANCE_DEFAULT_SQUARED.

Referenced by distance_point_line_squared(), distance_point_point(), ST_Distance_MultiPoint_MultiPoint_Squared(), ST_Distance_Point_MultiPoint_Squared(), and ST_Distance_Point_Point_Squared().

235  {
236  auto x = p1x - p2x;
237  auto y = p1y - p2y;
238  auto x2 = x * x;
239  auto y2 = y * y;
240  auto d2 = x2 + y2;
242  return 0.0;
243  }
244  return d2;
245 }
DEVICE ALWAYS_INLINE bool tol_zero(const double x, const double tolerance=TOLERANCE_DEFAULT)
#define TOLERANCE_DEFAULT_SQUARED

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

DEVICE ALWAYS_INLINE double 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 
)

Definition at line 2096 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size(), get_point(), polygon_contains_point(), and ST_Distance_Point_ClosedLineString().

Referenced by distance_point_multipolygon(), ST_Distance_MultiPoint_Polygon(), and ST_Distance_Point_Polygon().

2107  {
2108  auto exterior_ring_num_coords = polysize / compression_unit_size(ic2);
2109  if (poly_num_rings > 0) {
2110  exterior_ring_num_coords = poly_ring_sizes[0] * 2;
2111  }
2112  auto exterior_ring_coords_size = exterior_ring_num_coords * compression_unit_size(ic2);
2113 
2114  Point2D pt = get_point(p, 0, ic1, isr1, osr);
2116  poly, exterior_ring_num_coords, pt.x, pt.y, ic2, isr2, osr)) {
2117  // Outside the exterior ring
2119  p, psize, poly, exterior_ring_coords_size, ic1, isr1, ic2, isr2, osr, threshold);
2120  }
2121  // Inside exterior ring
2122  // Advance to first interior ring
2123  poly += exterior_ring_coords_size;
2124  // Check if one of the polygon's holes contains that point
2125  for (auto r = 1; r < poly_num_rings; r++) {
2126  auto interior_ring_num_coords = poly_ring_sizes[r] * 2;
2127  auto interior_ring_coords_size =
2128  interior_ring_num_coords * compression_unit_size(ic2);
2130  poly, interior_ring_num_coords, pt.x, pt.y, ic2, isr2, osr)) {
2131  // Inside an interior ring
2133  psize,
2134  poly,
2135  interior_ring_coords_size,
2136  ic1,
2137  isr1,
2138  ic2,
2139  isr2,
2140  osr,
2141  threshold);
2142  }
2143  poly += interior_ring_coords_size;
2144  }
2145  return 0.0;
2146 }
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 Point2D get_point(const int8_t *data, const int32_t x_index, const int32_t ic, const int32_t isr, const int32_t osr)
EXTENSION_NOINLINE double ST_Distance_Point_ClosedLineString(int8_t *p, int64_t psize, int8_t *l, int64_t lsize, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double threshold)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 
)

Definition at line 480 of file ExtensionFunctionsGeo.hpp.

References distance_line_line(), get_point(), and tol_zero().

Referenced by ST_Distance_LineString_Polygon().

489  {
490  double min_distance = 0.0;
491 
492  Point2D re1 = get_point(ring, ring_num_coords - 2, ic1, isr1, osr);
493  for (auto i = 0; i < ring_num_coords; i += 2) {
494  Point2D re2 = get_point(ring, i, ic1, isr1, osr);
495  Point2D le1 = get_point(l, 0, ic2, isr2, osr);
496  for (auto j = 2; j < lnum_coords; j += 2) {
497  Point2D le2 = get_point(l, j, ic2, isr2, osr);
498  auto distance =
499  distance_line_line(re1.x, re1.y, re2.x, re2.y, le1.x, le1.y, le2.x, le2.y);
500  if ((i == 0 && j == 2) || min_distance > distance) {
501  min_distance = distance;
502  if (tol_zero(min_distance)) {
503  return 0.0;
504  }
505  if (min_distance <= threshold) {
506  return min_distance;
507  }
508  }
509  le1 = le2;
510  }
511  re1 = re2;
512  }
513  return min_distance;
514 }
DEVICE ALWAYS_INLINE bool tol_zero(const double x, const double tolerance=TOLERANCE_DEFAULT)
DEVICE ALWAYS_INLINE Point2D get_point(const int8_t *data, const int32_t x_index, const int32_t ic, const int32_t isr, const int32_t osr)
DEVICE double distance_line_line(double l11x, double l11y, double l12x, double l12y, double l21x, double l21y, double l22x, double l22y)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 
)

Definition at line 517 of file ExtensionFunctionsGeo.hpp.

References distance_line_line(), get_point(), and tol_zero().

Referenced by ST_Distance_Polygon_Polygon().

526  {
527  double min_distance = 0.0;
528  Point2D e11 = get_point(ring1, ring1_num_coords - 2, ic1, isr1, osr);
529  for (auto i = 0; i < ring1_num_coords; i += 2) {
530  Point2D e12 = get_point(ring1, i, ic1, isr1, osr);
531  Point2D e21 = get_point(ring2, ring2_num_coords - 2, ic2, isr2, osr);
532  for (auto j = 0; j < ring2_num_coords; j += 2) {
533  Point2D e22 = get_point(ring2, j, ic2, isr2, osr);
534  auto distance =
535  distance_line_line(e11.x, e11.y, e12.x, e12.y, e21.x, e21.y, e22.x, e22.y);
536  if ((i == 0 && j == 0) || min_distance > distance) {
537  min_distance = distance;
538  if (tol_zero(min_distance)) {
539  return 0.0;
540  }
541  if (min_distance <= threshold) {
542  return min_distance;
543  }
544  }
545  e21 = e22;
546  }
547  e11 = e12;
548  }
549  return min_distance;
550 }
DEVICE ALWAYS_INLINE bool tol_zero(const double x, const double tolerance=TOLERANCE_DEFAULT)
DEVICE ALWAYS_INLINE Point2D get_point(const int8_t *data, const int32_t x_index, const int32_t ic, const int32_t isr, const int32_t osr)
DEVICE double distance_line_line(double l11x, double l11y, double l12x, double l12y, double l21x, double l21y, double l22x, double l22y)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

DEVICE ALWAYS_INLINE Point2D get_point ( const int8_t *  data,
const int32_t  x_index,
const int32_t  ic,
const int32_t  isr,
const int32_t  osr 
)
EXTENSION_INLINE int64_t HeavyDB_Geo_PolyBoundsPtr ( double *  bounds,
int64_t  size 
)

Definition at line 4995 of file ExtensionFunctionsGeo.hpp.

Referenced by com.mapd.calcite.parser.HeavyDBSqlOperatorTable::addUDF().

4995  {
4996  return reinterpret_cast<int64_t>(bounds);
4997 }

+ Here is the caller graph for this function:

template<typename T >
DEVICE ALWAYS_INLINE T is_left ( const T  lx0,
const T  ly0,
const T  lx1,
const T  ly1,
const T  px,
const T  py 
)

Tests if a point is left, on, or to the right of a 2D line

Returns
>0 if p is left of l, 0 if p is on l, and < 0 if p is right of l

Definition at line 558 of file ExtensionFunctionsGeo.hpp.

Referenced by point_in_polygon_winding_number().

558  {
559  return ((lx1 - lx0) * (py - ly0) - (px - lx0) * (ly1 - ly0));
560 }

+ Here is the caller graph for this function:

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 
)

Definition at line 5062 of file ExtensionFunctionsGeo.hpp.

Referenced by com.mapd.calcite.parser.HeavyDBSqlOperatorTable::addUDF().

5068  {
5069  const auto lon = decompress_coord<X>(p, 0, ic);
5070  const auto lat = decompress_coord<Y>(p, 0, ic);
5071  return !(lon < min_lon || lon > max_lon || lat < min_lat || lat > max_lat);
5072 }

+ Here is the caller graph for this function:

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 
)

Definition at line 5074 of file ExtensionFunctionsGeo.hpp.

Referenced by com.mapd.calcite.parser.HeavyDBSqlOperatorTable::addUDF().

5081  {
5082  const double const1 = 0.017453292519943295769236907684886;
5083  const double const2 = 6372797.560856;
5084  const auto lon = decompress_coord<X>(p, 0, ic);
5085  const auto lat = decompress_coord<Y>(p, 0, ic);
5086  const double latdiff = meters / (const1 * const2);
5087  const double t1 = sinf(meters / (2.0 * const2));
5088  const double t2 = cosf(const1 * lat);
5089  const double londiff = (2.0 * asinf(t1 / t2)) / const1;
5090  return !(lon + londiff < min_lon || lon - londiff > max_lon ||
5091  lat + latdiff < min_lat || lat - latdiff > max_lat);
5092 }

+ Here is the caller graph for this function:

DEVICE ALWAYS_INLINE double length_linestring ( int8_t *  l,
int32_t  lsize,
int32_t  ic,
int32_t  isr,
int32_t  osr,
bool  geodesic,
bool  check_closed 
)

Definition at line 1140 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size(), distance_in_meters(), distance_point_point(), and get_point().

Referenced by perimeter_multipolygon(), ST_Length_LineString(), ST_Length_LineString_Geodesic(), ST_Length_MultiLineString(), ST_Perimeter_Polygon(), and ST_Perimeter_Polygon_Geodesic().

1146  {
1147  auto l_num_coords = lsize / compression_unit_size(ic);
1148 
1149  double length = 0.0;
1150 
1151  Point2D l0 = get_point(l, 0, ic, isr, osr);
1152  Point2D l2 = l0;
1153  for (int32_t i = 2; i < l_num_coords; i += 2) {
1154  Point2D l1 = l2;
1155  l2 = get_point(l, i, ic, isr, osr);
1156  double ldist = geodesic ? distance_in_meters(l1.x, l1.y, l2.x, l2.y)
1157  : distance_point_point(l1.x, l1.y, l2.x, l2.y);
1158  length += ldist;
1159  }
1160  if (check_closed) {
1161  double ldist = geodesic ? distance_in_meters(l2.x, l2.y, l0.x, l0.y)
1162  : distance_point_point(l2.x, l2.y, l0.x, l0.y);
1163  length += ldist;
1164  }
1165  return length;
1166 }
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.
DEVICE ALWAYS_INLINE int32_t compression_unit_size(const int32_t ic)
DEVICE ALWAYS_INLINE Point2D get_point(const int8_t *data, const int32_t x_index, const int32_t ic, const int32_t isr, const int32_t osr)
DEVICE ALWAYS_INLINE double distance_point_point(double p1x, double p1y, double p2x, double p2y)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

DEVICE bool line_intersects_line ( double  l11x,
double  l11y,
double  l12x,
double  l12y,
double  l21x,
double  l21y,
double  l22x,
double  l22y 
)

Definition at line 336 of file ExtensionFunctionsGeo.hpp.

References on_segment(), and orientation().

Referenced by distance_line_line(), distance_line_line_squared(), linestring_intersects_line(), linestring_intersects_linestring(), polygon_contains_point(), and ring_intersects_line().

343  {
344  auto o1 = orientation(l11x, l11y, l12x, l12y, l21x, l21y);
345  auto o2 = orientation(l11x, l11y, l12x, l12y, l22x, l22y);
346  auto o3 = orientation(l21x, l21y, l22x, l22y, l11x, l11y);
347  auto o4 = orientation(l21x, l21y, l22x, l22y, l12x, l12y);
348 
349  // General case
350  if (o1 != o2 && o3 != o4) {
351  return true;
352  }
353 
354  // Special Cases
355  // l11, l12 and l21 are colinear and l21 lies on segment l11-l12
356  if (o1 == 0 && on_segment(l11x, l11y, l21x, l21y, l12x, l12y)) {
357  return true;
358  }
359 
360  // l11, l12 and l21 are colinear and l22 lies on segment l11-l12
361  if (o2 == 0 && on_segment(l11x, l11y, l22x, l22y, l12x, l12y)) {
362  return true;
363  }
364 
365  // l21, l22 and l11 are colinear and l11 lies on segment l21-l22
366  if (o3 == 0 && on_segment(l21x, l21y, l11x, l11y, l22x, l22y)) {
367  return true;
368  }
369 
370  // l21, l22 and l12 are colinear and l12 lies on segment l21-l22
371  if (o4 == 0 && on_segment(l21x, l21y, l12x, l12y, l22x, l22y)) {
372  return true;
373  }
374 
375  return false;
376 }
DEVICE ALWAYS_INLINE bool on_segment(double px, double py, double qx, double qy, double rx, double ry)
DEVICE ALWAYS_INLINE int16_t orientation(double px, double py, double qx, double qy, double rx, double ry)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 
)

Definition at line 379 of file ExtensionFunctionsGeo.hpp.

References get_point(), and line_intersects_line().

Referenced by ring_intersects_line().

387  {
388  Point2D e1 = get_point(l, 0, ic1, isr1, osr);
389  for (int64_t i = 2; i < lnum_coords; i += 2) {
390  Point2D e2 = get_point(l, i, ic1, isr1, osr);
391  if (line_intersects_line(e1.x, e1.y, e2.x, e2.y, l1x, l1y, l2x, l2y)) {
392  return true;
393  }
394  e1 = e2;
395  }
396  return false;
397 }
DEVICE bool line_intersects_line(double l11x, double l11y, double l12x, double l12y, double l21x, double l21y, double l22x, double l22y)
DEVICE ALWAYS_INLINE Point2D get_point(const int8_t *data, const int32_t x_index, const int32_t ic, const int32_t isr, const int32_t osr)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 
)

Definition at line 419 of file ExtensionFunctionsGeo.hpp.

References get_point(), and line_intersects_line().

427  {
428  Point2D e1 = get_point(l, 0, ic1, isr1, osr);
429  for (int64_t i = 2; i < lnum_coords; i += 2) {
430  Point2D e2 = get_point(l, i, ic1, isr1, osr);
431  if (line_intersects_line(e1.x, e1.y, e2.x, e2.y, l1x, l1y, l2x, l2y)) {
432  return true;
433  }
434  e1 = e2;
435  }
436  return false;
437 }
DEVICE bool line_intersects_line(double l11x, double l11y, double l12x, double l12y, double l21x, double l21y, double l22x, double l22y)
DEVICE ALWAYS_INLINE Point2D get_point(const int8_t *data, const int32_t x_index, const int32_t ic, const int32_t isr, const int32_t osr)

+ Here is the call graph for this function:

DEVICE double max_distance_point_line ( double  px,
double  py,
double  l1x,
double  l1y,
double  l2x,
double  l2y 
)

Definition at line 3769 of file ExtensionFunctionsGeo.hpp.

References distance_point_point().

Referenced by max_distance_point_linestring().

3774  {
3775  // TODO: switch to squared distances
3776  double length1 = distance_point_point(px, py, l1x, l1y);
3777  double length2 = distance_point_point(px, py, l2x, l2y);
3778  if (length1 > length2) {
3779  return length1;
3780  }
3781  return length2;
3782 }
DEVICE ALWAYS_INLINE double distance_point_point(double p1x, double p1y, double p2x, double p2y)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

DEVICE ALWAYS_INLINE double max_distance_point_linestring ( int8_t *  p,
int64_t  psize,
int8_t *  l,
int64_t  lsize,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr,
bool  check_closed 
)

Definition at line 3784 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size(), get_point(), and max_distance_point_line().

Referenced by ST_MaxDistance_LineString_Point(), and ST_MaxDistance_Point_LineString().

3793  {
3794  // TODO: switch to squared distances
3795  Point2D pt = get_point(p, 0, ic1, isr1, osr);
3796 
3797  auto l_num_coords = lsize / compression_unit_size(ic2);
3798 
3799  Point2D l1 = get_point(l, 0, ic2, isr2, osr);
3800  Point2D l2 = get_point(l, 2, ic2, isr2, osr);
3801 
3802  double max_dist = max_distance_point_line(pt.x, pt.y, l1.x, l1.y, l2.x, l2.y);
3803  for (int32_t i = 4; i < l_num_coords; i += 2) {
3804  l1 = l2; // advance one point
3805  l2 = get_point(l, i, ic2, isr2, osr);
3806  double ldist = max_distance_point_line(pt.x, pt.y, l1.x, l1.y, l2.x, l2.y);
3807  if (max_dist < ldist) {
3808  max_dist = ldist;
3809  }
3810  }
3811  if (l_num_coords > 4 && check_closed) {
3812  // Also check distance to the closing edge between the first and the last points
3813  l1 = get_point(l, 0, ic2, isr2, osr);
3814  double ldist = max_distance_point_line(pt.x, pt.y, l1.x, l1.y, l2.x, l2.y);
3815  if (max_dist < ldist) {
3816  max_dist = ldist;
3817  }
3818  }
3819  return max_dist;
3820 }
DEVICE double max_distance_point_line(double px, double py, double l1x, double l1y, double l2x, double l2y)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(const int32_t ic)
DEVICE ALWAYS_INLINE Point2D get_point(const int8_t *data, const int32_t x_index, const int32_t ic, const int32_t isr, const int32_t osr)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

DEVICE ALWAYS_INLINE bool on_segment ( double  px,
double  py,
double  qx,
double  qy,
double  rx,
double  ry 
)

Definition at line 312 of file ExtensionFunctionsGeo.hpp.

References tol_ge(), and tol_le().

Referenced by line_intersects_line().

317  {
318  return (tol_le(qx, fmax(px, rx)) && tol_ge(qx, fmin(px, rx)) &&
319  tol_le(qy, fmax(py, ry)) && tol_ge(qy, fmin(py, ry)));
320 }
DEVICE ALWAYS_INLINE bool tol_le(const double x, const double y, const double tolerance=TOLERANCE_DEFAULT)
DEVICE ALWAYS_INLINE bool tol_ge(const double x, const double y, const double tolerance=TOLERANCE_DEFAULT)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

DEVICE ALWAYS_INLINE int16_t orientation ( double  px,
double  py,
double  qx,
double  qy,
double  rx,
double  ry 
)

Definition at line 323 of file ExtensionFunctionsGeo.hpp.

References tol_zero().

Referenced by line_intersects_line().

323  {
324  auto val = ((qy - py) * (rx - qx) - (qx - px) * (ry - qy));
325  if (tol_zero(val)) {
326  return 0; // Points p, q and r are colinear
327  }
328  if (val > 0.0) {
329  return 1; // Clockwise point orientation
330  }
331  return 2; // Counterclockwise point orientation
332 }
DEVICE ALWAYS_INLINE bool tol_zero(const double x, const double tolerance=TOLERANCE_DEFAULT)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

DEVICE ALWAYS_INLINE double perimeter_multipolygon ( int8_t *  mpoly_coords,
int32_t  mpoly_coords_size,
int8_t *  mpoly_ring_sizes_in,
int32_t  mpoly_num_rings,
int8_t *  mpoly_poly_sizes,
int32_t  mpoly_num_polys,
int32_t  ic,
int32_t  isr,
int32_t  osr,
bool  geodesic 
)

Definition at line 1257 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size(), and length_linestring().

Referenced by ST_Perimeter_MultiPolygon(), and ST_Perimeter_MultiPolygon_Geodesic().

1266  {
1267  if (mpoly_num_polys <= 0 || mpoly_num_rings <= 0) {
1268  return 0.0;
1269  }
1270 
1271  double perimeter = 0.0;
1272 
1273  auto mpoly_ring_sizes = reinterpret_cast<int32_t*>(mpoly_ring_sizes_in);
1274 
1275  // Set specific poly pointers as we move through the coords/ringsizes/polyrings arrays.
1276  auto next_poly_coords = mpoly_coords;
1277  auto next_poly_ring_sizes = mpoly_ring_sizes;
1278 
1279  for (auto poly = 0; poly < mpoly_num_polys; poly++) {
1280  auto poly_coords = next_poly_coords;
1281  auto poly_ring_sizes = next_poly_ring_sizes;
1282  auto poly_num_rings = reinterpret_cast<int32_t*>(mpoly_poly_sizes)[poly];
1283  // Count number of coords in all of poly's rings, advance ring size pointer.
1284  int32_t poly_num_coords = 0;
1285  for (auto ring = 0; ring < poly_num_rings; ring++) {
1286  poly_num_coords += 2 * *next_poly_ring_sizes++;
1287  }
1288  auto poly_coords_size = poly_num_coords * compression_unit_size(ic);
1289  next_poly_coords += poly_coords_size;
1290 
1291  auto exterior_ring_num_coords = poly_ring_sizes[0] * 2;
1292  auto exterior_ring_coords_size = exterior_ring_num_coords * compression_unit_size(ic);
1293 
1294  perimeter += length_linestring(
1295  poly_coords, exterior_ring_coords_size, ic, isr, osr, geodesic, true);
1296  }
1297 
1298  return perimeter;
1299 }
DEVICE ALWAYS_INLINE double length_linestring(int8_t *l, int32_t lsize, int32_t ic, int32_t isr, int32_t osr, bool geodesic, bool check_closed)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(const int32_t ic)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 
)

Definition at line 921 of file ExtensionFunctionsGeo.hpp.

References get_point().

Referenced by ST_DWithin_Point_LineString(), ST_DWithin_Point_MultiPolygon(), and ST_DWithin_Point_Polygon().

929  {
930  // TODO: tolerance
931 
932  // Point has to be uncompressed and transformed to output SR.
933  // Bounding box has to be transformed to output SR.
934  Point2D p = get_point(p1, 0, ic1, isr1, osr);
935  Point2D const lb = transform_point<XY>({bounds2[0], bounds2[1]}, isr2, osr);
936  Point2D const rt = transform_point<XY>({bounds2[2], bounds2[3]}, isr2, osr);
937  if (p.x < lb.x - distance || // point is left of box2: px < box2.xmin - distance
938  p.x > rt.x + distance || // point is right of box2: px > box2.xmax + distance
939  p.y < lb.y - distance || // point is below box2: py < box2.ymin - distance
940  p.y > rt.y + distance) { // point is above box2: py > box2.ymax + distance
941  return false;
942  }
943  return true;
944 }
DEVICE ALWAYS_INLINE Point2D get_point(const int8_t *data, const int32_t x_index, const int32_t ic, const int32_t isr, const int32_t osr)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename T , EdgeBehavior TEdgeBehavior>
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 
)

Computes whether the point p is inside the polygon poly using the winding number algorithm. The winding number algorithm efficiently computes the winding number, which is the number of revolutions made around a point P while traveling around the polygon. If the winding number is non-zero, then P must be inside the polygon. The actual algorithm loops over all edges in the polygon, and determines the location of the crossing between a ray from the point P and each edge E of the polygon. In the implementation below, this crossing calculation is performed by assigning a fixed orientation to each edge, then computing the location of the point with respect to that edge. The parameter include_point_on_edge allows the algorithm to work for both point-inside-polygon, or point-on-polygon calculations. The original source and additional detail for this implementation is here: http://geomalgorithms.com/a03-_inclusion.html

Definition at line 587 of file ExtensionFunctionsGeo.hpp.

References compressed_coord(), DEBUG_STMT, get_point(), is_left(), kIncludePointOnEdge, heavydb.dtypes::T, tol_zero_template(), and UNLIKELY.

593  {
594  int32_t wn = 0;
595 
596  constexpr bool include_point_on_edge =
597  TEdgeBehavior == EdgeBehavior::kIncludePointOnEdge;
598 
599  auto get_x_coord = [=](const auto data, const auto index) -> T {
600  if constexpr (std::is_floating_point<T>::value) {
601  return get_point(data, index, ic1, isr1, osr).x;
602  } else {
603  return compressed_coord(data, index);
604  }
605  return T{}; // https://stackoverflow.com/a/64561686/2700898
606  };
607 
608  auto get_y_coord = [=](const auto data, const auto index) -> T {
609  if constexpr (std::is_floating_point<T>::value) {
610  return get_point(data, index, ic1, isr1, osr).y;
611  } else {
612  return compressed_coord(data, index + 1);
613  }
614  return T{}; // https://stackoverflow.com/a/64561686/2700898
615  };
616 
617  DEBUG_STMT(printf("Poly num coords: %d\n", poly_num_coords));
618  const int64_t num_edges = poly_num_coords / 2;
619 
620  int64_t e0_index = 0;
621  T e0x = get_x_coord(poly, e0_index * 2);
622  T e0y = get_y_coord(poly, e0_index * 2);
623 
624  int64_t e1_index;
625  T e1x, e1y;
626 
627  for (int64_t edge = 1; edge <= num_edges; edge++) {
628  DEBUG_STMT(printf("Edge %ld\n", edge));
629  // build the edge
630  e1_index = edge % num_edges;
631  e1x = get_x_coord(poly, e1_index * 2);
632  e1y = get_y_coord(poly, e1_index * 2);
633 
634  DEBUG_STMT(printf("edge 0: %ld : %f, %f\n", e0_index, (double)e0x, (double)e0y));
635  DEBUG_STMT(printf("edge 1: %ld : %f, %f\n", e1_index, (double)e1x, (double)e1y));
636 
637  auto get_epsilon = [=]() -> T {
638  if constexpr (std::is_floating_point<T>::value) {
639  const T edge_vec_magnitude =
640  (e1x - e0x) * (e1x - e0x) + (e1y - e0y) * (e1y - e0y);
641  return 0.003 * edge_vec_magnitude;
642  } else {
643  return T(0);
644  }
645  return T{}; // https://stackoverflow.com/a/64561686/2700898
646  };
647 
648  const T epsilon = get_epsilon();
649  DEBUG_STMT(printf("using epsilon value %e\n", (double)epsilon));
650 
651  if constexpr (include_point_on_edge) {
652  const T xp = (px - e1x) * (e0y - e1y) - (py - e1y) * (e0x - e1x);
653  const T pt_vec_magnitude = (px - e0x) * (px - e0x) + (py - e0y) * (py - e0y);
654  const T edge_vec_magnitude = (e1x - e0x) * (e1x - e0x) + (e1y - e0y) * (e1y - e0y);
655  if (tol_zero_template(xp, epsilon) && (pt_vec_magnitude <= edge_vec_magnitude)) {
656  DEBUG_STMT(printf("point is on edge: %e && %e <= %e\n",
657  (double)xp,
658  (double)pt_vec_magnitude,
659  (double)edge_vec_magnitude));
660  return include_point_on_edge;
661  }
662  }
663 
664  if (e0y <= py) {
665  if (e1y > py) {
666  // upward crossing
667  DEBUG_STMT(printf("upward crossing\n"));
668  const auto is_left_val = is_left(e0x, e0y, e1x, e1y, px, py);
669  DEBUG_STMT(printf("Left val %f and tol zero left val %d\n",
670  (double)is_left_val,
671  tol_zero_template(is_left_val, epsilon)));
672  if (UNLIKELY(tol_zero_template(is_left_val, epsilon))) {
673  // p is on the edge
674  return include_point_on_edge;
675  } else if (is_left_val > T(0)) { // p left of edge
676  // valid up intersection
677  DEBUG_STMT(printf("++wn\n"));
678  ++wn;
679  }
680  }
681  } else if (e1y <= py) {
682  // downward crossing
683  DEBUG_STMT(printf("downward crossing\n"));
684  const auto is_left_val = is_left(e0x, e0y, e1x, e1y, px, py);
685  DEBUG_STMT(printf("Left val %f and tol zero left val %d\n",
686  (double)is_left_val,
687  tol_zero_template(is_left_val, epsilon)));
688  if (UNLIKELY(tol_zero_template(is_left_val, epsilon))) {
689  // p is on the edge
690  return include_point_on_edge;
691  } else if (is_left_val < T(0)) { // p right of edge
692  // valid down intersection
693  DEBUG_STMT(printf("--wn\n"));
694  --wn;
695  }
696  }
697 
698  e0_index = e1_index;
699  e0x = e1x;
700  e0y = e1y;
701  }
702  DEBUG_STMT(printf("wn: %d\n", wn));
703  // wn == 0 --> P is outside the polygon
704  return !(wn == 0);
705 }
DEVICE ALWAYS_INLINE int32_t compressed_coord(const int8_t *data, const int32_t index)
DEVICE ALWAYS_INLINE T is_left(const T lx0, const T ly0, const T lx1, const T ly1, const T px, const T py)
#define DEBUG_STMT(x)
DEVICE ALWAYS_INLINE bool tol_zero_template(const T x, const T tolerance=TOLERANCE_DEFAULT)
#define UNLIKELY(x)
Definition: likely.h:25
DEVICE ALWAYS_INLINE Point2D get_point(const int8_t *data, const int32_t x_index, const int32_t ic, const int32_t isr, const int32_t osr)

+ Here is the call graph for this function:

EXTENSION_NOINLINE bool Point_Overlaps_Box ( double *  bounds,
int64_t  bounds_size,
double  px,
double  py 
)

Definition at line 870 of file ExtensionFunctionsGeo.hpp.

References box_contains_point().

873  {
874  // TODO: mixed spatial references
875  return box_contains_point(bounds, bounds_size, px, py);
876 }
DEVICE ALWAYS_INLINE bool box_contains_point(const double *bounds, const int64_t bounds_size, const double px, const double py)

+ Here is the call graph for this function:

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 
)

Definition at line 833 of file ExtensionFunctionsGeo.hpp.

References get_point(), polygon_contains_point(), and ring_intersects_line().

Referenced by ST_Contains_Polygon_LineString().

841  {
842  // Check that the first point is in the polygon
843  Point2D l1 = get_point(l, 0, ic2, isr2, osr);
844  if (!polygon_contains_point(poly, poly_num_coords, l1.x, l1.y, ic1, isr1, osr)) {
845  return false;
846  }
847 
848  // Go through line segments and check if there are no intersections with poly edges,
849  // i.e. linestring doesn't escape
850  for (int32_t i = 2; i < lnum_coords; i += 2) {
851  Point2D l2 = get_point(l, i, ic2, isr2, osr);
853  poly, poly_num_coords, l1.x, l1.y, l2.x, l2.y, ic1, isr1, osr)) {
854  return false;
855  }
856  l1 = l2;
857  }
858  return true;
859 }
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 Point2D get_point(const int8_t *data, const int32_t x_index, const int32_t ic, const int32_t isr, const 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)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 
)

Definition at line 721 of file ExtensionFunctionsGeo.hpp.

References distance_point_line(), get_point(), line_intersects_line(), run_benchmark_import::result, tol_eq(), and tol_zero().

Referenced by distance_point_polygon(), and polygon_contains_linestring().

727  {
728  bool result = false;
729  int xray_touch = 0;
730  bool horizontal_edge = false;
731  bool yray_intersects = false;
732 
733  Point2D e1 = get_point(poly, poly_num_coords - 2, ic1, isr1, osr);
734  for (int64_t i = 0; i < poly_num_coords; i += 2) {
735  Point2D e2 = get_point(poly, i, ic1, isr1, osr);
736 
737  // Check if point sits on an edge.
738  if (tol_zero(distance_point_line(px, py, e1.x, e1.y, e2.x, e2.y))) {
739  return true;
740  }
741 
742  // Before flipping the switch, check if xray hit a horizontal edge
743  // - If an edge lays on the xray, one of the previous edges touched it
744  // so while moving horizontally we're in 'xray_touch' state
745  // - Last edge that touched xray at (e2.x,e2.y) didn't register intersection
746  // - Next edge that diverges from xray at (e1,e1y) will register intersection
747  // - Can have several horizontal edges, one after the other, keep moving though
748  // in 'xray_touch' state without flipping the switch
749  horizontal_edge = (xray_touch != 0) && tol_eq(py, e1.y) && tol_eq(py, e2.y);
750 
751  // Main probe: xray
752  // Overshoot the xray to detect an intersection if there is one.
753  double xray = fmax(e2.x, e1.x) + 1.0;
754  if (px <= xray && // Only check for intersection if the edge is on the right
755  !horizontal_edge && // Keep moving through horizontal edges
756  line_intersects_line(px, // xray shooting from point p to the right
757  py,
758  xray,
759  py,
760  e1.x, // polygon edge
761  e1.y,
762  e2.x,
763  e2.y)) {
764  // Register intersection
765  result = !result;
766 
767  // Adjust for special cases
768  if (xray_touch == 0) {
769  if (tol_zero(distance_point_line(e2.x, e2.y, px, py, xray + 1.0, py))) {
770  // Xray goes through the edge's second vertex, unregister intersection -
771  // that vertex will be crossed again when we look at the following edge(s)
772  result = !result;
773  // Enter the xray-touch state:
774  // (1) - xray was touched by the edge from above, (-1) from below
775  xray_touch = (e1.y > py) ? 1 : -1;
776  }
777  } else {
778  // Previous edge touched the xray, intersection hasn't been registered,
779  // it has to be registered now if this edge continues across the xray.
780  if (xray_touch > 0) {
781  // Previous edge touched the xray from above
782  if (e2.y <= py) {
783  // Current edge crosses under xray: intersection is already registered
784  } else {
785  // Current edge just touched the xray and pulled up: unregister intersection
786  result = !result;
787  }
788  } else {
789  // Previous edge touched the xray from below
790  if (e2.y > py) {
791  // Current edge crosses over xray: intersection is already registered
792  } else {
793  // Current edge just touched the xray and pulled down: unregister intersection
794  result = !result;
795  }
796  }
797  // Exit the xray-touch state
798  xray_touch = 0;
799  }
800  }
801 
802  // Redundancy: vertical yray down
803  // Main probe xray may hit multiple complex fragments which increases a chance of
804  // error. Perform a simple secondary check for edge intersections to see if point is
805  // outside.
806  if (!yray_intersects) { // Continue checking on yray until intersection is found
807  double yray = fmin(e2.y, e1.y) - 1.0;
808  if (yray <= py) { // Only check for yray intersection if point P is above the edge
809  yray_intersects = line_intersects_line(px, // yray shooting from point P down
810  py,
811  px,
812  yray,
813  e1.x, // polygon edge
814  e1.y,
815  e2.x,
816  e2.y);
817  }
818  }
819 
820  // Advance to the next vertex
821  e1 = e2;
822  }
823  if (!yray_intersects) {
824  // yray has zero intersections - point is outside the polygon
825  return false;
826  }
827  // Otherwise rely on the main probe
828  return result;
829 }
DEVICE double distance_point_line(double px, double py, double l1x, double l1y, double l2x, double l2y)
DEVICE bool line_intersects_line(double l11x, double l11y, double l12x, double l12y, double l21x, double l21y, double l22x, double l22y)
DEVICE ALWAYS_INLINE bool tol_zero(const double x, const double tolerance=TOLERANCE_DEFAULT)
DEVICE ALWAYS_INLINE Point2D get_point(const int8_t *data, const int32_t x_index, const int32_t ic, const int32_t isr, const int32_t osr)
DEVICE ALWAYS_INLINE bool tol_eq(const double x, const double y, const double tolerance=TOLERANCE_DEFAULT)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 
)

Definition at line 400 of file ExtensionFunctionsGeo.hpp.

References get_point(), line_intersects_line(), and linestring_intersects_line().

Referenced by polygon_contains_linestring().

408  {
409  Point2D e1 = get_point(ring, ring_num_coords - 2, ic1, isr1, osr);
410  Point2D e2 = get_point(ring, 0, ic1, isr1, osr);
411  if (line_intersects_line(e1.x, e1.y, e2.x, e2.y, l1x, l1y, l2x, l2y)) {
412  return true;
413  }
415  ring, ring_num_coords, l1x, l1y, l2x, l2y, ic1, isr1, osr);
416 }
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)
DEVICE bool line_intersects_line(double l11x, double l11y, double l12x, double l12y, double l21x, double l21y, double l22x, double l22y)
DEVICE ALWAYS_INLINE Point2D get_point(const int8_t *data, const int32_t x_index, const int32_t ic, const int32_t isr, const int32_t osr)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_NOINLINE double ST_Area_MultiPolygon ( int8_t *  mpoly_coords,
int32_t  mpoly_coords_size,
int8_t *  mpoly_ring_sizes,
int32_t  mpoly_num_rings,
int8_t *  mpoly_poly_sizes_in,
int32_t  mpoly_num_polys,
int32_t  ic,
int32_t  isr,
int32_t  osr 
)

Definition at line 1421 of file ExtensionFunctionsGeo.hpp.

References area_polygon(), and compression_unit_size().

1429  {
1430  if (mpoly_num_rings <= 0 || mpoly_num_polys <= 0) {
1431  return 0.0;
1432  }
1433 
1434  double area = 0.0;
1435 
1436  auto mpoly_poly_sizes = reinterpret_cast<int32_t*>(mpoly_poly_sizes_in);
1437 
1438  // Set specific poly pointers as we move through the coords/ringsizes/polyrings arrays.
1439  auto next_poly_coords = mpoly_coords;
1440  auto next_poly_ring_sizes = reinterpret_cast<int32_t*>(mpoly_ring_sizes);
1441 
1442  for (auto poly = 0; poly < mpoly_num_polys; poly++) {
1443  auto poly_coords = next_poly_coords;
1444  auto poly_ring_sizes = next_poly_ring_sizes;
1445  auto poly_num_rings = mpoly_poly_sizes[poly];
1446  // Count number of coords in all of poly's rings, advance ring size pointer.
1447  int32_t poly_num_coords = 0;
1448  for (auto ring = 0; ring < poly_num_rings; ring++) {
1449  poly_num_coords += 2 * *next_poly_ring_sizes++;
1450  }
1451  auto poly_coords_size = poly_num_coords * compression_unit_size(ic);
1452  next_poly_coords += poly_coords_size;
1453 
1454  area += area_polygon(poly_coords,
1455  poly_coords_size,
1456  reinterpret_cast<int8_t*>(poly_ring_sizes),
1457  poly_num_rings,
1458  ic,
1459  isr,
1460  osr);
1461  }
1462  return area;
1463 }
DEVICE ALWAYS_INLINE double area_polygon(int8_t *poly_coords, int32_t poly_coords_size, int8_t *poly_ring_sizes_in, int32_t poly_num_rings, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(const int32_t ic)

+ Here is the call graph for this function:

EXTENSION_NOINLINE double ST_Area_Polygon ( int8_t *  poly_coords,
int32_t  poly_coords_size,
int8_t *  poly_ring_sizes,
int32_t  poly_num_rings,
int32_t  ic,
int32_t  isr,
int32_t  osr 
)

Definition at line 1409 of file ExtensionFunctionsGeo.hpp.

References area_polygon().

1415  {
1416  return area_polygon(
1417  poly_coords, poly_coords_size, poly_ring_sizes, poly_num_rings, ic, isr, osr);
1418 }
DEVICE ALWAYS_INLINE double area_polygon(int8_t *poly_coords, int32_t poly_coords_size, int8_t *poly_ring_sizes_in, int32_t poly_num_rings, int32_t ic, int32_t isr, int32_t osr)

+ Here is the call graph for this function:

EXTENSION_NOINLINE TextEncodingNone ST_AsBinary__GeoLineString__cpu_ ( RowFunctionManager mgr,
GeoLineString l 
)

Definition at line 5326 of file ExtensionFunctionsGeo.hpp.

References __wkb_to_str(), and to_Geospatial_GeoLineString().

Referenced by ST_AsWkb__GeoLineString__cpu_().

5326  {
5328  std::string wkb = __wkb_to_str(linestring);
5329  return TextEncodingNone(mgr, wkb);
5330 }
Geospatial::GeoLineString to_Geospatial_GeoLineString(GeoLineString &l)
ALWAYS_INLINE std::string __wkb_to_str(T &geometry)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_NOINLINE TextEncodingNone ST_AsBinary__GeoMultiLineString__cpu_ ( RowFunctionManager mgr,
GeoMultiLineString ml 
)

Definition at line 5333 of file ExtensionFunctionsGeo.hpp.

References __wkb_to_str(), and to_Geospatial_GeoMultiLineString().

Referenced by ST_AsWkb__GeoMultiLineString__cpu_().

5333  {
5335  std::string wkb = __wkb_to_str(multilinestring);
5336  return TextEncodingNone(mgr, wkb);
5337 }
Geospatial::GeoMultiLineString to_Geospatial_GeoMultiLineString(GeoMultiLineString &ml)
ALWAYS_INLINE std::string __wkb_to_str(T &geometry)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_NOINLINE TextEncodingNone ST_AsBinary__GeoMultiPoint__cpu_ ( RowFunctionManager mgr,
GeoMultiPoint mp 
)

Definition at line 5319 of file ExtensionFunctionsGeo.hpp.

References __wkb_to_str(), and to_Geospatial_GeoMultiPoint().

Referenced by ST_AsWkb__GeoMultiPoint__cpu_().

5319  {
5321  std::string wkb = __wkb_to_str(multipoint);
5322  return TextEncodingNone(mgr, wkb);
5323 }
Geospatial::GeoMultiPoint to_Geospatial_GeoMultiPoint(GeoMultiPoint &mp)
ALWAYS_INLINE std::string __wkb_to_str(T &geometry)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_NOINLINE TextEncodingNone ST_AsBinary__GeoMultiPolygon__cpu_ ( RowFunctionManager mgr,
GeoMultiPolygon mp 
)

Definition at line 5347 of file ExtensionFunctionsGeo.hpp.

References __wkb_to_str(), and to_Geospatial_GeoMultiPolygon().

Referenced by ST_AsWkb__GeoMultiPolygon__cpu_().

5347  {
5349  std::string wkb = __wkb_to_str(multipolygon);
5350  return TextEncodingNone(mgr, wkb);
5351 }
ALWAYS_INLINE std::string __wkb_to_str(T &geometry)
Geospatial::GeoMultiPolygon to_Geospatial_GeoMultiPolygon(GeoMultiPolygon &mp)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_NOINLINE TextEncodingNone ST_AsBinary__GeoPoint__cpu_ ( RowFunctionManager mgr,
GeoPoint p 
)

Definition at line 5311 of file ExtensionFunctionsGeo.hpp.

References __wkb_to_str(), and to_Geospatial_GeoPoint().

Referenced by ST_AsWkb__GeoPoint__cpu_().

5312  {
5314  std::string wkb = __wkb_to_str(point);
5315  return TextEncodingNone(mgr, wkb);
5316 }
Geospatial::GeoPoint to_Geospatial_GeoPoint(GeoPoint &p)
ALWAYS_INLINE std::string __wkb_to_str(T &geometry)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_NOINLINE TextEncodingNone ST_AsBinary__GeoPolygon__cpu_ ( RowFunctionManager mgr,
GeoPolygon p 
)

Definition at line 5339 of file ExtensionFunctionsGeo.hpp.

References __wkb_to_str(), and to_Geospatial_GeoPolygon().

Referenced by ST_AsWkb__GeoPolygon__cpu_().

5340  {
5342  std::string wkb = __wkb_to_str(polygon);
5343  return TextEncodingNone(mgr, wkb);
5344 }
ALWAYS_INLINE std::string __wkb_to_str(T &geometry)
Geospatial::GeoPolygon to_Geospatial_GeoPolygon(GeoPolygon &p)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_NOINLINE TextEncodingNone ST_AsText__GeoLineString__cpu_ ( RowFunctionManager mgr,
GeoLineString l 
)

Definition at line 5220 of file ExtensionFunctionsGeo.hpp.

References Geospatial::GeoBase::getWktString(), and to_Geospatial_GeoLineString().

Referenced by ST_AsWkt__GeoLineString__cpu_().

5220  {
5222  std::string wkt = linestring.getWktString();
5223  return TextEncodingNone(mgr, wkt);
5224 }
Geospatial::GeoLineString to_Geospatial_GeoLineString(GeoLineString &l)
std::string getWktString() const
Definition: Types.cpp:165

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_NOINLINE TextEncodingNone ST_AsText__GeoMultiLineString__cpu_ ( RowFunctionManager mgr,
GeoMultiLineString ml 
)

Definition at line 5227 of file ExtensionFunctionsGeo.hpp.

References Geospatial::GeoBase::getWktString(), and to_Geospatial_GeoMultiLineString().

Referenced by ST_AsWkt__GeoMultiLineString__cpu_().

5227  {
5229  std::string wkt = multilinestring.getWktString();
5230  return TextEncodingNone(mgr, wkt);
5231 }
Geospatial::GeoMultiLineString to_Geospatial_GeoMultiLineString(GeoMultiLineString &ml)
std::string getWktString() const
Definition: Types.cpp:165

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_NOINLINE TextEncodingNone ST_AsText__GeoMultiPoint__cpu_ ( RowFunctionManager mgr,
GeoMultiPoint mp 
)

Definition at line 5213 of file ExtensionFunctionsGeo.hpp.

References Geospatial::GeoBase::getWktString(), and to_Geospatial_GeoMultiPoint().

Referenced by ST_AsWkt__GeoMultiPoint__cpu_().

5213  {
5215  std::string wkt = multipoint.getWktString();
5216  return TextEncodingNone(mgr, wkt);
5217 }
Geospatial::GeoMultiPoint to_Geospatial_GeoMultiPoint(GeoMultiPoint &mp)
std::string getWktString() const
Definition: Types.cpp:165

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_NOINLINE TextEncodingNone ST_AsText__GeoMultiPolygon__cpu_ ( RowFunctionManager mgr,
GeoMultiPolygon mp 
)

Definition at line 5241 of file ExtensionFunctionsGeo.hpp.

References Geospatial::GeoBase::getWktString(), and to_Geospatial_GeoMultiPolygon().

Referenced by ST_AsWkt__GeoMultiPolygon__cpu_().

5241  {
5243  std::string wkt = multipolygon.getWktString();
5244  return TextEncodingNone(mgr, wkt);
5245 }
std::string getWktString() const
Definition: Types.cpp:165
Geospatial::GeoMultiPolygon to_Geospatial_GeoMultiPolygon(GeoMultiPolygon &mp)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_NOINLINE TextEncodingNone ST_AsText__GeoPoint__cpu_ ( RowFunctionManager mgr,
GeoPoint p 
)

Definition at line 5205 of file ExtensionFunctionsGeo.hpp.

References Geospatial::GeoBase::getWktString(), and to_Geospatial_GeoPoint().

Referenced by ST_AsWkt__GeoPoint__cpu_().

5206  {
5208  std::string wkt = point.getWktString();
5209  return TextEncodingNone(mgr, wkt);
5210 }
Geospatial::GeoPoint to_Geospatial_GeoPoint(GeoPoint &p)
std::string getWktString() const
Definition: Types.cpp:165

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_NOINLINE TextEncodingNone ST_AsText__GeoPolygon__cpu_ ( RowFunctionManager mgr,
GeoPolygon p 
)

Definition at line 5233 of file ExtensionFunctionsGeo.hpp.

References Geospatial::GeoBase::getWktString(), and to_Geospatial_GeoPolygon().

Referenced by ST_AsWkt__GeoPolygon__cpu_().

5234  {
5236  std::string wkt = polygon.getWktString();
5237  return TextEncodingNone(mgr, wkt);
5238 }
Geospatial::GeoPolygon to_Geospatial_GeoPolygon(GeoPolygon &p)
std::string getWktString() const
Definition: Types.cpp:165

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_NOINLINE TextEncodingNone ST_AsWkb__GeoLineString__cpu_ ( RowFunctionManager mgr,
GeoLineString p 
)

Definition at line 5371 of file ExtensionFunctionsGeo.hpp.

References ST_AsBinary__GeoLineString__cpu_().

5372  {
5373  return ST_AsBinary__GeoLineString__cpu_(mgr, p);
5374 }
EXTENSION_NOINLINE TextEncodingNone ST_AsBinary__GeoLineString__cpu_(RowFunctionManager &mgr, GeoLineString &l)

+ Here is the call graph for this function:

EXTENSION_NOINLINE TextEncodingNone ST_AsWkb__GeoMultiLineString__cpu_ ( RowFunctionManager mgr,
GeoMultiLineString p 
)

Definition at line 5377 of file ExtensionFunctionsGeo.hpp.

References ST_AsBinary__GeoMultiLineString__cpu_().

5377  {
5379 }
EXTENSION_NOINLINE TextEncodingNone ST_AsBinary__GeoMultiLineString__cpu_(RowFunctionManager &mgr, GeoMultiLineString &ml)

+ Here is the call graph for this function:

EXTENSION_NOINLINE TextEncodingNone ST_AsWkb__GeoMultiPoint__cpu_ ( RowFunctionManager mgr,
GeoMultiPoint p 
)

Definition at line 5366 of file ExtensionFunctionsGeo.hpp.

References ST_AsBinary__GeoMultiPoint__cpu_().

5367  {
5368  return ST_AsBinary__GeoMultiPoint__cpu_(mgr, p);
5369 }
EXTENSION_NOINLINE TextEncodingNone ST_AsBinary__GeoMultiPoint__cpu_(RowFunctionManager &mgr, GeoMultiPoint &mp)

+ Here is the call graph for this function:

EXTENSION_NOINLINE TextEncodingNone ST_AsWkb__GeoMultiPolygon__cpu_ ( RowFunctionManager mgr,
GeoMultiPolygon p 
)

Definition at line 5387 of file ExtensionFunctionsGeo.hpp.

References ST_AsBinary__GeoMultiPolygon__cpu_().

5387  {
5388  return ST_AsBinary__GeoMultiPolygon__cpu_(mgr, p);
5389 }
EXTENSION_NOINLINE TextEncodingNone ST_AsBinary__GeoMultiPolygon__cpu_(RowFunctionManager &mgr, GeoMultiPolygon &mp)

+ Here is the call graph for this function:

EXTENSION_NOINLINE TextEncodingNone ST_AsWkb__GeoPoint__cpu_ ( RowFunctionManager mgr,
GeoPoint p 
)

Definition at line 5361 of file ExtensionFunctionsGeo.hpp.

References ST_AsBinary__GeoPoint__cpu_().

5362  {
5363  return ST_AsBinary__GeoPoint__cpu_(mgr, p);
5364 }
EXTENSION_NOINLINE TextEncodingNone ST_AsBinary__GeoPoint__cpu_(RowFunctionManager &mgr, GeoPoint &p)

+ Here is the call graph for this function:

EXTENSION_NOINLINE TextEncodingNone ST_AsWkb__GeoPolygon__cpu_ ( RowFunctionManager mgr,
GeoPolygon p 
)

Definition at line 5381 of file ExtensionFunctionsGeo.hpp.

References ST_AsBinary__GeoPolygon__cpu_().

5382  {
5383  return ST_AsBinary__GeoPolygon__cpu_(mgr, p);
5384 }
EXTENSION_NOINLINE TextEncodingNone ST_AsBinary__GeoPolygon__cpu_(RowFunctionManager &mgr, GeoPolygon &p)

+ Here is the call graph for this function:

EXTENSION_NOINLINE TextEncodingNone ST_AsWkt__GeoLineString__cpu_ ( RowFunctionManager mgr,
GeoLineString p 
)

Definition at line 5265 of file ExtensionFunctionsGeo.hpp.

References ST_AsText__GeoLineString__cpu_().

5266  {
5267  return ST_AsText__GeoLineString__cpu_(mgr, p);
5268 }
EXTENSION_NOINLINE TextEncodingNone ST_AsText__GeoLineString__cpu_(RowFunctionManager &mgr, GeoLineString &l)

+ Here is the call graph for this function:

EXTENSION_NOINLINE TextEncodingNone ST_AsWkt__GeoMultiLineString__cpu_ ( RowFunctionManager mgr,
GeoMultiLineString p 
)

Definition at line 5271 of file ExtensionFunctionsGeo.hpp.

References ST_AsText__GeoMultiLineString__cpu_().

5271  {
5272  return ST_AsText__GeoMultiLineString__cpu_(mgr, p);
5273 }
EXTENSION_NOINLINE TextEncodingNone ST_AsText__GeoMultiLineString__cpu_(RowFunctionManager &mgr, GeoMultiLineString &ml)

+ Here is the call graph for this function:

EXTENSION_NOINLINE TextEncodingNone ST_AsWkt__GeoMultiPoint__cpu_ ( RowFunctionManager mgr,
GeoMultiPoint p 
)

Definition at line 5260 of file ExtensionFunctionsGeo.hpp.

References ST_AsText__GeoMultiPoint__cpu_().

5261  {
5262  return ST_AsText__GeoMultiPoint__cpu_(mgr, p);
5263 }
EXTENSION_NOINLINE TextEncodingNone ST_AsText__GeoMultiPoint__cpu_(RowFunctionManager &mgr, GeoMultiPoint &mp)

+ Here is the call graph for this function:

EXTENSION_NOINLINE TextEncodingNone ST_AsWkt__GeoMultiPolygon__cpu_ ( RowFunctionManager mgr,
GeoMultiPolygon p 
)

Definition at line 5281 of file ExtensionFunctionsGeo.hpp.

References ST_AsText__GeoMultiPolygon__cpu_().

5281  {
5282  return ST_AsText__GeoMultiPolygon__cpu_(mgr, p);
5283 }
EXTENSION_NOINLINE TextEncodingNone ST_AsText__GeoMultiPolygon__cpu_(RowFunctionManager &mgr, GeoMultiPolygon &mp)

+ Here is the call graph for this function:

EXTENSION_NOINLINE TextEncodingNone ST_AsWkt__GeoPoint__cpu_ ( RowFunctionManager mgr,
GeoPoint p 
)

Definition at line 5255 of file ExtensionFunctionsGeo.hpp.

References ST_AsText__GeoPoint__cpu_().

5256  {
5257  return ST_AsText__GeoPoint__cpu_(mgr, p);
5258 }
EXTENSION_NOINLINE TextEncodingNone ST_AsText__GeoPoint__cpu_(RowFunctionManager &mgr, GeoPoint &p)

+ Here is the call graph for this function:

EXTENSION_NOINLINE TextEncodingNone ST_AsWkt__GeoPolygon__cpu_ ( RowFunctionManager mgr,
GeoPolygon p 
)

Definition at line 5275 of file ExtensionFunctionsGeo.hpp.

References ST_AsText__GeoPolygon__cpu_().

5276  {
5277  return ST_AsText__GeoPolygon__cpu_(mgr, p);
5278 }
EXTENSION_NOINLINE TextEncodingNone ST_AsText__GeoPolygon__cpu_(RowFunctionManager &mgr, GeoPolygon &p)

+ Here is the call graph for this function:

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 
)

Definition at line 4287 of file ExtensionFunctionsGeo.hpp.

4301  {
4302  return Contains_MultiPolygon_Point_Impl<int64_t, EdgeBehavior::kExcludePointOnEdge>(
4303  mpoly_coords,
4304  mpoly_coords_size,
4305  mpoly_ring_sizes,
4306  mpoly_num_rings,
4307  mpoly_poly_sizes,
4308  mpoly_num_polys,
4309  mpoly_bounds,
4310  mpoly_bounds_size,
4311  p,
4312  psize,
4313  ic1,
4314  isr1,
4315  ic2,
4316  isr2,
4317  osr);
4318 }
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 
)

Definition at line 4070 of file ExtensionFunctionsGeo.hpp.

4082  {
4083  return Contains_Polygon_Point_Impl<int64_t, EdgeBehavior::kExcludePointOnEdge>(
4084  poly_coords,
4085  poly_coords_size,
4086  poly_ring_sizes,
4087  poly_num_rings,
4088  poly_bounds,
4089  poly_bounds_size,
4090  p,
4091  psize,
4092  ic1,
4093  isr1,
4094  ic2,
4095  isr2,
4096  osr);
4097 }
EXTENSION_NOINLINE void ST_Centroid_LineString ( int8_t *  coords,
int32_t  coords_sz,
int32_t  ic,
int32_t  isr,
int32_t  osr,
double *  linestring_centroid 
)

Definition at line 1560 of file ExtensionFunctionsGeo.hpp.

References centroid_add_linestring().

1565  {
1566  double length = 0.0;
1567  double linestring_centroid_sum[2] = {0.0, 0.0};
1568  int64_t num_points = 0;
1569  double point_centroid_sum[2] = {0.0, 0.0};
1570  centroid_add_linestring(coords,
1571  coords_sz,
1572  ic,
1573  isr,
1574  osr,
1575  false, // not closed
1576  &length,
1577  &linestring_centroid_sum[0],
1578  &num_points,
1579  &point_centroid_sum[0]);
1580  if (length > 0) {
1581  linestring_centroid[0] = linestring_centroid_sum[0] / length;
1582  linestring_centroid[1] = linestring_centroid_sum[1] / length;
1583  } else if (num_points > 0) {
1584  linestring_centroid[0] = point_centroid_sum[0] / num_points;
1585  linestring_centroid[1] = point_centroid_sum[1] / num_points;
1586  }
1587 }
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)

+ Here is the call graph for this function:

EXTENSION_NOINLINE void ST_Centroid_MultiPoint ( int8_t *  mp,
int32_t  mpsize,
int32_t  ic,
int32_t  isr,
int32_t  osr,
double *  multipoint_centroid 
)

Definition at line 1493 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size(), and get_point().

1498  {
1499  auto mp_num_coords = mpsize / compression_unit_size(ic);
1500  double x = 0.0;
1501  double y = 0.0;
1502  for (int32_t i = 0; i < mp_num_coords; i += 2) {
1503  Point2D mpp = get_point(mp, i, ic, isr, osr);
1504  x += mpp.x; // In case of overflows on large geometries,
1505  y += mpp.y; // move division into the loop
1506  }
1507  auto mp_num_points = mp_num_coords >> 1;
1508  multipoint_centroid[0] = x / mp_num_points;
1509  multipoint_centroid[1] = y / mp_num_points;
1510 }
DEVICE ALWAYS_INLINE int32_t compression_unit_size(const int32_t ic)
DEVICE ALWAYS_INLINE Point2D get_point(const int8_t *data, const int32_t x_index, const int32_t ic, const int32_t isr, const int32_t osr)

+ Here is the call graph for this function:

EXTENSION_NOINLINE void ST_Centroid_MultiPolygon ( int8_t *  mpoly_coords,
int32_t  mpoly_coords_size,
int32_t *  mpoly_ring_sizes,
int32_t  mpoly_num_rings,
int32_t *  mpoly_poly_sizes,
int32_t  mpoly_num_polys,
int32_t  ic,
int32_t  isr,
int32_t  osr,
double *  mpoly_centroid 
)

Definition at line 1739 of file ExtensionFunctionsGeo.hpp.

References centroid_add_polygon(), compression_unit_size(), and get_point().

1748  {
1749  if (mpoly_num_rings <= 0 || mpoly_num_polys <= 0) {
1750  mpoly_centroid[0] = 0.0;
1751  mpoly_centroid[1] = 0.0;
1752  }
1753 
1754  double total_area2 = 0.0;
1755  double cg3[2] = {0.0, 0.0};
1756  double total_length = 0.0;
1757  double linestring_centroid_sum[2] = {0.0, 0.0};
1758  int64_t num_points = 0;
1759  double point_centroid_sum[2] = {0.0, 0.0};
1760 
1761  // Set specific poly pointers as we move through the coords/ringsizes/polyrings arrays.
1762  auto next_poly_coords = mpoly_coords;
1763  auto next_poly_ring_sizes = mpoly_ring_sizes;
1764 
1765  for (auto poly = 0; poly < mpoly_num_polys; poly++) {
1766  auto poly_coords = next_poly_coords;
1767  auto poly_ring_sizes = next_poly_ring_sizes;
1768  auto poly_num_rings = mpoly_poly_sizes[poly];
1769  // Count number of coords in all of poly's rings, advance ring size pointer.
1770  int32_t poly_num_coords = 0;
1771  for (auto ring = 0; ring < poly_num_rings; ring++) {
1772  poly_num_coords += 2 * *next_poly_ring_sizes++;
1773  }
1774  auto poly_coords_size = poly_num_coords * compression_unit_size(ic);
1775  next_poly_coords += poly_coords_size;
1776 
1777  centroid_add_polygon(poly_coords,
1778  poly_coords_size,
1779  poly_ring_sizes,
1780  poly_num_rings,
1781  ic,
1782  isr,
1783  osr,
1784  &total_area2,
1785  &cg3[0],
1786  &total_length,
1787  &linestring_centroid_sum[0],
1788  &num_points,
1789  &point_centroid_sum[0]);
1790  }
1791 
1792  if (total_area2 != 0.0) {
1793  mpoly_centroid[0] = cg3[0] / 3 / total_area2;
1794  mpoly_centroid[1] = cg3[1] / 3 / total_area2;
1795  } else if (total_length > 0.0) {
1796  // zero-area multipolygon, fall back to linear centroid
1797  mpoly_centroid[0] = linestring_centroid_sum[0] / total_length;
1798  mpoly_centroid[1] = linestring_centroid_sum[1] / total_length;
1799  } else if (num_points > 0) {
1800  // zero-area zero-length multipolygon, fall further back to point centroid
1801  mpoly_centroid[0] = point_centroid_sum[0] / num_points;
1802  mpoly_centroid[1] = point_centroid_sum[1] / num_points;
1803  } else {
1804  Point2D centroid = get_point(mpoly_coords, 0, ic, isr, osr);
1805  mpoly_centroid[0] = centroid.x;
1806  mpoly_centroid[1] = centroid.y;
1807  }
1808 }
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)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(const int32_t ic)
DEVICE ALWAYS_INLINE Point2D get_point(const int8_t *data, const int32_t x_index, const int32_t ic, const int32_t isr, const int32_t osr)

+ Here is the call graph for this function:

EXTENSION_NOINLINE void ST_Centroid_Point ( int8_t *  p,
int32_t  psize,
int32_t  ic,
int32_t  isr,
int32_t  osr,
double *  point_centroid 
)

Definition at line 1481 of file ExtensionFunctionsGeo.hpp.

References get_point().

1486  {
1487  Point2D const centroid = get_point(p, 0, ic, isr, osr);
1488  point_centroid[0] = centroid.x;
1489  point_centroid[1] = centroid.y;
1490 }
DEVICE ALWAYS_INLINE Point2D get_point(const int8_t *data, const int32_t x_index, const int32_t ic, const int32_t isr, const int32_t osr)

+ Here is the call graph for this function:

EXTENSION_NOINLINE void ST_Centroid_Polygon ( int8_t *  poly_coords,
int32_t  poly_coords_size,
int32_t *  poly_ring_sizes,
int32_t  poly_num_rings,
int32_t  ic,
int32_t  isr,
int32_t  osr,
double *  poly_centroid 
)

Definition at line 1688 of file ExtensionFunctionsGeo.hpp.

References centroid_add_polygon(), and get_point().

1695  {
1696  if (poly_num_rings <= 0) {
1697  poly_centroid[0] = 0.0;
1698  poly_centroid[1] = 0.0;
1699  }
1700  double total_area2 = 0.0;
1701  double cg3[2] = {0.0, 0.0};
1702  double total_length = 0.0;
1703  double linestring_centroid_sum[2] = {0.0, 0.0};
1704  int64_t num_points = 0;
1705  double point_centroid_sum[2] = {0.0, 0.0};
1706  centroid_add_polygon(poly_coords,
1707  poly_coords_size,
1708  poly_ring_sizes,
1709  poly_num_rings,
1710  ic,
1711  isr,
1712  osr,
1713  &total_area2,
1714  &cg3[0],
1715  &total_length,
1716  &linestring_centroid_sum[0],
1717  &num_points,
1718  &point_centroid_sum[0]);
1719 
1720  if (total_area2 != 0.0) {
1721  poly_centroid[0] = cg3[0] / 3 / total_area2;
1722  poly_centroid[1] = cg3[1] / 3 / total_area2;
1723  } else if (total_length > 0.0) {
1724  // zero-area polygon, fall back to linear centroid
1725  poly_centroid[0] = linestring_centroid_sum[0] / total_length;
1726  poly_centroid[1] = linestring_centroid_sum[1] / total_length;
1727  } else if (num_points > 0) {
1728  // zero-area zero-length polygon, fall further back to point centroid
1729  poly_centroid[0] = point_centroid_sum[0] / num_points;
1730  poly_centroid[1] = point_centroid_sum[1] / num_points;
1731  } else {
1732  Point2D centroid = get_point(poly_coords, 0, ic, isr, osr);
1733  poly_centroid[0] = centroid.x;
1734  poly_centroid[1] = centroid.y;
1735  }
1736 }
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)
DEVICE ALWAYS_INLINE Point2D get_point(const int8_t *data, const int32_t x_index, const int32_t ic, const int32_t isr, const int32_t osr)

+ Here is the call graph for this function:

EXTENSION_INLINE bool ST_cIntersects_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 
)

Definition at line 4834 of file ExtensionFunctionsGeo.hpp.

4848  {
4849  return Contains_MultiPolygon_Point_Impl<int64_t, EdgeBehavior::kIncludePointOnEdge>(
4850  mpoly_coords,
4851  mpoly_coords_size,
4852  mpoly_ring_sizes,
4853  mpoly_num_rings,
4854  mpoly_poly_sizes,
4855  mpoly_num_polys,
4856  mpoly_bounds,
4857  mpoly_bounds_size,
4858  p,
4859  psize,
4860  ic1,
4861  isr1,
4862  ic2,
4863  isr2,
4864  osr);
4865 }
EXTENSION_INLINE bool ST_cIntersects_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 
)

Definition at line 4651 of file ExtensionFunctionsGeo.hpp.

4663  {
4664  return Contains_Polygon_Point_Impl<int64_t, EdgeBehavior::kIncludePointOnEdge>(
4665  poly,
4666  polysize,
4667  poly_ring_sizes,
4668  poly_num_rings,
4669  poly_bounds,
4670  poly_bounds_size,
4671  p,
4672  psize,
4673  ic1,
4674  isr1,
4675  ic2,
4676  isr2,
4677  osr);
4678 }
EXTENSION_INLINE bool ST_Contains_LineString_Point ( int8_t *  l,
int64_t  lsize,
double *  lbounds,
int64_t  lbounds_size,
int8_t *  p,
int64_t  psize,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr 
)

Definition at line 3938 of file ExtensionFunctionsGeo.hpp.

References ST_Distance_Point_LineString(), and tol_zero().

3948  {
3949  return tol_zero(
3950  ST_Distance_Point_LineString(p, psize, l, lsize, ic2, isr2, ic1, isr1, osr, 0.0));
3951 }
EXTENSION_NOINLINE double ST_Distance_Point_LineString(int8_t *p, int64_t psize, int8_t *l, int64_t lsize, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double threshold)
DEVICE ALWAYS_INLINE bool tol_zero(const double x, const double tolerance=TOLERANCE_DEFAULT)

+ Here is the call graph for this function:

EXTENSION_NOINLINE bool ST_Contains_LineString_Polygon ( int8_t *  l,
int64_t  lsize,
double *  lbounds,
int64_t  lbounds_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 
)

Definition at line 3954 of file ExtensionFunctionsGeo.hpp.

3968  {
3969  // TODO
3970  return false;
3971 }
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  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr 
)

Definition at line 4321 of file ExtensionFunctionsGeo.hpp.

References box_contains_box(), compression_unit_size(), and ST_Contains_Polygon_LineString().

4337  {
4338  if (mpoly_num_polys <= 0) {
4339  return false;
4340  }
4341 
4342  if (mpoly_bounds && lbounds) {
4343  if (!box_contains_box(mpoly_bounds, mpoly_bounds_size, lbounds, lbounds_size)) {
4344  return false;
4345  }
4346  }
4347 
4348  // Set specific poly pointers as we move through the coords/ringsizes/polyrings arrays.
4349  auto next_poly_coords = mpoly_coords;
4350  auto next_poly_ring_sizes = mpoly_ring_sizes;
4351 
4352  for (auto poly = 0; poly < mpoly_num_polys; poly++) {
4353  auto poly_coords = next_poly_coords;
4354  auto poly_ring_sizes = next_poly_ring_sizes;
4355  auto poly_num_rings = mpoly_poly_sizes[poly];
4356  // Count number of coords in all of poly's rings, advance ring size pointer.
4357  int32_t poly_num_coords = 0;
4358  for (auto ring = 0; ring < poly_num_rings; ring++) {
4359  poly_num_coords += 2 * *next_poly_ring_sizes++;
4360  }
4361  auto poly_coords_size = poly_num_coords * compression_unit_size(ic1);
4362  next_poly_coords += poly_coords_size;
4363 
4364  if (ST_Contains_Polygon_LineString(poly_coords,
4365  poly_coords_size,
4366  poly_ring_sizes,
4367  poly_num_rings,
4368  nullptr,
4369  0,
4370  l,
4371  lsize,
4372  nullptr,
4373  0,
4374  ic1,
4375  isr1,
4376  ic2,
4377  isr2,
4378  osr)) {
4379  return true;
4380  }
4381  }
4382 
4383  return false;
4384 }
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 ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(const int32_t ic)
DEVICE ALWAYS_INLINE bool box_contains_box(double *bounds1, int64_t bounds1_size, double *bounds2, int64_t bounds2_size)

+ Here is the call graph for this function:

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 
)

Definition at line 4254 of file ExtensionFunctionsGeo.hpp.

4268  {
4269  return Contains_MultiPolygon_Point_Impl<double, EdgeBehavior::kExcludePointOnEdge>(
4270  mpoly_coords,
4271  mpoly_coords_size,
4272  mpoly_ring_sizes,
4273  mpoly_num_rings,
4274  mpoly_poly_sizes,
4275  mpoly_num_polys,
4276  mpoly_bounds,
4277  mpoly_bounds_size,
4278  p,
4279  psize,
4280  ic1,
4281  isr1,
4282  ic2,
4283  isr2,
4284  osr);
4285 }
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  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr 
)

Definition at line 3873 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size(), get_point(), and tol_eq().

Referenced by ST_Contains_Point_Polygon().

3883  {
3884  Point2D const pt = get_point(p, 0, ic1, isr1, osr);
3885 
3886  if (lbounds) {
3887  if (tol_eq(pt.x, lbounds[0]) && tol_eq(pt.y, lbounds[1]) &&
3888  tol_eq(pt.x, lbounds[2]) && tol_eq(pt.y, lbounds[3])) {
3889  return true;
3890  }
3891  }
3892 
3893  auto l_num_coords = lsize / compression_unit_size(ic2);
3894  for (int i = 0; i < l_num_coords; i += 2) {
3895  Point2D pl = get_point(l, i, ic2, isr2, osr);
3896  if (tol_eq(pt.x, pl.x) && tol_eq(pt.y, pl.y)) {
3897  continue;
3898  }
3899  return false;
3900  }
3901  return true;
3902 }
DEVICE ALWAYS_INLINE int32_t compression_unit_size(const int32_t ic)
DEVICE ALWAYS_INLINE Point2D get_point(const int8_t *data, const int32_t x_index, const int32_t ic, const int32_t isr, const int32_t osr)
DEVICE ALWAYS_INLINE bool tol_eq(const double x, const double y, const double tolerance=TOLERANCE_DEFAULT)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 
)

Definition at line 3857 of file ExtensionFunctionsGeo.hpp.

References get_point(), tol(), and tol_eq().

3865  {
3866  Point2D const pt1 = get_point(p1, 0, ic1, isr1, osr);
3867  Point2D const pt2 = get_point(p2, 0, ic2, isr2, osr);
3868  double tolerance = tol(ic1, ic2);
3869  return tol_eq(pt1.x, pt2.x, tolerance) && tol_eq(pt1.y, pt2.y, tolerance);
3870 }
DEVICE ALWAYS_INLINE Point2D get_point(const int8_t *data, const int32_t x_index, const int32_t ic, const int32_t isr, const int32_t osr)
DEVICE ALWAYS_INLINE double tol(int32_t ic)
DEVICE ALWAYS_INLINE bool tol_eq(const double x, const double y, const double tolerance=TOLERANCE_DEFAULT)

+ Here is the call graph for this function:

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 
)

Definition at line 3905 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size(), and ST_Contains_Point_LineString().

3917  {
3918  auto exterior_ring_num_coords = poly_coords_size / compression_unit_size(ic2);
3919  if (poly_num_rings > 0) {
3920  exterior_ring_num_coords = poly_ring_sizes[0] * 2;
3921  }
3922  auto exterior_ring_coords_size = exterior_ring_num_coords * compression_unit_size(ic2);
3923 
3925  psize,
3926  poly_coords,
3927  exterior_ring_coords_size,
3928  poly_bounds,
3929  poly_bounds_size,
3930  ic1,
3931  isr1,
3932  ic2,
3933  isr2,
3934  osr);
3935 }
DEVICE ALWAYS_INLINE int32_t compression_unit_size(const int32_t ic)
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 ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)

+ Here is the call graph for this function:

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  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr 
)

Definition at line 4100 of file ExtensionFunctionsGeo.hpp.

References box_contains_box(), compression_unit_size(), and polygon_contains_linestring().

Referenced by ST_Contains_MultiPolygon_LineString(), and ST_Contains_Polygon_Polygon().

4114  {
4115  if (poly_num_rings > 1) {
4116  return false; // TODO: support polygons with interior rings
4117  }
4118 
4119  // Bail out if poly bounding box doesn't contain linestring bounding box
4120  if (poly_bounds && lbounds) {
4121  if (!box_contains_box(poly_bounds, poly_bounds_size, lbounds, lbounds_size)) {
4122  return false;
4123  }
4124  }
4125 
4126  const auto poly_num_coords = poly_coords_size / compression_unit_size(ic1);
4127  const auto lnum_coords = lsize / compression_unit_size(ic2);
4128 
4130  poly_coords, poly_num_coords, l, lnum_coords, ic1, isr1, ic2, isr2, osr);
4131 }
DEVICE ALWAYS_INLINE int32_t compression_unit_size(const int32_t ic)
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)
DEVICE ALWAYS_INLINE bool box_contains_box(double *bounds1, int64_t bounds1_size, double *bounds2, int64_t bounds2_size)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 
)

Definition at line 4041 of file ExtensionFunctionsGeo.hpp.

4053  {
4054  return Contains_Polygon_Point_Impl<double, EdgeBehavior::kExcludePointOnEdge>(
4055  poly_coords,
4056  poly_coords_size,
4057  poly_ring_sizes,
4058  poly_num_rings,
4059  poly_bounds,
4060  poly_bounds_size,
4061  p,
4062  psize,
4063  ic1,
4064  isr1,
4065  ic2,
4066  isr2,
4067  osr);
4068 }
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 
)

Definition at line 4134 of file ExtensionFunctionsGeo.hpp.

References box_contains_box(), compression_unit_size(), and ST_Contains_Polygon_LineString().

4150  {
4151  // TODO: needs to be extended, cover more cases
4152  // Right now only checking if simple poly1 (no holes) contains poly2's exterior shape
4153  if (poly1_num_rings > 1) {
4154  return false; // TODO: support polygons with interior rings
4155  }
4156 
4157  if (poly1_bounds && poly2_bounds) {
4158  if (!box_contains_box(
4159  poly1_bounds, poly1_bounds_size, poly2_bounds, poly2_bounds_size)) {
4160  return false;
4161  }
4162  }
4163 
4164  int64_t poly2_exterior_ring_coords_size = poly2_coords_size;
4165  if (poly2_num_rings > 0) {
4166  poly2_exterior_ring_coords_size =
4167  2 * poly2_ring_sizes[0] * compression_unit_size(ic2);
4168  }
4169  return ST_Contains_Polygon_LineString(poly1_coords,
4170  poly1_coords_size,
4171  poly1_ring_sizes,
4172  poly1_num_rings,
4173  poly1_bounds,
4174  poly1_bounds_size,
4175  poly2_coords,
4176  poly2_exterior_ring_coords_size,
4177  poly2_bounds,
4178  poly2_bounds_size,
4179  ic1,
4180  isr1,
4181  ic2,
4182  isr2,
4183  osr);
4184 }
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 ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(const int32_t ic)
DEVICE ALWAYS_INLINE bool box_contains_box(double *bounds1, int64_t bounds1_size, double *bounds2, int64_t bounds2_size)

+ Here is the call graph for this function:

EXTENSION_NOINLINE double ST_Distance_LineString_LineString ( int8_t *  l1,
int64_t  l1size,
int8_t *  l2,
int64_t  l2size,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr,
double  threshold 
)

Definition at line 2669 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size(), distance_line_line(), get_point(), tol_zero(), and TOLERANCE_DEFAULT_SQUARED.

Referenced by ST_DWithin_LineString_LineString(), and ST_Intersects_LineString_Linestring().

2678  {
2679  auto l1_num_coords = l1size / compression_unit_size(ic1);
2680  auto l2_num_coords = l2size / compression_unit_size(ic2);
2681 
2682  double threshold_squared = threshold * threshold;
2683  double dist_squared = 0.0;
2684  Point2D l11 = get_point(l1, 0, ic1, isr1, osr);
2685  for (int32_t i1 = 2; i1 < l1_num_coords; i1 += 2) {
2686  Point2D l12 = get_point(l1, i1, ic1, isr1, osr);
2687  Point2D l21 = get_point(l2, 0, ic2, isr2, osr);
2688  for (int32_t i2 = 2; i2 < l2_num_coords; i2 += 2) {
2689  Point2D l22 = get_point(l2, i2, ic2, isr2, osr);
2690 
2691  // double ldist_squared =
2692  // distance_line_line_squared(l11x, l11y, l12x, l12y, l21x, l21y, l22x, l22y);
2693  // TODO: fix distance_line_line_squared
2694  double ldist =
2695  distance_line_line(l11.x, l11.y, l12.x, l12.y, l21.x, l21.y, l22.x, l22.y);
2696  double ldist_squared = ldist * ldist;
2697 
2698  if (i1 == 2 && i2 == 2) {
2699  dist_squared = ldist_squared; // initialize dist with distance between the first
2700  // two segments
2701  } else if (dist_squared > ldist_squared) {
2702  dist_squared = ldist_squared;
2703  }
2704  if (tol_zero(dist_squared, TOLERANCE_DEFAULT_SQUARED)) {
2705  return 0.0; // Segments touch, short-circuit
2706  }
2707  if (dist_squared <= threshold_squared) {
2708  // If threashold_squared is defined and the calculated dist_squared dips under it,
2709  // short-circuit and return it
2710  return sqrt(dist_squared);
2711  }
2712 
2713  l21 = l22; // advance to the next point on l2
2714  }
2715 
2716  l11 = l12; // advance to the next point on l1
2717  }
2718  return sqrt(dist_squared);
2719 }
DEVICE ALWAYS_INLINE bool tol_zero(const double x, const double tolerance=TOLERANCE_DEFAULT)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(const int32_t ic)
DEVICE ALWAYS_INLINE Point2D get_point(const int8_t *data, const int32_t x_index, const int32_t ic, const int32_t isr, const int32_t osr)
#define TOLERANCE_DEFAULT_SQUARED
DEVICE double distance_line_line(double l11x, double l11y, double l12x, double l12y, double l21x, double l21y, double l22x, double l22y)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_INLINE double ST_Distance_LineString_MultiPoint ( int8_t *  l,
int64_t  lsize,
int8_t *  mp,
int64_t  mpsize,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr,
double  threshold 
)

Definition at line 2627 of file ExtensionFunctionsGeo.hpp.

References ST_Distance_MultiPoint_LineString().

2636  {
2638  mp, mpsize, l, lsize, ic2, isr2, ic1, isr1, osr, threshold);
2639 }
EXTENSION_INLINE double ST_Distance_MultiPoint_LineString(int8_t *mp, int64_t mpsize, int8_t *l, int64_t lsize, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double threshold)

+ Here is the call graph for this function:

EXTENSION_NOINLINE double ST_Distance_LineString_MultiPolygon ( int8_t *  l,
int64_t  lsize,
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 
)

Definition at line 2791 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size(), ST_Distance_LineString_Polygon(), and tol_zero().

Referenced by ST_Distance_MultiPolygon_LineString(), ST_DWithin_LineString_MultiPolygon(), and ST_Intersects_LineString_MultiPolygon().

2804  {
2805  // TODO: revisit implementation, cover all cases
2806  double min_distance = 0.0;
2807 
2808  // Set specific poly pointers as we move through the coords/ringsizes/polyrings arrays.
2809  auto next_poly_coords = mpoly_coords;
2810  auto next_poly_ring_sizes = mpoly_ring_sizes;
2811 
2812  for (auto poly = 0; poly < mpoly_num_polys; poly++) {
2813  auto poly_coords = next_poly_coords;
2814  auto poly_ring_sizes = next_poly_ring_sizes;
2815  auto poly_num_rings = mpoly_poly_sizes[poly];
2816  // Count number of coords in all of poly's rings, advance ring size pointer.
2817  int32_t poly_num_coords = 0;
2818  for (auto ring = 0; ring < poly_num_rings; ring++) {
2819  poly_num_coords += 2 * *next_poly_ring_sizes++;
2820  }
2821  auto poly_coords_size = poly_num_coords * compression_unit_size(ic2);
2822  next_poly_coords += poly_coords_size;
2823  double distance = ST_Distance_LineString_Polygon(l,
2824  lsize,
2825  poly_coords,
2826  poly_coords_size,
2827  poly_ring_sizes,
2828  poly_num_rings,
2829  ic1,
2830  isr1,
2831  ic2,
2832  isr2,
2833  osr,
2834  threshold);
2835  if (poly == 0 || min_distance > distance) {
2836  min_distance = distance;
2837  if (tol_zero(min_distance)) {
2838  min_distance = 0.0;
2839  break;
2840  }
2841  if (min_distance <= threshold) {
2842  return min_distance;
2843  }
2844  }
2845  }
2846 
2847  return min_distance;
2848 }
EXTENSION_NOINLINE double ST_Distance_LineString_Polygon(int8_t *l, int64_t lsize, 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)
DEVICE ALWAYS_INLINE bool tol_zero(const double x, const double tolerance=TOLERANCE_DEFAULT)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(const int32_t ic)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_INLINE double ST_Distance_LineString_Point ( int8_t *  l,
int64_t  lsize,
int8_t *  p,
int64_t  psize,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr,
double  threshold 
)

Definition at line 2612 of file ExtensionFunctionsGeo.hpp.

References ST_Distance_Point_LineString().

2621  {
2623  p, psize, l, lsize, ic2, isr2, ic1, isr1, osr, threshold);
2624 }
EXTENSION_NOINLINE double ST_Distance_Point_LineString(int8_t *p, int64_t psize, int8_t *l, int64_t lsize, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double threshold)

+ Here is the call graph for this function:

EXTENSION_INLINE double ST_Distance_LineString_Point_Geodesic ( int8_t *  l,
int64_t  lsize,
int8_t *  p,
int64_t  psize,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr 
)

Definition at line 1877 of file ExtensionFunctionsGeo.hpp.

References ST_Distance_Point_LineString_Geodesic().

1885  {
1886  // Currently only statically indexed LineString is supported
1888  p, psize, l, lsize, ic2, isr2, ic1, isr1, osr);
1889 }
EXTENSION_NOINLINE double ST_Distance_Point_LineString_Geodesic(int8_t *p, int64_t psize, int8_t *l, int64_t lsize, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)

+ Here is the call graph for this function:

EXTENSION_NOINLINE double ST_Distance_LineString_Polygon ( int8_t *  l,
int64_t  lsize,
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 
)

Definition at line 2722 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size(), distance_ring_linestring(), ST_Distance_Point_Polygon(), and tol_zero().

Referenced by ST_Distance_LineString_MultiPolygon(), ST_Distance_Polygon_LineString(), ST_DWithin_LineString_Polygon(), and ST_Intersects_LineString_Polygon().

2733  {
2734  auto lnum_coords = lsize / compression_unit_size(ic1);
2735  auto psize = 2 * compression_unit_size(ic1);
2736  auto min_distance =
2737  ST_Distance_Point_Polygon(l, // pointer to start of linestring for first point
2738  psize,
2739  poly_coords,
2740  poly_coords_size,
2741  poly_ring_sizes,
2742  poly_num_rings,
2743  ic1,
2744  isr1,
2745  ic2,
2746  isr2,
2747  osr,
2748  threshold);
2749  if (tol_zero(min_distance)) {
2750  // Linestring's first point is inside the poly
2751  return 0.0;
2752  }
2753  if (min_distance <= threshold) {
2754  return min_distance;
2755  }
2756 
2757  // Otherwise, linestring's first point is outside the external ring or inside
2758  // an internal ring. Measure minimum distance between linestring segments and
2759  // poly rings. Crossing a ring zeroes the distance and causes an early return.
2760  auto poly_ring_coords = poly_coords;
2761  for (auto r = 0; r < poly_num_rings; r++) {
2762  int64_t poly_ring_num_coords = poly_ring_sizes[r] * 2;
2763 
2764  auto distance = distance_ring_linestring(poly_ring_coords,
2765  poly_ring_num_coords,
2766  l,
2767  lnum_coords,
2768  ic2,
2769  isr2,
2770  ic1,
2771  isr1,
2772  osr,
2773  threshold);
2774  if (min_distance > distance) {
2775  min_distance = distance;
2776  if (tol_zero(min_distance)) {
2777  return 0.0;
2778  }
2779  if (min_distance <= threshold) {
2780  return min_distance;
2781  }
2782  }
2783 
2784  poly_ring_coords += poly_ring_num_coords * compression_unit_size(ic2);
2785  }
2786 
2787  return min_distance;
2788 }
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)
DEVICE ALWAYS_INLINE bool tol_zero(const double x, const double tolerance=TOLERANCE_DEFAULT)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(const int32_t ic)
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)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_NOINLINE double ST_Distance_MultiLineString_MultiLineString ( int8_t *  mls1,
int64_t  mls1size,
int32_t *  mls1_ls_sizes,
int64_t  mls1_ls_num,
int8_t *  mls2,
int64_t  mls2size,
int32_t *  mls2_ls_sizes,
int64_t  mls2_ls_num,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr,
double  threshold 
)

Definition at line 3245 of file ExtensionFunctionsGeo.hpp.

3258  {
3259  return 0.0;
3260 }
EXTENSION_INLINE double ST_Distance_MultiLineString_MultiPoint ( int8_t *  mls,
int64_t  mls_size,
int32_t *  mls_ls_sizes,
int64_t  mls_ls_num,
int8_t *  mp,
int64_t  mpsize,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr,
double  threshold 
)

Definition at line 2642 of file ExtensionFunctionsGeo.hpp.

References ST_Distance_MultiPoint_MultiLineString().

2653  {
2655  mpsize,
2656  mls,
2657  mls_size,
2658  mls_ls_sizes,
2659  mls_ls_num,
2660  ic2,
2661  isr2,
2662  ic1,
2663  isr1,
2664  osr,
2665  threshold);
2666 }
EXTENSION_INLINE double ST_Distance_MultiPoint_MultiLineString(int8_t *mp, int64_t mpsize, int8_t *mls, int64_t mls_size, int32_t *mls_ls_sizes, int64_t mls_ls_num, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double threshold)

+ Here is the call graph for this function:

EXTENSION_INLINE double ST_Distance_MultiLineString_Point ( int8_t *  mls,
int64_t  mls_size,
int32_t *  mls_ls_sizes,
int64_t  mls_ls_num,
int8_t *  p,
int64_t  psize,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr,
double  threshold 
)

Definition at line 2851 of file ExtensionFunctionsGeo.hpp.

References ST_Distance_Point_MultiLineString().

2862  {
2864  psize,
2865  mls,
2866  mls_size,
2867  mls_ls_sizes,
2868  mls_ls_num,
2869  ic2,
2870  isr2,
2871  ic1,
2872  isr1,
2873  osr,
2874  threshold);
2875 }
EXTENSION_NOINLINE double ST_Distance_Point_MultiLineString(int8_t *p, int64_t psize, int8_t *mls, int64_t mls_size, int32_t *mls_ls_sizes, int64_t mls_ls_num, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double threshold)

+ Here is the call graph for this function:

EXTENSION_INLINE double ST_Distance_MultiPoint_LineString ( int8_t *  mp,
int64_t  mpsize,
int8_t *  l,
int64_t  lsize,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr,
double  threshold 
)

Definition at line 2528 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size(), and distance_point_linestring().

Referenced by ST_Distance_LineString_MultiPoint().

2537  {
2538  auto mp_num_coords = mpsize / compression_unit_size(ic1);
2539  auto* p = mp;
2540  auto const psize = compression_unit_size(ic1) * 2;
2541  auto dist = distance_point_linestring(
2542  p, psize, l, lsize, ic1, isr1, ic2, isr2, osr, true, threshold);
2543  p += psize;
2544  for (int32_t i = 2; i < mp_num_coords; i += 2) {
2545  auto ldist = distance_point_linestring(
2546  p, psize, l, lsize, ic1, isr1, ic2, isr2, osr, true, threshold);
2547  p += psize;
2548  if (dist > ldist) {
2549  dist = ldist;
2550  }
2551  if (dist <= threshold) {
2552  return dist;
2553  }
2554  }
2555  return dist;
2556 }
DEVICE ALWAYS_INLINE double distance_point_linestring(int8_t *p, int64_t psize, int8_t *l, int64_t lsize, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, bool check_closed, double threshold)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(const int32_t ic)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_INLINE double ST_Distance_MultiPoint_MultiLineString ( int8_t *  mp,
int64_t  mpsize,
int8_t *  mls,
int64_t  mls_size,
int32_t *  mls_ls_sizes,
int64_t  mls_ls_num,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr,
double  threshold 
)

Definition at line 2559 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size(), and distance_point_multilinestring().

Referenced by ST_Distance_MultiLineString_MultiPoint().

2570  {
2571  auto mp_num_coords = mpsize / compression_unit_size(ic1);
2572  auto* p = mp;
2573  auto const psize = compression_unit_size(ic1) * 2;
2574  auto dist = distance_point_multilinestring(p,
2575  psize,
2576  mls,
2577  mls_size,
2578  mls_ls_sizes,
2579  mls_ls_num,
2580  ic1,
2581  isr1,
2582  ic2,
2583  isr2,
2584  osr,
2585  threshold);
2586  p += psize;
2587  for (int32_t i = 2; i < mp_num_coords; i += 2) {
2588  auto ldist = distance_point_multilinestring(p,
2589  psize,
2590  mls,
2591  mls_size,
2592  mls_ls_sizes,
2593  mls_ls_num,
2594  ic1,
2595  isr1,
2596  ic2,
2597  isr2,
2598  osr,
2599  threshold);
2600  p += psize;
2601  if (dist > ldist) {
2602  dist = ldist;
2603  }
2604  if (dist <= threshold) {
2605  return dist;
2606  }
2607  }
2608  return dist;
2609 }
DEVICE ALWAYS_INLINE double distance_point_multilinestring(int8_t *p, int64_t psize, int8_t *mls, int64_t mls_size, int32_t *mls_ls_sizes, int64_t mls_ls_num, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double threshold)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(const int32_t ic)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_NOINLINE double ST_Distance_MultiPoint_MultiPoint ( int8_t *  mp1,
int64_t  mp1size,
int8_t *  mp2,
int64_t  mp2size,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr,
double  threshold 
)

Definition at line 2468 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size(), distance_point_point(), and get_point().

2477  {
2478  auto mp1_num_coords = mp1size / compression_unit_size(ic1);
2479  auto mp2_num_coords = mp2size / compression_unit_size(ic2);
2480  double dist = -1.0;
2481  for (int32_t i = 0; i < mp1_num_coords; i += 2) {
2482  Point2D mp1p = get_point(mp1, 0, ic1, isr1, osr);
2483  for (int32_t j = 0; j < mp2_num_coords; j += 2) {
2484  Point2D mp2p = get_point(mp2, 0, ic2, isr2, osr);
2485  double ldist = distance_point_point(mp1p.x, mp1p.y, mp2p.x, mp2p.y);
2486  if (dist > ldist || dist < 0.0) {
2487  dist = ldist;
2488  }
2489  if (dist <= threshold) {
2490  return dist;
2491  }
2492  }
2493  }
2494  return dist;
2495 }
DEVICE ALWAYS_INLINE int32_t compression_unit_size(const int32_t ic)
DEVICE ALWAYS_INLINE Point2D get_point(const int8_t *data, const int32_t x_index, const int32_t ic, const int32_t isr, const int32_t osr)
DEVICE ALWAYS_INLINE double distance_point_point(double p1x, double p1y, double p2x, double p2y)

+ Here is the call graph for this function:

EXTENSION_NOINLINE double ST_Distance_MultiPoint_MultiPoint_Squared ( int8_t *  mp1,
int64_t  mp1size,
int8_t *  mp2,
int64_t  mp2size,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr,
double  threshold 
)

Definition at line 2498 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size(), distance_point_point_squared(), and get_point().

2507  {
2508  auto mp1_num_coords = mp1size / compression_unit_size(ic1);
2509  auto mp2_num_coords = mp2size / compression_unit_size(ic2);
2510  double dist = -1.0;
2511  for (int32_t i = 0; i < mp1_num_coords; i += 2) {
2512  Point2D mp1p = get_point(mp1, i, ic1, isr1, osr);
2513  for (int32_t j = 0; j < mp2_num_coords; j += 2) {
2514  Point2D mp2p = get_point(mp2, j, ic2, isr2, osr);
2515  double ldist = distance_point_point_squared(mp1p.x, mp1p.y, mp2p.x, mp2p.y);
2516  if (dist > ldist || dist < 0.0) {
2517  dist = ldist;
2518  }
2519  if (dist <= threshold) {
2520  return dist;
2521  }
2522  }
2523  }
2524  return dist;
2525 }
DEVICE ALWAYS_INLINE double distance_point_point_squared(double p1x, double p1y, double p2x, double p2y)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(const int32_t ic)
DEVICE ALWAYS_INLINE Point2D get_point(const int8_t *data, const int32_t x_index, const int32_t ic, const int32_t isr, const int32_t osr)

+ Here is the call graph for this function:

EXTENSION_INLINE double ST_Distance_MultiPoint_MultiPolygon ( int8_t *  mp,
int64_t  mpsize,
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 
)

Definition at line 2321 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size(), and distance_point_multipolygon().

Referenced by ST_Distance_MultiPolygon_MultiPoint().

2334  {
2335  auto mp_num_coords = mpsize / compression_unit_size(ic1);
2336  auto* p = mp;
2337  auto const psize = compression_unit_size(ic1) * 2;
2338  auto dist = distance_point_multipolygon(p,
2339  psize,
2340  mpoly_coords,
2341  mpoly_coords_size,
2342  mpoly_ring_sizes,
2343  mpoly_num_rings,
2344  mpoly_poly_sizes,
2345  mpoly_num_polys,
2346  ic1,
2347  isr1,
2348  ic2,
2349  isr2,
2350  osr,
2351  threshold);
2352  p += psize;
2353  for (int32_t i = 2; i < mp_num_coords; i += 2) {
2354  auto ldist = distance_point_multipolygon(p,
2355  psize,
2356  mpoly_coords,
2357  mpoly_coords_size,
2358  mpoly_ring_sizes,
2359  mpoly_num_rings,
2360  mpoly_poly_sizes,
2361  mpoly_num_polys,
2362  ic1,
2363  isr1,
2364  ic2,
2365  isr2,
2366  osr,
2367  threshold);
2368  p += psize;
2369  if (dist > ldist) {
2370  dist = ldist;
2371  }
2372  if (dist <= threshold) {
2373  return dist;
2374  }
2375  }
2376  return dist;
2377 }
DEVICE ALWAYS_INLINE double 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)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(const int32_t ic)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_INLINE double ST_Distance_MultiPoint_Point ( int8_t *  mp,
int64_t  mpsize,
int8_t *  p,
int64_t  psize,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr,
double  threshold 
)

Definition at line 2438 of file ExtensionFunctionsGeo.hpp.

References ST_Distance_Point_MultiPoint().

2447  {
2449  p, psize, mp, mpsize, ic2, isr2, ic1, isr1, osr, threshold);
2450 }
EXTENSION_NOINLINE double ST_Distance_Point_MultiPoint(int8_t *p, int64_t psize, int8_t *mp, int64_t mpsize, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double threshold)

+ Here is the call graph for this function:

EXTENSION_INLINE double ST_Distance_MultiPoint_Point_Squared ( int8_t *  mp,
int64_t  mpsize,
int8_t *  p,
int64_t  psize,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr,
double  threshold 
)

Definition at line 2453 of file ExtensionFunctionsGeo.hpp.

References ST_Distance_Point_MultiPoint_Squared().

2462  {
2464  p, psize, mp, mpsize, ic2, isr2, ic1, isr1, osr, threshold);
2465 }
EXTENSION_NOINLINE double ST_Distance_Point_MultiPoint_Squared(int8_t *p, int64_t psize, int8_t *mp, int64_t mpsize, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double threshold)

+ Here is the call graph for this function:

EXTENSION_INLINE double ST_Distance_MultiPoint_Polygon ( int8_t *  mp,
int64_t  mpsize,
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 
)

Definition at line 2268 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size(), and distance_point_polygon().

Referenced by ST_Distance_Polygon_MultiPoint().

2279  {
2280  auto mp_num_coords = mpsize / compression_unit_size(ic1);
2281  auto* p = mp;
2282  auto const psize = compression_unit_size(ic1) * 2;
2283  auto dist = distance_point_polygon(p,
2284  psize,
2285  poly,
2286  polysize,
2287  poly_ring_sizes,
2288  poly_num_rings,
2289  ic1,
2290  isr1,
2291  ic2,
2292  isr2,
2293  osr,
2294  threshold);
2295  p += psize;
2296  for (int32_t i = 2; i < mp_num_coords; i += 2) {
2297  auto ldist = distance_point_polygon(p,
2298  psize,
2299  poly,
2300  polysize,
2301  poly_ring_sizes,
2302  poly_num_rings,
2303  ic1,
2304  isr1,
2305  ic2,
2306  isr2,
2307  osr,
2308  threshold);
2309  p += psize;
2310  if (dist > ldist) {
2311  dist = ldist;
2312  }
2313  if (dist <= threshold) {
2314  return dist;
2315  }
2316  }
2317  return dist;
2318 }
DEVICE ALWAYS_INLINE double 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)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(const int32_t ic)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr,
double  threshold 
)

Definition at line 3111 of file ExtensionFunctionsGeo.hpp.

References ST_Distance_LineString_MultiPolygon().

3124  {
3126  lsize,
3127  mpoly_coords,
3128  mpoly_coords_size,
3129  mpoly_ring_sizes,
3130  mpoly_num_rings,
3131  mpoly_poly_sizes,
3132  mpoly_num_polys,
3133  ic2,
3134  isr2,
3135  ic1,
3136  isr1,
3137  osr,
3138  threshold);
3139 }
EXTENSION_NOINLINE double ST_Distance_LineString_MultiPolygon(int8_t *l, int64_t lsize, 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)

+ Here is the call graph for this function:

EXTENSION_INLINE double ST_Distance_MultiPolygon_MultiPoint ( 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 *  mp,
int64_t  mpsize,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr,
double  threshold 
)

Definition at line 2407 of file ExtensionFunctionsGeo.hpp.

References ST_Distance_MultiPoint_MultiPolygon().

2420  {
2422  mpsize,
2423  mpoly_coords,
2424  mpoly_coords_size,
2425  mpoly_ring_sizes,
2426  mpoly_num_rings,
2427  mpoly_poly_sizes,
2428  mpoly_num_polys,
2429  ic2,
2430  isr2,
2431  ic1,
2432  isr1,
2433  osr,
2434  threshold);
2435 }
EXTENSION_INLINE double ST_Distance_MultiPoint_MultiPolygon(int8_t *mp, int64_t mpsize, 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)

+ Here is the call graph for this function:

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 
)

Definition at line 3177 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size(), ST_Distance_Polygon_MultiPolygon(), and tol_zero().

Referenced by ST_DWithin_MultiPolygon_MultiPolygon(), and ST_Intersects_MultiPolygon_MultiPolygon().

3194  {
3195  double min_distance = 0.0;
3196 
3197  // Set specific poly pointers as we move through mpoly1's coords/ringsizes/polyrings
3198  // arrays.
3199  auto next_poly_coords = mpoly1_coords;
3200  auto next_poly_ring_sizes = mpoly1_ring_sizes;
3201 
3202  for (auto poly = 0; poly < mpoly1_num_polys; poly++) {
3203  auto poly_coords = next_poly_coords;
3204  auto poly_ring_sizes = next_poly_ring_sizes;
3205  auto poly_num_rings = mpoly1_poly_sizes[poly];
3206  // Count number of coords in all of poly's rings, advance ring size pointer.
3207  int32_t poly_num_coords = 0;
3208  for (auto ring = 0; ring < poly_num_rings; ring++) {
3209  poly_num_coords += 2 * *next_poly_ring_sizes++;
3210  }
3211  auto poly_coords_size = poly_num_coords * compression_unit_size(ic1);
3212  next_poly_coords += poly_coords_size;
3213  double distance = ST_Distance_Polygon_MultiPolygon(poly_coords,
3214  poly_coords_size,
3215  poly_ring_sizes,
3216  poly_num_rings,
3217  mpoly2_coords,
3218  mpoly2_coords_size,
3219  mpoly2_ring_sizes,
3220  mpoly2_num_rings,
3221  mpoly2_poly_sizes,
3222  mpoly2_num_polys,
3223  ic1,
3224  isr1,
3225  ic2,
3226  isr2,
3227  osr,
3228  threshold);
3229  if (poly == 0 || min_distance > distance) {
3230  min_distance = distance;
3231  if (tol_zero(min_distance)) {
3232  min_distance = 0.0;
3233  break;
3234  }
3235  if (min_distance <= threshold) {
3236  break;
3237  }
3238  }
3239  }
3240 
3241  return min_distance;
3242 }
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)
DEVICE ALWAYS_INLINE bool tol_zero(const double x, const double tolerance=TOLERANCE_DEFAULT)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(const int32_t ic)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 
)

Definition at line 3080 of file ExtensionFunctionsGeo.hpp.

References ST_Distance_Point_MultiPolygon().

3093  {
3095  psize,
3096  mpoly_coords,
3097  mpoly_coords_size,
3098  mpoly_ring_sizes,
3099  mpoly_num_rings,
3100  mpoly_poly_sizes,
3101  mpoly_num_polys,
3102  ic2,
3103  isr2,
3104  ic1,
3105  isr1,
3106  osr,
3107  threshold);
3108 }
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)

+ Here is the call graph for this function:

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 
)

Definition at line 3142 of file ExtensionFunctionsGeo.hpp.

References ST_Distance_Polygon_MultiPolygon().

3157  {
3158  return ST_Distance_Polygon_MultiPolygon(poly1_coords,
3159  poly1_coords_size,
3160  poly1_ring_sizes,
3161  poly1_num_rings,
3162  mpoly_coords,
3163  mpoly_coords_size,
3164  mpoly_ring_sizes,
3165  mpoly_num_rings,
3166  mpoly_poly_sizes,
3167  mpoly_num_polys,
3168  ic2,
3169  isr2,
3170  ic1,
3171  isr1,
3172  osr,
3173  threshold);
3174 }
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)

+ Here is the call graph for this function:

EXTENSION_NOINLINE double ST_Distance_Point_ClosedLineString ( int8_t *  p,
int64_t  psize,
int8_t *  l,
int64_t  lsize,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr,
double  threshold 
)

Definition at line 1989 of file ExtensionFunctionsGeo.hpp.

References distance_point_linestring().

Referenced by distance_point_polygon().

1998  {
2000  p, psize, l, lsize, ic1, isr1, ic2, isr2, osr, true, threshold);
2001 }
DEVICE ALWAYS_INLINE double distance_point_linestring(int8_t *p, int64_t psize, int8_t *l, int64_t lsize, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, bool check_closed, double threshold)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_NOINLINE double ST_Distance_Point_LineString ( int8_t *  p,
int64_t  psize,
int8_t *  l,
int64_t  lsize,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr,
double  threshold 
)

Definition at line 2004 of file ExtensionFunctionsGeo.hpp.

References distance_point_linestring().

Referenced by ST_Contains_LineString_Point(), ST_Distance_LineString_Point(), ST_DWithin_Point_LineString(), and ST_Intersects_Point_LineString().

2013  {
2015  p, psize, l, lsize, ic1, isr1, ic2, isr2, osr, false, threshold);
2016 }
DEVICE ALWAYS_INLINE double distance_point_linestring(int8_t *p, int64_t psize, int8_t *l, int64_t lsize, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, bool check_closed, double threshold)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_NOINLINE double ST_Distance_Point_LineString_Geodesic ( int8_t *  p,
int64_t  psize,
int8_t *  l,
int64_t  lsize,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr 
)

Definition at line 1860 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size(), distance_in_meters(), and get_point().

Referenced by ST_Distance_LineString_Point_Geodesic().

1868  {
1869  // Currently only statically indexed LineString is supported
1870  Point2D const pt = get_point(p, 0, ic1, 4326, 4326);
1871  const auto lpoints = lsize / (2 * compression_unit_size(ic2));
1872  Point2D const pl = get_point(l, 2 * (lpoints - 1), ic2, 4326, 4326);
1873  return distance_in_meters(pt.x, pt.y, pl.x, pl.y);
1874 }
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.
DEVICE ALWAYS_INLINE int32_t compression_unit_size(const int32_t ic)
DEVICE ALWAYS_INLINE Point2D get_point(const int8_t *data, const int32_t x_index, const int32_t ic, const int32_t isr, const int32_t osr)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_NOINLINE double ST_Distance_Point_MultiLineString ( int8_t *  p,
int64_t  psize,
int8_t *  mls,
int64_t  mls_size,
int32_t *  mls_ls_sizes,
int64_t  mls_ls_num,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr,
double  threshold 
)

Definition at line 2070 of file ExtensionFunctionsGeo.hpp.

References distance_point_multilinestring().

Referenced by ST_Distance_MultiLineString_Point().

2081  {
2083  psize,
2084  mls,
2085  mls_size,
2086  mls_ls_sizes,
2087  mls_ls_num,
2088  ic1,
2089  isr1,
2090  ic2,
2091  isr2,
2092  osr,
2093  threshold);
2094 }
DEVICE ALWAYS_INLINE double distance_point_multilinestring(int8_t *p, int64_t psize, int8_t *mls, int64_t mls_size, int32_t *mls_ls_sizes, int64_t mls_ls_num, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double threshold)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_NOINLINE double ST_Distance_Point_MultiPoint ( int8_t *  p,
int64_t  psize,
int8_t *  mp,
int64_t  mpsize,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr,
double  threshold 
)

Definition at line 1892 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size(), distance_point_point(), and get_point().

Referenced by ST_Distance_MultiPoint_Point().

1901  {
1902  Point2D pt = get_point(p, 0, ic1, isr1, osr);
1903  auto mp_num_coords = mpsize / compression_unit_size(ic2);
1904  Point2D mpp = get_point(mp, 0, ic2, isr2, osr);
1905  double dist = distance_point_point(pt.x, pt.y, mpp.x, mpp.y);
1906  for (int32_t i = 2; i < mp_num_coords; i += 2) {
1907  mpp = get_point(mp, i, ic2, isr2, osr);
1908  double ldist = distance_point_point(pt.x, pt.y, mpp.x, mpp.y);
1909  if (dist > ldist) {
1910  dist = ldist;
1911  }
1912  if (dist <= threshold) {
1913  return dist;
1914  }
1915  }
1916  return dist;
1917 }
DEVICE ALWAYS_INLINE int32_t compression_unit_size(const int32_t ic)
DEVICE ALWAYS_INLINE Point2D get_point(const int8_t *data, const int32_t x_index, const int32_t ic, const int32_t isr, const int32_t osr)
DEVICE ALWAYS_INLINE double distance_point_point(double p1x, double p1y, double p2x, double p2y)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_NOINLINE double ST_Distance_Point_MultiPoint_Squared ( int8_t *  p,
int64_t  psize,
int8_t *  mp,
int64_t  mpsize,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr,
double  threshold 
)

Definition at line 1920 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size(), distance_point_point_squared(), and get_point().

Referenced by ST_Distance_MultiPoint_Point_Squared().

1929  {
1930  Point2D pt = get_point(p, 0, ic1, isr1, osr);
1931  auto mp_num_coords = mpsize / compression_unit_size(ic2);
1932  Point2D mpp = get_point(mp, 0, ic2, isr2, osr);
1933  double dist = distance_point_point_squared(pt.x, pt.y, mpp.x, mpp.y);
1934  for (int32_t i = 2; i < mp_num_coords; i += 2) {
1935  mpp = get_point(mp, i, ic2, isr2, osr);
1936  double ldist = distance_point_point_squared(pt.x, pt.y, mpp.x, mpp.y);
1937  if (dist > ldist) {
1938  dist = ldist;
1939  }
1940  if (dist <= threshold) {
1941  return dist;
1942  }
1943  }
1944  return dist;
1945 }
DEVICE ALWAYS_INLINE double distance_point_point_squared(double p1x, double p1y, double p2x, double p2y)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(const int32_t ic)
DEVICE ALWAYS_INLINE Point2D get_point(const int8_t *data, const int32_t x_index, const int32_t ic, const int32_t isr, const int32_t osr)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 
)

Definition at line 2237 of file ExtensionFunctionsGeo.hpp.

References distance_point_multipolygon().

Referenced by ST_Distance_MultiPolygon_Point(), and ST_DWithin_Point_MultiPolygon().

2250  {
2251  return distance_point_multipolygon(p,
2252  psize,
2253  mpoly_coords,
2254  mpoly_coords_size,
2255  mpoly_ring_sizes,
2256  mpoly_num_rings,
2257  mpoly_poly_sizes,
2258  mpoly_num_polys,
2259  ic1,
2260  isr1,
2261  ic2,
2262  isr2,
2263  osr,
2264  threshold);
2265 }
DEVICE ALWAYS_INLINE double 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)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 
)

Definition at line 1815 of file ExtensionFunctionsGeo.hpp.

References distance_point_point(), and get_point().

Referenced by ST_Intersects_Point_Point().

1823  {
1824  Point2D const pt1 = get_point(p1, 0, ic1, isr1, osr);
1825  Point2D const pt2 = get_point(p2, 0, ic2, isr2, osr);
1826  return distance_point_point(pt1.x, pt1.y, pt2.x, pt2.y);
1827 }
DEVICE ALWAYS_INLINE Point2D get_point(const int8_t *data, const int32_t x_index, const int32_t ic, const int32_t isr, const int32_t osr)
DEVICE ALWAYS_INLINE double distance_point_point(double p1x, double p1y, double p2x, double p2y)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 
)

Definition at line 1845 of file ExtensionFunctionsGeo.hpp.

References distance_in_meters(), and get_point().

Referenced by ST_DWithin_Point_Point_Geodesic().

1853  {
1854  Point2D const pt1 = get_point(p1, 0, ic1, 4326, 4326);
1855  Point2D const pt2 = get_point(p2, 0, ic2, 4326, 4326);
1856  return distance_in_meters(pt1.x, pt1.y, pt2.x, pt2.y);
1857 }
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.
DEVICE ALWAYS_INLINE Point2D get_point(const int8_t *data, const int32_t x_index, const int32_t ic, const int32_t isr, const int32_t osr)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 
)

Definition at line 1830 of file ExtensionFunctionsGeo.hpp.

References distance_point_point_squared(), and get_point().

Referenced by ST_DWithin_Point_Point().

1838  {
1839  Point2D const pt1 = get_point(p1, 0, ic1, isr1, osr);
1840  Point2D const pt2 = get_point(p2, 0, ic2, isr2, osr);
1841  return distance_point_point_squared(pt1.x, pt1.y, pt2.x, pt2.y);
1842 }
DEVICE ALWAYS_INLINE double distance_point_point_squared(double p1x, double p1y, double p2x, double p2y)
DEVICE ALWAYS_INLINE Point2D get_point(const int8_t *data, const int32_t x_index, const int32_t ic, const int32_t isr, const int32_t osr)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 
)

Definition at line 2210 of file ExtensionFunctionsGeo.hpp.

References distance_point_polygon().

Referenced by ST_Distance_LineString_Polygon(), ST_Distance_Polygon_Point(), and ST_DWithin_Point_Polygon().

2221  {
2222  return distance_point_polygon(p,
2223  psize,
2224  poly,
2225  polysize,
2226  poly_ring_sizes,
2227  poly_num_rings,
2228  ic1,
2229  isr1,
2230  ic2,
2231  isr2,
2232  osr,
2233  threshold);
2234 }
DEVICE ALWAYS_INLINE double 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)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr,
double  threshold 
)

Definition at line 2905 of file ExtensionFunctionsGeo.hpp.

References ST_Distance_LineString_Polygon().

2916  {
2918  lsize,
2919  poly_coords,
2920  poly_coords_size,
2921  poly_ring_sizes,
2922  poly_num_rings,
2923  ic2,
2924  isr2,
2925  ic1,
2926  isr2,
2927  osr,
2928  threshold);
2929 }
EXTENSION_NOINLINE double ST_Distance_LineString_Polygon(int8_t *l, int64_t lsize, 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)

+ Here is the call graph for this function:

EXTENSION_INLINE double ST_Distance_Polygon_MultiPoint ( int8_t *  poly,
int64_t  polysize,
int32_t *  poly_ring_sizes,
int64_t  poly_num_rings,
int8_t *  mp,
int64_t  mpsize,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr,
double  threshold 
)

Definition at line 2380 of file ExtensionFunctionsGeo.hpp.

References ST_Distance_MultiPoint_Polygon().

2391  {
2393  mpsize,
2394  poly,
2395  polysize,
2396  poly_ring_sizes,
2397  poly_num_rings,
2398  ic2,
2399  isr2,
2400  ic1,
2401  isr1,
2402  osr,
2403  threshold);
2404 }
EXTENSION_INLINE double ST_Distance_MultiPoint_Polygon(int8_t *mp, int64_t mpsize, 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)

+ Here is the call graph for this function:

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 
)

Definition at line 3017 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size(), ST_Distance_Polygon_Polygon(), and tol_zero().

Referenced by ST_Distance_MultiPolygon_MultiPolygon(), ST_Distance_MultiPolygon_Polygon(), ST_DWithin_Polygon_MultiPolygon(), and ST_Intersects_Polygon_MultiPolygon().

3032  {
3033  double min_distance = 0.0;
3034 
3035  // Set specific poly pointers as we move through the coords/ringsizes/polyrings arrays.
3036  auto next_poly_coords = mpoly_coords;
3037  auto next_poly_ring_sizes = mpoly_ring_sizes;
3038 
3039  for (auto poly = 0; poly < mpoly_num_polys; poly++) {
3040  auto poly_coords = next_poly_coords;
3041  auto poly_ring_sizes = next_poly_ring_sizes;
3042  auto poly_num_rings = mpoly_poly_sizes[poly];
3043  // Count number of coords in all of poly's rings, advance ring size pointer.
3044  int32_t poly_num_coords = 0;
3045  for (auto ring = 0; ring < poly_num_rings; ring++) {
3046  poly_num_coords += 2 * *next_poly_ring_sizes++;
3047  }
3048  auto poly_coords_size = poly_num_coords * compression_unit_size(ic2);
3049  next_poly_coords += poly_coords_size;
3050  double distance = ST_Distance_Polygon_Polygon(poly1_coords,
3051  poly1_coords_size,
3052  poly1_ring_sizes,
3053  poly1_num_rings,
3054  poly_coords,
3055  poly_coords_size,
3056  poly_ring_sizes,
3057  poly_num_rings,
3058  ic1,
3059  isr1,
3060  ic2,
3061  isr2,
3062  osr,
3063  threshold);
3064  if (poly == 0 || min_distance > distance) {
3065  min_distance = distance;
3066  if (tol_zero(min_distance)) {
3067  min_distance = 0.0;
3068  break;
3069  }
3070  if (min_distance <= threshold) {
3071  break;
3072  }
3073  }
3074  }
3075 
3076  return min_distance;
3077 }
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)
DEVICE ALWAYS_INLINE bool tol_zero(const double x, const double tolerance=TOLERANCE_DEFAULT)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(const int32_t ic)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 
)

Definition at line 2878 of file ExtensionFunctionsGeo.hpp.

References ST_Distance_Point_Polygon().

Referenced by ST_Distance_Polygon_Polygon().

2889  {
2890  return ST_Distance_Point_Polygon(p,
2891  psize,
2892  poly_coords,
2893  poly_coords_size,
2894  poly_ring_sizes,
2895  poly_num_rings,
2896  ic2,
2897  isr2,
2898  ic1,
2899  isr1,
2900  osr,
2901  threshold);
2902 }
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)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 
)

Definition at line 2932 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size(), distance_ring_ring(), ST_Distance_Polygon_Point(), and tol_zero().

Referenced by ST_Distance_Polygon_MultiPolygon(), ST_DWithin_Polygon_Polygon(), and ST_Intersects_Polygon_Polygon().

2945  {
2946  // Check if poly1 contains the first point of poly2's shape, i.e. the external ring
2947  auto poly2_first_point_coords = poly2_coords;
2948  auto poly2_first_point_coords_size = compression_unit_size(ic2) * 2;
2949  auto min_distance = ST_Distance_Polygon_Point(poly1_coords,
2950  poly1_coords_size,
2951  poly1_ring_sizes,
2952  poly1_num_rings,
2953  poly2_first_point_coords,
2954  poly2_first_point_coords_size,
2955  ic1,
2956  isr1,
2957  ic2,
2958  isr2,
2959  osr,
2960  threshold);
2961  if (tol_zero(min_distance)) {
2962  // Polygons overlap
2963  return 0.0;
2964  }
2965  if (min_distance <= threshold) {
2966  return min_distance;
2967  }
2968 
2969  // Poly2's first point is either outside poly1's external ring or inside one of the
2970  // internal rings. Measure the smallest distance between a poly1 ring (external or
2971  // internal) and a poly2 ring (external or internal). If poly2 is completely outside
2972  // poly1, then the min distance would be between poly1's and poly2's external rings. If
2973  // poly2 is completely inside one of poly1 internal rings then the min distance would be
2974  // between that poly1 internal ring and poly2's external ring. If poly1 is completely
2975  // inside one of poly2 internal rings, min distance is between that internal ring and
2976  // poly1's external ring. In each case other rings don't get in the way. Any ring
2977  // intersection means zero distance - short-circuit and return.
2978 
2979  auto poly1_ring_coords = poly1_coords;
2980  for (auto r1 = 0; r1 < poly1_num_rings; r1++) {
2981  int64_t poly1_ring_num_coords = poly1_ring_sizes[r1] * 2;
2982 
2983  auto poly2_ring_coords = poly2_coords;
2984  for (auto r2 = 0; r2 < poly2_num_rings; r2++) {
2985  int64_t poly2_ring_num_coords = poly2_ring_sizes[r2] * 2;
2986 
2987  auto distance = distance_ring_ring(poly1_ring_coords,
2988  poly1_ring_num_coords,
2989  poly2_ring_coords,
2990  poly2_ring_num_coords,
2991  ic1,
2992  isr1,
2993  ic2,
2994  isr2,
2995  osr,
2996  threshold);
2997  if (min_distance > distance) {
2998  min_distance = distance;
2999  if (tol_zero(min_distance)) {
3000  return 0.0;
3001  }
3002  if (min_distance <= threshold) {
3003  return min_distance;
3004  }
3005  }
3006 
3007  poly2_ring_coords += poly2_ring_num_coords * compression_unit_size(ic2);
3008  }
3009 
3010  poly1_ring_coords += poly1_ring_num_coords * compression_unit_size(ic1);
3011  }
3012 
3013  return min_distance;
3014 }
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)
DEVICE ALWAYS_INLINE bool tol_zero(const double x, const double tolerance=TOLERANCE_DEFAULT)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(const int32_t ic)
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)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_INLINE bool ST_DWithin_LineString_LineString ( int8_t *  l1,
int64_t  l1size,
double *  l1bounds,
int64_t  l1bounds_size,
int8_t *  l2,
int64_t  l2size,
double *  l2bounds,
int64_t  l2bounds_size,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr,
double  distance_within 
)

Definition at line 3421 of file ExtensionFunctionsGeo.hpp.

References box_dwithin_box(), and ST_Distance_LineString_LineString().

3434  {
3435  if (l1bounds && l2bounds) {
3436  // Bounding boxes need to be transformed to output SR before proximity check
3437  if (!box_dwithin_box(l1bounds,
3438  l1bounds_size,
3439  isr1,
3440  l2bounds,
3441  l2bounds_size,
3442  isr2,
3443  osr,
3444  distance_within)) {
3445  return false;
3446  }
3447  }
3448 
3449  // May need to adjust the threshold by TOLERANCE_DEFAULT
3450  const double threshold = distance_within;
3452  l1, l1size, l2, l2size, ic1, isr1, ic2, isr2, osr, threshold) <=
3453  distance_within;
3454 }
EXTENSION_NOINLINE double ST_Distance_LineString_LineString(int8_t *l1, int64_t l1size, int8_t *l2, int64_t l2size, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double threshold)
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)

+ Here is the call graph for this function:

EXTENSION_INLINE bool ST_DWithin_LineString_MultiPolygon ( int8_t *  l1,
int64_t  l1size,
double *  l1bounds,
int64_t  l1bounds_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 
)

Definition at line 3522 of file ExtensionFunctionsGeo.hpp.

References box_dwithin_box(), compression_unit_size(), ST_Distance_LineString_MultiPolygon(), and trim_linestring_to_buffered_box().

3539  {
3540  if (l1bounds && mpoly_bounds) {
3541  // Bounding boxes need to be transformed to output SR before proximity check
3542  if (!box_dwithin_box(l1bounds,
3543  l1bounds_size,
3544  isr1,
3545  mpoly_bounds,
3546  mpoly_bounds_size,
3547  isr2,
3548  osr,
3549  distance_within)) {
3550  return false;
3551  }
3552  }
3553 
3554  // First, assume the entire linestring is relevant.
3555  CoordData l1_relevant_section{l1, l1size};
3556  // Mitigation for very long linestrings (5+ segments: think highways, powerlines)
3557  if (mpoly_bounds && l1size > 12 * compression_unit_size(ic1)) {
3558  // Before diving into distance calculations, try to trim the linestring just to
3559  // segments whose bounding boxes overlap the threshold-buffered mpoly bounding box.
3560  l1_relevant_section = trim_linestring_to_buffered_box(l1,
3561  l1size,
3562  ic1,
3563  isr1,
3564  mpoly_bounds,
3565  mpoly_bounds_size,
3566  isr2,
3567  osr,
3568  distance_within);
3569  if (!l1_relevant_section.ptr) {
3570  // The big short-circuit: if not a single segment's bounding box overlaped
3571  // with buffered mpoly bounding box, then it means that the entire linestring
3572  // doesn't come close enough to the multipolygon to be within distance.
3573  // The global bounding boxes for the input geometries may overlap but the linestring
3574  // never gets close enough to the mpoly to require an actual distance calculation.
3575  return false;
3576  }
3577  }
3578 
3579  // Run distance calculation but only on the linestring section that is relevant.
3580  // May need to adjust the threshold by TOLERANCE_DEFAULT
3581  const double threshold = distance_within;
3582  return ST_Distance_LineString_MultiPolygon(l1_relevant_section.ptr,
3583  l1_relevant_section.size,
3584  mpoly_coords,
3585  mpoly_coords_size,
3586  mpoly_ring_sizes,
3587  mpoly_num_rings,
3588  mpoly_poly_sizes,
3589  mpoly_num_polys,
3590  ic1,
3591  isr1,
3592  ic2,
3593  isr2,
3594  osr,
3595  threshold) <= distance_within;
3596 }
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)
DEVICE ALWAYS_INLINE CoordData trim_linestring_to_buffered_box(int8_t *l1, int64_t l1size, 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_LineString_MultiPolygon(int8_t *l, int64_t lsize, 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)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(const int32_t ic)

+ Here is the call graph for this function:

EXTENSION_INLINE bool ST_DWithin_LineString_Polygon ( int8_t *  l1,
int64_t  l1size,
double *  l1bounds,
int64_t  l1bounds_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,
double  distance_within 
)

Definition at line 3457 of file ExtensionFunctionsGeo.hpp.

References box_dwithin_box(), compression_unit_size(), ST_Distance_LineString_Polygon(), and trim_linestring_to_buffered_box().

3472  {
3473  if (l1bounds && poly_bounds) {
3474  // Bounding boxes need to be transformed to output SR before proximity check
3475  if (!box_dwithin_box(l1bounds,
3476  l1bounds_size,
3477  isr1,
3478  poly_bounds,
3479  poly_bounds_size,
3480  isr2,
3481  osr,
3482  distance_within)) {
3483  return false;
3484  }
3485  }
3486 
3487  // First, assume the entire linestring is relevant.
3488  CoordData l1_relevant_section{l1, l1size};
3489  // Mitigation for very long linestrings (5+ segments: think highways, powerlines)
3490  if (poly_bounds && l1size > 12 * compression_unit_size(ic1)) {
3491  // Before diving into distance calculations, try to trim the linestring just to
3492  // segments whose bounding boxes overlap the threshold-buffered poly bounding box.
3493  l1_relevant_section = trim_linestring_to_buffered_box(
3494  l1, l1size, ic1, isr1, poly_bounds, poly_bounds_size, isr2, osr, distance_within);
3495  if (!l1_relevant_section.ptr) {
3496  // The big short-circuit: if not a single segment's bounding box overlaped
3497  // with buffered poly bounding box, then it means that the entire linestring
3498  // doesn't come close enough to the polygon to be within distance.
3499  // The global bounding boxes for the input geometries may overlap but the linestring
3500  // never gets close enough to the poly to require an actual distance calculation.
3501  return false;
3502  }
3503  }
3504 
3505  // May need to adjust the threshold by TOLERANCE_DEFAULT
3506  const double threshold = distance_within;
3507  return ST_Distance_LineString_Polygon(l1_relevant_section.ptr,
3508  l1_relevant_section.size,
3509  poly_coords,
3510  poly_coords_size,
3511  poly_ring_sizes,
3512  poly_num_rings,
3513  ic1,
3514  isr1,
3515  ic2,
3516  isr2,
3517  osr,
3518  threshold) <= distance_within;
3519 }
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)
DEVICE ALWAYS_INLINE CoordData trim_linestring_to_buffered_box(int8_t *l1, int64_t l1size, 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_LineString_Polygon(int8_t *l, int64_t lsize, 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)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(const int32_t ic)

+ Here is the call graph for this function:

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 
)

Definition at line 3705 of file ExtensionFunctionsGeo.hpp.

References box_dwithin_box(), and ST_Distance_MultiPolygon_MultiPolygon().

3726  {
3727  if (mpoly1_bounds && mpoly2_bounds) {
3728  // Bounding boxes need to be transformed to output SR before proximity check
3729  if (!box_dwithin_box(mpoly1_bounds,
3730  mpoly1_bounds_size,
3731  isr1,
3732  mpoly2_bounds,
3733  mpoly2_bounds_size,
3734  isr2,
3735  osr,
3736  distance_within)) {
3737  return false;
3738  }
3739  }
3740 
3741  // May need to adjust the threshold by TOLERANCE_DEFAULT
3742  const double threshold = distance_within;
3743  return ST_Distance_MultiPolygon_MultiPolygon(mpoly1_coords,
3744  mpoly1_coords_size,
3745  mpoly1_ring_sizes,
3746  mpoly1_num_rings,
3747  mpoly1_poly_sizes,
3748  mpoly1_num_polys,
3749  mpoly2_coords,
3750  mpoly2_coords_size,
3751  mpoly2_ring_sizes,
3752  mpoly2_num_rings,
3753  mpoly2_poly_sizes,
3754  mpoly2_num_polys,
3755  ic1,
3756  isr1,
3757  ic2,
3758  isr2,
3759  osr,
3760  threshold) <= distance_within;
3761 }
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 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)

+ Here is the call graph for this function:

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  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr,
double  distance_within 
)

Definition at line 3299 of file ExtensionFunctionsGeo.hpp.

References point_dwithin_box(), and ST_Distance_Point_LineString().

3310  {
3311  if (l2bounds) {
3312  // Bounding boxes need to be transformed to output SR before proximity check
3313  if (!point_dwithin_box(
3314  p1, p1size, ic1, isr1, l2bounds, l2bounds_size, isr2, osr, distance_within)) {
3315  return false;
3316  }
3317  }
3318 
3319  // May need to adjust the threshold by TOLERANCE_DEFAULT
3320  const double threshold = distance_within;
3322  p1, p1size, l2, l2size, ic1, isr1, ic2, isr2, osr, threshold) <=
3323  distance_within;
3324 }
EXTENSION_NOINLINE double ST_Distance_Point_LineString(int8_t *p, int64_t psize, int8_t *l, int64_t lsize, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double threshold)
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)

+ Here is the call graph for this function:

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 
)

Definition at line 3372 of file ExtensionFunctionsGeo.hpp.

References point_dwithin_box(), and ST_Distance_Point_MultiPolygon().

3387  {
3388  if (mpoly_bounds) {
3389  if (!point_dwithin_box(p,
3390  psize,
3391  ic1,
3392  isr1,
3393  mpoly_bounds,
3394  mpoly_bounds_size,
3395  isr2,
3396  osr,
3397  distance_within)) {
3398  return false;
3399  }
3400  }
3401 
3402  // May need to adjust the threshold by TOLERANCE_DEFAULT
3403  const double threshold = distance_within;
3405  psize,
3406  mpoly_coords,
3407  mpoly_coords_size,
3408  mpoly_ring_sizes,
3409  mpoly_num_rings,
3410  mpoly_poly_sizes,
3411  mpoly_num_polys,
3412  ic1,
3413  isr1,
3414  ic2,
3415  isr2,
3416  osr,
3417  threshold) <= distance_within;
3418 }
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)
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)

+ Here is the call graph for this function:

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 
)

Definition at line 3267 of file ExtensionFunctionsGeo.hpp.

References ST_Distance_Point_Point_Squared().

3276  {
3278  p1, p1size, p2, p2size, ic1, isr1, ic2, isr2, osr) <=
3279  distance_within * distance_within;
3280 }
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)

+ Here is the call graph for this function:

EXTENSION_INLINE bool ST_DWithin_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,
double  distance_within 
)

Definition at line 3283 of file ExtensionFunctionsGeo.hpp.

References ST_Distance_Point_Point_Geodesic().

3292  {
3293  auto dist_meters =
3294  ST_Distance_Point_Point_Geodesic(p1, p1size, p2, p2size, ic1, isr1, ic2, isr2, osr);
3295  return (dist_meters <= distance_within);
3296 }
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)

+ Here is the call graph for this function:

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 
)

Definition at line 3327 of file ExtensionFunctionsGeo.hpp.

References point_dwithin_box(), and ST_Distance_Point_Polygon().

3340  {
3341  if (poly_bounds) {
3342  if (!point_dwithin_box(p,
3343  psize,
3344  ic1,
3345  isr1,
3346  poly_bounds,
3347  poly_bounds_size,
3348  isr2,
3349  osr,
3350  distance_within)) {
3351  return false;
3352  }
3353  }
3354 
3355  // May need to adjust the threshold by TOLERANCE_DEFAULT
3356  const double threshold = distance_within;
3357  return ST_Distance_Point_Polygon(p,
3358  psize,
3359  poly_coords,
3360  poly_coords_size,
3361  poly_ring_sizes,
3362  poly_num_rings,
3363  ic1,
3364  isr1,
3365  ic2,
3366  isr2,
3367  osr,
3368  threshold) <= distance_within;
3369 }
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)
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)

+ Here is the call graph for this function:

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 
)

Definition at line 3650 of file ExtensionFunctionsGeo.hpp.

References box_dwithin_box(), and ST_Distance_Polygon_MultiPolygon().

3669  {
3670  if (poly_bounds && mpoly_bounds) {
3671  // Bounding boxes need to be transformed to output SR before proximity check
3672  if (!box_dwithin_box(poly_bounds,
3673  poly_bounds_size,
3674  isr1,
3675  mpoly_bounds,
3676  mpoly_bounds_size,
3677  isr2,
3678  osr,
3679  distance_within)) {
3680  return false;
3681  }
3682  }
3683 
3684  // May need to adjust the threshold by TOLERANCE_DEFAULT
3685  const double threshold = distance_within;
3686  return ST_Distance_Polygon_MultiPolygon(poly_coords,
3687  poly_coords_size,
3688  poly_ring_sizes,
3689  poly_num_rings,
3690  mpoly_coords,
3691  mpoly_coords_size,
3692  mpoly_ring_sizes,
3693  mpoly_num_rings,
3694  mpoly_poly_sizes,
3695  mpoly_num_polys,
3696  ic1,
3697  isr1,
3698  ic2,
3699  isr2,
3700  osr,
3701  threshold) <= distance_within;
3702 }
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 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)

+ Here is the call graph for this function:

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 
)

Definition at line 3599 of file ExtensionFunctionsGeo.hpp.

References box_dwithin_box(), and ST_Distance_Polygon_Polygon().

3616  {
3617  if (poly1_bounds && poly2_bounds) {
3618  // Bounding boxes need to be transformed to output SR before proximity check
3619  if (!box_dwithin_box(poly1_bounds,
3620  poly1_bounds_size,
3621  isr1,
3622  poly2_bounds,
3623  poly2_bounds_size,
3624  isr2,
3625  osr,
3626  distance_within)) {
3627  return false;
3628  }
3629  }
3630 
3631  // May need to adjust the threshold by TOLERANCE_DEFAULT
3632  const double threshold = distance_within;
3633  return ST_Distance_Polygon_Polygon(poly1_coords,
3634  poly1_coords_size,
3635  poly1_ring_sizes,
3636  poly1_num_rings,
3637  poly2_coords,
3638  poly2_coords_size,
3639  poly2_ring_sizes,
3640  poly2_num_rings,
3641  ic1,
3642  isr1,
3643  ic2,
3644  isr2,
3645  osr,
3646  threshold) <= distance_within;
3647 }
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 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)

+ Here is the call graph for this function:

EXTENSION_NOINLINE bool ST_Intersects_LineString_Linestring ( int8_t *  l1,
int64_t  l1size,
double *  l1bounds,
int64_t  l1bounds_size,
int8_t *  l2,
int64_t  l2size,
double *  l2bounds,
int64_t  l2bounds_size,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr 
)

Definition at line 4507 of file ExtensionFunctionsGeo.hpp.

References box_overlaps_box(), ST_Distance_LineString_LineString(), and tol_zero().

4519  {
4520  if (l1bounds && l2bounds) {
4521  if (!box_overlaps_box(l1bounds, l1bounds_size, l2bounds, l2bounds_size)) {
4522  return false;
4523  }
4524  }
4525 
4527  l1, l1size, l2, l2size, ic1, isr1, ic2, isr2, osr, 0.0));
4528 }
EXTENSION_NOINLINE double ST_Distance_LineString_LineString(int8_t *l1, int64_t l1size, int8_t *l2, int64_t l2size, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double threshold)
DEVICE ALWAYS_INLINE bool box_overlaps_box(double *bounds1, int64_t bounds1_size, double *bounds2, int64_t bounds2_size)
DEVICE ALWAYS_INLINE bool tol_zero(const double x, const double tolerance=TOLERANCE_DEFAULT)

+ Here is the call graph for this function:

EXTENSION_NOINLINE bool ST_Intersects_LineString_MultiPolygon ( int8_t *  l,
int64_t  lsize,
double *  lbounds,
int64_t  lbounds_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 
)

Definition at line 4574 of file ExtensionFunctionsGeo.hpp.

References box_overlaps_box(), ST_Distance_LineString_MultiPolygon(), and tol_zero().

Referenced by ST_Intersects_MultiPolygon_LineString().

4590  {
4591  if (lbounds && mpoly_bounds) {
4592  if (!box_overlaps_box(lbounds, lbounds_size, mpoly_bounds, mpoly_bounds_size)) {
4593  return false;
4594  }
4595  }
4596 
4597  // Check for spatial intersection.
4598  // One way to do that would be to start with linestring's first point, if it's inside
4599  // any of the polygons - it means intersection. Otherwise follow the linestring, segment
4600  // by segment, checking for intersections with polygon shapes/holes, bail as soon as we
4601  // cross into a polygon.
4602 
4603  // Or, alternatively, just measure the distance:
4605  lsize,
4606  mpoly_coords,
4607  mpoly_coords_size,
4608  mpoly_ring_sizes,
4609  mpoly_num_rings,
4610  mpoly_poly_sizes,
4611  mpoly_num_polys,
4612  ic1,
4613  isr1,
4614  ic2,
4615  isr2,
4616  osr,
4617  0.0));
4618 }
DEVICE ALWAYS_INLINE bool box_overlaps_box(double *bounds1, int64_t bounds1_size, double *bounds2, int64_t bounds2_size)
EXTENSION_NOINLINE double ST_Distance_LineString_MultiPolygon(int8_t *l, int64_t lsize, 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)
DEVICE ALWAYS_INLINE bool tol_zero(const double x, const double tolerance=TOLERANCE_DEFAULT)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_INLINE bool ST_Intersects_LineString_Point ( int8_t *  l,
int64_t  lsize,
double *  lbounds,
int64_t  lbounds_size,
int8_t *  p,
int64_t  psize,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr 
)

Definition at line 4491 of file ExtensionFunctionsGeo.hpp.

References ST_Intersects_Point_LineString().

4501  {
4503  p, psize, l, lsize, lbounds, lbounds_size, ic2, isr2, ic1, isr1, osr);
4504 }
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 ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)

+ Here is the call graph for this function:

EXTENSION_NOINLINE bool ST_Intersects_LineString_Polygon ( int8_t *  l,
int64_t  lsize,
double *  lbounds,
int64_t  lbounds_size,
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 
)

Definition at line 4531 of file ExtensionFunctionsGeo.hpp.

References box_overlaps_box(), ST_Distance_LineString_Polygon(), and tol_zero().

Referenced by ST_Intersects_Polygon_LineString().

4545  {
4546  if (lbounds && poly_bounds) {
4547  if (!box_overlaps_box(lbounds, lbounds_size, poly_bounds, poly_bounds_size)) {
4548  return false;
4549  }
4550  }
4551 
4552  // Check for spatial intersection.
4553  // One way to do that would be to start with linestring's first point, if it's inside
4554  // the polygon - it means intersection. Otherwise follow the linestring, segment by
4555  // segment, checking for intersections with polygon rings, bail as soon as we cross into
4556  // the polygon.
4557 
4558  // Or, alternatively, just measure the distance:
4560  lsize,
4561  poly,
4562  polysize,
4563  poly_ring_sizes,
4564  poly_num_rings,
4565  ic1,
4566  isr1,
4567  ic2,
4568  isr2,
4569  osr,
4570  0.0));
4571 }
DEVICE ALWAYS_INLINE bool box_overlaps_box(double *bounds1, int64_t bounds1_size, double *bounds2, int64_t bounds2_size)
EXTENSION_NOINLINE double ST_Distance_LineString_Polygon(int8_t *l, int64_t lsize, 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)
DEVICE ALWAYS_INLINE bool tol_zero(const double x, const double tolerance=TOLERANCE_DEFAULT)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr 
)

Definition at line 4868 of file ExtensionFunctionsGeo.hpp.

References ST_Intersects_LineString_MultiPolygon().

4884  {
4886  lsize,
4887  lbounds,
4888  lbounds_size,
4889  mpoly_coords,
4890  mpoly_coords_size,
4891  mpoly_ring_sizes,
4892  mpoly_num_rings,
4893  mpoly_poly_sizes,
4894  mpoly_num_polys,
4895  mpoly_bounds,
4896  mpoly_bounds_size,
4897  ic2,
4898  isr2,
4899  ic1,
4900  isr1,
4901  osr);
4902 }
EXTENSION_NOINLINE bool ST_Intersects_LineString_MultiPolygon(int8_t *l, int64_t lsize, double *lbounds, int64_t lbounds_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)

+ Here is the call graph for this function:

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 
)

Definition at line 4946 of file ExtensionFunctionsGeo.hpp.

References box_overlaps_box(), ST_Distance_MultiPolygon_MultiPolygon(), and tol_zero().

4966  {
4967  if (mpoly1_bounds && mpoly2_bounds) {
4968  if (!box_overlaps_box(
4969  mpoly1_bounds, mpoly1_bounds_size, mpoly2_bounds, mpoly2_bounds_size)) {
4970  return false;
4971  }
4972  }
4973 
4974  return tol_zero(ST_Distance_MultiPolygon_MultiPolygon(mpoly1_coords,
4975  mpoly1_coords_size,
4976  mpoly1_ring_sizes,
4977  mpoly1_num_rings,
4978  mpoly1_poly_sizes,
4979  mpoly1_num_polys,
4980  mpoly2_coords,
4981  mpoly2_coords_size,
4982  mpoly2_ring_sizes,
4983  mpoly2_num_rings,
4984  mpoly2_poly_sizes,
4985  mpoly2_num_polys,
4986  ic1,
4987  isr1,
4988  ic2,
4989  isr2,
4990  osr,
4991  0.0));
4992 }
DEVICE ALWAYS_INLINE bool box_overlaps_box(double *bounds1, int64_t bounds1_size, double *bounds2, int64_t bounds2_size)
DEVICE ALWAYS_INLINE bool tol_zero(const double x, const double tolerance=TOLERANCE_DEFAULT)
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)

+ Here is the call graph for this function:

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 
)

Definition at line 4800 of file ExtensionFunctionsGeo.hpp.

4814  {
4815  return Contains_MultiPolygon_Point_Impl<double, EdgeBehavior::kIncludePointOnEdge>(
4816  mpoly_coords,
4817  mpoly_coords_size,
4818  mpoly_ring_sizes,
4819  mpoly_num_rings,
4820  mpoly_poly_sizes,
4821  mpoly_num_polys,
4822  mpoly_bounds,
4823  mpoly_bounds_size,
4824  p,
4825  psize,
4826  ic1,
4827  isr1,
4828  ic2,
4829  isr2,
4830  osr);
4831 }
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 
)

Definition at line 4905 of file ExtensionFunctionsGeo.hpp.

References ST_Intersects_Polygon_MultiPolygon().

4923  {
4924  return ST_Intersects_Polygon_MultiPolygon(poly_coords,
4925  poly_coords_size,
4926  poly_ring_sizes,
4927  poly_num_rings,
4928  poly_bounds,
4929  poly_bounds_size,
4930  mpoly_coords,
4931  mpoly_coords_size,
4932  mpoly_ring_sizes,
4933  mpoly_num_rings,
4934  mpoly_poly_sizes,
4935  mpoly_num_polys,
4936  mpoly_bounds,
4937  mpoly_bounds_size,
4938  ic2,
4939  isr2,
4940  ic1,
4941  isr1,
4942  osr);
4943 }
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)

+ Here is the call graph for this function:

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  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr 
)

Definition at line 4405 of file ExtensionFunctionsGeo.hpp.

References box_contains_point(), get_point(), ST_Distance_Point_LineString(), and tol_zero().

Referenced by ST_Intersects_LineString_Point().

4415  {
4416  if (lbounds) {
4417  Point2D const pt = get_point(p, 0, ic1, isr1, osr);
4418  if (!box_contains_point(lbounds, lbounds_size, pt.x, pt.y)) {
4419  return false;
4420  }
4421  }
4422  return tol_zero(
4423  ST_Distance_Point_LineString(p, psize, l, lsize, ic1, isr1, ic2, isr2, osr, 0.0));
4424 }
EXTENSION_NOINLINE double ST_Distance_Point_LineString(int8_t *p, int64_t psize, int8_t *l, int64_t lsize, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, double threshold)
DEVICE ALWAYS_INLINE bool box_contains_point(const double *bounds, const int64_t bounds_size, const double px, const double py)
DEVICE ALWAYS_INLINE bool tol_zero(const double x, const double tolerance=TOLERANCE_DEFAULT)
DEVICE ALWAYS_INLINE Point2D get_point(const int8_t *data, const int32_t x_index, const int32_t ic, const int32_t isr, const int32_t osr)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 
)

Definition at line 4457 of file ExtensionFunctionsGeo.hpp.

4471  {
4472  return Contains_MultiPolygon_Point_Impl<double, EdgeBehavior::kIncludePointOnEdge>(
4473  mpoly_coords,
4474  mpoly_coords_size,
4475  mpoly_ring_sizes,
4476  mpoly_num_rings,
4477  mpoly_poly_sizes,
4478  mpoly_num_polys,
4479  mpoly_bounds,
4480  mpoly_bounds_size,
4481  p,
4482  psize,
4483  ic1,
4484  isr1,
4485  ic2,
4486  isr2,
4487  osr);
4488 }
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 
)

Definition at line 4391 of file ExtensionFunctionsGeo.hpp.

References ST_Distance_Point_Point(), and tol_zero().

4399  {
4400  return tol_zero(
4401  ST_Distance_Point_Point(p1, p1size, p2, p2size, ic1, isr1, ic2, isr2, osr));
4402 }
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)
DEVICE ALWAYS_INLINE bool tol_zero(const double x, const double tolerance=TOLERANCE_DEFAULT)

+ Here is the call graph for this function:

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 
)

Definition at line 4427 of file ExtensionFunctionsGeo.hpp.

4439  {
4440  return Contains_Polygon_Point_Impl<double, EdgeBehavior::kIncludePointOnEdge>(
4441  poly,
4442  polysize,
4443  poly_ring_sizes,
4444  poly_num_rings,
4445  poly_bounds,
4446  poly_bounds_size,
4447  p,
4448  psize,
4449  ic2,
4450  isr2,
4451  ic1,
4452  isr1,
4453  osr);
4454 }
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  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr 
)

Definition at line 4681 of file ExtensionFunctionsGeo.hpp.

References ST_Intersects_LineString_Polygon().

4695  {
4697  lsize,
4698  lbounds,
4699  lbounds_size,
4700  poly,
4701  polysize,
4702  poly_ring_sizes,
4703  poly_num_rings,
4704  poly_bounds,
4705  poly_bounds_size,
4706  ic2,
4707  isr2,
4708  ic1,
4709  isr1,
4710  osr);
4711 }
EXTENSION_NOINLINE bool ST_Intersects_LineString_Polygon(int8_t *l, int64_t lsize, double *lbounds, int64_t lbounds_size, 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)

+ Here is the call graph for this function:

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 
)

Definition at line 4755 of file ExtensionFunctionsGeo.hpp.

References box_overlaps_box(), ST_Distance_Polygon_MultiPolygon(), and tol_zero().

Referenced by ST_Intersects_MultiPolygon_Polygon().

4773  {
4774  if (poly_bounds && mpoly_bounds) {
4775  if (!box_overlaps_box(
4776  poly_bounds, poly_bounds_size, mpoly_bounds, mpoly_bounds_size)) {
4777  return false;
4778  }
4779  }
4780 
4781  return tol_zero(ST_Distance_Polygon_MultiPolygon(poly_coords,
4782  poly_coords_size,
4783  poly_ring_sizes,
4784  poly_num_rings,
4785  mpoly_coords,
4786  mpoly_coords_size,
4787  mpoly_ring_sizes,
4788  mpoly_num_rings,
4789  mpoly_poly_sizes,
4790  mpoly_num_polys,
4791  ic1,
4792  isr1,
4793  ic2,
4794  isr2,
4795  osr,
4796  0.0));
4797 }
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)
DEVICE ALWAYS_INLINE bool box_overlaps_box(double *bounds1, int64_t bounds1_size, double *bounds2, int64_t bounds2_size)
DEVICE ALWAYS_INLINE bool tol_zero(const double x, const double tolerance=TOLERANCE_DEFAULT)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 
)

Definition at line 4621 of file ExtensionFunctionsGeo.hpp.

4633  {
4634  return Contains_Polygon_Point_Impl<double, EdgeBehavior::kIncludePointOnEdge>(
4635  poly,
4636  polysize,
4637  poly_ring_sizes,
4638  poly_num_rings,
4639  poly_bounds,
4640  poly_bounds_size,
4641  p,
4642  psize,
4643  ic1,
4644  isr1,
4645  ic2,
4646  isr2,
4647  osr);
4648 }
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 
)

Definition at line 4714 of file ExtensionFunctionsGeo.hpp.

References box_overlaps_box(), ST_Distance_Polygon_Polygon(), and tol_zero().

4730  {
4731  if (poly1_bounds && poly2_bounds) {
4732  if (!box_overlaps_box(
4733  poly1_bounds, poly1_bounds_size, poly2_bounds, poly2_bounds_size)) {
4734  return false;
4735  }
4736  }
4737 
4738  return tol_zero(ST_Distance_Polygon_Polygon(poly1_coords,
4739  poly1_coords_size,
4740  poly1_ring_sizes,
4741  poly1_num_rings,
4742  poly2_coords,
4743  poly2_coords_size,
4744  poly2_ring_sizes,
4745  poly2_num_rings,
4746  ic1,
4747  isr1,
4748  ic2,
4749  isr2,
4750  osr,
4751  0.0));
4752 }
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)
DEVICE ALWAYS_INLINE bool box_overlaps_box(double *bounds1, int64_t bounds1_size, double *bounds2, int64_t bounds2_size)
DEVICE ALWAYS_INLINE bool tol_zero(const double x, const double tolerance=TOLERANCE_DEFAULT)

+ Here is the call graph for this function:

EXTENSION_NOINLINE double ST_Length_LineString ( int8_t *  coords,
int64_t  coords_sz,
int32_t  ic,
int32_t  isr,
int32_t  osr 
)

Definition at line 1169 of file ExtensionFunctionsGeo.hpp.

References length_linestring().

1173  {
1174  return length_linestring(coords, coords_sz, ic, isr, osr, false, false);
1175 }
DEVICE ALWAYS_INLINE double length_linestring(int8_t *l, int32_t lsize, int32_t ic, int32_t isr, int32_t osr, bool geodesic, bool check_closed)

+ Here is the call graph for this function:

EXTENSION_NOINLINE double ST_Length_LineString_Geodesic ( int8_t *  coords,
int64_t  coords_sz,
int32_t  ic,
int32_t  isr,
int32_t  osr 
)

Definition at line 1178 of file ExtensionFunctionsGeo.hpp.

References length_linestring().

1182  {
1183  return length_linestring(coords, coords_sz, ic, isr, osr, true, false);
1184 }
DEVICE ALWAYS_INLINE double length_linestring(int8_t *l, int32_t lsize, int32_t ic, int32_t isr, int32_t osr, bool geodesic, bool check_closed)

+ Here is the call graph for this function:

EXTENSION_NOINLINE double ST_Length_MultiLineString ( int8_t *  coords,
int64_t  coords_sz,
int8_t *  linestring_sizes_in,
int64_t  linestring_sizes_sz,
int32_t  ic,
int32_t  isr,
int32_t  osr 
)

Definition at line 1187 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size(), and length_linestring().

1193  {
1194  if (linestring_sizes_sz <= 0) {
1195  return 0.0;
1196  }
1197  double mls_length = 0.0;
1198 
1199  auto next_linestring_coords = coords;
1200 
1201  for (auto l = 0; l < linestring_sizes_sz; l++) {
1202  auto linestring_coords = next_linestring_coords;
1203  auto linestring_sizes = reinterpret_cast<int32_t*>(linestring_sizes_in);
1204  auto linestring_num_points = linestring_sizes[l];
1205  auto linestring_num_coords = 2 * linestring_num_points;
1206  auto linestring_coords_size = linestring_num_coords * compression_unit_size(ic);
1207  next_linestring_coords += linestring_coords_size;
1208  double ls_length = length_linestring(
1209  linestring_coords, linestring_coords_size, ic, isr, osr, false, false);
1210  mls_length += ls_length;
1211  }
1212 
1213  return mls_length;
1214 }
DEVICE ALWAYS_INLINE double length_linestring(int8_t *l, int32_t lsize, int32_t ic, int32_t isr, int32_t osr, bool geodesic, bool check_closed)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(const int32_t ic)

+ Here is the call graph for this function:

EXTENSION_NOINLINE double ST_MaxDistance_LineString_Point ( int8_t *  l,
int64_t  lsize,
int8_t *  p,
int64_t  psize,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr 
)

Definition at line 3837 of file ExtensionFunctionsGeo.hpp.

References max_distance_point_linestring().

3845  {
3847  p, psize, l, lsize, ic2, isr2, ic1, isr1, osr, false);
3848 }
DEVICE ALWAYS_INLINE double max_distance_point_linestring(int8_t *p, int64_t psize, int8_t *l, int64_t lsize, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, bool check_closed)

+ Here is the call graph for this function:

EXTENSION_NOINLINE double ST_MaxDistance_Point_LineString ( int8_t *  p,
int64_t  psize,
int8_t *  l,
int64_t  lsize,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr 
)

Definition at line 3823 of file ExtensionFunctionsGeo.hpp.

References max_distance_point_linestring().

3831  {
3833  p, psize, l, lsize, ic1, isr1, ic2, isr2, osr, false);
3834 }
DEVICE ALWAYS_INLINE double max_distance_point_linestring(int8_t *p, int64_t psize, int8_t *l, int64_t lsize, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, bool check_closed)

+ Here is the call graph for this function:

EXTENSION_NOINLINE double ST_Perimeter_MultiPolygon ( int8_t *  mpoly_coords,
int32_t  mpoly_coords_size,
int8_t *  mpoly_ring_sizes,
int32_t  mpoly_num_rings,
int8_t *  mpoly_poly_sizes,
int32_t  mpoly_num_polys,
int32_t  ic,
int32_t  isr,
int32_t  osr 
)

Definition at line 1302 of file ExtensionFunctionsGeo.hpp.

References perimeter_multipolygon().

1310  {
1311  return perimeter_multipolygon(mpoly_coords,
1312  mpoly_coords_size,
1313  mpoly_ring_sizes,
1314  mpoly_num_rings,
1315  mpoly_poly_sizes,
1316  mpoly_num_polys,
1317  ic,
1318  isr,
1319  osr,
1320  false);
1321 }
DEVICE ALWAYS_INLINE double perimeter_multipolygon(int8_t *mpoly_coords, int32_t mpoly_coords_size, int8_t *mpoly_ring_sizes_in, int32_t mpoly_num_rings, int8_t *mpoly_poly_sizes, int32_t mpoly_num_polys, int32_t ic, int32_t isr, int32_t osr, bool geodesic)

+ Here is the call graph for this function:

EXTENSION_NOINLINE double ST_Perimeter_MultiPolygon_Geodesic ( int8_t *  mpoly_coords,
int32_t  mpoly_coords_size,
int8_t *  mpoly_ring_sizes,
int32_t  mpoly_num_rings,
int8_t *  mpoly_poly_sizes,
int32_t  mpoly_num_polys,
int32_t  ic,
int32_t  isr,
int32_t  osr 
)

Definition at line 1324 of file ExtensionFunctionsGeo.hpp.

References perimeter_multipolygon().

1332  {
1333  return perimeter_multipolygon(mpoly_coords,
1334  mpoly_coords_size,
1335  mpoly_ring_sizes,
1336  mpoly_num_rings,
1337  mpoly_poly_sizes,
1338  mpoly_num_polys,
1339  ic,
1340  isr,
1341  osr,
1342  true);
1343 }
DEVICE ALWAYS_INLINE double perimeter_multipolygon(int8_t *mpoly_coords, int32_t mpoly_coords_size, int8_t *mpoly_ring_sizes_in, int32_t mpoly_num_rings, int8_t *mpoly_poly_sizes, int32_t mpoly_num_polys, int32_t ic, int32_t isr, int32_t osr, bool geodesic)

+ Here is the call graph for this function:

EXTENSION_NOINLINE double ST_Perimeter_Polygon ( int8_t *  poly,
int32_t  polysize,
int8_t *  poly_ring_sizes,
int32_t  poly_num_rings,
int32_t  ic,
int32_t  isr,
int32_t  osr 
)

Definition at line 1221 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size(), and length_linestring().

1227  {
1228  if (poly_num_rings <= 0) {
1229  return 0.0;
1230  }
1231 
1232  auto exterior_ring_num_coords = poly_ring_sizes[0] * 2;
1233  auto exterior_ring_coords_size = exterior_ring_num_coords * compression_unit_size(ic);
1234 
1235  return length_linestring(poly, exterior_ring_coords_size, ic, isr, osr, false, true);
1236 }
DEVICE ALWAYS_INLINE double length_linestring(int8_t *l, int32_t lsize, int32_t ic, int32_t isr, int32_t osr, bool geodesic, bool check_closed)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(const int32_t ic)

+ Here is the call graph for this function:

EXTENSION_NOINLINE double ST_Perimeter_Polygon_Geodesic ( int8_t *  poly,
int32_t  polysize,
int8_t *  poly_ring_sizes_in,
int32_t  poly_num_rings,
int32_t  ic,
int32_t  isr,
int32_t  osr 
)

Definition at line 1239 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size(), and length_linestring().

1245  {
1246  if (poly_num_rings <= 0) {
1247  return 0.0;
1248  }
1249 
1250  auto poly_ring_sizes = reinterpret_cast<int32_t*>(poly_ring_sizes_in);
1251  auto exterior_ring_num_coords = poly_ring_sizes[0] * 2;
1252  auto exterior_ring_coords_size = exterior_ring_num_coords * compression_unit_size(ic);
1253 
1254  return length_linestring(poly, exterior_ring_coords_size, ic, isr, osr, true, true);
1255 }
DEVICE ALWAYS_INLINE double length_linestring(int8_t *l, int32_t lsize, int32_t ic, int32_t isr, int32_t osr, bool geodesic, bool check_closed)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(const int32_t ic)

+ Here is the call graph for this function:

EXTENSION_NOINLINE double ST_X_Point ( int8_t *  p,
int64_t  psize,
int32_t  ic,
int32_t  isr,
int32_t  osr 
)

Definition at line 1055 of file ExtensionFunctionsGeo.hpp.

Referenced by to_Geospatial_GeoPoint().

1055  {
1056  return coord<X>(p, 0, ic, isr, osr).x;
1057 }

+ Here is the caller graph for this function:

EXTENSION_NOINLINE double ST_XMax ( int8_t *  coords,
int64_t  size,
int32_t  ic,
int32_t  isr,
int32_t  osr 
)

Definition at line 1091 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size().

Referenced by com.mapd.calcite.parser.HeavyDBSqlOperatorTable::addUDF().

1091  {
1092  auto num_coords = size / compression_unit_size(ic);
1093  double xmax = 0.0;
1094  for (int32_t i = 0; i < num_coords; i += 2) {
1095  double x = coord<X>(coords, i, ic, isr, osr).x;
1096  if (i == 0 || x > xmax) {
1097  xmax = x;
1098  }
1099  }
1100  return xmax;
1101 }
DEVICE ALWAYS_INLINE int32_t compression_unit_size(const int32_t ic)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_INLINE double ST_XMax_Bounds ( double *  bounds,
int64_t  size,
int32_t  isr,
int32_t  osr 
)

Definition at line 1127 of file ExtensionFunctionsGeo.hpp.

1127  {
1128  return transform_point<X>({bounds[2], bounds[3]}, isr, osr).x;
1129 }
EXTENSION_NOINLINE double ST_XMin ( int8_t *  coords,
int64_t  size,
int32_t  ic,
int32_t  isr,
int32_t  osr 
)

Definition at line 1065 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size().

Referenced by com.mapd.calcite.parser.HeavyDBSqlOperatorTable::addUDF().

1065  {
1066  auto num_coords = size / compression_unit_size(ic);
1067  double xmin = 0.0;
1068  for (int32_t i = 0; i < num_coords; i += 2) {
1069  double x = coord<X>(coords, i, ic, isr, osr).x;
1070  if (i == 0 || x < xmin) {
1071  xmin = x;
1072  }
1073  }
1074  return xmin;
1075 }
DEVICE ALWAYS_INLINE int32_t compression_unit_size(const int32_t ic)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_INLINE double ST_XMin_Bounds ( double *  bounds,
int64_t  size,
int32_t  isr,
int32_t  osr 
)

Definition at line 1117 of file ExtensionFunctionsGeo.hpp.

1117  {
1118  return transform_point<X>({bounds[0], bounds[1]}, isr, osr).x;
1119 }
EXTENSION_NOINLINE double ST_Y_Point ( int8_t *  p,
int64_t  psize,
int32_t  ic,
int32_t  isr,
int32_t  osr 
)

Definition at line 1060 of file ExtensionFunctionsGeo.hpp.

Referenced by to_Geospatial_GeoPoint().

1060  {
1061  return coord<Y>(p, 0, ic, isr, osr).y;
1062 }

+ Here is the caller graph for this function:

EXTENSION_NOINLINE double ST_YMax ( int8_t *  coords,
int64_t  size,
int32_t  ic,
int32_t  isr,
int32_t  osr 
)

Definition at line 1104 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size().

Referenced by com.mapd.calcite.parser.HeavyDBSqlOperatorTable::addUDF().

1104  {
1105  auto num_coords = size / compression_unit_size(ic);
1106  double ymax = 0.0;
1107  for (int32_t i = 0; i < num_coords; i += 2) {
1108  double y = coord<Y>(coords, i, ic, isr, osr).y;
1109  if (i == 0 || y > ymax) {
1110  ymax = y;
1111  }
1112  }
1113  return ymax;
1114 }
DEVICE ALWAYS_INLINE int32_t compression_unit_size(const int32_t ic)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_INLINE double ST_YMax_Bounds ( double *  bounds,
int64_t  size,
int32_t  isr,
int32_t  osr 
)

Definition at line 1132 of file ExtensionFunctionsGeo.hpp.

1132  {
1133  return transform_point<Y>({bounds[2], bounds[3]}, isr, osr).y;
1134 }
EXTENSION_NOINLINE double ST_YMin ( int8_t *  coords,
int64_t  size,
int32_t  ic,
int32_t  isr,
int32_t  osr 
)

Definition at line 1078 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size().

Referenced by com.mapd.calcite.parser.HeavyDBSqlOperatorTable::addUDF().

1078  {
1079  auto num_coords = size / compression_unit_size(ic);
1080  double ymin = 0.0;
1081  for (int32_t i = 0; i < num_coords; i += 2) {
1082  double y = coord<Y>(coords, i, ic, isr, osr).y;
1083  if (i == 0 || y < ymin) {
1084  ymin = y;
1085  }
1086  }
1087  return ymin;
1088 }
DEVICE ALWAYS_INLINE int32_t compression_unit_size(const int32_t ic)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_INLINE double ST_YMin_Bounds ( double *  bounds,
int64_t  size,
int32_t  isr,
int32_t  osr 
)

Definition at line 1122 of file ExtensionFunctionsGeo.hpp.

1122  {
1123  return transform_point<Y>({bounds[0], bounds[1]}, isr, osr).y;
1124 }
Geospatial::GeoLineString to_Geospatial_GeoLineString ( GeoLineString l)

Definition at line 5123 of file ExtensionFunctionsGeo.hpp.

References Geospatial::decompress_coords< double, int32_t >(), GeoLineStringStruct::getCompression(), GeoLineStringStruct::getInputSrid(), GeoLineStringStruct::getOutputSrid(), GeoLineStringStruct::getSize(), and GeoLineStringStruct::ptr.

Referenced by ST_AsBinary__GeoLineString__cpu_(), and ST_AsText__GeoLineString__cpu_().

5123  {
5124  int8_t* ptr = l.ptr;
5125  int32_t lsize = l.getSize();
5126  int32_t ic = l.getCompression();
5127  int32_t isr = l.getInputSrid();
5128  int32_t osr = l.getOutputSrid();
5129 
5130  std::vector<double> coords =
5132  auto linestring = Geospatial::GeoLineString(coords);
5133  linestring.transform(isr, osr);
5134  return linestring;
5135 }
DEVICE int32_t getSize() const
Definition: heavydbTypes.h:990
DEVICE int32_t getOutputSrid() const
Definition: heavydbTypes.h:996
std::shared_ptr< std::vector< double > > decompress_coords< double, int32_t >(const int32_t &ic, const int8_t *coords, const size_t coords_sz)
DEVICE int32_t getCompression() const
Definition: heavydbTypes.h:992
DEVICE int32_t getInputSrid() const
Definition: heavydbTypes.h:994

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Geospatial::GeoMultiLineString to_Geospatial_GeoMultiLineString ( GeoMultiLineString ml)

Definition at line 5137 of file ExtensionFunctionsGeo.hpp.

References Geospatial::decompress_coords< double, int32_t >(), GeoMultiLineStringStruct::getCompression(), GeoMultiLineStringStruct::getCoordsSize(), GeoMultiLineStringStruct::getInputSrid(), GeoMultiLineStringStruct::getLineStringSizes(), GeoMultiLineStringStruct::getNumLineStrings(), GeoMultiLineStringStruct::getOutputSrid(), and GeoMultiLineStringStruct::ptr.

Referenced by ST_AsBinary__GeoMultiLineString__cpu_(), and ST_AsText__GeoMultiLineString__cpu_().

5137  {
5138  int8_t* ptr = ml.ptr;
5139  int32_t ml_coords_size = ml.getCoordsSize();
5140  int32_t* linestring_sizes = reinterpret_cast<int32_t*>(ml.getLineStringSizes());
5141  int32_t num_linestrings = ml.getNumLineStrings();
5142  int32_t ic = ml.getCompression();
5143  int32_t isr = ml.getInputSrid();
5144  int32_t osr = ml.getOutputSrid();
5145 
5146  std::vector<double> coords =
5147  *Geospatial::decompress_coords<double, int32_t>(ic, ptr, ml_coords_size);
5148 
5149  std::vector<int32_t> v_linestring_sizes(linestring_sizes,
5150  linestring_sizes + num_linestrings);
5151 
5152  auto multilinestring = Geospatial::GeoMultiLineString(coords, v_linestring_sizes);
5153  multilinestring.transform(isr, osr);
5154  return multilinestring;
5155 }
DEVICE int32_t getCoordsSize() const
DEVICE int32_t getNumLineStrings() const
DEVICE int8_t * getLineStringSizes()
DEVICE int32_t getInputSrid() const
DEVICE int32_t getCompression() const
std::shared_ptr< std::vector< double > > decompress_coords< double, int32_t >(const int32_t &ic, const int8_t *coords, const size_t coords_sz)
DEVICE int32_t getOutputSrid() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Geospatial::GeoMultiPoint to_Geospatial_GeoMultiPoint ( GeoMultiPoint mp)

Definition at line 5109 of file ExtensionFunctionsGeo.hpp.

References Geospatial::decompress_coords< double, int32_t >(), GeoMultiPointStruct::getCompression(), GeoMultiPointStruct::getInputSrid(), GeoMultiPointStruct::getOutputSrid(), GeoMultiPointStruct::getSize(), and GeoMultiPointStruct::ptr.

Referenced by ST_AsBinary__GeoMultiPoint__cpu_(), and ST_AsText__GeoMultiPoint__cpu_().

5109  {
5110  int8_t* ptr = mp.ptr;
5111  int32_t lsize = mp.getSize();
5112  int32_t ic = mp.getCompression();
5113  int32_t isr = mp.getInputSrid();
5114  int32_t osr = mp.getOutputSrid();
5115 
5116  std::vector<double> coords =
5118  auto multipoint = Geospatial::GeoMultiPoint(coords);
5119  multipoint.transform(isr, osr);
5120  return multipoint;
5121 }
DEVICE int32_t getSize() const
Definition: heavydbTypes.h:972
DEVICE int32_t getCompression() const
Definition: heavydbTypes.h:974
DEVICE int32_t getOutputSrid() const
Definition: heavydbTypes.h:978
std::shared_ptr< std::vector< double > > decompress_coords< double, int32_t >(const int32_t &ic, const int8_t *coords, const size_t coords_sz)
DEVICE int32_t getInputSrid() const
Definition: heavydbTypes.h:976

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Geospatial::GeoMultiPolygon to_Geospatial_GeoMultiPolygon ( GeoMultiPolygon mp)

Definition at line 5175 of file ExtensionFunctionsGeo.hpp.

References Geospatial::decompress_coords< double, int32_t >().

Referenced by ST_AsBinary__GeoMultiPolygon__cpu_(), and ST_AsText__GeoMultiPolygon__cpu_().

5175  {
5176  int8_t* poly_coords = mp.ptr_coords;
5177  int32_t poly_coords_size = mp.getCoordsSize();
5178  int32_t* poly_ring_sizes = reinterpret_cast<int32_t*>(mp.getRingSizes());
5179  int32_t poly_num_rings = mp.getNumRings();
5180  int32_t* poly_sizes = reinterpret_cast<int32_t*>(mp.getPolygonSizes());
5181  int32_t num_polys = mp.getNumPolygons();
5182  int32_t ic = mp.getCompression();
5183  int32_t isr = mp.getInputSrid();
5184  int32_t osr = mp.getOutputSrid();
5185 
5186  std::vector<double> coords =
5187  *Geospatial::decompress_coords<double, int32_t>(ic, poly_coords, poly_coords_size);
5188 
5189  std::vector<int32_t> ring_sizes(poly_ring_sizes, poly_ring_sizes + poly_num_rings);
5190  std::vector<int32_t> poly_rings(poly_sizes, poly_sizes + num_polys);
5191 
5192  auto multipolygon = Geospatial::GeoMultiPolygon(coords, ring_sizes, poly_rings);
5193  multipolygon.transform(isr, osr);
5194  return multipolygon;
5195 }
std::shared_ptr< std::vector< double > > decompress_coords< double, int32_t >(const int32_t &ic, const int8_t *coords, const size_t coords_sz)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Geospatial::GeoPoint to_Geospatial_GeoPoint ( GeoPoint p)

Definition at line 5096 of file ExtensionFunctionsGeo.hpp.

References GeoPointStruct::getCompression(), GeoPointStruct::getInputSrid(), GeoPointStruct::getOutputSrid(), GeoPointStruct::getSize(), GeoPointStruct::ptr, ST_X_Point(), and ST_Y_Point().

Referenced by ST_AsBinary__GeoPoint__cpu_(), and ST_AsText__GeoPoint__cpu_().

5096  {
5097  int8_t* ptr = p.ptr;
5098  int32_t lsize = p.getSize();
5099  int32_t ic = p.getCompression();
5100  int32_t isr = p.getInputSrid();
5101  int32_t osr = p.getOutputSrid();
5102 
5103  double x = ST_X_Point(ptr, lsize, ic, isr, osr);
5104  double y = ST_Y_Point(ptr, lsize, ic, isr, osr);
5105  auto point = Geospatial::GeoPoint(std::vector<double>{x, y});
5106  return point;
5107 }
DEVICE int64_t getSize() const
Definition: heavydbTypes.h:954
EXTENSION_NOINLINE double ST_X_Point(int8_t *p, int64_t psize, int32_t ic, int32_t isr, int32_t osr)
DEVICE int32_t getInputSrid() const
Definition: heavydbTypes.h:958
DEVICE int32_t getCompression() const
Definition: heavydbTypes.h:956
EXTENSION_NOINLINE double ST_Y_Point(int8_t *p, int64_t psize, int32_t ic, int32_t isr, int32_t osr)
DEVICE int32_t getOutputSrid() const
Definition: heavydbTypes.h:960

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Geospatial::GeoPolygon to_Geospatial_GeoPolygon ( GeoPolygon p)

Definition at line 5157 of file ExtensionFunctionsGeo.hpp.

References Geospatial::decompress_coords< double, int32_t >().

Referenced by ST_AsBinary__GeoPolygon__cpu_(), and ST_AsText__GeoPolygon__cpu_().

5157  {
5158  int8_t* poly_coords = p.ptr_coords;
5159  int32_t poly_coords_size = p.getCoordsSize();
5160  int32_t* poly_ring_sizes = reinterpret_cast<int32_t*>(p.getRingSizes());
5161  int32_t poly_num_rings = p.getNumRings();
5162  int32_t ic = p.getCompression();
5163  int32_t isr = p.getInputSrid();
5164  int32_t osr = p.getOutputSrid();
5165 
5166  std::vector<double> coords =
5167  *Geospatial::decompress_coords<double, int32_t>(ic, poly_coords, poly_coords_size);
5168 
5169  std::vector<int32_t> ring_sizes(poly_ring_sizes, poly_ring_sizes + poly_num_rings);
5170  auto polygon = Geospatial::GeoPolygon(coords, ring_sizes);
5171  polygon.transform(isr, osr);
5172  return polygon;
5173 }
std::shared_ptr< std::vector< double > > decompress_coords< double, int32_t >(const int32_t &ic, const int8_t *coords, const size_t coords_sz)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

DEVICE ALWAYS_INLINE double tol ( int32_t  ic)

Definition at line 35 of file ExtensionFunctionsGeo.hpp.

References COMPRESSION_GEOINT32, TOLERANCE_DEFAULT, and TOLERANCE_GEOINT32.

Referenced by ST_Contains_Point_Point(), and tol().

35  {
36  if (ic == COMPRESSION_GEOINT32) {
37  return TOLERANCE_GEOINT32;
38  }
39  return TOLERANCE_DEFAULT;
40 }
#define TOLERANCE_GEOINT32
#define TOLERANCE_DEFAULT
#define COMPRESSION_GEOINT32

+ Here is the caller graph for this function:

DEVICE ALWAYS_INLINE double tol ( const int32_t  ic1,
const int32_t  ic2 
)

Definition at line 43 of file ExtensionFunctionsGeo.hpp.

References tol().

43  {
44  return fmax(tol(ic1), tol(ic2));
45 }
DEVICE ALWAYS_INLINE double tol(int32_t ic)

+ Here is the call graph for this function:

DEVICE ALWAYS_INLINE bool tol_eq ( const double  x,
const double  y,
const double  tolerance = TOLERANCE_DEFAULT 
)

Definition at line 52 of file ExtensionFunctionsGeo.hpp.

Referenced by polygon_contains_point(), ST_Contains_Point_LineString(), and ST_Contains_Point_Point().

54  {
55  auto diff = x - y;
56  return (-tolerance <= diff) && (diff <= tolerance);
57 }

+ Here is the caller graph for this function:

DEVICE ALWAYS_INLINE bool tol_ge ( const double  x,
const double  y,
const double  tolerance = TOLERANCE_DEFAULT 
)

Definition at line 65 of file ExtensionFunctionsGeo.hpp.

Referenced by box_contains_point(), and on_segment().

67  {
68  return (x + tolerance) >= y;
69 }

+ Here is the caller graph for this function:

DEVICE ALWAYS_INLINE bool tol_le ( const double  x,
const double  y,
const double  tolerance = TOLERANCE_DEFAULT 
)

Definition at line 59 of file ExtensionFunctionsGeo.hpp.

Referenced by box_contains_point(), and on_segment().

61  {
62  return x <= (y + tolerance);
63 }

+ Here is the caller graph for this function:

template<typename T >
DEVICE ALWAYS_INLINE bool tol_zero_template ( const T  x,
const T  tolerance = TOLERANCE_DEFAULT 
)

Definition at line 563 of file ExtensionFunctionsGeo.hpp.

Referenced by point_in_polygon_winding_number().

564  {
565  if constexpr (!std::is_floating_point<T>::value) {
566  return x == 0; // assume integer 0s are always 0
567  }
568  return (-tolerance <= x) && (x <= tolerance);
569 }

+ Here is the caller graph for this function:

template<Coords C>
DEVICE ALWAYS_INLINE Point2D transform_point ( const Point2D  point,
const int32_t  isr,
const int32_t  osr 
)

Definition at line 155 of file ExtensionFunctionsGeo.hpp.

References is_utm_srid(), and to_string().

157  {
158  if (isr == osr || osr == 0) {
159  return point;
160  } else if (isr == 4326) {
161  if (osr == 900913) {
162  return conv_4326_900913<C>(point); // WGS 84 --> Web Mercator
163 #ifdef ENABLE_UTM_TRANSFORM
164  } else if (is_utm_srid(osr)) {
165  return conv_4326_utm<C>(point, osr); // WGS 84 --> UTM
166  }
167  } else if (is_utm_srid(isr)) {
168  if (osr == 4326) {
169  return conv_utm_4326<C>(point, osr); // UTM --> WGS 84
170 #endif
171  }
172  }
173 #ifdef __CUDACC__
174  return {}; // (NaN,NaN)
175 #else
176  throw std::runtime_error("Unhandled geo transformation from " + std::to_string(isr) +
177  " to " + std::to_string(osr) + '.');
178 #endif
179 }
std::string to_string(char const *&&v)
DEVICE bool is_utm_srid(unsigned const srid)
Definition: Utm.h:113

+ Here is the call graph for this function:

DEVICE ALWAYS_INLINE CoordData trim_linestring_to_buffered_box ( int8_t *  l1,
int64_t  l1size,
int32_t  ic1,
int32_t  isr1,
double *  bounds2,
int64_t  bounds2_size,
int32_t  isr2,
int32_t  osr,
double  distance 
)

Definition at line 982 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size(), and get_point().

Referenced by ST_DWithin_LineString_MultiPolygon(), and ST_DWithin_LineString_Polygon().

990  {
991  // TODO: tolerance
992 
993  // Bounds come in corresponding input spatial references.
994  // For example, here the first bounding box may come in 4326, second in 900913:
995  // ST_DWithin(ST_Transform(linestring4326, 900913), linestring900913, 10)
996  // Distance is given in osr spatial reference units, in this case 10 meters.
997  // Bounds should be converted to osr before calculations, if isr != osr.
998 
999  Point2D const lb = transform_point<XY>({bounds2[0], bounds2[1]}, isr2, osr);
1000  Point2D const rt = transform_point<XY>({bounds2[2], bounds2[3]}, isr2, osr);
1001  CoordData l1_relevant_section;
1002  // Interate through linestring segments.
1003  // Mark the start of the relevant section FIRST TIME WE ENTER the buffered box.
1004  // Set the size of the relevant section the LAST TIME WE GET OUT of the box.
1005  auto l1_num_coords = l1size / compression_unit_size(ic1);
1006  Point2D l11 = get_point(l1, 0, ic1, isr1, osr);
1007  for (int32_t i1 = 2; i1 < l1_num_coords; i1 += 2) {
1008  Point2D l12 = get_point(l1, i1, ic1, isr1, osr);
1009  // Check for overlap between the line box and the buffered box
1010  if (
1011  // line box is left of buffered box
1012  fmax(l11.x, l12.x) + distance < lb.x ||
1013  // line box is right of buffered box
1014  fmin(l11.x, l12.x) - distance > rt.x ||
1015  // line box is below buffered box
1016  fmax(l11.y, l12.y) + distance < lb.y ||
1017  // line box is above buffered box
1018  fmin(l11.y, l12.y) - distance > rt.y) {
1019  // No overlap
1020  if (l1_relevant_section.ptr && l1_relevant_section.size == 0) {
1021  // Can finalize relevant section size
1022  l1_relevant_section.size =
1023  l1 + i1 * compression_unit_size(ic1) - l1_relevant_section.ptr;
1024  }
1025  } else {
1026  // Overlap
1027  if (!l1_relevant_section.ptr) {
1028  // Start tracking relevant section
1029  l1_relevant_section.ptr = l1 + (i1 - 2) * compression_unit_size(ic1);
1030  }
1031  // Keep relevant section size unfinalized while there is overlap,
1032  // linestring may reenter the buffered box.
1033  l1_relevant_section.size = 0;
1034  }
1035  // Advance to the next line segment.
1036  l11.x = l12.x;
1037  l11.y = l12.y;
1038  }
1039  if (l1_relevant_section.ptr && l1_relevant_section.size == 0) {
1040  // If we did start tracking the relevant section (i.e. entered the buffered bbox)
1041  // and haven't finalized the size (i.e. stayed in the bbox until the end)
1042  // finalize now based on the last point.
1043  l1_relevant_section.size = l1size - (l1_relevant_section.ptr - l1);
1044  }
1045  if (l1_relevant_section.ptr &&
1046  (l1_relevant_section.size < 4 * compression_unit_size(ic1))) {
1047  // Haven't found a section with at least 1 segment: zoom out
1048  l1_relevant_section = {l1, l1size};
1049  }
1050 
1051  return l1_relevant_section;
1052 }
DEVICE ALWAYS_INLINE int32_t compression_unit_size(const int32_t ic)
DEVICE ALWAYS_INLINE Point2D get_point(const int8_t *data, const int32_t x_index, const int32_t ic, const int32_t isr, const int32_t osr)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

DEVICE ALWAYS_INLINE bool x_and_y_are_dependent ( const int32_t  isr,
const int32_t  osr 
)

Definition at line 182 of file ExtensionFunctionsGeo.hpp.

References is_utm_srid().

Referenced by coord().

182  {
183 #ifdef ENABLE_UTM_TRANSFORM
184  return isr != osr && (is_utm_srid(isr) || is_utm_srid(osr));
185 #else
186  return false;
187 #endif
188 }
DEVICE bool is_utm_srid(unsigned const srid)
Definition: Utm.h:113

+ Here is the call graph for this function:

+ Here is the caller graph for this function: