You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sedona.apache.org by "zongsizhang (via GitHub)" <gi...@apache.org> on 2023/02/13 12:22:44 UTC

[GitHub] [sedona] zongsizhang commented on a diff in pull request #764: [WIP] [SEDONA-235] Integrate S2, add ST_S2CellIDs

zongsizhang commented on code in PR #764:
URL: https://github.com/apache/sedona/pull/764#discussion_r1104396437


##########
common/src/main/java/org/apache/sedona/common/Functions.java:
##########
@@ -543,4 +542,25 @@ public static Geometry split(Geometry input, Geometry blade) {
         // check input geometry
         return new GeometrySplitter(GEOMETRY_FACTORY).split(input, blade);
     }
+
+
+    /**
+     * get the coordinates of a geometry and transform to Google s2 cell id
+     * @param input Geometry
+     * @param level integer, minimum level of cells covering the geometry
+     * @return List of coordinates
+     */
+    public static Long[] s2CellIDs(Geometry input, int level) {
+        HashSet<S2CellId> cellIds = new HashSet<>();
+        List<Geometry> geoms = GeomUtils.extractGeometryCollection(input);
+        for (Geometry geom : geoms) {
+            try {
+                cellIds.addAll(S2Utils.s2RegionToCellIDs(S2Utils.toS2Region(geom), 1, level, Integer.MAX_VALUE - 1));

Review Comment:
   they are all supported already. MultiPoint, MultiPolygon, MultiLineString are GeometryCollection, after extraction they become points, polygons and linestrings.



-- 
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: dev-unsubscribe@sedona.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org