opensearch-project / opensearch-spark

Spark Accelerator framework ; It enables secondary indices to remote data stores.
Apache License 2.0
23 stars 33 forks source link

[FEATURE]PPL/SQL Geo Functionality Support #880

Open YANG-DB opened 2 weeks ago

YANG-DB commented 2 weeks ago

Is your feature request related to a problem? We would like to add advanced geo-spatial commands support.

Context

Here’s a list of common SQL/PPL geo-spatial commands, often used in databases like PostGIS, Oracle Spatial, and other geospatial extensions for SQL-compliant systems.

These can be implemented or adapted in PPL / SQL (under the Spark Engine) for spatial analysis tasks.

Geospatial Functions for Geometry Operations

Distance: Computes the distance between two geometries (e.g., points, polygons).

Distance(geomA, geomB)

Intersects: Determines if two geometries intersect.

Intersects(geomA, geomB)

Contains: Checks if one geometry contains another.

Contains(geomA, geomB)

Within: Determines if one geometry is within another.

Within(geomA, geomB)

Overlaps: Checks if two geometries overlap.

Overlaps(geomA, geomB)

Crosses: Tests if one geometry crosses another.

Crosses(geomA, geomB)

Geospatial Transformation Functions

Transform: Transforms a geometry to a different spatial reference system (SRID).

Transform(geometry, targetSRID)

Buffer: Creates a buffer area around a geometry at a specified distance.

Buffer(geometry, distance)

Centroid: Calculates the centroid (center point) of a geometry.

Centroid(geometry)

Union: Merges multiple geometries into one.

Union(geomA, geomB)

Difference: Computes the difference between two geometries.

Difference(geomA, geomB)

Simplify: Reduces the complexity of a geometry, keeping its shape intact within a specified tolerance.

Simplify(geometry, tolerance)

Geometry Creation and Manipulation

Point: Creates a point geometry from given X and Y coordinates.

Point(x, y)

LineString: Creates a line geometry from an array of points.

LineString([point1, point2, ...])

Polygon: Forms a polygon geometry from boundary coordinates.

Polygon(boundary)

MakeEnvelope: Creates a rectangular polygon based on corner coordinates.

MakeEnvelope(xMin, yMin, xMax, yMax, SRID)

Spatial Index and Aggregate Functions

GeomFromText: Converts Well-Known Text (WKT) representation to a geometry.

GeomFromText('POINT(1 1)')

AsText: Converts a geometry to its WKT representation.

AsText(geometry)

Area: Computes the area of a polygonal geometry.

Area(geometry)

Length: Calculates the length of a linear geometry.

Length(geometry)

Collect: Aggregates multiple geometries into a single multi-geometry.

Collect(geometry_set)


geometry refers to spatial data types used to represent shapes, locations, and spatial relationships. This typically includes various geometric objects such as:

These commands cover a broad range of spatial operations used for queries, analysis, and transformations in SQL environments

Do you have any additional context?

dblock commented 8 hours ago

[Catch All Triage - 1, 2, 3, 4, 5]