You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@sedona.apache.org by "ZhuochengShang (via GitHub)" <gi...@apache.org> on 2025/08/12 03:21:26 UTC

[PR] [GH-]add new constructor ST_GeogFromGeoHash [sedona]

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

   ## What changes were proposed in this PR?
   add new constructor ST_GeogFromGeoHash
   


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

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


Re: [PR] [GH-2272]add new constructor ST_GeogFromGeoHash [sedona]

Posted by "jiayuasu (via GitHub)" <gi...@apache.org>.
jiayuasu commented on code in PR #2271:
URL: https://github.com/apache/sedona/pull/2271#discussion_r2277446528


##########
docs/api/sql/geography/Constructor.md:
##########
@@ -61,6 +61,28 @@ Output:
 SRID: 4326; LINESTRING (-2.1 -0.4, -1.5 -0.7)
 ```
 
+## ST_GeomFromGeoHash

Review Comment:
   ```suggestion
   ## ST_GeogFromGeoHash
   ```



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

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


Re: [PR] [GH-2272]add new constructor ST_GeogFromGeoHash [sedona]

Posted by "jiayuasu (via GitHub)" <gi...@apache.org>.
jiayuasu commented on code in PR #2271:
URL: https://github.com/apache/sedona/pull/2271#discussion_r2271539488


##########
spark/common/src/test/scala/org/apache/sedona/sql/geography/ConstructorsTest.scala:
##########
@@ -19,14 +19,35 @@
 package org.apache.sedona.sql.geography
 
 import org.apache.sedona.common.S2Geography.Geography
+import org.apache.sedona.common.geography.Constructors
 import org.apache.sedona.sql.TestBaseScala
+import org.junit.Assert.assertEquals
 import org.locationtech.jts.geom.PrecisionModel
 
 class ConstructorsTest extends TestBaseScala {
 
   import sparkSession.implicits._
   val precisionModel: PrecisionModel = new PrecisionModel(PrecisionModel.FIXED);
 
+  it("Passed ST_GeogFromGeoHash") {
+    var geohash = "9q9j8ue2v71y5zzy0s4q";
+    var precision = 16;
+    var row =
+      sparkSession.sql(s"SELECT ST_GeogFromGeoHash('$geohash','$precision') AS geog").first()
+    var geoStr = row.get(0).asInstanceOf[Geography].toText(new PrecisionModel(1e6))
+    var expectedWkt =
+      "POLYGON ((-122.3061 37.554162, -122.3061 37.554162, -122.3061 37.554162, -122.3061 37.554162, -122.3061 37.554162))"
+    assertEquals(expectedWkt, geoStr)
+
+    geohash = "s00twy01mt"
+    precision = 4;
+    row = sparkSession.sql(s"SELECT ST_GeogFromGeoHash('$geohash','$precision') AS geog").first()
+    geoStr = row.get(0).asInstanceOf[Geography].toText(new PrecisionModel(1e6))
+    expectedWkt =
+      "POLYGON ((0.703125 0.8789062, 1.0546875 0.8789062, 1.0546875 1.0546875, 0.703125 1.0546875, 0.703125 0.8789062))"

Review Comment:
   Please check SRID too



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

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


Re: [PR] [GH-2272]add new constructor ST_GeogFromGeoHash [sedona]

Posted by "Kontinuation (via GitHub)" <gi...@apache.org>.
Kontinuation commented on code in PR #2271:
URL: https://github.com/apache/sedona/pull/2271#discussion_r2275280248


##########
docs/api/sql/geography/Constructor.md:
##########
@@ -17,7 +17,25 @@
  under the License.
  -->
 
-## ST_GeogFromWKT
+## ST_GeomFromGeoHash
+
+Introduction: Create Geography from geohash string and optional precision
+
+Format: `ST_GeogFromGeoHash(geohash: String, precision: Integer)`
+
+Since: `v1.8.0`
+
+SQL Example
+
+```sql
+SELECT ST_GeogFromGeoHash('9q9j8ue2v71y5zzy0s4q', 16)
+```
+
+Output:
+
+```
+SRID=4326; POLYGON ((-122.3061 37.554162, -122.3061 37.554162, -122.3061 37.554162, -122.3061 37.554162, -122.3061 37.554162))"
+```

Review Comment:
   We lost the next section header `## ST_GeogFromWKT` here as well.



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

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


Re: [PR] [GH-2272]add new constructor ST_GeogFromGeoHash [sedona]

Posted by "jiayuasu (via GitHub)" <gi...@apache.org>.
jiayuasu commented on code in PR #2271:
URL: https://github.com/apache/sedona/pull/2271#discussion_r2277442142


##########
docs/api/sql/geography/Constructor.md:
##########
@@ -61,6 +61,28 @@ Output:
 SRID: 4326; LINESTRING (-2.1 -0.4, -1.5 -0.7)
 ```
 
+## ST_GeomFromGeoHash

Review Comment:
   ST_GeogFromGeoHash not Geom



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

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


Re: [PR] [GH-2272]add new constructor ST_GeogFromGeoHash [sedona]

Posted by "jiayuasu (via GitHub)" <gi...@apache.org>.
jiayuasu merged PR #2271:
URL: https://github.com/apache/sedona/pull/2271


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

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


Re: [PR] [GH-2272]add new constructor ST_GeogFromGeoHash [sedona]

Posted by "jiayuasu (via GitHub)" <gi...@apache.org>.
jiayuasu commented on PR #2271:
URL: https://github.com/apache/sedona/pull/2271#issuecomment-3187116364

   @ZhuochengShang Please resolve conflicts


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

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