From 471e3dc2f62fefa2ebcd2ad4ac8077da50c49e7b Mon Sep 17 00:00:00 2001 From: nicolas-f Date: Tue, 3 Dec 2024 09:22:26 +0100 Subject: [PATCH] Add flat geobuffer driver --- .../wps/Import_and_Export/Export_Table.groovy | 9 +++++++-- .../wps/Import_and_Export/Import_File.groovy | 8 ++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/wps_scripts/src/main/groovy/org/noise_planet/noisemodelling/wps/Import_and_Export/Export_Table.groovy b/wps_scripts/src/main/groovy/org/noise_planet/noisemodelling/wps/Import_and_Export/Export_Table.groovy index 7077cee03..8cdd1f3d9 100644 --- a/wps_scripts/src/main/groovy/org/noise_planet/noisemodelling/wps/Import_and_Export/Export_Table.groovy +++ b/wps_scripts/src/main/groovy/org/noise_planet/noisemodelling/wps/Import_and_Export/Export_Table.groovy @@ -23,6 +23,7 @@ import org.geotools.jdbc.JDBCDataStore import org.h2gis.api.EmptyProgressVisitor import org.h2gis.functions.io.csv.CSVDriverFunction import org.h2gis.functions.io.dbf.DBFDriverFunction +import org.h2gis.functions.io.fgb.FGBDriverFunction import org.h2gis.functions.io.geojson.GeoJsonDriverFunction import org.h2gis.functions.io.json.JsonDriverFunction import org.h2gis.functions.io.kml.KMLDriverFunction @@ -39,7 +40,7 @@ import java.sql.Connection title = 'Export table' description = '➡️ Export table from the database into a local file.
'+ '
' + - 'Valid file extensions: csv, dbf, geojson, gpx, bz2, gz, osm, shp, tsv

' + + 'Valid file extensions: csv, dbf, geojson, gpx, bz2, gz, osm, shp, tsv, fgb

' + 'Export table' inputs = [ @@ -105,7 +106,7 @@ def exec(Connection connection, input) { // run export - String ext = exportPath.substring(exportPath.lastIndexOf('.') + 1, exportPath.length()) + String ext = exportPath.substring(exportPath.lastIndexOf('.') + 1, exportPath.length()).toLowerCase(Locale.ROOT) switch (ext) { case "csv": CSVDriverFunction csvDriver = new CSVDriverFunction() @@ -135,6 +136,10 @@ def exec(Connection connection, input) { TSVDriverFunction tsvDriver = new TSVDriverFunction() tsvDriver.exportTable(connection, tableToExport, new File(exportPath), true, new EmptyProgressVisitor()) break + case "fgb": + FGBDriverFunction fgbDriver = new FGBDriverFunction() + fgbDriver.exportTable(connection, tableToExport, new File(exportPath), true, new EmptyProgressVisitor()) + break default: throw new Exception("The file extension is not valid. No table has been exported.") break diff --git a/wps_scripts/src/main/groovy/org/noise_planet/noisemodelling/wps/Import_and_Export/Import_File.groovy b/wps_scripts/src/main/groovy/org/noise_planet/noisemodelling/wps/Import_and_Export/Import_File.groovy index 114015fd4..45492fb7a 100644 --- a/wps_scripts/src/main/groovy/org/noise_planet/noisemodelling/wps/Import_and_Export/Import_File.groovy +++ b/wps_scripts/src/main/groovy/org/noise_planet/noisemodelling/wps/Import_and_Export/Import_File.groovy @@ -24,6 +24,7 @@ import org.geotools.jdbc.JDBCDataStore import org.h2gis.api.EmptyProgressVisitor import org.h2gis.functions.io.csv.CSVDriverFunction import org.h2gis.functions.io.dbf.DBFDriverFunction +import org.h2gis.functions.io.fgb.FGBDriverFunction import org.h2gis.functions.io.geojson.GeoJsonDriverFunction import org.h2gis.functions.io.gpx.GPXDriverFunction import org.h2gis.functions.io.osm.OSMDriverFunction @@ -169,7 +170,7 @@ def exec(Connection connection, input) { stmt.execute(dropOutputTable) // Get the extension of the file - String ext = pathFile.substring(pathFile.lastIndexOf('.') + 1, pathFile.length()) + String ext = pathFile.substring(pathFile.lastIndexOf('.') + 1, pathFile.length()).toLowerCase() switch (ext) { case "csv": CSVDriverFunction csvDriver = new CSVDriverFunction() @@ -212,7 +213,10 @@ def exec(Connection connection, input) { logger.warn("The PK2 column automatically created by the SHP driver has been deleted.") } break - + case "fgb": + FGBDriverFunction fgbDriver = new FGBDriverFunction() + fgbDriver.importFile(connection, tableName, new File(pathFile), new EmptyProgressVisitor()) + break case "tsv": TSVDriverFunction tsvDriver = new TSVDriverFunction() tsvDriver.importFile(connection, tableName, new File(pathFile), new EmptyProgressVisitor())