Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flatgeobuffer driver #1327

Merged
merged 27 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
596088b
Start flatgeobuf implementation
ebocher Oct 17, 2022
749af20
Start flatgeobuf implementation
ebocher Oct 17, 2022
13c2c7f
Clear the buffer
ebocher Oct 17, 2022
2902f86
Some fixes
ebocher Oct 21, 2022
c020e4c
Next step for FGB driver
ebocher Jan 9, 2023
2f8115f
Prepare FlatGeoBuffer table engine.
ebocher Jan 10, 2023
0689ba7
Merge branch 'master' into flatgeobuffer_exporter
ebocher Oct 9, 2023
8263c64
Write function using driver, add unit test for reference file
nicolas-f Oct 10, 2023
f9259ac
update flatgeobuffer dependency version, fix read of fields (missing …
nicolas-f Oct 10, 2023
1d54c77
Read is working
nicolas-f Oct 10, 2023
2611769
geojson is supposed to have an optional ID field into the feature obj…
nicolas-f Oct 10, 2023
5c11654
oups wrong execute location
nicolas-f Oct 10, 2023
f2b66c2
manage Z and M
nicolas-f Oct 11, 2023
b62ecfc
yeah z working
nicolas-f Oct 11, 2023
40f01c9
unit test 3d
nicolas-f Oct 11, 2023
6af3fdb
test z and m
nicolas-f Oct 11, 2023
03218cb
feature address from Index
nicolas-f Oct 12, 2023
669b2fa
Issues with index when vizualizing on Gdal
nicolas-f Oct 13, 2023
6a3d29a
fix issue with buffer
nicolas-f Oct 13, 2023
b095b86
Creating index in FGB file is working on Gdal
nicolas-f Oct 13, 2023
716c159
check ordering
nicolas-f Oct 13, 2023
5cae7b4
optimisations
nicolas-f Oct 13, 2023
3c43c39
documetation
nicolas-f Oct 17, 2023
cb620fd
Create changelog
nicolas-f Oct 17, 2023
3da5140
headers and authors
nicolas-f Oct 17, 2023
3ad1999
javadoc
nicolas-f Oct 17, 2023
daf1704
Merge pull request #19 from nicolas-f/flatgeobuffer_exporter
ebocher Oct 17, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Changelog for v2.2.1
## Changelog for v2.1.1
+ Next version
+ Update EPSG 2100 definition for GGRS87 / Greek Grid transformation
+ Add geojson utility to convert a resultset to JSON map
Expand All @@ -24,4 +24,6 @@
+ Set scope as test for slf4j-simple
+ Zip and unzip functions with subfolders
+ GeoJson driver must be able to read json extension
+ GeoJson handle the M ordinate. The limitation is only ZM is supported (default Z value to 0 if M is given but not Z)
+ GeoJson handle the M ordinate. The limitation is only ZM is supported (default Z value to 0 if M is given but not Z)
+ GeoJson read the optional ID field on feature as an attribute, but currently it will be saved back into feature attribute.
+ FlatGeobuf driver. Read Write driver and FileTable. This driver does not support mixed geometry type. On write a spatial index is created by default. The spatial index on file table is not currently supported.
4 changes: 4 additions & 0 deletions h2gis-functions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@
<groupId>org.orbisgis</groupId>
<artifactId>poly2tri</artifactId>
</dependency>
<dependency>
<groupId>org.wololo</groupId>
<artifactId>flatgeobuf</artifactId>
</dependency>

<dependency>
<groupId>org.orbisgis</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ private H2GISDBFactory() {

/**
* Open the connection to an existing database
* @param dbName
* @return
* @throws SQLException
* @param dbName Database name
* @return Active connection
* @throws SQLException Exception
*/
public static Connection openSpatialDataBase(String dbName) throws SQLException {
String dbFilePath = getDataBasePath(dbName);
Expand All @@ -75,10 +75,9 @@ public static Connection openSpatialDataBase(String dbName) throws SQLException
* Create a spatial database
* @param dbName filename
* @return Connection
* @throws java.sql.SQLException
* @throws java.lang.ClassNotFoundException
* @throws java.sql.SQLException SQL Exception
*/
public static Connection createSpatialDataBase(String dbName)throws SQLException, ClassNotFoundException {
public static Connection createSpatialDataBase(String dbName)throws SQLException {
return createSpatialDataBase(dbName,true);
}

Expand All @@ -100,7 +99,7 @@ private static String getDataBasePath(String dbName) {
* @param dbName DataBase name, or path URI
* @param initSpatial True to enable basic spatial capabilities
* @return DataSource
* @throws SQLException
* @throws SQLException SQL issue
*/
public static DataSource createDataSource(String dbName ,boolean initSpatial) throws SQLException {
return createDataSource(dbName, initSpatial, H2_PARAMETERS);
Expand All @@ -110,7 +109,7 @@ public static DataSource createDataSource(String dbName ,boolean initSpatial) th
* Create a database, init spatial funcyion and return a DataSource
* @param properties for the opening of the DataBase.
* @return a DataSource
* @throws SQLException
* @throws SQLException SQL issue
*/
public static DataSource createDataSource(Properties properties) throws SQLException {
return createDataSource(properties, true);
Expand All @@ -121,7 +120,7 @@ public static DataSource createDataSource(Properties properties) throws SQLExcep
* @param properties for the opening of the DataBase.
* @param initSpatial true to load the spatial functions
* @return a DataSource
* @throws SQLException
* @throws SQLException SQL issue
*/
public static DataSource createDataSource(Properties properties, boolean initSpatial) throws SQLException {
// Create H2 memory DataSource
Expand All @@ -138,11 +137,11 @@ public static DataSource createDataSource(Properties properties, boolean initSpa

/**
* Create a database and return a DataSource
* @param dbName
* @param initSpatial
* @param h2Parameters
* @return
* @throws SQLException
* @param dbName Database name
* @param initSpatial true to load the spatial functions
* @param h2Parameters Additional h2 parameters
* @return DataSource instance
* @throws SQLException SQL issue
*/
public static DataSource createDataSource(String dbName ,boolean initSpatial, String h2Parameters) throws SQLException {
// Create H2 memory DataSource
Expand All @@ -164,9 +163,9 @@ public static DataSource createDataSource(String dbName ,boolean initSpatial, St

/**
*
* @param dbName
* @param h2_PARAMETERS
* @return
* @param dbName Database name
* @param h2_PARAMETERS User defined h2 parameters
* @return The path of the database
*/
private static String initDBFile( String dbName, String h2_PARAMETERS ) {
String dbFilePath = getDataBasePath(dbName);
Expand All @@ -189,10 +188,9 @@ private static String initDBFile( String dbName, String h2_PARAMETERS ) {
* @param initSpatial If true add spatial features to the database
* @param h2Parameters Additional h2 parameters
* @return Connection
* @throws java.sql.SQLException
* @throws java.lang.ClassNotFoundException
* @throws java.sql.SQLException SQL Exception
*/
public static Connection createSpatialDataBase(String dbName,boolean initSpatial, String h2Parameters )throws SQLException, ClassNotFoundException {
public static Connection createSpatialDataBase(String dbName,boolean initSpatial, String h2Parameters ) throws SQLException {
String databasePath = initDBFile(dbName, h2Parameters);
org.h2.Driver.load();
// Keep a connection alive to not close the DataBase on each unit test
Expand All @@ -210,10 +208,9 @@ public static Connection createSpatialDataBase(String dbName,boolean initSpatial
* @param dbName filename
* @param initSpatial If true add spatial features to the database
* @return Connection
* @throws java.sql.SQLException
* @throws java.lang.ClassNotFoundException
* @throws java.sql.SQLException Database issue
*/
public static Connection createSpatialDataBase(String dbName, boolean initSpatial )throws SQLException, ClassNotFoundException {
public static Connection createSpatialDataBase(String dbName, boolean initSpatial )throws SQLException {
return createSpatialDataBase(dbName, initSpatial, H2_PARAMETERS);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ public static Function[] getBuiltInsFunctions() {
* @param connection Active H2 connection
* @param BundleSymbolicName OSGi Bundle symbolic name
* @param BundleVersion OSGi Bundle version
* @throws java.sql.SQLException
* @throws java.sql.SQLException Database issue
*/
public static void load(Connection connection, String BundleSymbolicName, String BundleVersion) throws SQLException {
String packagePrepend = BundleSymbolicName+":"+BundleVersion+":";
Expand All @@ -354,7 +354,7 @@ public static void load(Connection connection, String BundleSymbolicName, String
/**
* Register GEOMETRY type and register H2GIS functions
* @param connection Active H2 connection
* @throws java.sql.SQLException
* @throws java.sql.SQLException Database issue
*/
public static void load(Connection connection) throws SQLException {
org.locationtech.jts.JTSVersion jtsVersion = org.locationtech.jts.JTSVersion.CURRENT_VERSION;
Expand All @@ -369,7 +369,7 @@ public static void load(Connection connection) throws SQLException {
/**
* Register view in order to create GEOMETRY_COLUMNS standard table.
* @param connection Open connection
* @throws java.sql.SQLException
* @throws java.sql.SQLException Database issue
*/
public static void registerSpatialTables(Connection connection) throws SQLException {
Statement st = connection.createStatement();
Expand Down Expand Up @@ -502,7 +502,7 @@ public static String getAlias(Function function) {
* Remove the specified function from the provided DataBase connection
* @param st Active statement
* @param function function to remove
* @throws SQLException
* @throws SQLException Database issue
*/
public static void unRegisterFunction(Statement st, Function function) throws SQLException {
String functionAlias = getStringProperty(function, Function.PROP_NAME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import org.h2gis.api.*;
import org.h2gis.functions.io.dbf.DBFDriverFunction;
import org.h2gis.functions.io.dbf.DBFEngine;
import org.h2gis.functions.io.fgb.FGBDriverFunction;
import org.h2gis.functions.io.fgb.FGBEngine;
import org.h2gis.functions.io.shp.SHPDriverFunction;
import org.h2gis.functions.io.shp.SHPEngine;
import org.h2gis.utilities.TableLocation;
Expand All @@ -41,17 +43,20 @@
* Manage additional table engines in H2.
* Use the appropriate driver to open a specified file path.
* @author Nicolas Fortin
* @author Sylvain PALOMINOS (UBS 2019)
* @author Sylvain Paliminos (UBS 2019)
* @author Erwan Bocher (CNRS)
*/
public class DriverManager extends AbstractFunction implements ScalarFunction, DriverFunction {

private static final DriverDef[] DRIVERS = new DriverDef[] {
new DriverDef(DBFEngine.class.getName(),"dbf"),
new DriverDef(SHPEngine.class.getName(),"shp")};
new DriverDef(SHPEngine.class.getName(),"shp"),
new DriverDef(FGBEngine.class.getName(), "fgb")};
private static final int FORMAT = 0;
private static final int DESCRIPTION = 1;
private static final String[][] formatDescription = new String[][] {{"dbf", DBFDriverFunction.DESCRIPTION},
{"shp", SHPDriverFunction.DESCRIPTION}};
{"shp", SHPDriverFunction.DESCRIPTION},
{"fgb", FGBDriverFunction.DESCRIPTION}};

public DriverManager() {
addProperty(PROP_NAME, "FILE_TABLE");
Expand Down Expand Up @@ -199,12 +204,12 @@ public String[] importFile(Connection connection, String tableReference, File f

/**
* Method to check the import and export arguments
* @param connection
* @param tableReference
* @param fileName
* @param progress
* @return
* @throws SQLException
* @param connection Active connection, do not close this connection.
* @param tableReference Table name
* @param fileName Path of the data file
* @param progress Progress instance
* @return progress instance
* @throws SQLException Database issue
*/
public static ProgressVisitor check(Connection connection, String tableReference, File fileName, ProgressVisitor progress) throws SQLException {
if (connection == null) {
Expand Down