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

Add support for GeoPackage to deegree #1437

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
7194218
deegree-gpkg - initial commit
diegomigliavacca Nov 14, 2014
57c397b
Merge branch 'master' into deegree-gpkg-3.4
diegomigliavacca Dec 14, 2018
333ae39
Updated pom.xml to current SNAPSHOT-version
julianzz98 Apr 5, 2022
bfe19d9
fixes #1105 using trimmed OGC schemas zip file
tfr42 Jun 23, 2022
dfd1bb3
Merge pull request #1349 from tfr42/ogcschemas-1105
stephanr Jun 29, 2022
76227b5
[maven-release-plugin] prepare release deegree-3.4.32
deegree-ci Jun 30, 2022
e1ade3e
Updated GPKG branch to version 3.4.27, logging still needs to be reso…
julianzz98 Jul 13, 2022
606c91c
#8309 - Resolve merge conficts to update branch to deegree verison 3.…
julianzz98 Aug 28, 2022
445f3bf
#8309 - Corrected version in POM
julianzz98 Aug 28, 2022
e34e1a8
#8209 - set version to 3.5.0-SNAPSHOT
lgoltz Dec 8, 2022
1f8c472
Merge remote-tracking branch 'deegree/main' into deegree-gpkg-3.4
lgoltz Dec 8, 2022
4984e52
#8209 - fixed compiler errors; removed repositories from submodules; …
lgoltz Dec 8, 2022
6b8ada8
#8209 - upgrade to sqlite-jdbc 3.40.0.0
lgoltz Dec 8, 2022
448b0a2
#8209 - optional configVesion
lgoltz Dec 8, 2022
4f07aba
#8209 - emoved version from path t example and config
lgoltz Dec 8, 2022
e90cf66
#8209 - added example JDBC connection fo GeoPackage
lgoltz Dec 8, 2022
9fc6ff9
#8209 fixed missing dependency to deegree-tilestore-gpkg
tfr42 Dec 9, 2022
53f96ec
#8209 updated JavaDoc with @since tag
tfr42 Dec 12, 2022
afc68de
Merge remote-tracking branch 'deegree/main' into deegree-gpkg-3.4
lgoltz Jun 12, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<DataSourceConnectionProvider
xmlns="http://www.deegree.org/connectionprovider/datasource" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.deegree.org/connectionprovider/datasource http://schemas.deegree.org/jdbc/datasource/3.5/datasource.xsd">

<!-- Creation / lookup of javax.sql.DataSource instance -->
<DataSource javaClass="org.apache.commons.dbcp2.BasicDataSource" />

<Property name="url" value="jdbc:sqlite:/home/user/example.gpkg" />

</DataSourceConnectionProvider>
4 changes: 4 additions & 0 deletions deegree-core/deegree-core-db/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
</dependency>
</dependencies>
</project>

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>deegree-sqldialect-gpkg</artifactId>
<name>deegree-sqldialect-gpkg</name>
<packaging>jar</packaging>
<description>SQL dialect for GeoPackage</description>

<properties>
<deegree.module.status>rework</deegree.module.status>
</properties>

<parent>
<groupId>org.deegree</groupId>
<artifactId>deegree-core-sqldialect</artifactId>
<version>3.5.0-SNAPSHOT</version>
</parent>

<dependencies>
<dependency>
<groupId>org.deegree</groupId>
<artifactId>deegree-sqldialect-commons</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.deegree</groupId>
<artifactId>deegree-core-db</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
/*----------------------------------------------------------------------------
This file is part of deegree, http://deegree.org/
Copyright (C) 2001-2010 by:
- Department of Geography, University of Bonn -
and
- lat/lon GmbH -

This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free
Software Foundation; either version 2.1 of the License, or (at your option)
any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

Contact information:

lat/lon GmbH
Aennchenstr. 19, 53177 Bonn
Germany
http://lat-lon.de/

Department of Geography, University of Bonn
Prof. Dr. Klaus Greve
Postfach 1147, 53001 Bonn
Germany
http://www.geographie.uni-bonn.de/deegree/

e-mail: [email protected]
----------------------------------------------------------------------------*/
package org.deegree.sqldialect.gpkg;

import org.deegree.commons.jdbc.SQLIdentifier;
import org.deegree.commons.jdbc.TableName;
import org.deegree.commons.tom.primitive.PrimitiveType;
import org.deegree.commons.tom.sql.DefaultPrimitiveConverter;
import org.deegree.commons.tom.sql.PrimitiveParticleConverter;
import org.deegree.cs.coordinatesystems.ICRS;
import org.deegree.filter.FilterEvaluationException;
import org.deegree.filter.OperatorFilter;
import org.deegree.filter.sort.SortProperty;
import org.deegree.geometry.Envelope;
import org.deegree.geometry.utils.GeometryParticleConverter;
import org.deegree.sqldialect.SQLDialect;
import org.deegree.sqldialect.SortCriterion;
import org.deegree.sqldialect.filter.AbstractWhereBuilder;
import org.deegree.sqldialect.filter.PropertyNameMapper;
import org.deegree.sqldialect.filter.UnmappableException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

/**
* {@link SQLDialect} for GeoPackage databases.
*
* @author <a href="mailto:[email protected]">Diego Migliavacca</a>
* @since 3.5
*/
public class GpkgDialect implements SQLDialect {

private static Logger LOG = LoggerFactory.getLogger(GpkgDialect.class);

private char defaultEscapeChar = Character.UNASSIGNED;

@Override
public int getMaxColumnNameLength() {
return 2000;
}

@Override
public int getMaxTableNameLength() {
return 2000;
}

public String getDefaultSchema() {
return "main";
}

public String stringPlus() {
return "||";
}

public String stringIndex(String pattern, String string) {
return "INSTR(" + string + "," + pattern + ")";
}

public String cast(String expr, String type) {
return "CAST(" + expr + " AS " + type + ")";
}

@Override
public String geometryMetadata(TableName qTable, String column, boolean isGeographical) {
return null;
}

@Override
public AbstractWhereBuilder getWhereBuilder(PropertyNameMapper mapper, OperatorFilter filter,
SortProperty[] sortCrit, List<SortCriterion> defaultSortCriteria, boolean allowPartialMappings)
throws UnmappableException, FilterEvaluationException {
return new GpkgWhereBuilder(this, mapper, filter, sortCrit, defaultSortCriteria, allowPartialMappings);
}

@Override
public String getUndefinedSrid() {
return "-1";
}

@Override
public String getBBoxAggregateSnippet(String column) {
return null;
}

@Override
public Envelope getBBoxAggregateValue(ResultSet rs, int colIdx, ICRS crs) throws SQLException {
return null;
}

@Override
public GeometryParticleConverter getGeometryConverter(String column, ICRS crs, String srid, boolean is2D) {
return new GpkgGeometryConverter(column, crs, srid);
}

@Override
public PrimitiveParticleConverter getPrimitiveConverter(String column, PrimitiveType pt) {
return new DefaultPrimitiveConverter(pt, column);
}

@Override
public void createDB(Connection adminConn, String dbName) throws SQLException {
}

@Override
public void dropDB(Connection adminConn, String dbName) throws SQLException {
}

@Override
public void createAutoColumn(StringBuffer currentStmt, List<StringBuffer> additionalSmts, SQLIdentifier column,
SQLIdentifier table) {
currentStmt.append(column);
}

@Override
public ResultSet getTableColumnMetadata(DatabaseMetaData md, TableName qTable) throws SQLException {
String schema = qTable.getSchema() != null ? qTable.getSchema() : getDefaultSchema();
String table = qTable.getTable();
return md.getColumns(null, schema.toLowerCase(), table.toLowerCase(), null);
}

@Override
public boolean requiresTransactionForCursorMode() {
return false;
}

@Override
public String getSelectSequenceNextVal(String sequence) {
return null;
}

@Override
public boolean isRowLimitingCapable() {
// TODO Auto-generated method stub
return true;
}

@Override
public char getTailingEscapeChar() {
// TODO Auto-generated method stub
return defaultEscapeChar;
}

@Override
public char getLeadingEscapeChar() {
// TODO Auto-generated method stub
return defaultEscapeChar;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*----------------------------------------------------------------------------
This file is part of deegree, http://deegree.org/
Copyright (C) 2001-2012 by:
- Department of Geography, University of Bonn -
and
- lat/lon GmbH -

This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free
Software Foundation; either version 2.1 of the License, or (at your option)
any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

Contact information:

lat/lon GmbH
Aennchenstr. 19, 53177 Bonn
Germany
http://lat-lon.de/

Department of Geography, University of Bonn
Prof. Dr. Klaus Greve
Postfach 1147, 53001 Bonn
Germany
http://www.geographie.uni-bonn.de/deegree/

e-mail: [email protected]
----------------------------------------------------------------------------*/
package org.deegree.sqldialect.gpkg;

import java.sql.Connection;

import org.deegree.sqldialect.SQLDialect;
import org.deegree.db.dialect.SqlDialectProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* {@link SqlDialectProvider} for GeoPackage databases.
*
* @author <a href="mailto:[email protected]">Diego Migliavacca</a>
* @since 3.5
*/
public class GpkgDialectProvider implements SqlDialectProvider {

private static Logger LOG = LoggerFactory.getLogger(GpkgDialectProvider.class);

@Override
public boolean supportsConnection(final Connection connection) {
String url;
try {
url = connection.getMetaData().getURL();
}
catch (Exception e) {
LOG.debug("Could not determine metadata/url of connection: {}", e.getLocalizedMessage());
LOG.trace("Stack trace:", e);
return false;
}
return url.startsWith("jdbc:sqlite:");
}

@Override
public SQLDialect createDialect(final Connection conn) {
return new GpkgDialect();
}

}
Loading