OmniSciDB  a5dc49c757
 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++) {