jiayuasu commented on code in PR #2661:
URL: https://github.com/apache/sedona/pull/2661#discussion_r2825950474


##########
spark/common/src/main/scala/org/apache/spark/sql/execution/datasources/geoparquet/GeoParquetRowConverter.scala:
##########
@@ -220,6 +220,8 @@ private[geoparquet] class GeoParquetRowConverter(
             override def addBinary(value: Binary): Unit = {
               val wkbReader = new WKBReader()
               val geom = wkbReader.read(value.getBytes)
+              val srid = schemaConverter.getSrid(parquetType.getName)
+              geom.setSRID(srid)
               this.updater.set(GeometryUDT.serialize(geom))

Review Comment:
   fixed



##########
spark/common/src/main/scala/org/apache/spark/sql/execution/datasources/geoparquet/GeoParquetSchemaConverter.scala:
##########
@@ -78,6 +78,21 @@ class GeoParquetToSparkSchemaConverter(
       
conf.get(PortableSQLConf.PARQUET_INFER_TIMESTAMP_NTZ_ENABLED.key).toBoolean,
     parameters = parameters)
 
+  /**
+   * Returns the SRID for a geometry column based on the CRS metadata in the 
GeoParquet file.
+   * @param columnName
+   *   name of the geometry column
+   * @return
+   *   the SRID extracted from the CRS metadata. Returns 4326 if the CRS is 
omitted, 0 if the CRS
+   *   is null or unrecognized, or the EPSG code if the PROJJSON contains an 
EPSG identifier.
+   */
+  def getSrid(columnName: String): Int = {
+    geoParquetMetaData.columns.get(columnName) match {
+      case Some(fieldMetadata) => 
GeoParquetMetaData.extractSridFromCrs(fieldMetadata.crs)
+      case None => 0
+    }
+  }

Review Comment:
   fixed



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