This is an automated email from the ASF dual-hosted git repository.
imbruced pushed a commit to branch feature/geopackage-reader
in repository https://gitbox.apache.org/repos/asf/sedona.git
The following commit(s) were added to refs/heads/feature/geopackage-reader by
this push:
new 8735051f8 Add other missing data types.
8735051f8 is described below
commit 8735051f8de112e476857feaf7b56b32a75fc47e
Author: pawelkocinski <[email protected]>
AuthorDate: Tue Sep 24 18:42:08 2024 +0200
Add other missing data types.
---
.../connection/GeoPackageConnectionManager.scala | 94 +++++++++++++---------
.../datasources/geopackage/model/TileMatrix.scala | 14 ++--
2 files changed, 63 insertions(+), 45 deletions(-)
diff --git
a/spark/common/src/main/scala/org/apache/sedona/sql/datasources/geopackage/connection/GeoPackageConnectionManager.scala
b/spark/common/src/main/scala/org/apache/sedona/sql/datasources/geopackage/connection/GeoPackageConnectionManager.scala
index 5f98be3e4..ba89e2a24 100644
---
a/spark/common/src/main/scala/org/apache/sedona/sql/datasources/geopackage/connection/GeoPackageConnectionManager.scala
+++
b/spark/common/src/main/scala/org/apache/sedona/sql/datasources/geopackage/connection/GeoPackageConnectionManager.scala
@@ -69,11 +69,17 @@ object GeoPackageConnectionManager {
val rs =
statement.executeQuery(s"select * from gpkg_contents where table_name =
'$tableName'")
- rs.getString("data_type") match {
- case "features" => TableType.FEATURES
- case "tiles" => TableType.TILES
- case _ => TableType.UNKNOWN
+ try {
+ rs.getString("data_type") match {
+ case "features" => TableType.FEATURES
+ case "tiles" => TableType.TILES
+ case _ => TableType.UNKNOWN
+ }
+ } finally {
+ rs.close()
+ closeStatement(statement)
}
+
}
def getZoomLevelData(path: String, tableName: String): mutable.HashMap[Int,
TileMatrix] = {
@@ -81,23 +87,29 @@ object GeoPackageConnectionManager {
val rs =
stmt.executeQuery(f"select * from gpkg_tile_matrix where table_name =
'${tableName}'")
val result: mutable.HashMap[Int, TileMatrix] = mutable.HashMap()
- while (rs.next()) {
- val zoom_level = rs.getInt("zoom_level")
- val matrix_width = rs.getInt("matrix_width")
- val matrix_height = rs.getInt("matrix_height")
- val tile_width = rs.getInt("tile_width")
- val tile_height = rs.getInt("tile_height")
- val pixel_x_size = rs.getDouble("pixel_x_size")
- val pixel_y_size = rs.getDouble("pixel_y_size")
-
- result(zoom_level) = TileMatrix(
- zoom_level,
- matrix_width,
- matrix_height,
- tile_width,
- tile_height,
- pixel_x_size,
- pixel_y_size)
+
+ try {
+ while (rs.next()) {
+ val zoom_level = rs.getInt("zoom_level")
+ val matrix_width = rs.getInt("matrix_width")
+ val matrix_height = rs.getInt("matrix_height")
+ val tile_width = rs.getInt("tile_width")
+ val tile_height = rs.getInt("tile_height")
+ val pixel_x_size = rs.getDouble("pixel_x_size")
+ val pixel_y_size = rs.getDouble("pixel_y_size")
+
+ result(zoom_level) = TileMatrix(
+ zoom_level,
+ matrix_width,
+ matrix_height,
+ tile_width,
+ tile_height,
+ pixel_x_size,
+ pixel_y_size)
+ }
+ } finally {
+ rs.close()
+ closeStatement(stmt)
}
result
@@ -109,22 +121,28 @@ object GeoPackageConnectionManager {
val rs = statement.executeQuery(
s"select * from gpkg_tile_matrix_set where table_name = '$tableName'")
- val minX = rs.getDouble("min_x")
- val minY = rs.getDouble("min_y")
- val maxX = rs.getDouble("max_x")
- val maxY = rs.getDouble("max_y")
- val srsID = rs.getInt("srs_id")
-
- val getZoomLevelData = GeoPackageConnectionManager.getZoomLevelData(path,
tableName)
-
- TileMetadata(
- tableName = tableName,
- minX = minX,
- minY = minY,
- maxX = maxX,
- maxY = maxY,
- srsID = srsID,
- zoomLevelMetadata = getZoomLevelData,
- tileRowMetadata = null)
+ try {
+ val minX = rs.getDouble("min_x")
+ val minY = rs.getDouble("min_y")
+ val maxX = rs.getDouble("max_x")
+ val maxY = rs.getDouble("max_y")
+ val srsID = rs.getInt("srs_id")
+
+ val getZoomLevelData =
GeoPackageConnectionManager.getZoomLevelData(path, tableName)
+
+ TileMetadata(
+ tableName = tableName,
+ minX = minX,
+ minY = minY,
+ maxX = maxX,
+ maxY = maxY,
+ srsID = srsID,
+ zoomLevelMetadata = getZoomLevelData,
+ tileRowMetadata = null)
+ }
+ finally {
+ rs.close()
+ closeStatement(statement)
+ }
}
}
diff --git
a/spark/common/src/main/scala/org/apache/sedona/sql/datasources/geopackage/model/TileMatrix.scala
b/spark/common/src/main/scala/org/apache/sedona/sql/datasources/geopackage/model/TileMatrix.scala
index fc13c4536..de572e69d 100644
---
a/spark/common/src/main/scala/org/apache/sedona/sql/datasources/geopackage/model/TileMatrix.scala
+++
b/spark/common/src/main/scala/org/apache/sedona/sql/datasources/geopackage/model/TileMatrix.scala
@@ -19,10 +19,10 @@
package org.apache.sedona.sql.datasources.geopackage.model
case class TileMatrix(
- zoomLevel: Int,
- matrixWidth: Int,
- matrixHeight: Int,
- tileWidth: Int,
- tileHeight: Int,
- pixelXSize: Double,
- pixelYSize: Double)
+ zoomLevel: Int,
+ matrixWidth: Int,
+ matrixHeight: Int,
+ tileWidth: Int,
+ tileHeight: Int,
+ pixelXSize: Double,
+ pixelYSize: Double)