Copilot commented on code in PR #2668:
URL: https://github.com/apache/sedona/pull/2668#discussion_r2836065297


##########
common/src/main/java/org/apache/sedona/common/Functions.java:
##########
@@ -1815,6 +1815,128 @@ public static Geometry[] h3ToGeom(long[] cells) {
     return polygons.toArray(new Polygon[0]);
   }
 
+  // =========================================================================
+  // Bing Tile functions
+  // =========================================================================
+
+  /**
+   * Creates a Bing tile quadkey from tile XY coordinates and zoom level.
+   *
+   * @param tileX the tile X coordinate
+   * @param tileY the tile Y coordinate
+   * @param zoomLevel the zoom level (1 to 23)
+   * @return the quadkey string
+   */
+  public static String bingTile(int tileX, int tileY, int zoomLevel) {
+    return BingTile.fromCoordinates(tileX, tileY, zoomLevel).toQuadKey();
+  }
+
+  /**
+   * Returns the Bing tile quadkey at a given zoom level containing the 
specified point.
+   *
+   * @param longitude the longitude (-180 to 180)
+   * @param latitude the latitude (-85.05112878 to 85.05112878)
+   * @param zoomLevel the zoom level (1 to 23)
+   * @return the quadkey string
+   */
+  public static String bingTileAt(double longitude, double latitude, int 
zoomLevel) {
+    return BingTile.fromLatLon(latitude, longitude, zoomLevel).toQuadKey();
+  }
+
+  /**
+   * Returns the 3x3 neighborhood of Bing tiles around the tile containing the 
specified point.
+   *
+   * @param longitude the longitude
+   * @param latitude the latitude
+   * @param zoomLevel the zoom level (1 to 23)
+   * @return array of quadkey strings
+   */
+  public static String[] bingTilesAround(double longitude, double latitude, 
int zoomLevel) {
+    List<BingTile> tiles = BingTile.tilesAround(latitude, longitude, 
zoomLevel);
+    return tiles.stream().map(BingTile::toQuadKey).toArray(String[]::new);
+  }
+
+  /**
+   * Returns the zoom level of a Bing tile quadkey.
+   *
+   * @param quadKey the quadkey string
+   * @return the zoom level
+   */
+  public static int bingTileZoomLevel(String quadKey) {
+    // Validate the quadkey by parsing it
+    BingTile.fromQuadKey(quadKey);
+    return quadKey.length();
+  }
+
+  /**
+   * Returns the X coordinate of a Bing tile from its quadkey.
+   *
+   * @param quadKey the quadkey string
+   * @return the tile X coordinate
+   */
+  public static int bingTileX(String quadKey) {
+    return BingTile.fromQuadKey(quadKey).getX();
+  }
+
+  /**
+   * Returns the Y coordinate of a Bing tile from its quadkey.
+   *
+   * @param quadKey the quadkey string
+   * @return the tile Y coordinate
+   */
+  public static int bingTileY(String quadKey) {
+    return BingTile.fromQuadKey(quadKey).getY();
+  }
+
+  /**
+   * Returns the polygon representation of a Bing tile given its quadkey.
+   *
+   * @param quadKey the quadkey string
+   * @return the tile polygon
+   */
+  public static Geometry bingTilePolygon(String quadKey) {
+    return BingTile.fromQuadKey(quadKey).toPolygon();
+  }
+
+  /**
+   * Returns the quadkey of the Bing tile containing the specified point. 
(Alias for bingTileAt
+   * returning string directly.)
+   *
+   * @param quadKey the quadkey string
+   * @return the quadkey string (identity, but validates the input)

Review Comment:
   The JavaDoc comment describes this function incorrectly. It says "Returns 
the quadkey of the Bing tile containing the specified point" but this function 
actually validates and normalizes a quadkey string (it takes a quadkey as input 
and returns the same quadkey after validation). The parameter name and return 
value indicate this is an identity function for validation purposes, not a 
function that finds a tile containing a point.
   ```suggestion
      * Validates and normalizes a Bing tile quadkey string.
      *
      * <p>The input quadkey is parsed into a {@code BingTile} for validation, 
and the
      * corresponding (possibly normalized) quadkey string is returned. Invalid 
quadkeys
      * will cause {@code BingTile.fromQuadKey} to throw an exception.
      *
      * @param quadKey the quadkey string to validate and normalize
      * @return the validated and normalized quadkey string
   ```



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