jiayuasu opened a new pull request, #2668:
URL: https://github.com/apache/sedona/pull/2668

   ## Did you read the Contributor Guide?
   
   - Yes, I have read the [Contributor 
Rules](https://sedona.apache.org/latest/community/rule/) and [Contributor 
Developer Guide](https://sedona.apache.org/latest/community/develop/)
   
   ## Is this PR related to a ticket?
   
   - Yes, and the PR name follows the format `[GH-XXX] my subject`. Closes #1327
   
   ## What changes were proposed in this PR?
   
   Adds 9 Bing Tile functions for working with Bing Maps tile coordinates. The 
functions convert between geographic coordinates and Bing tile quad-keys, and 
support spatial queries over tile grids.
   
   ### New Functions
   
   | Function | Description |
   |---|---|
   | `ST_BingTile(tileX, tileY, zoomLevel)` | Create a Bing tile quad-key from 
tile XY coordinates and zoom level |
   | `ST_BingTileAt(longitude, latitude, zoomLevel)` | Return the quad-key of 
the tile covering a lon/lat point at a given zoom |
   | `ST_BingTilesAround(longitude, latitude, zoomLevel)` | Return the 9 
quad-keys surrounding (and including) a point |
   | `ST_BingTileZoomLevel(quadKey)` | Extract the zoom level from a quad-key |
   | `ST_BingTileX(quadKey)` | Extract the tile X coordinate from a quad-key |
   | `ST_BingTileY(quadKey)` | Extract the tile Y coordinate from a quad-key |
   | `ST_BingTilePolygon(quadKey)` | Return the bounding-box polygon of a tile 
as a Geometry |
   | `ST_BingTileCellIDs(geometry, zoomLevel)` | Return all quad-keys whose 
tiles are covered by a geometry |
   | `ST_BingTileToGeom(quadKeys)` | Return a GeometryCollection built from the 
polygons of a quad-key array |
   
   ### Design Decisions
   
   - **Quad-key string representation**: Tiles are identified by quad-key 
strings (e.g., `"123"`) rather than a custom BingTile type, for compatibility 
with all Sedona engines.
   - **Longitude-first parameter order**: `ST_BingTileAt` and 
`ST_BingTilesAround` take `(longitude, latitude, zoomLevel)`, consistent with 
Sedona's existing `ST_Point(x, y)` convention.
   - **Optimized covering algorithm**: `ST_BingTileCellIDs` uses brute-force 
enumeration for zoom < 10 and recursive quadtree subdivision from zoom 10 for 
higher zoom levels, balancing simplicity and performance.
   
   ### Modules Changed
   
   - **common**: Core implementation in `BingTile.java` utility class; public 
API in `Functions.java`
   - **spark**: Expression classes (`Functions.scala`), DataFrame API 
(`st_functions.scala`), UDF catalog (`Catalog.scala`)
   - **flink**: Catalog and expression registration
   - **snowflake**: UDFs.java (WKB binary I/O) and UDFsV2.java (GeoJSON String 
I/O)
   - **python**: PySpark bindings in `st_functions.py`
   - **docs**: API reference for Spark, Flink, and Snowflake
   
   ## How was this patch tested?
   
   Tests across all engines, using reference values from Trino's 
`TestBingTileFunctions`:
   
   - **common**: 31 unit tests in `FunctionsTest.java` covering all functions, 
edge cases (antimeridian, poles, max zoom), and error cases
   - **spark SQL**: 23 tests in `STBingTileFunctions.scala`
   - **spark DataFrame API**: 16 tests in `dataFrameAPITestScala.scala`
   - **flink**: 9 tests in `FunctionTest.java`
   - **snowflake**: 9 tests each in `TestFunctions.java` (V1) and 
`TestFunctionsV2.java` (V2)
   
   ```
   mvn test -pl common 
-Dtest="org.apache.sedona.common.FunctionsTest#testBingTile*" 
-DfailIfNoTests=false
   mvn test -pl spark/common 
-Dsuites=org.apache.sedona.sql.functions.STBingTileFunctions 
-DfailIfNoTests=false
   ```
   
   ## Did this PR include necessary documentation updates?
   
   - Yes, API documentation has been added to Spark, Flink, and Snowflake 
Function.md pages.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to