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

OGC GeoPackage implementation - 3.4 #333

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
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 @@ -52,6 +52,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
Expand Up @@ -92,6 +92,7 @@ public void startup( Workspace workspace ) {
try {
for ( Driver d : ServiceLoader.load( Driver.class, workspace.getModuleClassLoader() ) ) {
registerDriver( new DriverWrapper( d ) );
registerDriver( new DriverWrapper( new org.sqlite.JDBC() ) );
Copy link
Member

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.

LOG.info( "Found and loaded {}", d.getClass().getName() );
}
} catch ( SQLException e ) {
Expand Down
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>
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;
}
}
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();
}
}
Loading