-
-
Notifications
You must be signed in to change notification settings - Fork 100
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
OGC GeoPackage implementation - 3.4 #333
Closed
Closed
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
deegree-core/deegree-core-sqldialect/deegree-sqldialect-gpkg/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<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.4-pre17-SNAPSHOT</version> | ||
</parent> | ||
|
||
<repositories> | ||
<repository> | ||
<id>deegree-repo</id> | ||
<url>http://repo.deegree.org/content/groups/public</url> | ||
<releases> | ||
<updatePolicy>never</updatePolicy> | ||
</releases> | ||
<snapshots> | ||
<enabled>true</enabled> | ||
</snapshots> | ||
</repository> | ||
</repositories> | ||
|
||
<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> |
168 changes: 168 additions & 0 deletions
168
...ialect/deegree-sqldialect-gpkg/src/main/java/org/deegree/sqldialect/gpkg/GpkgDialect.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
/*---------------------------------------------------------------------------- | ||
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 java.sql.Connection; | ||
import java.sql.DatabaseMetaData; | ||
import java.sql.ResultSet; | ||
import java.sql.SQLException; | ||
import java.util.List; | ||
|
||
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.filter.AbstractWhereBuilder; | ||
import org.deegree.sqldialect.filter.PropertyNameMapper; | ||
import org.deegree.sqldialect.filter.UnmappableException; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* {@link SQLDialect} for GeoPackage databases. | ||
* | ||
* @author <a href="mailto:[email protected]">Diego Migliavacca</a> | ||
* @author last edited by: $Author: dmigliavacca $ | ||
*/ | ||
public class GpkgDialect implements SQLDialect { | ||
|
||
private static Logger LOG = LoggerFactory.getLogger( GpkgDialect.class ); | ||
|
||
@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, boolean allowPartialMappings ) | ||
throws UnmappableException, FilterEvaluationException { | ||
return new GpkgWhereBuilder( this, mapper, filter, sortCrit, 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; | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
...eegree-sqldialect-gpkg/src/main/java/org/deegree/sqldialect/gpkg/GpkgDialectProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/*---------------------------------------------------------------------------- | ||
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> | ||
* @author last edited by: $Author: dmigliavacca $ | ||
*/ | ||
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(); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if instantiating the driver manually is a good idea.