-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
2,037 additions
and
15 deletions.
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
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
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
2 changes: 2 additions & 0 deletions
2
src/hakunapi-gpkg/src/main/java/fi/nls/hakunapi/gpkg/GPKGGeometryColumn.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
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
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>fi.nls.hakunapi</groupId> | ||
<artifactId>src</artifactId> | ||
<version>1.2.0-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>hakunapi-source-gpkg</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>fi.nls.hakunapi</groupId> | ||
<artifactId>hakunapi-gpkg</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.zaxxer</groupId> | ||
<artifactId>HikariCP</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
88 changes: 88 additions & 0 deletions
88
src/hakunapi-source-gpkg/src/main/java/fi/nls/hakunapi/source/gpkg/BufferedResultSet.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,88 @@ | ||
package fi.nls.hakunapi.source.gpkg; | ||
|
||
import java.sql.Connection; | ||
import java.sql.PreparedStatement; | ||
import java.sql.ResultSet; | ||
import java.util.List; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import fi.nls.hakunapi.core.FeatureStream; | ||
import fi.nls.hakunapi.core.ObjectArrayValueContainer; | ||
import fi.nls.hakunapi.core.ValueContainer; | ||
import fi.nls.hakunapi.core.ValueMapper; | ||
import fi.nls.hakunapi.core.ValueProvider; | ||
import fi.nls.hakunapi.core.util.U; | ||
|
||
public class BufferedResultSet implements FeatureStream { | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(BufferedResultSet.class); | ||
|
||
private final Connection c; | ||
private final PreparedStatement ps; | ||
private final ResultSet rs; | ||
private final ResultSetValueProvider valueProvider; | ||
private final List<ValueMapper> mappers; | ||
private final ValueContainer[] buffer; | ||
|
||
private int i; | ||
private int j; | ||
private boolean closed; | ||
|
||
public BufferedResultSet(Connection c, PreparedStatement ps, ResultSet rs, int numColsRs, List<ValueMapper> mappers, int bufSize) { | ||
this.c = c; | ||
this.ps = ps; | ||
this.rs = rs; | ||
this.valueProvider = new ResultSetValueProvider(rs, numColsRs); | ||
this.mappers = mappers; | ||
this.buffer = new ValueContainer[bufSize]; | ||
} | ||
|
||
@Override | ||
public boolean hasNext() { | ||
if (i < j) { | ||
return true; | ||
} | ||
if (closed) { | ||
return false; | ||
} | ||
|
||
i = 0; | ||
j = 0; | ||
try { | ||
for (; j < buffer.length; j++) { | ||
if (!rs.next()) { | ||
close(); | ||
break; | ||
} | ||
ValueContainer container = buffer[j]; | ||
if (container == null) { | ||
buffer[j] = container = new ObjectArrayValueContainer(mappers.size()); | ||
} | ||
for (ValueMapper mapper : mappers) { | ||
mapper.accept(valueProvider, container); | ||
} | ||
} | ||
return j > 0; | ||
} catch (Exception e) { | ||
LOG.error("Failed to retrieve more features", e); | ||
close(); | ||
return false; | ||
} | ||
} | ||
|
||
@Override | ||
public ValueProvider next() { | ||
return buffer[i++]; | ||
} | ||
|
||
@Override | ||
public void close() { | ||
closed = true; | ||
U.closeSilent(rs); | ||
U.closeSilent(ps); | ||
U.closeSilent(c); | ||
} | ||
|
||
} |
48 changes: 48 additions & 0 deletions
48
src/hakunapi-source-gpkg/src/main/java/fi/nls/hakunapi/source/gpkg/GpkgFeatureType.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,48 @@ | ||
package fi.nls.hakunapi.source.gpkg; | ||
|
||
import javax.sql.DataSource; | ||
|
||
import fi.nls.hakunapi.core.FeatureProducer; | ||
import fi.nls.hakunapi.core.SimpleFeatureType; | ||
import fi.nls.hakunapi.gpkg.extension.RtreeIndexExtension; | ||
|
||
public class GpkgFeatureType extends SimpleFeatureType { | ||
|
||
private String table; | ||
private boolean spatialIndex; | ||
private DataSource ds; | ||
|
||
public String getTable() { | ||
return table; | ||
} | ||
|
||
public void setTable(String table) { | ||
this.table = table; | ||
} | ||
|
||
public boolean isSpatialIndex() { | ||
return spatialIndex; | ||
} | ||
|
||
public void setSpatialIndex(boolean spatialIndex) { | ||
this.spatialIndex = spatialIndex; | ||
} | ||
|
||
public DataSource getDatabase() { | ||
return ds; | ||
} | ||
|
||
public void setDatabase(DataSource ds) { | ||
this.ds = ds; | ||
} | ||
|
||
@Override | ||
public FeatureProducer getFeatureProducer() { | ||
return new GpkgSimpleFeatureProducer(); | ||
} | ||
|
||
public String getSpatialIndexName() { | ||
return RtreeIndexExtension.getRtreeName(table, getGeom().getColumn()); | ||
} | ||
|
||
} |
Oops, something went wrong.