Skip to content

Commit

Permalink
Add flat geobuffer driver
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-f committed Dec 3, 2024
1 parent e9e048b commit 471e3dc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -39,7 +40,7 @@ import java.sql.Connection
title = 'Export table'
description = '&#10145;&#65039; Export table from the database into a local file. </br> '+
'<hr>' +
'Valid file extensions: csv, dbf, geojson, gpx, bz2, gz, osm, shp, tsv </br> </br>' +
'Valid file extensions: csv, dbf, geojson, gpx, bz2, gz, osm, shp, tsv, fgb </br> </br>' +
'<img src="/wps_images/export_table.png" alt="Export table" width="95%" align="center">'

inputs = [
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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())
Expand Down

0 comments on commit 471e3dc

Please sign in to comment.