OmniSciDB  06b3bd477c
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ExtensionFunctionsGeo.hpp File Reference
+ 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.

Functions

DEVICE ALWAYS_INLINE double tol (int32_t ic)
 
DEVICE ALWAYS_INLINE double tol (int32_t ic1, int32_t ic2)
 
DEVICE ALWAYS_INLINE bool tol_zero (double x, double tolerance=TOLERANCE_DEFAULT)
 
DEVICE ALWAYS_INLINE bool tol_eq (double x, double y, double tolerance=TOLERANCE_DEFAULT)
 
DEVICE ALWAYS_INLINE bool tol_le (double x, double y, double tolerance=TOLERANCE_DEFAULT)
 
DEVICE ALWAYS_INLINE bool tol_ge (double x, double y, double tolerance=TOLERANCE_DEFAULT)
 
DEVICE ALWAYS_INLINE double decompress_coord (int8_t *data, int32_t index, int32_t ic, bool x)
 
DEVICE ALWAYS_INLINE int32_t compression_unit_size (int32_t ic)
 
DEVICE ALWAYS_INLINE double transform_coord (double coord, int32_t isr, int32_t osr, bool x)
 
DEVICE ALWAYS_INLINE double coord_x (int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
 
DEVICE ALWAYS_INLINE double coord_y (int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
 
DEVICE ALWAYS_INLINE double distance_point_point_squared (double p1x, double p1y, double p2x, double p2y)
 
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 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_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)
 
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)
 
DEVICE bool polygon_contains_point (int8_t *poly, int32_t poly_num_coords, double px, double py, int32_t ic1, int32_t isr1, 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 (double *bounds, int64_t bounds_size, double px, 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)
 
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_X_LineString (int8_t *l, int64_t lsize, int32_t lindex, int32_t ic, int32_t isr, int32_t osr)
 
EXTENSION_NOINLINE double ST_Y_LineString (int8_t *l, int64_t lsize, int32_t lindex, 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, int64_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_Perimeter_Polygon (int8_t *poly, int64_t polysize, int32_t *poly_ring_sizes, int64_t poly_num_rings, int32_t ic, int32_t isr, int32_t osr)
 
EXTENSION_NOINLINE double ST_Perimeter_Polygon_Geodesic (int8_t *poly, int64_t polysize, int32_t *poly_ring_sizes, int64_t poly_num_rings, int32_t ic, int32_t isr, int32_t osr)
 
DEVICE ALWAYS_INLINE double perimeter_multipolygon (int8_t *mpoly_coords, int64_t mpoly_coords_size, int32_t *mpoly_ring_sizes, int64_t mpoly_num_rings, int32_t *mpoly_poly_sizes, int64_t mpoly_num_polys, int32_t ic, int32_t isr, int32_t osr, bool geodesic)
 
EXTENSION_NOINLINE double ST_Perimeter_MultiPolygon (int8_t *mpoly_coords, int64_t mpoly_coords_size, int32_t *mpoly_ring_sizes, int64_t mpoly_num_rings, int32_t *mpoly_poly_sizes, int64_t mpoly_num_polys, int32_t ic, int32_t isr, int32_t osr)
 
EXTENSION_NOINLINE double ST_Perimeter_MultiPolygon_Geodesic (int8_t *mpoly_coords, int64_t mpoly_coords_size, int32_t *mpoly_ring_sizes, int64_t mpoly_num_rings, int32_t *mpoly_poly_sizes, int64_t mpoly_num_polys, int32_t ic, int32_t isr, int32_t osr)
 
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, int64_t poly_coords_size, int32_t *poly_ring_sizes, int64_t poly_num_rings, int32_t ic, int32_t isr, int32_t osr)
 
EXTENSION_NOINLINE double ST_Area_Polygon (int8_t *poly_coords, int64_t poly_coords_size, int32_t *poly_ring_sizes, int64_t poly_num_rings, int32_t ic, int32_t isr, int32_t osr)
 
EXTENSION_INLINE double ST_Area_Polygon_Geodesic (int8_t *poly_coords, int64_t poly_coords_size, int32_t *poly_ring_sizes, int64_t poly_num_rings, int32_t ic, int32_t isr, int32_t osr)
 
EXTENSION_NOINLINE double ST_Area_MultiPolygon (int8_t *mpoly_coords, int64_t mpoly_coords_size, int32_t *mpoly_ring_sizes, int64_t mpoly_num_rings, int32_t *mpoly_poly_sizes, int64_t mpoly_num_polys, int32_t ic, int32_t isr, int32_t osr)
 
EXTENSION_INLINE double ST_Area_MultiPolygon_Geodesic (int8_t *mpoly_coords, int64_t mpoly_coords_size, int32_t *mpoly_ring_sizes, int64_t mpoly_num_rings, int32_t *mpoly_poly_sizes, int64_t mpoly_num_polys, int32_t ic, int32_t isr, int32_t osr)
 
EXTENSION_INLINE int32_t ST_NPoints (int8_t *coords, int64_t coords_sz, int32_t ic)
 
EXTENSION_INLINE int32_t ST_NRings (int32_t *poly_ring_sizes, int64_t poly_num_rings)
 
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 lindex, 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, int32_t lindex, 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_LineString_LineString_Geodesic (int8_t *l1, int64_t l1size, int32_t l1index, int8_t *l2, int64_t l2size, int32_t l2index, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
 
DEVICE ALWAYS_INLINE double distance_point_linestring (int8_t *p, int64_t psize, int8_t *l, int64_t lsize, int32_t lindex, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, bool check_closed)
 
EXTENSION_NOINLINE double ST_Distance_Point_ClosedLineString (int8_t *p, int64_t psize, int8_t *l, int64_t lsize, int32_t lindex, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
 
EXTENSION_NOINLINE double ST_Distance_Point_LineString (int8_t *p, int64_t psize, int8_t *l, int64_t lsize, int32_t lindex, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
 
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)
 
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)
 
EXTENSION_INLINE double ST_Distance_LineString_Point (int8_t *l, int64_t lsize, int32_t lindex, int8_t *p, int64_t psize, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
 
EXTENSION_NOINLINE double ST_Distance_LineString_LineString (int8_t *l1, int64_t l1size, int32_t l1index, int8_t *l2, int64_t l2size, int32_t l2index, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
 
EXTENSION_NOINLINE double ST_Distance_LineString_Polygon (int8_t *l, int64_t lsize, int32_t lindex, int8_t *poly_coords, int64_t poly_coords_size, int32_t *poly_ring_sizes, int64_t poly_num_rings, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
 
EXTENSION_NOINLINE double ST_Distance_LineString_MultiPolygon (int8_t *l, int64_t lsize, int32_t lindex, int8_t *mpoly_coords, int64_t mpoly_coords_size, int32_t *mpoly_ring_sizes, int64_t mpoly_num_rings, int32_t *mpoly_poly_sizes, int64_t mpoly_num_polys, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
 
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)
 
EXTENSION_INLINE double ST_Distance_Polygon_LineString (int8_t *poly_coords, int64_t poly_coords_size, int32_t *poly_ring_sizes, int64_t poly_num_rings, int8_t *l, int64_t lsize, int32_t li, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
 
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)
 
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)
 
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)
 
EXTENSION_INLINE double ST_Distance_MultiPolygon_LineString (int8_t *mpoly_coords, int64_t mpoly_coords_size, int32_t *mpoly_ring_sizes, int64_t mpoly_num_rings, int32_t *mpoly_poly_sizes, int64_t mpoly_num_polys, int8_t *l, int64_t lsize, int32_t lindex, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
 
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)
 
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)
 
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 lindex, 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 lindex, 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, int32_t lindex, 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 li, 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, int32_t li, int8_t *p, int64_t psize, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
 
EXTENSION_NOINLINE bool ST_Contains_LineString_LineString (int8_t *l1, int64_t l1size, double *l1bounds, int64_t l1bounds_size, int32_t l1i, int8_t *l2, int64_t l2size, double *l2bounds, int64_t l2bounds_size, int32_t l2i, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
 
EXTENSION_NOINLINE bool ST_Contains_LineString_Polygon (int8_t *l, int64_t lsize, double *lbounds, int64_t lbounds_size, int32_t li, int8_t *poly_coords, int64_t poly_coords_size, int32_t *poly_ring_sizes, int64_t poly_num_rings, double *poly_bounds, int64_t poly_bounds_size, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
 
EXTENSION_NOINLINE bool ST_Contains_Polygon_Point (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 *p, int64_t psize, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, 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 li, 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)
 
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_Contains_MultiPolygon_LineString (int8_t *mpoly_coords, int64_t mpoly_coords_size, int32_t *mpoly_ring_sizes, int64_t mpoly_num_rings, int32_t *mpoly_poly_sizes, int64_t mpoly_num_polys, double *mpoly_bounds, int64_t mpoly_bounds_size, int8_t *l, int64_t lsize, double *lbounds, int64_t lbounds_size, int32_t li, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
 
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 li, 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, int32_t li, int8_t *p, int64_t psize, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
 
EXTENSION_NOINLINE bool ST_Intersects_LineString_Linestring (int8_t *l1, int64_t l1size, double *l1bounds, int64_t l1bounds_size, int32_t l1i, int8_t *l2, int64_t l2size, double *l2bounds, int64_t l2bounds_size, int32_t l2i, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
 
EXTENSION_NOINLINE bool ST_Intersects_LineString_Polygon (int8_t *l, int64_t lsize, double *lbounds, int64_t lbounds_size, int32_t li, int8_t *poly, int64_t polysize, int32_t *poly_ring_sizes, int64_t poly_num_rings, double *poly_bounds, int64_t poly_bounds_size, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
 
EXTENSION_NOINLINE bool ST_Intersects_LineString_MultiPolygon (int8_t *l, int64_t lsize, double *lbounds, int64_t lbounds_size, int32_t li, int8_t *mpoly_coords, int64_t mpoly_coords_size, int32_t *mpoly_ring_sizes, int64_t mpoly_num_rings, int32_t *mpoly_poly_sizes, int64_t mpoly_num_polys, double *mpoly_bounds, int64_t mpoly_bounds_size, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
 
EXTENSION_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_Intersects_Polygon_LineString (int8_t *poly, int64_t polysize, int32_t *poly_ring_sizes, int64_t poly_num_rings, double *poly_bounds, int64_t poly_bounds_size, int8_t *l, int64_t lsize, double *lbounds, int64_t lbounds_size, int32_t li, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
 
EXTENSION_NOINLINE 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_Intersects_MultiPolygon_LineString (int8_t *mpoly_coords, int64_t mpoly_coords_size, int32_t *mpoly_ring_sizes, int64_t mpoly_num_rings, int32_t *mpoly_poly_sizes, int64_t mpoly_num_polys, double *mpoly_bounds, int64_t mpoly_bounds_size, int8_t *l, int64_t lsize, double *lbounds, int64_t lbounds_size, int32_t li, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
 
EXTENSION_INLINE 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 OmniSci_Geo_PolyBoundsPtr (double *bounds, int64_t size)
 
EXTENSION_INLINE int32_t OmniSci_Geo_PolyRenderGroup (int32_t render_group)
 
EXTENSION_INLINE int64_t MapD_GeoPolyBoundsPtr (double *bounds, int64_t size)
 
EXTENSION_INLINE int32_t MapD_GeoPolyRenderGroup (int32_t render_group)
 
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)
 

Function Documentation

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

Definition at line 944 of file ExtensionFunctionsGeo.hpp.

References area_ring(), and compression_unit_size().

Referenced by ST_Area_MultiPolygon(), and ST_Area_Polygon().

950  {
951  if (poly_num_rings <= 0) {
952  return 0.0;
953  }
954 
955  double area = 0.0;
956  auto ring_coords = poly_coords;
957 
958  // Add up the areas of all rings.
959  // External ring is CCW, open - positive area.
960  // Internal rings (holes) are CW, open - negative areas.
961  for (auto r = 0; r < poly_num_rings; r++) {
962  auto ring_coords_size = poly_ring_sizes[r] * 2 * compression_unit_size(ic);
963  area += area_ring(ring_coords, ring_coords_size, ic, isr, osr);
964  // Advance to the next ring.
965  ring_coords += ring_coords_size;
966  }
967  return area;
968 }
DEVICE ALWAYS_INLINE int32_t compression_unit_size(int32_t ic)
DEVICE ALWAYS_INLINE double area_ring(int8_t *ring, int64_t ringsize, int32_t ic, int32_t isr, int32_t osr)

+ 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 917 of file ExtensionFunctionsGeo.hpp.

References area_triangle(), compression_unit_size(), coord_x(), and coord_y().

Referenced by area_polygon().

921  {
922  auto ring_num_coords = ringsize / compression_unit_size(ic);
923 
924  if (ring_num_coords < 6) {
925  return 0.0;
926  }
927 
928  double area = 0.0;
929 
930  double x1 = coord_x(ring, 0, ic, isr, osr);
931  double y1 = coord_y(ring, 1, ic, isr, osr);
932  double x2 = coord_x(ring, 2, ic, isr, osr);
933  double y2 = coord_y(ring, 3, ic, isr, osr);
934  for (int32_t i = 4; i < ring_num_coords; i += 2) {
935  double x3 = coord_x(ring, i, ic, isr, osr);
936  double y3 = coord_y(ring, i + 1, ic, isr, osr);
937  area += area_triangle(x1, y1, x2, y2, x3, y3);
938  x2 = x3;
939  y2 = y3;
940  }
941  return area;
942 }
DEVICE ALWAYS_INLINE double coord_x(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE double coord_y(int8_t *data, int32_t index, 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 int32_t compression_unit_size(int32_t ic)

+ 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 908 of file ExtensionFunctionsGeo.hpp.

Referenced by area_ring().

913  {
914  return (x1 * y2 - x2 * y1 + x3 * y1 - x1 * y3 + x2 * y3 - x3 * y2) / 2.0;
915 }

+ 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 574 of file ExtensionFunctionsGeo.hpp.

References box_contains_point().

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

577  {
578  return (
580  bounds1, bounds1_size, bounds2[0], bounds2[1]) && // box1 <- box2: xmin, ymin
582  bounds1, bounds1_size, bounds2[2], bounds2[3])); // box1 <- box2: xmax, ymax
583 }
DEVICE ALWAYS_INLINE bool box_contains_point(double *bounds, int64_t bounds_size, double px, 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 585 of file ExtensionFunctionsGeo.hpp.

References box_contains_point().

588  {
589  return (
591  bounds1, bounds1_size, bounds2[0], bounds2[1]) || // box1 <- box2: xmin, ymin
593  bounds1, bounds1_size, bounds2[2], bounds2[3]) || // box1 <- box2: xmax, ymax
595  bounds1, bounds1_size, bounds2[0], bounds2[3]) || // box1 <- box2: xmin, ymax
597  bounds1, bounds1_size, bounds2[2], bounds2[1])); // box1 <- box2: xmax, ymin
598 }
DEVICE ALWAYS_INLINE bool box_contains_point(double *bounds, int64_t bounds_size, double px, double py)

+ Here is the call graph for this function:

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

Definition at line 559 of file ExtensionFunctionsGeo.hpp.

References tol_ge(), and tol_le().

Referenced by box_contains_box(), box_contains_box_vertex(), Point_Overlaps_Box(), ST_Contains_MultiPolygon_LineString(), ST_Contains_MultiPolygon_Point(), ST_Contains_Polygon_LineString(), ST_Contains_Polygon_Point(), and ST_Intersects_Point_LineString().

562  {
563  return (tol_ge(px, bounds[0]) && tol_ge(py, bounds[1]) && tol_le(px, bounds[2]) &&
564  tol_le(py, bounds[3]));
565 }
DEVICE ALWAYS_INLINE bool tol_le(double x, double y, double tolerance=TOLERANCE_DEFAULT)
DEVICE ALWAYS_INLINE bool tol_ge(double x, double y, 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_overlaps_box ( double *  bounds1,
int64_t  bounds1_size,
double *  bounds2,
int64_t  bounds2_size 
)

Definition at line 600 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().

603  {
604  // TODO: tolerance
605  if (bounds1[2] < bounds2[0] || // box1 is left of box2: box1.xmax < box2.xmin
606  bounds1[0] > bounds2[2] || // box1 is right of box2: box1.xmin > box2.xmax
607  bounds1[3] < bounds2[1] || // box1 is below box2: box1.ymax < box2.miny
608  bounds1[1] > bounds2[3]) { // box1 is above box2: box1.ymin > box1.ymax
609  return false;
610  }
611  return true;
612 }

+ Here is the caller graph for this function:

DEVICE ALWAYS_INLINE int32_t compression_unit_size ( int32_t  ic)

Definition at line 60 of file ExtensionFunctionsGeo.hpp.

References COMPRESSION_GEOINT32.

Referenced by area_polygon(), area_ring(), distance_point_linestring(), length_linestring(), max_distance_point_linestring(), perimeter_multipolygon(), ST_Area_MultiPolygon(), ST_Contains_MultiPolygon_LineString(), ST_Contains_MultiPolygon_Point(), ST_Contains_Point_LineString(), ST_Contains_Point_Polygon(), ST_Contains_Polygon_LineString(), ST_Contains_Polygon_Point(), ST_Contains_Polygon_Polygon(), ST_Distance_LineString_LineString(), ST_Distance_LineString_LineString_Geodesic(), ST_Distance_LineString_MultiPolygon(), ST_Distance_LineString_Polygon(), ST_Distance_MultiPolygon_MultiPolygon(), ST_Distance_Point_LineString(), ST_Distance_Point_LineString_Geodesic(), ST_Distance_Point_MultiPolygon(), ST_Distance_Point_Polygon(), ST_Distance_Polygon_MultiPolygon(), ST_Distance_Polygon_Polygon(), ST_Intersects_LineString_Linestring(), ST_Intersects_LineString_MultiPolygon(), ST_Intersects_LineString_Polygon(), ST_Intersects_Point_LineString(), ST_NPoints(), ST_Perimeter_Polygon(), ST_Perimeter_Polygon_Geodesic(), ST_X_LineString(), ST_XMax(), ST_XMin(), ST_Y_LineString(), ST_YMax(), and ST_YMin().

60  {
61  if (ic == COMPRESSION_GEOINT32) {
62  return 4;
63  }
64  return 8;
65 }
#define COMPRESSION_GEOINT32

+ Here is the caller 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 3240 of file ExtensionFunctionsGeo.hpp.

References decompress_coord(), and transform_coord().

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

3249  {
3250  const double const1 = 0.017453292519943295769236907684886;
3251  const double const2 = 6372797.560856;
3252  const auto lat = decompress_coord(p, 1, ic, false);
3253  const double latdiff = meters / (const1 * const2);
3254  const double newlat =
3255  (lat < 0) ? lat + latdiff : lat - latdiff; // assumes a lat range of [-90, 90]
3256  double t1 = transform_coord(lat, isr, osr, false);
3257  double t2 = transform_coord(newlat, isr, osr, false);
3258  const double min_domain_y = transform_coord(min_lat, isr, osr, false);
3259  const double max_domain_y = transform_coord(max_lat, isr, osr, false);
3260  const double domain_diff = max_domain_y - min_domain_y;
3261  t1 = ((t1 - min_domain_y) / domain_diff) * static_cast<double>(img_height);
3262  t2 = ((t2 - min_domain_y) / domain_diff) * static_cast<double>(img_height);
3263 
3264  // TODO(croot): need to account for edge cases, such as getting close to the poles.
3265  const double sz = fabs(t1 - t2);
3266  return (sz < min_height ? min_height : sz);
3267 }
DEVICE ALWAYS_INLINE double transform_coord(double coord, int32_t isr, int32_t osr, bool x)
DEVICE ALWAYS_INLINE double decompress_coord(int8_t *data, int32_t index, int32_t ic, bool x)

+ Here is the call graph for this function:

+ 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 3209 of file ExtensionFunctionsGeo.hpp.

References decompress_coord(), and transform_coord().

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

3218  {
3219  const double const1 = 0.017453292519943295769236907684886;
3220  const double const2 = 6372797.560856;
3221  const auto lon = decompress_coord(p, 0, ic, true);
3222  const auto lat = decompress_coord(p, 1, ic, false);
3223  double t1 = sinf(meters / (2.0 * const2));
3224  double t2 = cosf(const1 * lat);
3225  const double newlon = lon - (2.0 * asinf(t1 / t2)) / const1;
3226  t1 = transform_coord(lon, isr, osr, true);
3227  t2 = transform_coord(newlon, isr, osr, true);
3228  const double min_domain_x = transform_coord(min_lon, isr, osr, true);
3229  const double max_domain_x = transform_coord(max_lon, isr, osr, true);
3230  const double domain_diff = max_domain_x - min_domain_x;
3231  t1 = ((t1 - min_domain_x) / domain_diff) * static_cast<double>(img_width);
3232  t2 = ((t2 - min_domain_x) / domain_diff) * static_cast<double>(img_width);
3233 
3234  // TODO(croot): need to account for edge cases, such as getting close to the poles.
3235  const double sz = fabs(t1 - t2);
3236  return (sz < min_width ? min_width : sz);
3237 }
DEVICE ALWAYS_INLINE double transform_coord(double coord, int32_t isr, int32_t osr, bool x)
DEVICE ALWAYS_INLINE double decompress_coord(int8_t *data, int32_t index, int32_t ic, bool x)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

DEVICE ALWAYS_INLINE double coord_x ( int8_t *  data,
int32_t  index,
int32_t  ic,
int32_t  isr,
int32_t  osr 
)

Definition at line 85 of file ExtensionFunctionsGeo.hpp.

References decompress_coord(), and transform_coord().

Referenced by area_ring(), distance_point_linestring(), distance_ring_linestring(), distance_ring_ring(), length_linestring(), linestring_intersects_line(), linestring_intersects_linestring(), max_distance_point_linestring(), polygon_contains_linestring(), polygon_contains_point(), ring_intersects_line(), ST_Contains_MultiPolygon_LineString(), ST_Contains_MultiPolygon_Point(), ST_Contains_Point_LineString(), ST_Contains_Point_Point(), ST_Contains_Polygon_LineString(), ST_Contains_Polygon_Point(), ST_Distance_LineString_LineString(), ST_Distance_LineString_LineString_Geodesic(), ST_Distance_Point_LineString(), ST_Distance_Point_LineString_Geodesic(), ST_Distance_Point_Point(), ST_Distance_Point_Point_Geodesic(), ST_Distance_Point_Point_Squared(), ST_Distance_Point_Polygon(), ST_Intersects_Point_LineString(), ST_X_LineString(), ST_X_Point(), ST_XMax(), and ST_XMin().

89  {
90  auto decompressed_coord_x = decompress_coord(data, index, ic, true);
91  auto decompressed_transformed_coord_x =
92  transform_coord(decompressed_coord_x, isr, osr, true);
93  return decompressed_transformed_coord_x;
94 }
DEVICE ALWAYS_INLINE double transform_coord(double coord, int32_t isr, int32_t osr, bool x)
DEVICE ALWAYS_INLINE double decompress_coord(int8_t *data, int32_t index, int32_t ic, bool x)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

DEVICE ALWAYS_INLINE double coord_y ( int8_t *  data,
int32_t  index,
int32_t  ic,
int32_t  isr,
int32_t  osr 
)

Definition at line 97 of file ExtensionFunctionsGeo.hpp.

References decompress_coord(), and transform_coord().

Referenced by area_ring(), distance_point_linestring(), distance_ring_linestring(), distance_ring_ring(), length_linestring(), linestring_intersects_line(), linestring_intersects_linestring(), max_distance_point_linestring(), polygon_contains_linestring(), polygon_contains_point(), ring_intersects_line(), ST_Contains_MultiPolygon_LineString(), ST_Contains_MultiPolygon_Point(), ST_Contains_Point_LineString(), ST_Contains_Point_Point(), ST_Contains_Polygon_LineString(), ST_Contains_Polygon_Point(), ST_Distance_LineString_LineString(), ST_Distance_LineString_LineString_Geodesic(), ST_Distance_Point_LineString(), ST_Distance_Point_LineString_Geodesic(), ST_Distance_Point_Point(), ST_Distance_Point_Point_Geodesic(), ST_Distance_Point_Point_Squared(), ST_Distance_Point_Polygon(), ST_Intersects_Point_LineString(), ST_Y_LineString(), ST_Y_Point(), ST_YMax(), and ST_YMin().

101  {
102  auto decompressed_coord_y = decompress_coord(data, index, ic, false);
103  auto decompressed_transformed_coord_y =
104  transform_coord(decompressed_coord_y, isr, osr, false);
105  return decompressed_transformed_coord_y;
106 }
DEVICE ALWAYS_INLINE double transform_coord(double coord, int32_t isr, int32_t osr, bool x)
DEVICE ALWAYS_INLINE double decompress_coord(int8_t *data, int32_t index, int32_t ic, bool x)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

DEVICE ALWAYS_INLINE double decompress_coord ( int8_t *  data,
int32_t  index,
int32_t  ic,
bool  x 
)

Definition at line 43 of file ExtensionFunctionsGeo.hpp.

References COMPRESSION_GEOINT32, Geo_namespace::decompress_lattitude_coord_geoint32(), and Geo_namespace::decompress_longitude_coord_geoint32().

Referenced by convert_meters_to_pixel_height(), convert_meters_to_pixel_width(), coord_x(), coord_y(), is_point_in_view(), and is_point_size_in_view().

46  {
47  if (ic == COMPRESSION_GEOINT32) {
48  auto compressed_coords = reinterpret_cast<int32_t*>(data);
49  auto compressed_coord = compressed_coords[index];
50  if (x) {
52  } else {
54  }
55  }
56  auto double_coords = reinterpret_cast<double*>(data);
57  return double_coords[index];
58 }
DEVICE double decompress_lattitude_coord_geoint32(const int32_t compressed)
#define COMPRESSION_GEOINT32
DEVICE double decompress_longitude_coord_geoint32(const int32_t compressed)

+ Here is the call graph for this function:

+ Here is the caller 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 299 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().

306  {
307  if (line_intersects_line(l11x, l11y, l12x, l12y, l21x, l21y, l22x, l22y)) {
308  return 0.0;
309  }
310  double dist12 = fmin(distance_point_line(l11x, l11y, l21x, l21y, l22x, l22y),
311  distance_point_line(l12x, l12y, l21x, l21y, l22x, l22y));
312  double dist21 = fmin(distance_point_line(l21x, l21y, l11x, l11y, l12x, l12y),
313  distance_point_line(l22x, l22y, l11x, l11y, l12x, l12y));
314  return fmin(dist12, dist21);
315 }
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_point_line ( double  px,
double  py,
double  l1x,
double  l1y,
double  l2x,
double  l2y 
)

Definition at line 135 of file ExtensionFunctionsGeo.hpp.

References distance_point_point(), and tol_zero().

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

140  {
141  double length = distance_point_point(l1x, l1y, l2x, l2y);
142  if (tol_zero(length)) {
143  return distance_point_point(px, py, l1x, l1y);
144  }
145 
146  // Find projection of point P onto the line segment AB:
147  // Line containing that segment: A + k * (B - A)
148  // Projection of point P onto the line touches it at
149  // k = dot(P-A,B-A) / length^2
150  // AB segment is represented by k = [0,1]
151  // Clamping k to [0,1] will give the shortest distance from P to AB segment
152  double dotprod = (px - l1x) * (l2x - l1x) + (py - l1y) * (l2y - l1y);
153  double k = dotprod / (length * length);
154  k = fmax(0.0, fmin(1.0, k));
155  double projx = l1x + k * (l2x - l1x);
156  double projy = l1y + k * (l2y - l1y);
157  return distance_point_point(px, py, projx, projy);
158 }
DEVICE ALWAYS_INLINE bool tol_zero(double x, 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 ALWAYS_INLINE double distance_point_linestring ( int8_t *  p,
int64_t  psize,
int8_t *  l,
int64_t  lsize,
int32_t  lindex,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr,
bool  check_closed 
)

Definition at line 1186 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size(), coord_x(), coord_y(), distance_point_line(), and distance_point_point().

Referenced by ST_Distance_Point_ClosedLineString(), and ST_Distance_Point_LineString().

1196  {
1197  double px = coord_x(p, 0, ic1, isr1, osr);
1198  double py = coord_y(p, 1, ic1, isr1, osr);
1199 
1200  auto l_num_coords = lsize / compression_unit_size(ic2);
1201  auto l_num_points = l_num_coords / 2;
1202  if (lindex != 0) { // Statically indexed linestring
1203  if (lindex < 0 || lindex > l_num_points) {
1204  lindex = l_num_points; // Endpoint
1205  }
1206  double lx = coord_x(l, 2 * (lindex - 1), ic2, isr2, osr);
1207  double ly = coord_y(l, 2 * (lindex - 1) + 1, ic2, isr2, osr);
1208  return distance_point_point(px, py, lx, ly);
1209  }
1210 
1211  double l1x = coord_x(l, 0, ic2, isr2, osr);
1212  double l1y = coord_y(l, 1, ic2, isr2, osr);
1213  double l2x = coord_x(l, 2, ic2, isr2, osr);
1214  double l2y = coord_y(l, 3, ic2, isr2, osr);
1215 
1216  double dist = distance_point_line(px, py, l1x, l1y, l2x, l2y);
1217  for (int32_t i = 4; i < l_num_coords; i += 2) {
1218  l1x = l2x; // advance one point
1219  l1y = l2y;
1220  l2x = coord_x(l, i, ic2, isr2, osr);
1221  l2y = coord_y(l, i + 1, ic2, isr2, osr);
1222  double ldist = distance_point_line(px, py, l1x, l1y, l2x, l2y);
1223  if (dist > ldist) {
1224  dist = ldist;
1225  }
1226  }
1227  if (l_num_coords > 4 && check_closed) {
1228  // Also check distance to the closing edge between the first and the last points
1229  l1x = coord_x(l, 0, ic2, isr2, osr);
1230  l1y = coord_y(l, 1, ic2, isr2, osr);
1231  double ldist = distance_point_line(px, py, l1x, l1y, l2x, l2y);
1232  if (dist > ldist) {
1233  dist = ldist;
1234  }
1235  }
1236  return dist;
1237 }
DEVICE ALWAYS_INLINE double coord_x(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE double coord_y(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
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(int32_t ic)
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 distance_point_point ( double  p1x,
double  p1y,
double  p2x,
double  p2y 
)

Definition at line 125 of file ExtensionFunctionsGeo.hpp.

References distance_point_point_squared().

Referenced by distance_point_line(), distance_point_linestring(), length_linestring(), max_distance_point_line(), max_distance_point_linestring(), ST_Distance_Point_LineString(), and ST_Distance_Point_Point().

128  {
129  auto d2 = distance_point_point_squared(p1x, p1y, p2x, p2y);
130  return sqrt(d2);
131 }
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 109 of file ExtensionFunctionsGeo.hpp.

References tol_zero(), and TOLERANCE_DEFAULT.

Referenced by distance_point_point(), and ST_Distance_Point_Point_Squared().

112  {
113  auto x = p1x - p2x;
114  auto y = p1y - p2y;
115  auto x2 = x * x;
116  auto y2 = y * y;
117  auto d2 = x2 + y2;
119  return 0.0;
120  }
121  return d2;
122 }
#define TOLERANCE_DEFAULT
DEVICE ALWAYS_INLINE bool tol_zero(double x, double tolerance=TOLERANCE_DEFAULT)

+ 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 
)

Definition at line 318 of file ExtensionFunctionsGeo.hpp.

References coord_x(), coord_y(), distance_line_line(), and tol_zero().

Referenced by ST_Distance_LineString_Polygon().

326  {
327  double min_distance = 0.0;
328 
329  double re1x = coord_x(ring, ring_num_coords - 2, ic1, isr1, osr);
330  double re1y = coord_y(ring, ring_num_coords - 1, ic1, isr1, osr);
331  for (auto i = 0; i < ring_num_coords; i += 2) {
332  double re2x = coord_x(ring, i, ic1, isr1, osr);
333  double re2y = coord_y(ring, i + 1, ic1, isr1, osr);
334 
335  double le1x = coord_x(l, 0, ic2, isr2, osr);
336  double le1y = coord_y(l, 1, ic2, isr2, osr);
337  for (auto j = 2; j < lnum_coords; j += 2) {
338  double le2x = coord_x(l, j, ic2, isr2, osr);
339  double le2y = coord_y(l, j + 1, ic2, isr2, osr);
340 
341  auto distance = distance_line_line(re1x, re1y, re2x, re2y, le1x, le1y, le2x, le2y);
342  if ((i == 0 && j == 2) || min_distance > distance) {
343  min_distance = distance;
344  if (tol_zero(min_distance)) {
345  return 0.0;
346  }
347  }
348  le1x = le2x;
349  le1y = le2y;
350  }
351  re1x = re2x;
352  re1y = re2y;
353  }
354 
355  return min_distance;
356 }
DEVICE ALWAYS_INLINE double coord_x(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE double coord_y(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE bool tol_zero(double x, double tolerance=TOLERANCE_DEFAULT)
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 
)

Definition at line 359 of file ExtensionFunctionsGeo.hpp.

References coord_x(), coord_y(), distance_line_line(), and tol_zero().

Referenced by ST_Distance_Polygon_Polygon().

367  {
368  double min_distance = 0.0;
369 
370  double e11x = coord_x(ring1, ring1_num_coords - 2, ic1, isr1, osr);
371  double e11y = coord_y(ring1, ring1_num_coords - 1, ic1, isr1, osr);
372  for (auto i = 0; i < ring1_num_coords; i += 2) {
373  double e12x = coord_x(ring1, i, ic1, isr1, osr);
374  double e12y = coord_y(ring1, i + 1, ic1, isr1, osr);
375 
376  double e21x = coord_x(ring2, ring2_num_coords - 2, ic2, isr2, osr);
377  double e21y = coord_y(ring2, ring2_num_coords - 1, ic2, isr2, osr);
378  for (auto j = 0; j < ring2_num_coords; j += 2) {
379  double e22x = coord_x(ring2, j, ic2, isr2, osr);
380  double e22y = coord_y(ring2, j + 1, ic2, isr2, osr);
381 
382  auto distance = distance_line_line(e11x, e11y, e12x, e12y, e21x, e21y, e22x, e22y);
383  if ((i == 0 && j == 0) || min_distance > distance) {
384  min_distance = distance;
385  if (tol_zero(min_distance)) {
386  return 0.0;
387  }
388  }
389  e21x = e22x;
390  e21y = e22y;
391  }
392  e11x = e12x;
393  e11y = e12y;
394  }
395 
396  return min_distance;
397 }
DEVICE ALWAYS_INLINE double coord_x(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE double coord_y(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE bool tol_zero(double x, double tolerance=TOLERANCE_DEFAULT)
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_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 3269 of file ExtensionFunctionsGeo.hpp.

References decompress_coord().

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

3275  {
3276  const auto lon = decompress_coord(p, 0, ic, true);
3277  const auto lat = decompress_coord(p, 1, ic, false);
3278  return !(lon < min_lon || lon > max_lon || lat < min_lat || lat > max_lat);
3279 }
DEVICE ALWAYS_INLINE double decompress_coord(int8_t *data, int32_t index, int32_t ic, bool x)

+ Here is the call graph for this function:

+ 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 3281 of file ExtensionFunctionsGeo.hpp.

References decompress_coord().

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

3288  {
3289  const double const1 = 0.017453292519943295769236907684886;
3290  const double const2 = 6372797.560856;
3291  const auto lon = decompress_coord(p, 0, ic, true);
3292  const auto lat = decompress_coord(p, 1, ic, false);
3293  const double latdiff = meters / (const1 * const2);
3294  const double t1 = sinf(meters / (2.0 * const2));
3295  const double t2 = cosf(const1 * lat);
3296  const double londiff = (2.0 * asinf(t1 / t2)) / const1;
3297  return !(lon + londiff < min_lon || lon - londiff > max_lon ||
3298  lat + latdiff < min_lat || lat - latdiff > max_lat);
3299 }
DEVICE ALWAYS_INLINE double decompress_coord(int8_t *data, int32_t index, int32_t ic, bool x)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 728 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size(), coord_x(), coord_y(), distance_in_meters(), and distance_point_point().

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

734  {
735  auto l_num_coords = lsize / compression_unit_size(ic);
736 
737  double length = 0.0;
738 
739  double l0x = coord_x(l, 0, ic, isr, osr);
740  double l0y = coord_y(l, 1, ic, isr, osr);
741  double l2x = l0x;
742  double l2y = l0y;
743  for (int32_t i = 2; i < l_num_coords; i += 2) {
744  double l1x = l2x;
745  double l1y = l2y;
746  l2x = coord_x(l, i, ic, isr, osr);
747  l2y = coord_y(l, i + 1, ic, isr, osr);
748  double ldist = geodesic ? distance_in_meters(l1x, l1y, l2x, l2y)
749  : distance_point_point(l1x, l1y, l2x, l2y);
750  length += ldist;
751  }
752  if (check_closed) {
753  double ldist = geodesic ? distance_in_meters(l2x, l2y, l0x, l0y)
754  : distance_point_point(l2x, l2y, l0x, l0y);
755  length += ldist;
756  }
757  return length;
758 }
DEVICE ALWAYS_INLINE double coord_x(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE double coord_y(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(int32_t ic)
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 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 186 of file ExtensionFunctionsGeo.hpp.

References on_segment(), and orientation().

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

193  {
194  auto o1 = orientation(l11x, l11y, l12x, l12y, l21x, l21y);
195  auto o2 = orientation(l11x, l11y, l12x, l12y, l22x, l22y);
196  auto o3 = orientation(l21x, l21y, l22x, l22y, l11x, l11y);
197  auto o4 = orientation(l21x, l21y, l22x, l22y, l12x, l12y);
198 
199  // General case
200  if (o1 != o2 && o3 != o4) {
201  return true;
202  }
203 
204  // Special Cases
205  // l11, l12 and l21 are colinear and l21 lies on segment l11-l12
206  if (o1 == 0 && on_segment(l11x, l11y, l21x, l21y, l12x, l12y)) {
207  return true;
208  }
209 
210  // l11, l12 and l21 are colinear and l22 lies on segment l11-l12
211  if (o2 == 0 && on_segment(l11x, l11y, l22x, l22y, l12x, l12y)) {
212  return true;
213  }
214 
215  // l21, l22 and l11 are colinear and l11 lies on segment l21-l22
216  if (o3 == 0 && on_segment(l21x, l21y, l11x, l11y, l22x, l22y)) {
217  return true;
218  }
219 
220  // l21, l22 and l12 are colinear and l12 lies on segment l21-l22
221  if (o4 == 0 && on_segment(l21x, l21y, l12x, l12y, l22x, l22y)) {
222  return true;
223  }
224 
225  return false;
226 }
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 229 of file ExtensionFunctionsGeo.hpp.

References coord_x(), coord_y(), and line_intersects_line().

Referenced by ring_intersects_line().

237  {
238  double e1x = coord_x(l, 0, ic1, isr1, osr);
239  double e1y = coord_y(l, 1, ic1, isr1, osr);
240  for (int64_t i = 2; i < lnum_coords; i += 2) {
241  double e2x = coord_x(l, i, ic1, isr1, osr);
242  double e2y = coord_y(l, i + 1, ic1, isr1, osr);
243  if (line_intersects_line(e1x, e1y, e2x, e2y, l1x, l1y, l2x, l2y)) {
244  return true;
245  }
246  e1x = e2x;
247  e1y = e2y;
248  }
249  return false;
250 }
DEVICE ALWAYS_INLINE double coord_x(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE double coord_y(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
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 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 274 of file ExtensionFunctionsGeo.hpp.

References coord_x(), coord_y(), and line_intersects_line().

282  {
283  double e1x = coord_x(l, 0, ic1, isr1, osr);
284  double e1y = coord_y(l, 1, ic1, isr1, osr);
285  for (int64_t i = 2; i < lnum_coords; i += 2) {
286  double e2x = coord_x(l, i, ic1, isr1, osr);
287  double e2y = coord_y(l, i + 1, ic1, isr1, osr);
288  if (line_intersects_line(e1x, e1y, e2x, e2y, l1x, l1y, l2x, l2y)) {
289  return true;
290  }
291  e1x = e2x;
292  e1y = e2y;
293  }
294  return false;
295 }
DEVICE ALWAYS_INLINE double coord_x(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE double coord_y(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
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:

EXTENSION_INLINE int64_t MapD_GeoPolyBoundsPtr ( double *  bounds,
int64_t  size 
)

Definition at line 3199 of file ExtensionFunctionsGeo.hpp.

References OmniSci_Geo_PolyBoundsPtr().

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

3199  {
3200  return OmniSci_Geo_PolyBoundsPtr(bounds, size);
3201 }
EXTENSION_INLINE int64_t OmniSci_Geo_PolyBoundsPtr(double *bounds, int64_t size)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_INLINE int32_t MapD_GeoPolyRenderGroup ( int32_t  render_group)

Definition at line 3204 of file ExtensionFunctionsGeo.hpp.

References OmniSci_Geo_PolyRenderGroup().

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

3204  {
3205  return OmniSci_Geo_PolyRenderGroup(render_group);
3206 }
EXTENSION_INLINE int32_t OmniSci_Geo_PolyRenderGroup(int32_t render_group)

+ Here is the call graph for this function:

+ Here is the caller 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 1967 of file ExtensionFunctionsGeo.hpp.

References distance_point_point().

Referenced by max_distance_point_linestring().

1972  {
1973  double length1 = distance_point_point(px, py, l1x, l1y);
1974  double length2 = distance_point_point(px, py, l2x, l2y);
1975  if (length1 > length2) {
1976  return length1;
1977  }
1978  return length2;
1979 }
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  lindex,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr,
bool  check_closed 
)

Definition at line 1981 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size(), coord_x(), coord_y(), distance_point_point(), and max_distance_point_line().

Referenced by ST_MaxDistance_LineString_Point(), and ST_MaxDistance_Point_LineString().

1991  {
1992  double px = coord_x(p, 0, ic1, isr1, osr);
1993  double py = coord_y(p, 1, ic1, isr1, osr);
1994 
1995  auto l_num_coords = lsize / compression_unit_size(ic2);
1996  auto l_num_points = l_num_coords / 2;
1997  if (lindex != 0) { // Statically indexed linestring
1998  if (lindex < 0 || lindex > l_num_points) {
1999  lindex = l_num_points; // Endpoint
2000  }
2001  double lx = coord_x(l, 2 * (lindex - 1), ic2, isr2, osr);
2002  double ly = coord_y(l, 2 * (lindex - 1) + 1, ic2, isr2, osr);
2003  return distance_point_point(px, py, lx, ly);
2004  }
2005 
2006  double l1x = coord_x(l, 0, ic2, isr2, osr);
2007  double l1y = coord_y(l, 1, ic2, isr2, osr);
2008  double l2x = coord_x(l, 2, ic2, isr2, osr);
2009  double l2y = coord_y(l, 3, ic2, isr2, osr);
2010 
2011  double max_dist = max_distance_point_line(px, py, l1x, l1y, l2x, l2y);
2012  for (int32_t i = 4; i < l_num_coords; i += 2) {
2013  l1x = l2x; // advance one point
2014  l1y = l2y;
2015  l2x = coord_x(l, i, ic2, isr2, osr);
2016  l2y = coord_y(l, i + 1, ic2, isr2, osr);
2017  double ldist = max_distance_point_line(px, py, l1x, l1y, l2x, l2y);
2018  if (max_dist < ldist) {
2019  max_dist = ldist;
2020  }
2021  }
2022  if (l_num_coords > 4 && check_closed) {
2023  // Also check distance to the closing edge between the first and the last points
2024  l1x = coord_x(l, 0, ic2, isr2, osr);
2025  l1y = coord_y(l, 1, ic2, isr2, osr);
2026  double ldist = max_distance_point_line(px, py, l1x, l1y, l2x, l2y);
2027  if (max_dist < ldist) {
2028  max_dist = ldist;
2029  }
2030  }
2031  return max_dist;
2032 }
DEVICE ALWAYS_INLINE double coord_x(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE double coord_y(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
DEVICE double max_distance_point_line(double px, double py, double l1x, double l1y, double l2x, double l2y)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(int32_t ic)
DEVICE ALWAYS_INLINE double distance_point_point(double p1x, double p1y, double p2x, double p2y)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_INLINE int64_t OmniSci_Geo_PolyBoundsPtr ( double *  bounds,
int64_t  size 
)

Definition at line 3189 of file ExtensionFunctionsGeo.hpp.

Referenced by com.mapd.calcite.parser.MapDSqlOperatorTable::addUDF(), and MapD_GeoPolyBoundsPtr().

3189  {
3190  return reinterpret_cast<int64_t>(bounds);
3191 }

+ Here is the caller graph for this function:

EXTENSION_INLINE int32_t OmniSci_Geo_PolyRenderGroup ( int32_t  render_group)

Definition at line 3194 of file ExtensionFunctionsGeo.hpp.

Referenced by com.mapd.calcite.parser.MapDSqlOperatorTable::addUDF(), and MapD_GeoPolyRenderGroup().

3194  {
3195  return render_group;
3196 }

+ 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 162 of file ExtensionFunctionsGeo.hpp.

References tol_ge(), and tol_le().

Referenced by line_intersects_line().

167  {
168  return (tol_le(qx, fmax(px, rx)) && tol_ge(qx, fmin(px, rx)) &&
169  tol_le(qy, fmax(py, ry)) && tol_ge(qy, fmin(py, ry)));
170 }
DEVICE ALWAYS_INLINE bool tol_le(double x, double y, double tolerance=TOLERANCE_DEFAULT)
DEVICE ALWAYS_INLINE bool tol_ge(double x, double y, 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 173 of file ExtensionFunctionsGeo.hpp.

References tol_zero().

Referenced by line_intersects_line().

173  {
174  auto val = ((qy - py) * (rx - qx) - (qx - px) * (ry - qy));
175  if (tol_zero(val)) {
176  return 0; // Points p, q and r are colinear
177  }
178  if (val > 0.0) {
179  return 1; // Clockwise point orientation
180  }
181  return 2; // Counterclockwise point orientation
182 }
DEVICE ALWAYS_INLINE bool tol_zero(double x, 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,
int64_t  mpoly_coords_size,
int32_t *  mpoly_ring_sizes,
int64_t  mpoly_num_rings,
int32_t *  mpoly_poly_sizes,
int64_t  mpoly_num_polys,
int32_t  ic,
int32_t  isr,
int32_t  osr,
bool  geodesic 
)

Definition at line 818 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size(), and length_linestring().

Referenced by ST_Perimeter_MultiPolygon(), and ST_Perimeter_MultiPolygon_Geodesic().

827  {
828  if (mpoly_num_polys <= 0 || mpoly_num_rings <= 0) {
829  return 0.0;
830  }
831 
832  double perimeter = 0.0;
833 
834  // Set specific poly pointers as we move through the coords/ringsizes/polyrings arrays.
835  auto next_poly_coords = mpoly_coords;
836  auto next_poly_ring_sizes = mpoly_ring_sizes;
837 
838  for (auto poly = 0; poly < mpoly_num_polys; poly++) {
839  auto poly_coords = next_poly_coords;
840  auto poly_ring_sizes = next_poly_ring_sizes;
841  auto poly_num_rings = mpoly_poly_sizes[poly];
842  // Count number of coords in all of poly's rings, advance ring size pointer.
843  int32_t poly_num_coords = 0;
844  for (auto ring = 0; ring < poly_num_rings; ring++) {
845  poly_num_coords += 2 * *next_poly_ring_sizes++;
846  }
847  auto poly_coords_size = poly_num_coords * compression_unit_size(ic);
848  next_poly_coords += poly_coords_size;
849 
850  auto exterior_ring_num_coords = poly_ring_sizes[0] * 2;
851  auto exterior_ring_coords_size = exterior_ring_num_coords * compression_unit_size(ic);
852 
853  perimeter += length_linestring(
854  poly_coords, exterior_ring_coords_size, ic, isr, osr, geodesic, true);
855  }
856 
857  return perimeter;
858 }
DEVICE ALWAYS_INLINE double length_linestring(int8_t *l, int64_t lsize, int32_t ic, int32_t isr, int32_t osr, bool geodesic, bool check_closed)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(int32_t ic)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 567 of file ExtensionFunctionsGeo.hpp.

References box_contains_point().

570  {
571  return box_contains_point(bounds, bounds_size, px, py);
572 }
DEVICE ALWAYS_INLINE bool box_contains_point(double *bounds, int64_t bounds_size, double px, 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 529 of file ExtensionFunctionsGeo.hpp.

References coord_x(), coord_y(), polygon_contains_point(), and ring_intersects_line().

Referenced by ST_Contains_Polygon_LineString().

537  {
538  // Check that the first point is in the polygon
539  double l1x = coord_x(l, 0, ic2, isr2, osr);
540  double l1y = coord_y(l, 1, ic2, isr2, osr);
541  if (!polygon_contains_point(poly, poly_num_coords, l1x, l1y, ic1, isr1, osr)) {
542  return false;
543  }
544 
545  // Go through line segments and check if there are no intersections with poly edges,
546  // i.e. linestring doesn't escape
547  for (int32_t i = 2; i < lnum_coords; i += 2) {
548  double l2x = coord_x(l, i, ic2, isr2, osr);
549  double l2y = coord_y(l, i + 1, ic2, isr2, osr);
550  if (ring_intersects_line(poly, poly_num_coords, l1x, l1y, l2x, l2y, ic1, isr1, osr)) {
551  return false;
552  }
553  l1x = l2x;
554  l1y = l2y;
555  }
556  return true;
557 }
DEVICE ALWAYS_INLINE double coord_x(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE double coord_y(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
DEVICE bool polygon_contains_point(int8_t *poly, int32_t poly_num_coords, double px, double py, 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)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

DEVICE bool polygon_contains_point ( int8_t *  poly,
int32_t  poly_num_coords,
double  px,
double  py,
int32_t  ic1,
int32_t  isr1,
int32_t  osr 
)

Definition at line 414 of file ExtensionFunctionsGeo.hpp.

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

Referenced by polygon_contains_linestring(), ST_Contains_Polygon_LineString(), ST_Contains_Polygon_Point(), and ST_Distance_Point_Polygon().

420  {
421  bool result = false;
422  int xray_touch = 0;
423  bool horizontal_edge = false;
424  bool yray_intersects = false;
425 
426  double e1x = coord_x(poly, poly_num_coords - 2, ic1, isr1, osr);
427  double e1y = coord_y(poly, poly_num_coords - 1, ic1, isr1, osr);
428  for (int64_t i = 0; i < poly_num_coords; i += 2) {
429  double e2x = coord_x(poly, i, ic1, isr1, osr);
430  double e2y = coord_y(poly, i + 1, ic1, isr1, osr);
431 
432  // Check if point sits on an edge.
433  if (tol_zero(distance_point_line(px, py, e1x, e1y, e2x, e2y))) {
434  return true;
435  }
436 
437  // Before flipping the switch, check if xray hit a horizontal edge
438  // - If an edge lays on the xray, one of the previous edges touched it
439  // so while moving horizontally we're in 'xray_touch' state
440  // - Last edge that touched xray at (e2x,e2y) didn't register intersection
441  // - Next edge that diverges from xray at (e1,e1y) will register intersection
442  // - Can have several horizontal edges, one after the other, keep moving though
443  // in 'xray_touch' state without flipping the switch
444  horizontal_edge = (xray_touch != 0) && tol_eq(py, e1y) && tol_eq(py, e2y);
445 
446  // Main probe: xray
447  // Overshoot the xray to detect an intersection if there is one.
448  double xray = fmax(e2x, e1x) + 1.0;
449  if (px <= xray && // Only check for intersection if the edge is on the right
450  !horizontal_edge && // Keep moving through horizontal edges
451  line_intersects_line(px, // xray shooting from point p to the right
452  py,
453  xray,
454  py,
455  e1x, // polygon edge
456  e1y,
457  e2x,
458  e2y)) {
459  // Register intersection
460  result = !result;
461 
462  // Adjust for special cases
463  if (xray_touch == 0) {
464  if (tol_zero(distance_point_line(e2x, e2y, px, py, xray + 1.0, py))) {
465  // Xray goes through the edge's second vertex, unregister intersection -
466  // that vertex will be crossed again when we look at the following edge(s)
467  result = !result;
468  // Enter the xray-touch state:
469  // (1) - xray was touched by the edge from above, (-1) from below
470  xray_touch = (e1y > py) ? 1 : -1;
471  }
472  } else {
473  // Previous edge touched the xray, intersection hasn't been registered,
474  // it has to be registered now if this edge continues across the xray.
475  if (xray_touch > 0) {
476  // Previous edge touched the xray from above
477  if (e2y <= py) {
478  // Current edge crosses under xray: intersection is already registered
479  } else {
480  // Current edge just touched the xray and pulled up: unregister intersection
481  result = !result;
482  }
483  } else {
484  // Previous edge touched the xray from below
485  if (e2y > py) {
486  // Current edge crosses over xray: intersection is already registered
487  } else {
488  // Current edge just touched the xray and pulled down: unregister intersection
489  result = !result;
490  }
491  }
492  // Exit the xray-touch state
493  xray_touch = 0;
494  }
495  }
496 
497  // Redundancy: vertical yray down
498  // Main probe xray may hit multiple complex fragments which increases a chance of
499  // error. Perform a simple secondary check for edge intersections to see if point is
500  // outside.
501  if (!yray_intersects) { // Continue checking on yray until intersection is found
502  double yray = fmin(e2y, e1y) - 1.0;
503  if (yray <= py) { // Only check for yray intersection if point P is above the edge
504  yray_intersects = line_intersects_line(px, // yray shooting from point P down
505  py,
506  px,
507  yray,
508  e1x, // polygon edge
509  e1y,
510  e2x,
511  e2y);
512  }
513  }
514 
515  // Advance to the next vertex
516  e1x = e2x;
517  e1y = e2y;
518  }
519  if (!yray_intersects) {
520  // yray has zero intersections - point is outside the polygon
521  return false;
522  }
523  // Otherwise rely on the main probe
524  return result;
525 }
DEVICE ALWAYS_INLINE double coord_x(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE double coord_y(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
DEVICE double distance_point_line(double px, double py, double l1x, double l1y, double l2x, double l2y)
DEVICE ALWAYS_INLINE bool tol_eq(double x, double y, double tolerance=TOLERANCE_DEFAULT)
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(double x, 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 253 of file ExtensionFunctionsGeo.hpp.

References coord_x(), coord_y(), line_intersects_line(), and linestring_intersects_line().

Referenced by polygon_contains_linestring().

261  {
262  double e1x = coord_x(ring, ring_num_coords - 2, ic1, isr1, osr);
263  double e1y = coord_y(ring, ring_num_coords - 1, ic1, isr1, osr);
264  double e2x = coord_x(ring, 0, ic1, isr1, osr);
265  double e2y = coord_y(ring, 1, ic1, isr1, osr);
266  if (line_intersects_line(e1x, e1y, e2x, e2y, l1x, l1y, l2x, l2y)) {
267  return true;
268  }
270  ring, ring_num_coords, l1x, l1y, l2x, l2y, ic1, isr1, osr);
271 }
DEVICE ALWAYS_INLINE double coord_x(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE double coord_y(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
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)

+ 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,
int64_t  mpoly_coords_size,
int32_t *  mpoly_ring_sizes,
int64_t  mpoly_num_rings,
int32_t *  mpoly_poly_sizes,
int64_t  mpoly_num_polys,
int32_t  ic,
int32_t  isr,
int32_t  osr 
)

Definition at line 995 of file ExtensionFunctionsGeo.hpp.

References area_polygon(), and compression_unit_size().

Referenced by ST_Area_MultiPolygon_Geodesic().

1003  {
1004  if (mpoly_num_rings <= 0 || mpoly_num_polys <= 0) {
1005  return 0.0;
1006  }
1007 
1008  double area = 0.0;
1009 
1010  // Set specific poly pointers as we move through the coords/ringsizes/polyrings arrays.
1011  auto next_poly_coords = mpoly_coords;
1012  auto next_poly_ring_sizes = mpoly_ring_sizes;
1013 
1014  for (auto poly = 0; poly < mpoly_num_polys; poly++) {
1015  auto poly_coords = next_poly_coords;
1016  auto poly_ring_sizes = next_poly_ring_sizes;
1017  auto poly_num_rings = mpoly_poly_sizes[poly];
1018  // Count number of coords in all of poly's rings, advance ring size pointer.
1019  int32_t poly_num_coords = 0;
1020  for (auto ring = 0; ring < poly_num_rings; ring++) {
1021  poly_num_coords += 2 * *next_poly_ring_sizes++;
1022  }
1023  auto poly_coords_size = poly_num_coords * compression_unit_size(ic);
1024  next_poly_coords += poly_coords_size;
1025 
1026  area += area_polygon(
1027  poly_coords, poly_coords_size, poly_ring_sizes, poly_num_rings, ic, isr, osr);
1028  }
1029  return area;
1030 }
DEVICE ALWAYS_INLINE double area_polygon(int8_t *poly_coords, int64_t poly_coords_size, int32_t *poly_ring_sizes, int64_t poly_num_rings, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(int32_t ic)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_INLINE double ST_Area_MultiPolygon_Geodesic ( int8_t *  mpoly_coords,
int64_t  mpoly_coords_size,
int32_t *  mpoly_ring_sizes,
int64_t  mpoly_num_rings,
int32_t *  mpoly_poly_sizes,
int64_t  mpoly_num_polys,
int32_t  ic,
int32_t  isr,
int32_t  osr 
)

Definition at line 1033 of file ExtensionFunctionsGeo.hpp.

References ST_Area_MultiPolygon().

1041  {
1042  return ST_Area_MultiPolygon(mpoly_coords,
1043  mpoly_coords_size,
1044  mpoly_ring_sizes,
1045  mpoly_num_rings,
1046  mpoly_poly_sizes,
1047  mpoly_num_polys,
1048  ic,
1049  isr,
1050  osr);
1051 }
EXTENSION_NOINLINE double ST_Area_MultiPolygon(int8_t *mpoly_coords, int64_t mpoly_coords_size, int32_t *mpoly_ring_sizes, int64_t mpoly_num_rings, int32_t *mpoly_poly_sizes, int64_t mpoly_num_polys, int32_t ic, int32_t isr, int32_t osr)

+ Here is the call graph for this function:

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

Definition at line 971 of file ExtensionFunctionsGeo.hpp.

References area_polygon().

Referenced by ST_Area_Polygon_Geodesic().

977  {
978  return area_polygon(
979  poly_coords, poly_coords_size, poly_ring_sizes, poly_num_rings, ic, isr, osr);
980 }
DEVICE ALWAYS_INLINE double area_polygon(int8_t *poly_coords, int64_t poly_coords_size, int32_t *poly_ring_sizes, int64_t poly_num_rings, int32_t ic, int32_t isr, int32_t osr)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_INLINE double ST_Area_Polygon_Geodesic ( int8_t *  poly_coords,
int64_t  poly_coords_size,
int32_t *  poly_ring_sizes,
int64_t  poly_num_rings,
int32_t  ic,
int32_t  isr,
int32_t  osr 
)

Definition at line 983 of file ExtensionFunctionsGeo.hpp.

References ST_Area_Polygon().

989  {
990  return ST_Area_Polygon(
991  poly_coords, poly_coords_size, poly_ring_sizes, poly_num_rings, ic, isr, osr);
992 }
EXTENSION_NOINLINE double ST_Area_Polygon(int8_t *poly_coords, int64_t poly_coords_size, int32_t *poly_ring_sizes, int64_t poly_num_rings, int32_t ic, int32_t isr, int32_t osr)

+ Here is the call graph for this function:

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

Definition at line 2173 of file ExtensionFunctionsGeo.hpp.

References ST_Distance_LineString_LineString(), and tol_zero().

2187  {
2188  if (l1i != 0 || l2i != 0) {
2189  // At least one linestring is indexed, can rely on distance
2191  l1, l1size, l1i, l2, l2size, l2i, ic1, isr1, ic2, isr2, osr));
2192  }
2193 
2194  // TODO: sublinestring
2195  // For each line segment in l2 check if there is a segment in l1
2196  // that it's colinear with and both l2 vertices are on l1 segment.
2197  // Bail if any line segment deviates from the path.
2198  return false;
2199 }
DEVICE ALWAYS_INLINE bool tol_zero(double x, double tolerance=TOLERANCE_DEFAULT)
EXTENSION_NOINLINE double ST_Distance_LineString_LineString(int8_t *l1, int64_t l1size, int32_t l1index, int8_t *l2, int64_t l2size, int32_t l2index, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)

+ Here is the call graph for this function:

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

Definition at line 2156 of file ExtensionFunctionsGeo.hpp.

References ST_Distance_Point_LineString(), and tol_zero().

2167  {
2168  return tol_zero(
2169  ST_Distance_Point_LineString(p, psize, l, lsize, li, ic2, isr2, ic1, isr1, osr));
2170 }
EXTENSION_NOINLINE double ST_Distance_Point_LineString(int8_t *p, int64_t psize, int8_t *l, int64_t lsize, int32_t lindex, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
DEVICE ALWAYS_INLINE bool tol_zero(double x, 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,
int32_t  li,
int8_t *  poly_coords,
int64_t  poly_coords_size,
int32_t *  poly_ring_sizes,
int64_t  poly_num_rings,
double *  poly_bounds,
int64_t  poly_bounds_size,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr 
)

Definition at line 2202 of file ExtensionFunctionsGeo.hpp.

2217  {
2218  // TODO
2219  return false;
2220 }
EXTENSION_NOINLINE bool ST_Contains_MultiPolygon_LineString ( int8_t *  mpoly_coords,
int64_t  mpoly_coords_size,
int32_t *  mpoly_ring_sizes,
int64_t  mpoly_num_rings,
int32_t *  mpoly_poly_sizes,
int64_t  mpoly_num_polys,
double *  mpoly_bounds,
int64_t  mpoly_bounds_size,
int8_t *  l,
int64_t  lsize,
double *  lbounds,
int64_t  lbounds_size,
int32_t  li,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr 
)

Definition at line 2442 of file ExtensionFunctionsGeo.hpp.

References box_contains_box(), box_contains_point(), compression_unit_size(), coord_x(), coord_y(), ST_Contains_MultiPolygon_Point(), and ST_Contains_Polygon_LineString().

2459  {
2460  if (mpoly_num_polys <= 0) {
2461  return false;
2462  }
2463 
2464  auto lnum_coords = lsize / compression_unit_size(ic2);
2465  auto lnum_points = lnum_coords / 2;
2466  if (li != 0) {
2467  // Statically indexed linestring
2468  if (li < 0 || li > lnum_points) {
2469  li = lnum_points;
2470  }
2471  double lx = coord_x(l, 2 * (li - 1), ic2, isr2, osr);
2472  double ly = coord_y(l, 2 * (li - 1) + 1, ic2, isr2, osr);
2473 
2474  if (mpoly_bounds) {
2475  if (!box_contains_point(mpoly_bounds, mpoly_bounds_size, lx, ly)) {
2476  return false;
2477  }
2478  }
2479  auto p = l + li * compression_unit_size(ic2);
2480  auto psize = 2 * compression_unit_size(ic2);
2481  return ST_Contains_MultiPolygon_Point(mpoly_coords,
2482  mpoly_coords_size,
2483  mpoly_ring_sizes,
2484  mpoly_num_rings,
2485  mpoly_poly_sizes,
2486  mpoly_num_polys,
2487  mpoly_bounds,
2488  mpoly_bounds_size,
2489  p,
2490  psize,
2491  ic1,
2492  isr1,
2493  ic2,
2494  isr2,
2495  osr);
2496  }
2497 
2498  if (mpoly_bounds && lbounds) {
2499  if (!box_contains_box(mpoly_bounds, mpoly_bounds_size, lbounds, lbounds_size)) {
2500  return false;
2501  }
2502  }
2503 
2504  // Set specific poly pointers as we move through the coords/ringsizes/polyrings arrays.
2505  auto next_poly_coords = mpoly_coords;
2506  auto next_poly_ring_sizes = mpoly_ring_sizes;
2507 
2508  for (auto poly = 0; poly < mpoly_num_polys; poly++) {
2509  auto poly_coords = next_poly_coords;
2510  auto poly_ring_sizes = next_poly_ring_sizes;
2511  auto poly_num_rings = mpoly_poly_sizes[poly];
2512  // Count number of coords in all of poly's rings, advance ring size pointer.
2513  int32_t poly_num_coords = 0;
2514  for (auto ring = 0; ring < poly_num_rings; ring++) {
2515  poly_num_coords += 2 * *next_poly_ring_sizes++;
2516  }
2517  auto poly_coords_size = poly_num_coords * compression_unit_size(ic1);
2518  next_poly_coords += poly_coords_size;
2519 
2520  if (ST_Contains_Polygon_LineString(poly_coords,
2521  poly_coords_size,
2522  poly_ring_sizes,
2523  poly_num_rings,
2524  nullptr,
2525  0,
2526  l,
2527  lsize,
2528  nullptr,
2529  0,
2530  li,
2531  ic1,
2532  isr1,
2533  ic2,
2534  isr2,
2535  osr)) {
2536  return true;
2537  }
2538  }
2539 
2540  return false;
2541 }
DEVICE ALWAYS_INLINE double coord_x(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE double coord_y(int8_t *data, int32_t index, int32_t ic, int32_t isr, 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 li, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(int32_t ic)
DEVICE ALWAYS_INLINE bool box_contains_point(double *bounds, int64_t bounds_size, double px, double py)
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)
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 2375 of file ExtensionFunctionsGeo.hpp.

References box_contains_point(), compression_unit_size(), coord_x(), coord_y(), and ST_Contains_Polygon_Point().

Referenced by ST_Contains_MultiPolygon_LineString(), ST_Intersects_LineString_MultiPolygon(), ST_Intersects_MultiPolygon_Point(), and ST_Intersects_Point_MultiPolygon().

2389  {
2390  if (mpoly_num_polys <= 0) {
2391  return false;
2392  }
2393 
2394  double px = coord_x(p, 0, ic2, isr2, osr);
2395  double py = coord_y(p, 1, ic2, isr2, osr);
2396 
2397  // TODO: mpoly_bounds could contain individual bounding boxes too:
2398  // first two points - box for the entire multipolygon, then a pair for each polygon
2399  if (mpoly_bounds) {
2400  if (!box_contains_point(mpoly_bounds, mpoly_bounds_size, px, py)) {
2401  return false;
2402  }
2403  }
2404 
2405  // Set specific poly pointers as we move through the coords/ringsizes/polyrings arrays.
2406  auto next_poly_coords = mpoly_coords;
2407  auto next_poly_ring_sizes = mpoly_ring_sizes;
2408 
2409  for (auto poly = 0; poly < mpoly_num_polys; poly++) {
2410  auto poly_coords = next_poly_coords;
2411  auto poly_ring_sizes = next_poly_ring_sizes;
2412  auto poly_num_rings = mpoly_poly_sizes[poly];
2413  // Count number of coords in all of poly's rings, advance ring size pointer.
2414  int32_t poly_num_coords = 0;
2415  for (auto ring = 0; ring < poly_num_rings; ring++) {
2416  poly_num_coords += 2 * *next_poly_ring_sizes++;
2417  }
2418  auto poly_coords_size = poly_num_coords * compression_unit_size(ic1);
2419  next_poly_coords += poly_coords_size;
2420  // TODO: pass individual bounding boxes for each polygon
2421  if (ST_Contains_Polygon_Point(poly_coords,
2422  poly_coords_size,
2423  poly_ring_sizes,
2424  poly_num_rings,
2425  nullptr,
2426  0,
2427  p,
2428  psize,
2429  ic1,
2430  isr1,
2431  ic2,
2432  isr2,
2433  osr)) {
2434  return true;
2435  }
2436  }
2437 
2438  return false;
2439 }
DEVICE ALWAYS_INLINE double coord_x(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE double coord_y(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
EXTENSION_NOINLINE bool ST_Contains_Polygon_Point(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 *p, int64_t psize, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(int32_t ic)
DEVICE ALWAYS_INLINE bool box_contains_point(double *bounds, int64_t bounds_size, double px, double py)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 2087 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size(), coord_x(), coord_y(), and tol_eq().

Referenced by ST_Contains_Point_Polygon().

2098  {
2099  double px = coord_x(p, 0, ic1, isr1, osr);
2100  double py = coord_y(p, 1, ic1, isr1, osr);
2101 
2102  if (lbounds) {
2103  if (tol_eq(px, lbounds[0]) && tol_eq(py, lbounds[1]) && tol_eq(px, lbounds[2]) &&
2104  tol_eq(py, lbounds[3])) {
2105  return true;
2106  }
2107  }
2108 
2109  auto l_num_coords = lsize / compression_unit_size(ic2);
2110  for (int i = 0; i < l_num_coords; i += 2) {
2111  double lx = coord_x(l, i, ic2, isr2, osr);
2112  double ly = coord_y(l, i + 1, ic2, isr2, osr);
2113  if (tol_eq(px, lx) && tol_eq(py, ly)) {
2114  continue;
2115  }
2116  return false;
2117  }
2118  return true;
2119 }
DEVICE ALWAYS_INLINE double coord_x(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE double coord_y(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE bool tol_eq(double x, double y, double tolerance=TOLERANCE_DEFAULT)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(int32_t ic)

+ 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 2069 of file ExtensionFunctionsGeo.hpp.

References coord_x(), coord_y(), tol(), and tol_eq().

2077  {
2078  double p1x = coord_x(p1, 0, ic1, isr1, osr);
2079  double p1y = coord_y(p1, 1, ic1, isr1, osr);
2080  double p2x = coord_x(p2, 0, ic2, isr2, osr);
2081  double p2y = coord_y(p2, 1, ic2, isr2, osr);
2082  double tolerance = tol(ic1, ic2);
2083  return tol_eq(p1x, p2x, tolerance) && tol_eq(p1y, p2y, tolerance);
2084 }
DEVICE ALWAYS_INLINE double coord_x(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE double coord_y(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE bool tol_eq(double x, double y, double tolerance=TOLERANCE_DEFAULT)
DEVICE ALWAYS_INLINE double tol(int32_t ic)

+ 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 2122 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size(), and ST_Contains_Point_LineString().

2134  {
2135  auto exterior_ring_num_coords = poly_coords_size / compression_unit_size(ic2);
2136  if (poly_num_rings > 0) {
2137  exterior_ring_num_coords = poly_ring_sizes[0] * 2;
2138  }
2139  auto exterior_ring_coords_size = exterior_ring_num_coords * compression_unit_size(ic2);
2140 
2142  psize,
2143  poly_coords,
2144  exterior_ring_coords_size,
2145  poly_bounds,
2146  poly_bounds_size,
2147  0,
2148  ic1,
2149  isr1,
2150  ic2,
2151  isr2,
2152  osr);
2153 }
DEVICE ALWAYS_INLINE int32_t compression_unit_size(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 li, 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  li,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr 
)

Definition at line 2270 of file ExtensionFunctionsGeo.hpp.

References box_contains_box(), box_contains_point(), compression_unit_size(), coord_x(), coord_y(), polygon_contains_linestring(), and polygon_contains_point().

Referenced by ST_Contains_MultiPolygon_LineString(), and ST_Contains_Polygon_Polygon().

2285  {
2286  if (poly_num_rings > 1) {
2287  return false; // TODO: support polygons with interior rings
2288  }
2289 
2290  auto poly_num_coords = poly_coords_size / compression_unit_size(ic1);
2291  auto lnum_coords = lsize / compression_unit_size(ic2);
2292  auto lnum_points = lnum_coords / 2;
2293  if (li != 0) {
2294  // Statically indexed linestring
2295  if (li < 0 || li > lnum_points) {
2296  li = lnum_points;
2297  }
2298  double lx = coord_x(l, 2 * (li - 1), ic2, isr2, osr);
2299  double ly = coord_y(l, 2 * (li - 1) + 1, ic2, isr2, osr);
2300 
2301  if (poly_bounds) {
2302  if (!box_contains_point(poly_bounds, poly_bounds_size, lx, ly)) {
2303  return false;
2304  }
2305  }
2306  return polygon_contains_point(poly_coords, poly_num_coords, lx, ly, ic1, isr1, osr);
2307  }
2308 
2309  // Bail out if poly bounding box doesn't contain linestring bounding box
2310  if (poly_bounds && lbounds) {
2311  if (!box_contains_box(poly_bounds, poly_bounds_size, lbounds, lbounds_size)) {
2312  return false;
2313  }
2314  }
2315 
2317  poly_coords, poly_num_coords, l, lnum_coords, ic1, isr1, ic2, isr2, osr);
2318 }
DEVICE ALWAYS_INLINE double coord_x(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE double coord_y(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(int32_t ic)
DEVICE ALWAYS_INLINE bool box_contains_point(double *bounds, int64_t bounds_size, double px, double py)
DEVICE bool polygon_contains_point(int8_t *poly, int32_t poly_num_coords, double px, double py, int32_t ic1, int32_t isr1, 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_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 ( 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 *  p,
int64_t  psize,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr 
)

Definition at line 2223 of file ExtensionFunctionsGeo.hpp.

References box_contains_point(), compression_unit_size(), coord_x(), coord_y(), and polygon_contains_point().

Referenced by ST_Contains_MultiPolygon_Point(), ST_Intersects_LineString_Polygon(), ST_Intersects_Point_Polygon(), and ST_Intersects_Polygon_Point().

2235  {
2236  double px = coord_x(p, 0, ic2, isr2, osr);
2237  double py = coord_y(p, 1, ic2, isr2, osr);
2238 
2239  if (poly_bounds) {
2240  if (!box_contains_point(poly_bounds, poly_bounds_size, px, py)) {
2241  return false;
2242  }
2243  }
2244 
2245  auto poly_num_coords = poly_coords_size / compression_unit_size(ic1);
2246  auto exterior_ring_num_coords = poly_num_coords;
2247  if (poly_num_rings > 0) {
2248  exterior_ring_num_coords = poly_ring_sizes[0] * 2;
2249  }
2250 
2251  auto poly = poly_coords;
2252  if (polygon_contains_point(poly, exterior_ring_num_coords, px, py, ic1, isr1, osr)) {
2253  // Inside exterior ring
2254  poly += exterior_ring_num_coords * compression_unit_size(ic1);
2255  // Check that none of the polygon's holes contain that point
2256  for (auto r = 1; r < poly_num_rings; r++) {
2257  int64_t interior_ring_num_coords = poly_ring_sizes[r] * 2;
2259  poly, interior_ring_num_coords, px, py, ic1, isr1, osr)) {
2260  return false;
2261  }
2262  poly += interior_ring_num_coords * compression_unit_size(ic1);
2263  }
2264  return true;
2265  }
2266  return false;
2267 }
DEVICE ALWAYS_INLINE double coord_x(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE double coord_y(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(int32_t ic)
DEVICE ALWAYS_INLINE bool box_contains_point(double *bounds, int64_t bounds_size, double px, double py)
DEVICE bool polygon_contains_point(int8_t *poly, int32_t poly_num_coords, double px, double py, 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:

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 2321 of file ExtensionFunctionsGeo.hpp.

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

2337  {
2338  // TODO: needs to be extended, cover more cases
2339  // Right now only checking if simple poly1 (no holes) contains poly2's exterior shape
2340  if (poly1_num_rings > 1) {
2341  return false; // TODO: support polygons with interior rings
2342  }
2343 
2344  if (poly1_bounds && poly2_bounds) {
2345  if (!box_contains_box(
2346  poly1_bounds, poly1_bounds_size, poly2_bounds, poly2_bounds_size)) {
2347  return false;
2348  }
2349  }
2350 
2351  int64_t poly2_exterior_ring_coords_size = poly2_coords_size;
2352  if (poly2_num_rings > 0) {
2353  poly2_exterior_ring_coords_size =
2354  2 * poly2_ring_sizes[0] * compression_unit_size(ic2);
2355  }
2356  return ST_Contains_Polygon_LineString(poly1_coords,
2357  poly1_coords_size,
2358  poly1_ring_sizes,
2359  poly1_num_rings,
2360  poly1_bounds,
2361  poly1_bounds_size,
2362  poly2_coords,
2363  poly2_exterior_ring_coords_size,
2364  poly2_bounds,
2365  poly2_bounds_size,
2366  0,
2367  ic1,
2368  isr1,
2369  ic2,
2370  isr2,
2371  osr);
2372 }
EXTENSION_NOINLINE bool ST_Contains_Polygon_LineString(int8_t *poly_coords, int64_t poly_coords_size, int32_t *poly_ring_sizes, int64_t poly_num_rings, double *poly_bounds, int64_t poly_bounds_size, int8_t *l, int64_t lsize, double *lbounds, int64_t lbounds_size, int32_t li, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(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,
int32_t  l1index,
int8_t *  l2,
int64_t  l2size,
int32_t  l2index,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr 
)

Definition at line 1398 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size(), coord_x(), coord_y(), distance_line_line(), ST_Distance_Point_LineString(), and tol_zero().

Referenced by ST_Contains_LineString_LineString(), and ST_Intersects_LineString_Linestring().

1408  {
1409  auto l1_num_coords = l1size / compression_unit_size(ic1);
1410  if (l1index != 0) {
1411  // l1 is a statically indexed linestring
1412  auto l1_num_points = l1_num_coords / 2;
1413  if (l1index < 0 || l1index > l1_num_points) {
1414  l1index = l1_num_points;
1415  }
1416  int8_t* p = l1 + 2 * (l1index - 1) * compression_unit_size(ic1);
1417  int64_t psize = 2 * compression_unit_size(ic1);
1419  p, psize, l2, l2size, l2index, ic1, isr1, ic2, isr2, osr);
1420  }
1421 
1422  auto l2_num_coords = l2size / compression_unit_size(ic2);
1423  if (l2index != 0) {
1424  // l2 is a statically indexed linestring
1425  auto l2_num_points = l2_num_coords / 2;
1426  if (l2index < 0 || l2index > l2_num_points) {
1427  l2index = l2_num_points;
1428  }
1429  int8_t* p = l2 + 2 * (l2index - 1) * compression_unit_size(ic2);
1430  int64_t psize = 2 * compression_unit_size(ic2);
1432  p, psize, l1, l1size, l1index, ic2, isr2, ic1, isr1, osr);
1433  }
1434 
1435  double dist = 0.0;
1436  double l11x = coord_x(l1, 0, ic1, isr1, osr);
1437  double l11y = coord_y(l1, 1, ic1, isr1, osr);
1438  for (int32_t i1 = 2; i1 < l1_num_coords; i1 += 2) {
1439  double l12x = coord_x(l1, i1, ic1, isr1, osr);
1440  double l12y = coord_y(l1, i1 + 1, ic1, isr1, osr);
1441 
1442  double l21x = coord_x(l2, 0, ic2, isr2, osr);
1443  double l21y = coord_y(l2, 1, ic2, isr2, osr);
1444  for (int32_t i2 = 2; i2 < l2_num_coords; i2 += 2) {
1445  double l22x = coord_x(l2, i2, ic2, isr2, osr);
1446  double l22y = coord_y(l2, i2 + 1, ic2, isr2, osr);
1447 
1448  double ldist = distance_line_line(l11x, l11y, l12x, l12y, l21x, l21y, l22x, l22y);
1449  if (i1 == 2 && i2 == 2) {
1450  dist = ldist; // initialize dist with distance between the first two segments
1451  } else if (dist > ldist) {
1452  dist = ldist;
1453  }
1454  if (tol_zero(dist)) {
1455  return 0.0; // segments touch
1456  }
1457 
1458  l21x = l22x; // advance to the next point on l2
1459  l21y = l22y;
1460  }
1461 
1462  l11x = l12x; // advance to the next point on l1
1463  l11y = l12y;
1464  }
1465  return dist;
1466 }
DEVICE ALWAYS_INLINE double coord_x(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE double coord_y(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
EXTENSION_NOINLINE double ST_Distance_Point_LineString(int8_t *p, int64_t psize, int8_t *l, int64_t lsize, int32_t lindex, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(int32_t ic)
DEVICE ALWAYS_INLINE bool tol_zero(double x, double tolerance=TOLERANCE_DEFAULT)
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_NOINLINE double ST_Distance_LineString_LineString_Geodesic ( int8_t *  l1,
int64_t  l1size,
int32_t  l1index,
int8_t *  l2,
int64_t  l2size,
int32_t  l2index,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr 
)

Definition at line 1159 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size(), coord_x(), coord_y(), and distance_in_meters().

1169  {
1170  // Currently only statically indexed LineStrings are supported
1171  auto l1points = l1size / (2 * compression_unit_size(ic1));
1172  if (l1index < 0 || l1index > l1points) {
1173  l1index = l1points; // Endpoint
1174  }
1175  double l1x = coord_x(l1, 2 * (l1index - 1), ic1, 4326, 4326);
1176  double l1y = coord_y(l1, 2 * (l1index - 1) + 1, ic1, 4326, 4326);
1177  auto l2points = l2size / (2 * compression_unit_size(ic2));
1178  if (l2index < 0 || l2index > l2points) {
1179  l2index = l2points; // Endpoint
1180  }
1181  double l2x = coord_x(l2, 2 * (l2index - 1), ic2, 4326, 4326);
1182  double l2y = coord_y(l2, 2 * (l2index - 1) + 1, ic2, 4326, 4326);
1183  return distance_in_meters(l1x, l1y, l2x, l2y);
1184 }
DEVICE ALWAYS_INLINE double coord_x(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE double coord_y(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(int32_t ic)
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.

+ Here is the call graph for this function:

EXTENSION_NOINLINE double ST_Distance_LineString_MultiPolygon ( int8_t *  l,
int64_t  lsize,
int32_t  lindex,
int8_t *  mpoly_coords,
int64_t  mpoly_coords_size,
int32_t *  mpoly_ring_sizes,
int64_t  mpoly_num_rings,
int32_t *  mpoly_poly_sizes,
int64_t  mpoly_num_polys,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr 
)

Definition at line 1538 of file ExtensionFunctionsGeo.hpp.

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

Referenced by ST_Distance_MultiPolygon_LineString(), and ST_Intersects_LineString_MultiPolygon().

1551  {
1552  // TODO: revisit implementation, cover all cases
1553 
1554  auto lnum_coords = lsize / compression_unit_size(ic1);
1555  auto lnum_points = lnum_coords / 2;
1556  if (lindex != 0) {
1557  // Statically indexed linestring
1558  if (lindex < 0 || lindex > lnum_points) {
1559  lindex = lnum_points;
1560  }
1561  auto p = l + lindex * compression_unit_size(ic1);
1562  auto psize = 2 * compression_unit_size(ic1);
1564  psize,
1565  mpoly_coords,
1566  mpoly_coords_size,
1567  mpoly_ring_sizes,
1568  mpoly_num_rings,
1569  mpoly_poly_sizes,
1570  mpoly_num_polys,
1571  ic1,
1572  isr1,
1573  ic2,
1574  isr2,
1575  osr);
1576  }
1577 
1578  double min_distance = 0.0;
1579 
1580  // Set specific poly pointers as we move through the coords/ringsizes/polyrings arrays.
1581  auto next_poly_coords = mpoly_coords;
1582  auto next_poly_ring_sizes = mpoly_ring_sizes;
1583 
1584  for (auto poly = 0; poly < mpoly_num_polys; poly++) {
1585  auto poly_coords = next_poly_coords;
1586  auto poly_ring_sizes = next_poly_ring_sizes;
1587  auto poly_num_rings = mpoly_poly_sizes[poly];
1588  // Count number of coords in all of poly's rings, advance ring size pointer.
1589  int32_t poly_num_coords = 0;
1590  for (auto ring = 0; ring < poly_num_rings; ring++) {
1591  poly_num_coords += 2 * *next_poly_ring_sizes++;
1592  }
1593  auto poly_coords_size = poly_num_coords * compression_unit_size(ic2);
1594  next_poly_coords += poly_coords_size;
1595  double distance = ST_Distance_LineString_Polygon(l,
1596  lsize,
1597  lindex,
1598  poly_coords,
1599  poly_coords_size,
1600  poly_ring_sizes,
1601  poly_num_rings,
1602  ic1,
1603  isr1,
1604  ic2,
1605  isr2,
1606  osr);
1607  if (poly == 0 || min_distance > distance) {
1608  min_distance = distance;
1609  if (tol_zero(min_distance)) {
1610  min_distance = 0.0;
1611  break;
1612  }
1613  }
1614  }
1615 
1616  return min_distance;
1617 }
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)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(int32_t ic)
DEVICE ALWAYS_INLINE bool tol_zero(double x, double tolerance=TOLERANCE_DEFAULT)
EXTENSION_NOINLINE double ST_Distance_LineString_Polygon(int8_t *l, int64_t lsize, int32_t lindex, int8_t *poly_coords, int64_t poly_coords_size, int32_t *poly_ring_sizes, int64_t poly_num_rings, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)

+ 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,
int32_t  lindex,
int8_t *  p,
int64_t  psize,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr 
)

Definition at line 1383 of file ExtensionFunctionsGeo.hpp.

References ST_Distance_Point_LineString().

1392  {
1394  p, psize, l, lsize, lindex, ic2, isr2, ic1, isr1, osr);
1395 }
EXTENSION_NOINLINE double ST_Distance_Point_LineString(int8_t *p, int64_t psize, int8_t *l, int64_t lsize, int32_t lindex, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)

+ Here is the call graph for this function:

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

Definition at line 1143 of file ExtensionFunctionsGeo.hpp.

References ST_Distance_Point_LineString_Geodesic().

1152  {
1153  // Currently only statically indexed LineString is supported
1155  p, psize, l, lsize, lindex, ic2, isr2, ic1, isr1, osr);
1156 }
EXTENSION_NOINLINE double ST_Distance_Point_LineString_Geodesic(int8_t *p, int64_t psize, int8_t *l, int64_t lsize, int32_t lindex, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)

+ Here is the call graph for this function:

EXTENSION_NOINLINE double ST_Distance_LineString_Polygon ( int8_t *  l,
int64_t  lsize,
int32_t  lindex,
int8_t *  poly_coords,
int64_t  poly_coords_size,
int32_t *  poly_ring_sizes,
int64_t  poly_num_rings,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr 
)

Definition at line 1469 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(), and ST_Intersects_LineString_Polygon().

1480  {
1481  auto lnum_coords = lsize / compression_unit_size(ic1);
1482  auto lnum_points = lnum_coords / 2;
1483  if (lindex < 0 || lindex > lnum_points) {
1484  lindex = lnum_points;
1485  }
1486  auto p = l + lindex * compression_unit_size(ic1);
1487  auto psize = 2 * compression_unit_size(ic1);
1488  auto min_distance = ST_Distance_Point_Polygon(p,
1489  psize,
1490  poly_coords,
1491  poly_coords_size,
1492  poly_ring_sizes,
1493  poly_num_rings,
1494  ic1,
1495  isr1,
1496  ic2,
1497  isr2,
1498  osr);
1499  if (lindex != 0) {
1500  // Statically indexed linestring: return distance from the indexed point to poly
1501  return min_distance;
1502  }
1503  if (tol_zero(min_distance)) {
1504  // Linestring's first point is inside the poly
1505  return 0.0;
1506  }
1507 
1508  // Otherwise, linestring's first point is outside the external ring or inside
1509  // an internal ring. Measure minimum distance between linestring segments and
1510  // poly rings. Crossing a ring zeroes the distance and causes an early return.
1511  auto poly_ring_coords = poly_coords;
1512  for (auto r = 0; r < poly_num_rings; r++) {
1513  int64_t poly_ring_num_coords = poly_ring_sizes[r] * 2;
1514 
1515  auto distance = distance_ring_linestring(poly_ring_coords,
1516  poly_ring_num_coords,
1517  l,
1518  lnum_coords,
1519  ic2,
1520  isr2,
1521  ic1,
1522  isr1,
1523  osr);
1524  if (min_distance > distance) {
1525  min_distance = distance;
1526  if (tol_zero(min_distance)) {
1527  return 0.0;
1528  }
1529  }
1530 
1531  poly_ring_coords += poly_ring_num_coords * compression_unit_size(ic2);
1532  }
1533 
1534  return min_distance;
1535 }
DEVICE ALWAYS_INLINE int32_t compression_unit_size(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)
DEVICE ALWAYS_INLINE bool tol_zero(double x, double tolerance=TOLERANCE_DEFAULT)
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)

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

Definition at line 1835 of file ExtensionFunctionsGeo.hpp.

References ST_Distance_LineString_MultiPolygon().

1848  {
1850  lsize,
1851  lindex,
1852  mpoly_coords,
1853  mpoly_coords_size,
1854  mpoly_ring_sizes,
1855  mpoly_num_rings,
1856  mpoly_poly_sizes,
1857  mpoly_num_polys,
1858  ic2,
1859  isr2,
1860  ic1,
1861  isr1,
1862  osr);
1863 }
EXTENSION_NOINLINE double ST_Distance_LineString_MultiPolygon(int8_t *l, int64_t lsize, int32_t lindex, int8_t *mpoly_coords, int64_t mpoly_coords_size, int32_t *mpoly_ring_sizes, int64_t mpoly_num_rings, int32_t *mpoly_poly_sizes, int64_t mpoly_num_polys, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)

+ 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 
)

Definition at line 1899 of file ExtensionFunctionsGeo.hpp.

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

Referenced by ST_Intersects_MultiPolygon_MultiPolygon().

1915  {
1916  double min_distance = 0.0;
1917 
1918  // Set specific poly pointers as we move through mpoly1's coords/ringsizes/polyrings
1919  // arrays.
1920  auto next_poly_coords = mpoly1_coords;
1921  auto next_poly_ring_sizes = mpoly1_ring_sizes;
1922 
1923  for (auto poly = 0; poly < mpoly1_num_polys; poly++) {
1924  auto poly_coords = next_poly_coords;
1925  auto poly_ring_sizes = next_poly_ring_sizes;
1926  auto poly_num_rings = mpoly1_poly_sizes[poly];
1927  // Count number of coords in all of poly's rings, advance ring size pointer.
1928  int32_t poly_num_coords = 0;
1929  for (auto ring = 0; ring < poly_num_rings; ring++) {
1930  poly_num_coords += 2 * *next_poly_ring_sizes++;
1931  }
1932  auto poly_coords_size = poly_num_coords * compression_unit_size(ic1);
1933  next_poly_coords += poly_coords_size;
1934  double distance = ST_Distance_Polygon_MultiPolygon(poly_coords,
1935  poly_coords_size,
1936  poly_ring_sizes,
1937  poly_num_rings,
1938  mpoly2_coords,
1939  mpoly2_coords_size,
1940  mpoly2_ring_sizes,
1941  mpoly2_num_rings,
1942  mpoly2_poly_sizes,
1943  mpoly2_num_polys,
1944  ic1,
1945  isr1,
1946  ic2,
1947  isr2,
1948  osr);
1949  if (poly == 0 || min_distance > distance) {
1950  min_distance = distance;
1951  if (tol_zero(min_distance)) {
1952  min_distance = 0.0;
1953  break;
1954  }
1955  }
1956  }
1957 
1958  return min_distance;
1959 }
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)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(int32_t ic)
DEVICE ALWAYS_INLINE bool tol_zero(double x, double tolerance=TOLERANCE_DEFAULT)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_INLINE double ST_Distance_MultiPolygon_Point ( int8_t *  mpoly_coords,
int64_t  mpoly_coords_size,
int32_t *  mpoly_ring_sizes,
int64_t  mpoly_num_rings,
int32_t *  mpoly_poly_sizes,
int64_t  mpoly_num_polys,
int8_t *  p,
int64_t  psize,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr 
)

Definition at line 1806 of file ExtensionFunctionsGeo.hpp.

References ST_Distance_Point_MultiPolygon().

1818  {
1820  psize,
1821  mpoly_coords,
1822  mpoly_coords_size,
1823  mpoly_ring_sizes,
1824  mpoly_num_rings,
1825  mpoly_poly_sizes,
1826  mpoly_num_polys,
1827  ic2,
1828  isr2,
1829  ic1,
1830  isr1,
1831  osr);
1832 }
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)

+ Here is the call graph for this function:

EXTENSION_INLINE double ST_Distance_MultiPolygon_Polygon ( int8_t *  mpoly_coords,
int64_t  mpoly_coords_size,
int32_t *  mpoly_ring_sizes,
int64_t  mpoly_num_rings,
int32_t *  mpoly_poly_sizes,
int64_t  mpoly_num_polys,
int8_t *  poly1_coords,
int64_t  poly1_coords_size,
int32_t *  poly1_ring_sizes,
int64_t  poly1_num_rings,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr 
)

Definition at line 1866 of file ExtensionFunctionsGeo.hpp.

References ST_Distance_Polygon_MultiPolygon().

1880  {
1881  return ST_Distance_Polygon_MultiPolygon(poly1_coords,
1882  poly1_coords_size,
1883  poly1_ring_sizes,
1884  poly1_num_rings,
1885  mpoly_coords,
1886  mpoly_coords_size,
1887  mpoly_ring_sizes,
1888  mpoly_num_rings,
1889  mpoly_poly_sizes,
1890  mpoly_num_polys,
1891  ic2,
1892  isr2,
1893  ic1,
1894  isr1,
1895  osr);
1896 }
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)

+ Here is the call graph for this function:

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

Definition at line 1240 of file ExtensionFunctionsGeo.hpp.

References distance_point_linestring().

Referenced by ST_Distance_Point_Polygon().

1249  {
1251  p, psize, l, lsize, lindex, ic1, isr1, ic2, isr2, osr, true);
1252 }
DEVICE ALWAYS_INLINE double distance_point_linestring(int8_t *p, int64_t psize, int8_t *l, int64_t lsize, int32_t lindex, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, bool check_closed)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 1255 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size(), coord_x(), coord_y(), distance_point_linestring(), and distance_point_point().

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

1264  {
1265  if (lindex != 0) { // Statically indexed linestring
1266  auto l_num_coords = lsize / compression_unit_size(ic2);
1267  auto l_num_points = l_num_coords / 2;
1268  if (lindex < 0 || lindex > l_num_points) {
1269  lindex = l_num_points; // Endpoint
1270  }
1271  double px = coord_x(p, 0, ic1, isr1, osr);
1272  double py = coord_y(p, 1, ic1, isr1, osr);
1273  double lx = coord_x(l, 2 * (lindex - 1), ic2, isr2, osr);
1274  double ly = coord_y(l, 2 * (lindex - 1) + 1, ic2, isr2, osr);
1275  return distance_point_point(px, py, lx, ly);
1276  }
1277 
1279  p, psize, l, lsize, lindex, ic1, isr1, ic2, isr2, osr, false);
1280 }
DEVICE ALWAYS_INLINE double coord_x(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE double coord_y(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(int32_t ic)
DEVICE ALWAYS_INLINE double distance_point_linestring(int8_t *p, int64_t psize, int8_t *l, int64_t lsize, int32_t lindex, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, bool check_closed)
DEVICE ALWAYS_INLINE double distance_point_point(double p1x, double p1y, double p2x, double p2y)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 1120 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size(), coord_x(), coord_y(), and distance_in_meters().

Referenced by ST_Distance_LineString_Point_Geodesic().

1129  {
1130  // Currently only statically indexed LineString is supported
1131  double px = coord_x(p, 0, ic1, 4326, 4326);
1132  double py = coord_y(p, 1, ic1, 4326, 4326);
1133  auto lpoints = lsize / (2 * compression_unit_size(ic2));
1134  if (lindex < 0 || lindex > lpoints) {
1135  lindex = lpoints; // Endpoint
1136  }
1137  double lx = coord_x(l, 2 * (lindex - 1), ic2, 4326, 4326);
1138  double ly = coord_y(l, 2 * (lindex - 1) + 1, ic2, 4326, 4326);
1139  return distance_in_meters(px, py, lx, ly);
1140 }
DEVICE ALWAYS_INLINE double coord_x(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE double coord_y(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(int32_t ic)
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.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_NOINLINE double ST_Distance_Point_MultiPolygon ( int8_t *  p,
int64_t  psize,
int8_t *  mpoly_coords,
int64_t  mpoly_coords_size,
int32_t *  mpoly_ring_sizes,
int64_t  mpoly_num_rings,
int32_t *  mpoly_poly_sizes,
int64_t  mpoly_num_polys,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr 
)

Definition at line 1326 of file ExtensionFunctionsGeo.hpp.

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

Referenced by ST_Distance_LineString_MultiPolygon(), and ST_Distance_MultiPolygon_Point().

1338  {
1339  if (mpoly_num_polys <= 0) {
1340  return 0.0;
1341  }
1342  double min_distance = 0.0;
1343 
1344  // Set specific poly pointers as we move through the coords/ringsizes/polyrings arrays.
1345  auto next_poly_coords = mpoly_coords;
1346  auto next_poly_ring_sizes = mpoly_ring_sizes;
1347 
1348  for (auto poly = 0; poly < mpoly_num_polys; poly++) {
1349  auto poly_coords = next_poly_coords;
1350  auto poly_ring_sizes = next_poly_ring_sizes;
1351  auto poly_num_rings = mpoly_poly_sizes[poly];
1352  // Count number of coords in all of poly's rings, advance ring size pointer.
1353  int32_t poly_num_coords = 0;
1354  for (auto ring = 0; ring < poly_num_rings; ring++) {
1355  poly_num_coords += 2 * *next_poly_ring_sizes++;
1356  }
1357  auto poly_coords_size = poly_num_coords * compression_unit_size(ic2);
1358  next_poly_coords += poly_coords_size;
1359  double distance = ST_Distance_Point_Polygon(p,
1360  psize,
1361  poly_coords,
1362  poly_coords_size,
1363  poly_ring_sizes,
1364  poly_num_rings,
1365  ic1,
1366  isr1,
1367  ic2,
1368  isr2,
1369  osr);
1370  if (poly == 0 || min_distance > distance) {
1371  min_distance = distance;
1372  if (tol_zero(min_distance)) {
1373  min_distance = 0.0;
1374  break;
1375  }
1376  }
1377  }
1378 
1379  return min_distance;
1380 }
DEVICE ALWAYS_INLINE int32_t compression_unit_size(int32_t ic)
DEVICE ALWAYS_INLINE bool tol_zero(double x, double tolerance=TOLERANCE_DEFAULT)
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)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_NOINLINE double ST_Distance_Point_Point ( int8_t *  p1,
int64_t  p1size,
int8_t *  p2,
int64_t  p2size,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr 
)

Definition at line 1069 of file ExtensionFunctionsGeo.hpp.

References coord_x(), coord_y(), and distance_point_point().

Referenced by ST_Intersects_Point_LineString(), and ST_Intersects_Point_Point().

1077  {
1078  double p1x = coord_x(p1, 0, ic1, isr1, osr);
1079  double p1y = coord_y(p1, 1, ic1, isr1, osr);
1080  double p2x = coord_x(p2, 0, ic2, isr2, osr);
1081  double p2y = coord_y(p2, 1, ic2, isr2, osr);
1082  return distance_point_point(p1x, p1y, p2x, p2y);
1083 }
DEVICE ALWAYS_INLINE double coord_x(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE double coord_y(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE double distance_point_point(double p1x, double p1y, double p2x, double p2y)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_NOINLINE double ST_Distance_Point_Point_Geodesic ( int8_t *  p1,
int64_t  p1size,
int8_t *  p2,
int64_t  p2size,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr 
)

Definition at line 1103 of file ExtensionFunctionsGeo.hpp.

References coord_x(), coord_y(), and distance_in_meters().

1111  {
1112  double p1x = coord_x(p1, 0, ic1, 4326, 4326);
1113  double p1y = coord_y(p1, 1, ic1, 4326, 4326);
1114  double p2x = coord_x(p2, 0, ic2, 4326, 4326);
1115  double p2y = coord_y(p2, 1, ic2, 4326, 4326);
1116  return distance_in_meters(p1x, p1y, p2x, p2y);
1117 }
DEVICE ALWAYS_INLINE double coord_x(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE double coord_y(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
EXTENSION_NOINLINE double distance_in_meters(const double fromlon, const double fromlat, const double tolon, const double tolat)
Computes the distance, in meters, between two WGS-84 positions.

+ Here is the call graph for this function:

EXTENSION_NOINLINE double ST_Distance_Point_Point_Squared ( int8_t *  p1,
int64_t  p1size,
int8_t *  p2,
int64_t  p2size,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr 
)

Definition at line 1086 of file ExtensionFunctionsGeo.hpp.

References coord_x(), coord_y(), and distance_point_point_squared().

1094  {
1095  double p1x = coord_x(p1, 0, ic1, isr1, osr);
1096  double p1y = coord_y(p1, 1, ic1, isr1, osr);
1097  double p2x = coord_x(p2, 0, ic2, isr2, osr);
1098  double p2y = coord_y(p2, 1, ic2, isr2, osr);
1099  return distance_point_point_squared(p1x, p1y, p2x, p2y);
1100 }
DEVICE ALWAYS_INLINE double coord_x(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE double coord_y(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE double distance_point_point_squared(double p1x, double p1y, double p2x, double p2y)

+ Here is the call graph for this function:

EXTENSION_NOINLINE double ST_Distance_Point_Polygon ( int8_t *  p,
int64_t  psize,
int8_t *  poly,
int64_t  polysize,
int32_t *  poly_ring_sizes,
int64_t  poly_num_rings,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr 
)

Definition at line 1283 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size(), coord_x(), coord_y(), polygon_contains_point(), and ST_Distance_Point_ClosedLineString().

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

1293  {
1294  auto exterior_ring_num_coords = polysize / compression_unit_size(ic2);
1295  if (poly_num_rings > 0) {
1296  exterior_ring_num_coords = poly_ring_sizes[0] * 2;
1297  }
1298  auto exterior_ring_coords_size = exterior_ring_num_coords * compression_unit_size(ic2);
1299 
1300  double px = coord_x(p, 0, ic1, isr1, osr);
1301  double py = coord_y(p, 1, ic1, isr1, osr);
1302  if (!polygon_contains_point(poly, exterior_ring_num_coords, px, py, ic2, isr2, osr)) {
1303  // Outside the exterior ring
1305  p, psize, poly, exterior_ring_coords_size, 0, ic1, isr1, ic2, isr2, osr);
1306  }
1307  // Inside exterior ring
1308  // Advance to first interior ring
1309  poly += exterior_ring_coords_size;
1310  // Check if one of the polygon's holes contains that point
1311  for (auto r = 1; r < poly_num_rings; r++) {
1312  auto interior_ring_num_coords = poly_ring_sizes[r] * 2;
1313  auto interior_ring_coords_size =
1314  interior_ring_num_coords * compression_unit_size(ic2);
1315  if (polygon_contains_point(poly, interior_ring_num_coords, px, py, ic2, isr2, osr)) {
1316  // Inside an interior ring
1318  p, psize, poly, interior_ring_coords_size, 0, ic1, isr1, ic2, isr2, osr);
1319  }
1320  poly += interior_ring_coords_size;
1321  }
1322  return 0.0;
1323 }
DEVICE ALWAYS_INLINE double coord_x(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE double coord_y(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(int32_t ic)
DEVICE bool polygon_contains_point(int8_t *poly, int32_t poly_num_coords, double px, double py, int32_t ic1, int32_t isr1, int32_t osr)
EXTENSION_NOINLINE double ST_Distance_Point_ClosedLineString(int8_t *p, int64_t psize, int8_t *l, int64_t lsize, int32_t lindex, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_INLINE double ST_Distance_Polygon_LineString ( int8_t *  poly_coords,
int64_t  poly_coords_size,
int32_t *  poly_ring_sizes,
int64_t  poly_num_rings,
int8_t *  l,
int64_t  lsize,
int32_t  li,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr 
)

Definition at line 1645 of file ExtensionFunctionsGeo.hpp.

References ST_Distance_LineString_Polygon().

1656  {
1658  lsize,
1659  li,
1660  poly_coords,
1661  poly_coords_size,
1662  poly_ring_sizes,
1663  poly_num_rings,
1664  ic2,
1665  isr2,
1666  ic1,
1667  isr2,
1668  osr);
1669 }
EXTENSION_NOINLINE double ST_Distance_LineString_Polygon(int8_t *l, int64_t lsize, int32_t lindex, int8_t *poly_coords, int64_t poly_coords_size, int32_t *poly_ring_sizes, int64_t poly_num_rings, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)

+ Here is the call graph for this function:

EXTENSION_NOINLINE double ST_Distance_Polygon_MultiPolygon ( int8_t *  poly1_coords,
int64_t  poly1_coords_size,
int32_t *  poly1_ring_sizes,
int64_t  poly1_num_rings,
int8_t *  mpoly_coords,
int64_t  mpoly_coords_size,
int32_t *  mpoly_ring_sizes,
int64_t  mpoly_num_rings,
int32_t *  mpoly_poly_sizes,
int64_t  mpoly_num_polys,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr 
)

Definition at line 1748 of file ExtensionFunctionsGeo.hpp.

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

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

1762  {
1763  double min_distance = 0.0;
1764 
1765  // Set specific poly pointers as we move through the coords/ringsizes/polyrings arrays.
1766  auto next_poly_coords = mpoly_coords;
1767  auto next_poly_ring_sizes = mpoly_ring_sizes;
1768 
1769  for (auto poly = 0; poly < mpoly_num_polys; poly++) {
1770  auto poly_coords = next_poly_coords;
1771  auto poly_ring_sizes = next_poly_ring_sizes;
1772  auto poly_num_rings = mpoly_poly_sizes[poly];
1773  // Count number of coords in all of poly's rings, advance ring size pointer.
1774  int32_t poly_num_coords = 0;
1775  for (auto ring = 0; ring < poly_num_rings; ring++) {
1776  poly_num_coords += 2 * *next_poly_ring_sizes++;
1777  }
1778  auto poly_coords_size = poly_num_coords * compression_unit_size(ic2);
1779  next_poly_coords += poly_coords_size;
1780  double distance = ST_Distance_Polygon_Polygon(poly1_coords,
1781  poly1_coords_size,
1782  poly1_ring_sizes,
1783  poly1_num_rings,
1784  poly_coords,
1785  poly_coords_size,
1786  poly_ring_sizes,
1787  poly_num_rings,
1788  ic1,
1789  isr1,
1790  ic2,
1791  isr2,
1792  osr);
1793  if (poly == 0 || min_distance > distance) {
1794  min_distance = distance;
1795  if (tol_zero(min_distance)) {
1796  min_distance = 0.0;
1797  break;
1798  }
1799  }
1800  }
1801 
1802  return min_distance;
1803 }
DEVICE ALWAYS_INLINE int32_t compression_unit_size(int32_t ic)
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)
DEVICE ALWAYS_INLINE bool tol_zero(double x, double tolerance=TOLERANCE_DEFAULT)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_INLINE double ST_Distance_Polygon_Point ( int8_t *  poly_coords,
int64_t  poly_coords_size,
int32_t *  poly_ring_sizes,
int64_t  poly_num_rings,
int8_t *  p,
int64_t  psize,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr 
)

Definition at line 1620 of file ExtensionFunctionsGeo.hpp.

References ST_Distance_Point_Polygon().

Referenced by ST_Distance_Polygon_Polygon().

1630  {
1631  return ST_Distance_Point_Polygon(p,
1632  psize,
1633  poly_coords,
1634  poly_coords_size,
1635  poly_ring_sizes,
1636  poly_num_rings,
1637  ic2,
1638  isr2,
1639  ic1,
1640  isr1,
1641  osr);
1642 }
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)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_NOINLINE double ST_Distance_Polygon_Polygon ( int8_t *  poly1_coords,
int64_t  poly1_coords_size,
int32_t *  poly1_ring_sizes,
int64_t  poly1_num_rings,
int8_t *  poly2_coords,
int64_t  poly2_coords_size,
int32_t *  poly2_ring_sizes,
int64_t  poly2_num_rings,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr 
)

Definition at line 1672 of file ExtensionFunctionsGeo.hpp.

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

Referenced by ST_Distance_Polygon_MultiPolygon(), and ST_Intersects_Polygon_Polygon().

1684  {
1685  // Check if poly1 contains the first point of poly2's shape, i.e. the external ring
1686  auto poly2_first_point_coords = poly2_coords;
1687  auto poly2_first_point_coords_size = compression_unit_size(ic2) * 2;
1688  auto min_distance = ST_Distance_Polygon_Point(poly1_coords,
1689  poly1_coords_size,
1690  poly1_ring_sizes,
1691  poly1_num_rings,
1692  poly2_first_point_coords,
1693  poly2_first_point_coords_size,
1694  ic1,
1695  isr1,
1696  ic2,
1697  isr2,
1698  osr);
1699  if (tol_zero(min_distance)) {
1700  // Polygons overlap
1701  return 0.0;
1702  }
1703 
1704  // Poly2's first point is either outside poly1's external ring or inside one of the
1705  // internal rings. Measure the smallest distance between a poly1 ring (external or
1706  // internal) and a poly2 ring (external or internal). If poly2 is completely outside
1707  // poly1, then the min distance would be between poly1's and poly2's external rings. If
1708  // poly2 is completely inside one of poly1 internal rings then the min distance would be
1709  // between that poly1 internal ring and poly2's external ring. If poly1 is completely
1710  // inside one of poly2 internal rings, min distance is between that internal ring and
1711  // poly1's external ring. In each case other rings don't get in the way. Any ring
1712  // intersection means zero distance - short-circuit and return.
1713 
1714  auto poly1_ring_coords = poly1_coords;
1715  for (auto r1 = 0; r1 < poly1_num_rings; r1++) {
1716  int64_t poly1_ring_num_coords = poly1_ring_sizes[r1] * 2;
1717 
1718  auto poly2_ring_coords = poly2_coords;
1719  for (auto r2 = 0; r2 < poly2_num_rings; r2++) {
1720  int64_t poly2_ring_num_coords = poly2_ring_sizes[r2] * 2;
1721 
1722  auto distance = distance_ring_ring(poly1_ring_coords,
1723  poly1_ring_num_coords,
1724  poly2_ring_coords,
1725  poly2_ring_num_coords,
1726  ic1,
1727  isr1,
1728  ic2,
1729  isr2,
1730  osr);
1731  if (min_distance > distance) {
1732  min_distance = distance;
1733  if (tol_zero(min_distance)) {
1734  return 0.0;
1735  }
1736  }
1737 
1738  poly2_ring_coords += poly2_ring_num_coords * compression_unit_size(ic2);
1739  }
1740 
1741  poly1_ring_coords += poly1_ring_num_coords * compression_unit_size(ic1);
1742  }
1743 
1744  return min_distance;
1745 }
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)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(int32_t ic)
DEVICE ALWAYS_INLINE bool tol_zero(double x, double tolerance=TOLERANCE_DEFAULT)
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)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 2679 of file ExtensionFunctionsGeo.hpp.

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

2693  {
2694  auto l2num_coords = l2size / compression_unit_size(ic2);
2695  auto l2num_points = l2num_coords / 2;
2696  if (l2i != 0) {
2697  // Statically indexed linestring
2698  if (l2i < 0 || l2i > l2num_points) {
2699  l2i = l2num_points;
2700  }
2701  auto p2 = l2 + l2i * compression_unit_size(ic2);
2702  auto p2size = 2 * compression_unit_size(ic2);
2704  l1, l1size, l1bounds, l1bounds_size, l1i, p2, p2size, ic1, isr1, ic2, isr2, osr);
2705  }
2706  auto l1num_coords = l1size / compression_unit_size(ic1);
2707  auto l1num_points = l1num_coords / 2;
2708  if (l1i != 0) {
2709  // Statically indexed linestring
2710  if (l1i < 0 || l1i > l1num_points) {
2711  l1i = l1num_points;
2712  }
2713  auto p1 = l1 + l1i * compression_unit_size(ic1);
2714  auto p1size = 2 * compression_unit_size(ic1);
2716  l2, l2size, l2bounds, l2bounds_size, l2i, p1, p1size, ic2, isr2, ic1, isr1, osr);
2717  }
2718 
2719  if (l1bounds && l2bounds) {
2720  if (!box_overlaps_box(l1bounds, l1bounds_size, l2bounds, l2bounds_size)) {
2721  return false;
2722  }
2723  }
2724 
2726  l1, l1size, l1i, l2, l2size, l2i, ic1, isr1, ic2, isr2, osr));
2727 }
DEVICE ALWAYS_INLINE int32_t compression_unit_size(int32_t ic)
EXTENSION_INLINE bool ST_Intersects_LineString_Point(int8_t *l, int64_t lsize, double *lbounds, int64_t lbounds_size, int32_t li, int8_t *p, int64_t psize, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
DEVICE ALWAYS_INLINE bool box_overlaps_box(double *bounds1, int64_t bounds1_size, double *bounds2, int64_t bounds2_size)
DEVICE ALWAYS_INLINE bool tol_zero(double x, double tolerance=TOLERANCE_DEFAULT)
EXTENSION_NOINLINE double ST_Distance_LineString_LineString(int8_t *l1, int64_t l1size, int32_t l1index, int8_t *l2, int64_t l2size, int32_t l2index, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)

+ Here is the call graph for this function:

EXTENSION_NOINLINE bool ST_Intersects_LineString_MultiPolygon ( int8_t *  l,
int64_t  lsize,
double *  lbounds,
int64_t  lbounds_size,
int32_t  li,
int8_t *  mpoly_coords,
int64_t  mpoly_coords_size,
int32_t *  mpoly_ring_sizes,
int64_t  mpoly_num_rings,
int32_t *  mpoly_poly_sizes,
int64_t  mpoly_num_polys,
double *  mpoly_bounds,
int64_t  mpoly_bounds_size,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr 
)

Definition at line 2798 of file ExtensionFunctionsGeo.hpp.

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

Referenced by ST_Intersects_MultiPolygon_LineString().

2815  {
2816  auto lnum_coords = lsize / compression_unit_size(ic1);
2817  auto lnum_points = lnum_coords / 2;
2818  if (li != 0) {
2819  // Statically indexed linestring
2820  if (li < 0 || li > lnum_points) {
2821  li = lnum_points;
2822  }
2823  auto p = l + li * compression_unit_size(ic1);
2824  auto psize = 2 * compression_unit_size(ic1);
2825  return ST_Contains_MultiPolygon_Point(mpoly_coords,
2826  mpoly_coords_size,
2827  mpoly_ring_sizes,
2828  mpoly_num_rings,
2829  mpoly_poly_sizes,
2830  mpoly_num_polys,
2831  mpoly_bounds,
2832  mpoly_bounds_size,
2833  p,
2834  psize,
2835  ic2,
2836  isr2,
2837  ic1,
2838  isr1,
2839  osr);
2840  }
2841 
2842  if (lbounds && mpoly_bounds) {
2843  if (!box_overlaps_box(lbounds, lbounds_size, mpoly_bounds, mpoly_bounds_size)) {
2844  return false;
2845  }
2846  }
2847 
2848  // Check for spatial intersection.
2849  // One way to do that would be to start with linestring's first point, if it's inside
2850  // any of the polygons - it means intersection. Otherwise follow the linestring, segment
2851  // by segment, checking for intersections with polygon shapes/holes, bail as soon as we
2852  // cross into a polygon.
2853 
2854  // Or, alternatively, just measure the distance:
2856  lsize,
2857  li,
2858  mpoly_coords,
2859  mpoly_coords_size,
2860  mpoly_ring_sizes,
2861  mpoly_num_rings,
2862  mpoly_poly_sizes,
2863  mpoly_num_polys,
2864  ic1,
2865  isr1,
2866  ic2,
2867  isr2,
2868  osr));
2869 }
DEVICE ALWAYS_INLINE int32_t compression_unit_size(int32_t ic)
DEVICE ALWAYS_INLINE bool box_overlaps_box(double *bounds1, int64_t bounds1_size, double *bounds2, int64_t bounds2_size)
EXTENSION_NOINLINE double ST_Distance_LineString_MultiPolygon(int8_t *l, int64_t lsize, int32_t lindex, int8_t *mpoly_coords, int64_t mpoly_coords_size, int32_t *mpoly_ring_sizes, int64_t mpoly_num_rings, int32_t *mpoly_poly_sizes, int64_t mpoly_num_polys, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
DEVICE ALWAYS_INLINE bool tol_zero(double x, double tolerance=TOLERANCE_DEFAULT)
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)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 2662 of file ExtensionFunctionsGeo.hpp.

References ST_Intersects_Point_LineString().

Referenced by ST_Intersects_LineString_Linestring().

2673  {
2675  p, psize, l, lsize, lbounds, lbounds_size, li, ic2, isr2, ic1, isr1, osr);
2676 }
EXTENSION_NOINLINE bool ST_Intersects_Point_LineString(int8_t *p, int64_t psize, int8_t *l, int64_t lsize, double *lbounds, int64_t lbounds_size, int32_t li, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_NOINLINE bool ST_Intersects_LineString_Polygon ( int8_t *  l,
int64_t  lsize,
double *  lbounds,
int64_t  lbounds_size,
int32_t  li,
int8_t *  poly,
int64_t  polysize,
int32_t *  poly_ring_sizes,
int64_t  poly_num_rings,
double *  poly_bounds,
int64_t  poly_bounds_size,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr 
)

Definition at line 2730 of file ExtensionFunctionsGeo.hpp.

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

Referenced by ST_Intersects_Polygon_LineString().

2745  {
2746  auto lnum_coords = lsize / compression_unit_size(ic1);
2747  auto lnum_points = lnum_coords / 2;
2748  if (li != 0) {
2749  // Statically indexed linestring
2750  if (li < 0 || li > lnum_points) {
2751  li = lnum_points;
2752  }
2753  auto p = l + li * compression_unit_size(ic1);
2754  auto psize = 2 * compression_unit_size(ic1);
2755  return ST_Contains_Polygon_Point(poly,
2756  polysize,
2757  poly_ring_sizes,
2758  poly_num_rings,
2759  poly_bounds,
2760  poly_bounds_size,
2761  p,
2762  psize,
2763  ic2,
2764  isr2,
2765  ic1,
2766  isr1,
2767  osr);
2768  }
2769 
2770  if (lbounds && poly_bounds) {
2771  if (!box_overlaps_box(lbounds, lbounds_size, poly_bounds, poly_bounds_size)) {
2772  return false;
2773  }
2774  }
2775 
2776  // Check for spatial intersection.
2777  // One way to do that would be to start with linestring's first point, if it's inside
2778  // the polygon - it means intersection. Otherwise follow the linestring, segment by
2779  // segment, checking for intersections with polygon rings, bail as soon as we cross into
2780  // the polygon.
2781 
2782  // Or, alternatively, just measure the distance:
2784  lsize,
2785  li,
2786  poly,
2787  polysize,
2788  poly_ring_sizes,
2789  poly_num_rings,
2790  ic1,
2791  isr1,
2792  ic2,
2793  isr2,
2794  osr));
2795 }
EXTENSION_NOINLINE bool ST_Contains_Polygon_Point(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 *p, int64_t psize, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(int32_t ic)
DEVICE ALWAYS_INLINE bool box_overlaps_box(double *bounds1, int64_t bounds1_size, double *bounds2, int64_t bounds2_size)
DEVICE ALWAYS_INLINE bool tol_zero(double x, double tolerance=TOLERANCE_DEFAULT)
EXTENSION_NOINLINE double ST_Distance_LineString_Polygon(int8_t *l, int64_t lsize, int32_t lindex, int8_t *poly_coords, int64_t poly_coords_size, int32_t *poly_ring_sizes, int64_t poly_num_rings, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_INLINE bool ST_Intersects_MultiPolygon_LineString ( int8_t *  mpoly_coords,
int64_t  mpoly_coords_size,
int32_t *  mpoly_ring_sizes,
int64_t  mpoly_num_rings,
int32_t *  mpoly_poly_sizes,
int64_t  mpoly_num_polys,
double *  mpoly_bounds,
int64_t  mpoly_bounds_size,
int8_t *  l,
int64_t  lsize,
double *  lbounds,
int64_t  lbounds_size,
int32_t  li,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr 
)

Definition at line 3053 of file ExtensionFunctionsGeo.hpp.

References ST_Intersects_LineString_MultiPolygon().

3070  {
3072  lsize,
3073  lbounds,
3074  lbounds_size,
3075  li,
3076  mpoly_coords,
3077  mpoly_coords_size,
3078  mpoly_ring_sizes,
3079  mpoly_num_rings,
3080  mpoly_poly_sizes,
3081  mpoly_num_polys,
3082  mpoly_bounds,
3083  mpoly_bounds_size,
3084  ic2,
3085  isr2,
3086  ic1,
3087  isr1,
3088  osr);
3089 }
EXTENSION_NOINLINE bool ST_Intersects_LineString_MultiPolygon(int8_t *l, int64_t lsize, double *lbounds, int64_t lbounds_size, int32_t li, int8_t *mpoly_coords, int64_t mpoly_coords_size, int32_t *mpoly_ring_sizes, int64_t mpoly_num_rings, int32_t *mpoly_poly_sizes, int64_t mpoly_num_polys, double *mpoly_bounds, int64_t mpoly_bounds_size, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)

+ Here is the call graph for this function:

EXTENSION_INLINE bool ST_Intersects_MultiPolygon_MultiPolygon ( int8_t *  mpoly1_coords,
int64_t  mpoly1_coords_size,
int32_t *  mpoly1_ring_sizes,
int64_t  mpoly1_num_rings,
int32_t *  mpoly1_poly_sizes,
int64_t  mpoly1_num_polys,
double *  mpoly1_bounds,
int64_t  mpoly1_bounds_size,
int8_t *  mpoly2_coords,
int64_t  mpoly2_coords_size,
int32_t *  mpoly2_ring_sizes,
int64_t  mpoly2_num_rings,
int32_t *  mpoly2_poly_sizes,
int64_t  mpoly2_num_polys,
double *  mpoly2_bounds,
int64_t  mpoly2_bounds_size,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr 
)

Definition at line 3133 of file ExtensionFunctionsGeo.hpp.

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

3153  {
3154  if (mpoly1_bounds && mpoly2_bounds) {
3155  if (!box_overlaps_box(
3156  mpoly1_bounds, mpoly1_bounds_size, mpoly2_bounds, mpoly2_bounds_size)) {
3157  return false;
3158  }
3159  }
3160 
3161  return tol_zero(ST_Distance_MultiPolygon_MultiPolygon(mpoly1_coords,
3162  mpoly1_coords_size,
3163  mpoly1_ring_sizes,
3164  mpoly1_num_rings,
3165  mpoly1_poly_sizes,
3166  mpoly1_num_polys,
3167  mpoly2_coords,
3168  mpoly2_coords_size,
3169  mpoly2_ring_sizes,
3170  mpoly2_num_rings,
3171  mpoly2_poly_sizes,
3172  mpoly2_num_polys,
3173  ic1,
3174  isr1,
3175  ic2,
3176  isr2,
3177  osr));
3178 }
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)
DEVICE ALWAYS_INLINE bool box_overlaps_box(double *bounds1, int64_t bounds1_size, double *bounds2, int64_t bounds2_size)
DEVICE ALWAYS_INLINE bool tol_zero(double x, double tolerance=TOLERANCE_DEFAULT)

+ Here is the call graph for this function:

EXTENSION_INLINE bool ST_Intersects_MultiPolygon_Point ( int8_t *  mpoly_coords,
int64_t  mpoly_coords_size,
int32_t *  mpoly_ring_sizes,
int64_t  mpoly_num_rings,
int32_t *  mpoly_poly_sizes,
int64_t  mpoly_num_polys,
double *  mpoly_bounds,
int64_t  mpoly_bounds_size,
int8_t *  p,
int64_t  psize,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr 
)

Definition at line 3020 of file ExtensionFunctionsGeo.hpp.

References ST_Contains_MultiPolygon_Point().

3034  {
3035  return ST_Contains_MultiPolygon_Point(mpoly_coords,
3036  mpoly_coords_size,
3037  mpoly_ring_sizes,
3038  mpoly_num_rings,
3039  mpoly_poly_sizes,
3040  mpoly_num_polys,
3041  mpoly_bounds,
3042  mpoly_bounds_size,
3043  p,
3044  psize,
3045  ic1,
3046  isr1,
3047  ic2,
3048  isr2,
3049  osr);
3050 }
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)

+ Here is the call graph for this function:

EXTENSION_INLINE bool ST_Intersects_MultiPolygon_Polygon ( int8_t *  mpoly_coords,
int64_t  mpoly_coords_size,
int32_t *  mpoly_ring_sizes,
int64_t  mpoly_num_rings,
int32_t *  mpoly_poly_sizes,
int64_t  mpoly_num_polys,
double *  mpoly_bounds,
int64_t  mpoly_bounds_size,
int8_t *  poly_coords,
int64_t  poly_coords_size,
int32_t *  poly_ring_sizes,
int64_t  poly_num_rings,
double *  poly_bounds,
int64_t  poly_bounds_size,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr 
)

Definition at line 3092 of file ExtensionFunctionsGeo.hpp.

References ST_Intersects_Polygon_MultiPolygon().

3110  {
3111  return ST_Intersects_Polygon_MultiPolygon(poly_coords,
3112  poly_coords_size,
3113  poly_ring_sizes,
3114  poly_num_rings,
3115  poly_bounds,
3116  poly_bounds_size,
3117  mpoly_coords,
3118  mpoly_coords_size,
3119  mpoly_ring_sizes,
3120  mpoly_num_rings,
3121  mpoly_poly_sizes,
3122  mpoly_num_polys,
3123  mpoly_bounds,
3124  mpoly_bounds_size,
3125  ic2,
3126  isr2,
3127  ic1,
3128  isr1,
3129  osr);
3130 }
EXTENSION_NOINLINE bool ST_Intersects_Polygon_MultiPolygon(int8_t *poly_coords, int64_t poly_coords_size, int32_t *poly_ring_sizes, int64_t poly_num_rings, double *poly_bounds, int64_t poly_bounds_size, int8_t *mpoly_coords, int64_t mpoly_coords_size, int32_t *mpoly_ring_sizes, int64_t mpoly_num_rings, int32_t *mpoly_poly_sizes, int64_t mpoly_num_polys, double *mpoly_bounds, int64_t mpoly_bounds_size, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)

+ Here is the call graph for this function:

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

Definition at line 2562 of file ExtensionFunctionsGeo.hpp.

References box_contains_point(), compression_unit_size(), coord_x(), coord_y(), ST_Distance_Point_LineString(), ST_Distance_Point_Point(), and tol_zero().

Referenced by ST_Intersects_LineString_Point().

2573  {
2574  double px = coord_x(p, 0, ic1, isr1, osr);
2575  double py = coord_y(p, 1, ic1, isr1, osr);
2576 
2577  auto lnum_coords = lsize / compression_unit_size(ic2);
2578  auto lnum_points = lnum_coords / 2;
2579  if (li != 0) {
2580  // Statically indexed linestring
2581  if (li < 0 || li > lnum_points) {
2582  li = lnum_points;
2583  }
2584  auto p2 = l + li * compression_unit_size(ic2);
2585  auto p2size = 2 * compression_unit_size(ic2);
2586  return tol_zero(
2587  ST_Distance_Point_Point(p2, p2size, p, psize, ic2, isr2, ic1, isr1, osr));
2588  }
2589 
2590  if (lbounds) {
2591  if (!box_contains_point(lbounds, lbounds_size, px, py)) {
2592  return false;
2593  }
2594  }
2595  return tol_zero(
2596  ST_Distance_Point_LineString(p, psize, l, lsize, li, ic1, isr1, ic2, isr2, osr));
2597 }
DEVICE ALWAYS_INLINE double coord_x(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE double coord_y(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
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_LineString(int8_t *p, int64_t psize, int8_t *l, int64_t lsize, int32_t lindex, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(int32_t ic)
DEVICE ALWAYS_INLINE bool box_contains_point(double *bounds, int64_t bounds_size, double px, double py)
DEVICE ALWAYS_INLINE bool tol_zero(double x, double tolerance=TOLERANCE_DEFAULT)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_INLINE bool ST_Intersects_Point_MultiPolygon ( int8_t *  p,
int64_t  psize,
int8_t *  mpoly_coords,
int64_t  mpoly_coords_size,
int32_t *  mpoly_ring_sizes,
int64_t  mpoly_num_rings,
int32_t *  mpoly_poly_sizes,
int64_t  mpoly_num_polys,
double *  mpoly_bounds,
int64_t  mpoly_bounds_size,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr 
)

Definition at line 2629 of file ExtensionFunctionsGeo.hpp.

References ST_Contains_MultiPolygon_Point().

2643  {
2644  return ST_Contains_MultiPolygon_Point(mpoly_coords,
2645  mpoly_coords_size,
2646  mpoly_ring_sizes,
2647  mpoly_num_rings,
2648  mpoly_poly_sizes,
2649  mpoly_num_polys,
2650  mpoly_bounds,
2651  mpoly_bounds_size,
2652  p,
2653  psize,
2654  ic2,
2655  isr2,
2656  ic1,
2657  isr1,
2658  osr);
2659 }
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)

+ Here is the call graph for this function:

EXTENSION_INLINE bool ST_Intersects_Point_Point ( int8_t *  p1,
int64_t  p1size,
int8_t *  p2,
int64_t  p2size,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr 
)

Definition at line 2548 of file ExtensionFunctionsGeo.hpp.

References ST_Distance_Point_Point(), and tol_zero().

2556  {
2557  return tol_zero(
2558  ST_Distance_Point_Point(p1, p1size, p2, p2size, ic1, isr1, ic2, isr2, osr));
2559 }
EXTENSION_NOINLINE double ST_Distance_Point_Point(int8_t *p1, int64_t p1size, int8_t *p2, int64_t p2size, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)
DEVICE ALWAYS_INLINE bool tol_zero(double x, double tolerance=TOLERANCE_DEFAULT)

+ Here is the call graph for this function:

EXTENSION_INLINE bool ST_Intersects_Point_Polygon ( int8_t *  p,
int64_t  psize,
int8_t *  poly,
int64_t  polysize,
int32_t *  poly_ring_sizes,
int64_t  poly_num_rings,
double *  poly_bounds,
int64_t  poly_bounds_size,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr 
)

Definition at line 2600 of file ExtensionFunctionsGeo.hpp.

References ST_Contains_Polygon_Point().

2612  {
2613  return ST_Contains_Polygon_Point(poly,
2614  polysize,
2615  poly_ring_sizes,
2616  poly_num_rings,
2617  poly_bounds,
2618  poly_bounds_size,
2619  p,
2620  psize,
2621  ic2,
2622  isr2,
2623  ic1,
2624  isr1,
2625  osr);
2626 }
EXTENSION_NOINLINE bool ST_Contains_Polygon_Point(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 *p, int64_t psize, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)

+ Here is the call graph for this function:

EXTENSION_INLINE bool ST_Intersects_Polygon_LineString ( int8_t *  poly,
int64_t  polysize,
int32_t *  poly_ring_sizes,
int64_t  poly_num_rings,
double *  poly_bounds,
int64_t  poly_bounds_size,
int8_t *  l,
int64_t  lsize,
double *  lbounds,
int64_t  lbounds_size,
int32_t  li,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr 
)

Definition at line 2901 of file ExtensionFunctionsGeo.hpp.

References ST_Intersects_LineString_Polygon().

2916  {
2918  lsize,
2919  lbounds,
2920  lbounds_size,
2921  li,
2922  poly,
2923  polysize,
2924  poly_ring_sizes,
2925  poly_num_rings,
2926  poly_bounds,
2927  poly_bounds_size,
2928  ic2,
2929  isr2,
2930  ic1,
2931  isr1,
2932  osr);
2933 }
EXTENSION_NOINLINE bool ST_Intersects_LineString_Polygon(int8_t *l, int64_t lsize, double *lbounds, int64_t lbounds_size, int32_t li, int8_t *poly, int64_t polysize, int32_t *poly_ring_sizes, int64_t poly_num_rings, double *poly_bounds, int64_t poly_bounds_size, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)

+ Here is the call graph for this function:

EXTENSION_NOINLINE bool ST_Intersects_Polygon_MultiPolygon ( int8_t *  poly_coords,
int64_t  poly_coords_size,
int32_t *  poly_ring_sizes,
int64_t  poly_num_rings,
double *  poly_bounds,
int64_t  poly_bounds_size,
int8_t *  mpoly_coords,
int64_t  mpoly_coords_size,
int32_t *  mpoly_ring_sizes,
int64_t  mpoly_num_rings,
int32_t *  mpoly_poly_sizes,
int64_t  mpoly_num_polys,
double *  mpoly_bounds,
int64_t  mpoly_bounds_size,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr 
)

Definition at line 2976 of file ExtensionFunctionsGeo.hpp.

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

Referenced by ST_Intersects_MultiPolygon_Polygon().

2994  {
2995  if (poly_bounds && mpoly_bounds) {
2996  if (!box_overlaps_box(
2997  poly_bounds, poly_bounds_size, mpoly_bounds, mpoly_bounds_size)) {
2998  return false;
2999  }
3000  }
3001 
3002  return tol_zero(ST_Distance_Polygon_MultiPolygon(poly_coords,
3003  poly_coords_size,
3004  poly_ring_sizes,
3005  poly_num_rings,
3006  mpoly_coords,
3007  mpoly_coords_size,
3008  mpoly_ring_sizes,
3009  mpoly_num_rings,
3010  mpoly_poly_sizes,
3011  mpoly_num_polys,
3012  ic1,
3013  isr1,
3014  ic2,
3015  isr2,
3016  osr));
3017 }
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)
DEVICE ALWAYS_INLINE bool box_overlaps_box(double *bounds1, int64_t bounds1_size, double *bounds2, int64_t bounds2_size)
DEVICE ALWAYS_INLINE bool tol_zero(double x, double tolerance=TOLERANCE_DEFAULT)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_INLINE bool ST_Intersects_Polygon_Point ( int8_t *  poly,
int64_t  polysize,
int32_t *  poly_ring_sizes,
int64_t  poly_num_rings,
double *  poly_bounds,
int64_t  poly_bounds_size,
int8_t *  p,
int64_t  psize,
int32_t  ic1,
int32_t  isr1,
int32_t  ic2,
int32_t  isr2,
int32_t  osr 
)

Definition at line 2872 of file ExtensionFunctionsGeo.hpp.

References ST_Contains_Polygon_Point().

2884  {
2885  return ST_Contains_Polygon_Point(poly,
2886  polysize,
2887  poly_ring_sizes,
2888  poly_num_rings,
2889  poly_bounds,
2890  poly_bounds_size,
2891  p,
2892  psize,
2893  ic1,
2894  isr1,
2895  ic2,
2896  isr2,
2897  osr);
2898 }
EXTENSION_NOINLINE bool ST_Contains_Polygon_Point(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 *p, int64_t psize, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr)

+ Here is the call graph for this function:

EXTENSION_NOINLINE bool ST_Intersects_Polygon_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 2936 of file ExtensionFunctionsGeo.hpp.

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

2952  {
2953  if (poly1_bounds && poly2_bounds) {
2954  if (!box_overlaps_box(
2955  poly1_bounds, poly1_bounds_size, poly2_bounds, poly2_bounds_size)) {
2956  return false;
2957  }
2958  }
2959 
2960  return tol_zero(ST_Distance_Polygon_Polygon(poly1_coords,
2961  poly1_coords_size,
2962  poly1_ring_sizes,
2963  poly1_num_rings,
2964  poly2_coords,
2965  poly2_coords_size,
2966  poly2_ring_sizes,
2967  poly2_num_rings,
2968  ic1,
2969  isr1,
2970  ic2,
2971  isr2,
2972  osr));
2973 }
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)
DEVICE ALWAYS_INLINE bool box_overlaps_box(double *bounds1, int64_t bounds1_size, double *bounds2, int64_t bounds2_size)
DEVICE ALWAYS_INLINE bool tol_zero(double x, double tolerance=TOLERANCE_DEFAULT)

+ Here is the call graph for this function:

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

Definition at line 761 of file ExtensionFunctionsGeo.hpp.

References length_linestring().

765  {
766  return length_linestring(coords, coords_sz, ic, isr, osr, false, false);
767 }
DEVICE ALWAYS_INLINE double length_linestring(int8_t *l, int64_t lsize, int32_t ic, int32_t isr, int32_t osr, bool geodesic, bool check_closed)

+ Here is the call graph for this function:

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

Definition at line 770 of file ExtensionFunctionsGeo.hpp.

References length_linestring().

774  {
775  return length_linestring(coords, coords_sz, ic, isr, osr, true, false);
776 }
DEVICE ALWAYS_INLINE double length_linestring(int8_t *l, int64_t lsize, int32_t ic, int32_t isr, int32_t osr, bool geodesic, bool check_closed)

+ Here is the call graph for this function:

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

Definition at line 2050 of file ExtensionFunctionsGeo.hpp.

References max_distance_point_linestring().

2059  {
2061  p, psize, l, lsize, lindex, ic2, isr2, ic1, isr1, osr, false);
2062 }
DEVICE ALWAYS_INLINE double max_distance_point_linestring(int8_t *p, int64_t psize, int8_t *l, int64_t lsize, int32_t lindex, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, bool check_closed)

+ Here is the call graph for this function:

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

Definition at line 2035 of file ExtensionFunctionsGeo.hpp.

References max_distance_point_linestring().

2044  {
2046  p, psize, l, lsize, lindex, ic1, isr1, ic2, isr2, osr, false);
2047 }
DEVICE ALWAYS_INLINE double max_distance_point_linestring(int8_t *p, int64_t psize, int8_t *l, int64_t lsize, int32_t lindex, int32_t ic1, int32_t isr1, int32_t ic2, int32_t isr2, int32_t osr, bool check_closed)

+ Here is the call graph for this function:

EXTENSION_INLINE int32_t ST_NPoints ( int8_t *  coords,
int64_t  coords_sz,
int32_t  ic 
)

Definition at line 1054 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size().

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

1054  {
1055  auto num_pts = coords_sz / compression_unit_size(ic);
1056  return static_cast<int32_t>(num_pts / 2);
1057 }
DEVICE ALWAYS_INLINE int32_t compression_unit_size(int32_t ic)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_INLINE int32_t ST_NRings ( int32_t *  poly_ring_sizes,
int64_t  poly_num_rings 
)

Definition at line 1060 of file ExtensionFunctionsGeo.hpp.

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

1060  {
1061  return static_cast<int32_t>(poly_num_rings);
1062 }

+ Here is the caller graph for this function:

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

Definition at line 861 of file ExtensionFunctionsGeo.hpp.

References perimeter_multipolygon().

869  {
870  return perimeter_multipolygon(mpoly_coords,
871  mpoly_coords_size,
872  mpoly_ring_sizes,
873  mpoly_num_rings,
874  mpoly_poly_sizes,
875  mpoly_num_polys,
876  ic,
877  isr,
878  osr,
879  false);
880 }
DEVICE ALWAYS_INLINE double perimeter_multipolygon(int8_t *mpoly_coords, int64_t mpoly_coords_size, int32_t *mpoly_ring_sizes, int64_t mpoly_num_rings, int32_t *mpoly_poly_sizes, int64_t mpoly_num_polys, int32_t ic, int32_t isr, int32_t osr, bool geodesic)

+ Here is the call graph for this function:

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

Definition at line 883 of file ExtensionFunctionsGeo.hpp.

References perimeter_multipolygon().

891  {
892  return perimeter_multipolygon(mpoly_coords,
893  mpoly_coords_size,
894  mpoly_ring_sizes,
895  mpoly_num_rings,
896  mpoly_poly_sizes,
897  mpoly_num_polys,
898  ic,
899  isr,
900  osr,
901  true);
902 }
DEVICE ALWAYS_INLINE double perimeter_multipolygon(int8_t *mpoly_coords, int64_t mpoly_coords_size, int32_t *mpoly_ring_sizes, int64_t mpoly_num_rings, int32_t *mpoly_poly_sizes, int64_t mpoly_num_polys, int32_t ic, int32_t isr, int32_t osr, bool geodesic)

+ Here is the call graph for this function:

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

Definition at line 783 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size(), and length_linestring().

789  {
790  if (poly_num_rings <= 0) {
791  return 0.0;
792  }
793 
794  auto exterior_ring_num_coords = poly_ring_sizes[0] * 2;
795  auto exterior_ring_coords_size = exterior_ring_num_coords * compression_unit_size(ic);
796 
797  return length_linestring(poly, exterior_ring_coords_size, ic, isr, osr, false, true);
798 }
DEVICE ALWAYS_INLINE double length_linestring(int8_t *l, int64_t lsize, int32_t ic, int32_t isr, int32_t osr, bool geodesic, bool check_closed)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(int32_t ic)

+ Here is the call graph for this function:

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

Definition at line 801 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size(), and length_linestring().

807  {
808  if (poly_num_rings <= 0) {
809  return 0.0;
810  }
811 
812  auto exterior_ring_num_coords = poly_ring_sizes[0] * 2;
813  auto exterior_ring_coords_size = exterior_ring_num_coords * compression_unit_size(ic);
814 
815  return length_linestring(poly, exterior_ring_coords_size, ic, isr, osr, true, true);
816 }
DEVICE ALWAYS_INLINE double length_linestring(int8_t *l, int64_t lsize, int32_t ic, int32_t isr, int32_t osr, bool geodesic, bool check_closed)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(int32_t ic)

+ Here is the call graph for this function:

EXTENSION_NOINLINE double ST_X_LineString ( int8_t *  l,
int64_t  lsize,
int32_t  lindex,
int32_t  ic,
int32_t  isr,
int32_t  osr 
)

Definition at line 625 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size(), and coord_x().

630  {
631  auto l_num_points = lsize / (2 * compression_unit_size(ic));
632  if (lindex < 0 || lindex > l_num_points) {
633  lindex = l_num_points; // Endpoint
634  }
635  return coord_x(l, 2 * (lindex - 1), ic, isr, osr);
636 }
DEVICE ALWAYS_INLINE double coord_x(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(int32_t ic)

+ Here is the call graph for this function:

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

Definition at line 615 of file ExtensionFunctionsGeo.hpp.

References coord_x().

615  {
616  return coord_x(p, 0, ic, isr, osr);
617 }
DEVICE ALWAYS_INLINE double coord_x(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)

+ Here is the call graph for this function:

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

Definition at line 679 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size(), and coord_x().

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

679  {
680  auto num_coords = size / compression_unit_size(ic);
681  double xmax = 0.0;
682  for (int32_t i = 0; i < num_coords; i += 2) {
683  double x = coord_x(coords, i, ic, isr, osr);
684  if (i == 0 || x > xmax) {
685  xmax = x;
686  }
687  }
688  return xmax;
689 }
DEVICE ALWAYS_INLINE double coord_x(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(int32_t ic)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 715 of file ExtensionFunctionsGeo.hpp.

References transform_coord().

715  {
716  return transform_coord(bounds[2], isr, osr, true);
717 }
DEVICE ALWAYS_INLINE double transform_coord(double coord, int32_t isr, int32_t osr, bool x)

+ Here is the call graph for this function:

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

Definition at line 653 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size(), and coord_x().

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

653  {
654  auto num_coords = size / compression_unit_size(ic);
655  double xmin = 0.0;
656  for (int32_t i = 0; i < num_coords; i += 2) {
657  double x = coord_x(coords, i, ic, isr, osr);
658  if (i == 0 || x < xmin) {
659  xmin = x;
660  }
661  }
662  return xmin;
663 }
DEVICE ALWAYS_INLINE double coord_x(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(int32_t ic)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 705 of file ExtensionFunctionsGeo.hpp.

References transform_coord().

705  {
706  return transform_coord(bounds[0], isr, osr, true);
707 }
DEVICE ALWAYS_INLINE double transform_coord(double coord, int32_t isr, int32_t osr, bool x)

+ Here is the call graph for this function:

EXTENSION_NOINLINE double ST_Y_LineString ( int8_t *  l,
int64_t  lsize,
int32_t  lindex,
int32_t  ic,
int32_t  isr,
int32_t  osr 
)

Definition at line 639 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size(), and coord_y().

644  {
645  auto l_num_points = lsize / (2 * compression_unit_size(ic));
646  if (lindex < 0 || lindex > l_num_points) {
647  lindex = l_num_points; // Endpoint
648  }
649  return coord_y(l, 2 * (lindex - 1) + 1, ic, isr, osr);
650 }
DEVICE ALWAYS_INLINE double coord_y(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(int32_t ic)

+ Here is the call graph for this function:

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

Definition at line 620 of file ExtensionFunctionsGeo.hpp.

References coord_y().

620  {
621  return coord_y(p, 1, ic, isr, osr);
622 }
DEVICE ALWAYS_INLINE double coord_y(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)

+ Here is the call graph for this function:

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

Definition at line 692 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size(), and coord_y().

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

692  {
693  auto num_coords = size / compression_unit_size(ic);
694  double ymax = 0.0;
695  for (int32_t i = 1; i < num_coords; i += 2) {
696  double y = coord_y(coords, i, ic, isr, osr);
697  if (i == 1 || y > ymax) {
698  ymax = y;
699  }
700  }
701  return ymax;
702 }
DEVICE ALWAYS_INLINE double coord_y(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(int32_t ic)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 720 of file ExtensionFunctionsGeo.hpp.

References transform_coord().

720  {
721  return transform_coord(bounds[3], isr, osr, false);
722 }
DEVICE ALWAYS_INLINE double transform_coord(double coord, int32_t isr, int32_t osr, bool x)

+ Here is the call graph for this function:

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

Definition at line 666 of file ExtensionFunctionsGeo.hpp.

References compression_unit_size(), and coord_y().

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

666  {
667  auto num_coords = size / compression_unit_size(ic);
668  double ymin = 0.0;
669  for (int32_t i = 1; i < num_coords; i += 2) {
670  double y = coord_y(coords, i, ic, isr, osr);
671  if (i == 1 || y < ymin) {
672  ymin = y;
673  }
674  }
675  return ymin;
676 }
DEVICE ALWAYS_INLINE double coord_y(int8_t *data, int32_t index, int32_t ic, int32_t isr, int32_t osr)
DEVICE ALWAYS_INLINE int32_t compression_unit_size(int32_t ic)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 710 of file ExtensionFunctionsGeo.hpp.

References transform_coord().

710  {
711  return transform_coord(bounds[1], isr, osr, false);
712 }
DEVICE ALWAYS_INLINE double transform_coord(double coord, int32_t isr, int32_t osr, bool x)

+ Here is the call graph for this function:

DEVICE ALWAYS_INLINE double tol ( int32_t  ic)

Definition at line 8 of file ExtensionFunctionsGeo.hpp.

References COMPRESSION_GEOINT32, TOLERANCE_DEFAULT, and TOLERANCE_GEOINT32.

Referenced by ST_Contains_Point_Point(), and tol().

8  {
9  if (ic == COMPRESSION_GEOINT32) {
10  return TOLERANCE_GEOINT32;
11  }
12  return TOLERANCE_DEFAULT;
13 }
#define TOLERANCE_GEOINT32
#define TOLERANCE_DEFAULT
#define COMPRESSION_GEOINT32

+ Here is the caller graph for this function:

DEVICE ALWAYS_INLINE double tol ( int32_t  ic1,
int32_t  ic2 
)

Definition at line 16 of file ExtensionFunctionsGeo.hpp.

References tol().

16  {
17  return fmax(tol(ic1), tol(ic2));
18 }
DEVICE ALWAYS_INLINE double tol(int32_t ic)

+ Here is the call graph for this function:

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

Definition at line 24 of file ExtensionFunctionsGeo.hpp.

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

26  {
27  auto diff = x - y;
28  return (-tolerance <= diff) && (diff <= tolerance);
29 }

+ Here is the caller graph for this function:

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

Definition at line 37 of file ExtensionFunctionsGeo.hpp.

Referenced by box_contains_point(), and on_segment().

39  {
40  return (x + tolerance) >= y;
41 }

+ Here is the caller graph for this function:

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

Definition at line 31 of file ExtensionFunctionsGeo.hpp.

Referenced by box_contains_point(), and on_segment().

33  {
34  return x <= (y + tolerance);
35 }

+ Here is the caller graph for this function:

DEVICE ALWAYS_INLINE double transform_coord ( double  coord,
int32_t  isr,
int32_t  osr,
bool  x 
)

Definition at line 67 of file ExtensionFunctionsGeo.hpp.

References conv_4326_900913_x(), and conv_4326_900913_y().

Referenced by convert_meters_to_pixel_height(), convert_meters_to_pixel_width(), coord_x(), coord_y(), ST_XMax_Bounds(), ST_XMin_Bounds(), ST_YMax_Bounds(), and ST_YMin_Bounds().

70  {
71  if (isr == 4326) {
72  if (osr == 900913) {
73  // WGS 84 --> Web Mercator
74  if (x) {
75  return conv_4326_900913_x(coord);
76  } else {
77  return conv_4326_900913_y(coord);
78  }
79  }
80  }
81  return coord;
82 }
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:

+ Here is the caller graph for this function: