Skip to content

Commit 1825c80

Browse files
committed
Merge pull request #13 from ngageoint/develop
Develop to Master, 1.1.1 changes
2 parents f791475 + 10dba01 commit 1825c80

File tree

10 files changed

+364
-26
lines changed

10 files changed

+364
-26
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ Adheres to [Semantic Versioning](http://semver.org/).
77
## 1.1.1 (TBD)
88

99
* Javadoc project links to external libraries
10+
* Additional GeoPackage createFeatureTableWithMetadata methods - [Issue #10](https://github.com/ngageoint/geopackage-core-java/issues/10)
11+
* min and max column query methods - [Issue #11](https://github.com/ngageoint/geopackage-core-java/issues/11)
12+
* Determine bounding box from Tile Grid methods - [Issue #12](https://github.com/ngageoint/geopackage-core-java/issues/12)
13+
* Data Columns Dao get data column by table and column names method
1014
* TBD
1115

1216
## [1.1.0](https://github.com/ngageoint/geopackage-core-java/releases/tag/1.1.0) (10-08-2015)

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
<dependency>
5151
<groupId>mil.nga</groupId>
5252
<artifactId>wkb</artifactId>
53-
<version>1.0.0</version>
53+
<version>1.0.1</version>
5454
</dependency>
5555
<dependency>
5656
<groupId>junit</groupId>

src/main/java/mil/nga/geopackage/GeoPackageConstants.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,9 @@ public class GeoPackageConstants {
4242
*/
4343
public static final byte GEO_PACKAGE_GEOMETRY_VERSION_1 = 0;
4444

45+
/**
46+
* SQLite header string prefix
47+
*/
48+
public static final String SQLITE_HEADER_PREFIX = "SQLite format 3";
49+
4550
}

src/main/java/mil/nga/geopackage/GeoPackageCore.java

Lines changed: 115 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import mil.nga.geopackage.features.columns.GeometryColumnsDao;
1616
import mil.nga.geopackage.features.columns.GeometryColumnsSfSqlDao;
1717
import mil.nga.geopackage.features.columns.GeometryColumnsSqlMmDao;
18+
import mil.nga.geopackage.features.user.FeatureColumn;
1819
import mil.nga.geopackage.features.user.FeatureTable;
1920
import mil.nga.geopackage.metadata.MetadataDao;
2021
import mil.nga.geopackage.metadata.reference.MetadataReferenceDao;
@@ -145,16 +146,128 @@ public interface GeoPackageCore extends Closeable {
145146
public void createFeatureTable(FeatureTable table);
146147

147148
/**
148-
* Create a new feature table with GeoPackage metadata
149+
* Create a new feature table with GeoPackage metadata. Create the Geometry
150+
* Columns table if needed, create a user feature table, create a new
151+
* Contents, insert the new Geometry Columns.
152+
*
153+
* The user feature table will be created with 2 columns, an id column named
154+
* "id" and a geometry column using {@link GeometryColumns#getColumnName()}.
149155
*
150156
* @param geometryColumns
157+
* geometry columns to create
151158
* @param boundingBox
159+
* contents bounding box
152160
* @param srsId
153-
* @return
161+
* spatial reference system id
162+
* @return geometry columns
154163
*/
155164
public GeometryColumns createFeatureTableWithMetadata(
156165
GeometryColumns geometryColumns, BoundingBox boundingBox, long srsId);
157166

167+
/**
168+
* Create a new feature table with GeoPackage metadata. Create the Geometry
169+
* Columns table if needed, create a user feature table, create a new
170+
* Contents, insert the new Geometry Columns.
171+
*
172+
* The user feature table will be created with 2 columns, an id column with
173+
* the provided name and a geometry column using
174+
* {@link GeometryColumns#getColumnName()}.
175+
*
176+
* @param geometryColumns
177+
* geometry columns to create
178+
* @param idColumnName
179+
* id column name
180+
* @param boundingBox
181+
* contents bounding box
182+
* @param srsId
183+
* spatial reference system id
184+
* @return geometry columns
185+
* @since 1.1.1
186+
*/
187+
public GeometryColumns createFeatureTableWithMetadata(
188+
GeometryColumns geometryColumns, String idColumnName,
189+
BoundingBox boundingBox, long srsId);
190+
191+
/**
192+
* Create a new feature table with GeoPackage metadata. Create the Geometry
193+
* Columns table if needed, create a user feature table, create a new
194+
* Contents, insert the new Geometry Columns.
195+
*
196+
* The user feature table will be created with 2 + additionalColumns.size()
197+
* columns, an id column named "id", a geometry column using
198+
* {@link GeometryColumns#getColumnName()}, and the provided additional
199+
* columns.
200+
*
201+
* @param geometryColumns
202+
* geometry columns to create
203+
* @param additionalColumns
204+
* additional user feature table columns to create in addition to
205+
* id and geometry columns
206+
* @param boundingBox
207+
* contents bounding box
208+
* @param srsId
209+
* spatial reference system id
210+
* @return geometry columns
211+
* @since 1.1.1
212+
*/
213+
public GeometryColumns createFeatureTableWithMetadata(
214+
GeometryColumns geometryColumns,
215+
List<FeatureColumn> additionalColumns, BoundingBox boundingBox,
216+
long srsId);
217+
218+
/**
219+
* Create a new feature table with GeoPackage metadata. Create the Geometry
220+
* Columns table if needed, create a user feature table, create a new
221+
* Contents, insert the new Geometry Columns.
222+
*
223+
* The user feature table will be created with 2 + additionalColumns.size()
224+
* columns, an id column with the provided name, a geometry column using
225+
* {@link GeometryColumns#getColumnName()}, and the provided additional
226+
* columns.
227+
*
228+
* @param geometryColumns
229+
* geometry columns to create
230+
* @param idColumnName
231+
* id column name
232+
* @param additionalColumns
233+
* additional user feature table columns to create in addition to
234+
* id and geometry columns
235+
* @param boundingBox
236+
* contents bounding box
237+
* @param srsId
238+
* spatial reference system id
239+
* @return geometry columns
240+
* @since 1.1.1
241+
*/
242+
public GeometryColumns createFeatureTableWithMetadata(
243+
GeometryColumns geometryColumns, String idColumnName,
244+
List<FeatureColumn> additionalColumns, BoundingBox boundingBox,
245+
long srsId);
246+
247+
/**
248+
* Create a new feature table with GeoPackage metadata. Create the Geometry
249+
* Columns table if needed, create a user feature table, create a new
250+
* Contents, insert the new Geometry Columns.
251+
*
252+
* The user feature table will be created using only the provided columns.
253+
* These should include the id column and the geometry column defined in
254+
* {@link GeometryColumns#getColumnName()}
255+
*
256+
* @param geometryColumns
257+
* geometry columns to create
258+
* @param boundingBox
259+
* contents bounding box
260+
* @param srsId
261+
* spatial reference system id
262+
* @param columns
263+
* user feature table columns to create
264+
* @return geometry columns
265+
* @since 1.1.1
266+
*/
267+
public GeometryColumns createFeatureTableWithMetadata(
268+
GeometryColumns geometryColumns, BoundingBox boundingBox,
269+
long srsId, List<FeatureColumn> columns);
270+
158271
/**
159272
* Get a Tile Matrix Set DAO
160273
*

src/main/java/mil/nga/geopackage/db/GeoPackageCoreConnection.java

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public abstract class GeoPackageCoreConnection implements Closeable {
3535
* @param table
3636
* @param whereClause
3737
* @param whereArgs
38-
* @return
38+
* @return rows deleted
3939
*/
4040
public abstract int delete(String table, String whereClause,
4141
String[] whereArgs);
@@ -46,10 +46,36 @@ public abstract int delete(String table, String whereClause,
4646
* @param table
4747
* @param where
4848
* @param args
49-
* @return
49+
* @return count
5050
*/
5151
public abstract int count(String table, String where, String[] args);
5252

53+
/**
54+
* Get the min result of the column
55+
*
56+
* @param table
57+
* @param column
58+
* @param where
59+
* @param args
60+
* @return min or null
61+
* @since 1.1.1
62+
*/
63+
public abstract Integer min(String table, String column, String where,
64+
String[] args);
65+
66+
/**
67+
* Get the max result of the column
68+
*
69+
* @param table
70+
* @param column
71+
* @param where
72+
* @param args
73+
* @return max or null
74+
* @since 1.1.1
75+
*/
76+
public abstract Integer max(String table, String column, String where,
77+
String[] args);
78+
5379
/**
5480
* {@inheritDoc}
5581
*/

src/main/java/mil/nga/geopackage/factory/GeoPackageCoreImpl.java

Lines changed: 65 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,67 @@ public void createFeatureTable(FeatureTable table) {
295295
@Override
296296
public GeometryColumns createFeatureTableWithMetadata(
297297
GeometryColumns geometryColumns, BoundingBox boundingBox, long srsId) {
298+
return createFeatureTableWithMetadata(geometryColumns, null, null,
299+
boundingBox, srsId);
300+
}
301+
302+
/**
303+
* {@inheritDoc}
304+
*/
305+
@Override
306+
public GeometryColumns createFeatureTableWithMetadata(
307+
GeometryColumns geometryColumns, String idColumnName,
308+
BoundingBox boundingBox, long srsId) {
309+
return createFeatureTableWithMetadata(geometryColumns, idColumnName,
310+
null, boundingBox, srsId);
311+
}
312+
313+
/**
314+
* {@inheritDoc}
315+
*/
316+
@Override
317+
public GeometryColumns createFeatureTableWithMetadata(
318+
GeometryColumns geometryColumns,
319+
List<FeatureColumn> additionalColumns, BoundingBox boundingBox,
320+
long srsId) {
321+
return createFeatureTableWithMetadata(geometryColumns, null,
322+
additionalColumns, boundingBox, srsId);
323+
}
324+
325+
/**
326+
* {@inheritDoc}
327+
*/
328+
@Override
329+
public GeometryColumns createFeatureTableWithMetadata(
330+
GeometryColumns geometryColumns, String idColumnName,
331+
List<FeatureColumn> additionalColumns, BoundingBox boundingBox,
332+
long srsId) {
333+
334+
if (idColumnName == null) {
335+
idColumnName = "id";
336+
}
337+
338+
List<FeatureColumn> columns = new ArrayList<FeatureColumn>();
339+
columns.add(FeatureColumn.createPrimaryKeyColumn(0, idColumnName));
340+
columns.add(FeatureColumn.createGeometryColumn(1,
341+
geometryColumns.getColumnName(),
342+
geometryColumns.getGeometryType(), false, null));
343+
344+
if (additionalColumns != null) {
345+
columns.addAll(additionalColumns);
346+
}
347+
348+
return createFeatureTableWithMetadata(geometryColumns, boundingBox,
349+
srsId, columns);
350+
}
351+
352+
/**
353+
* {@inheritDoc}
354+
*/
355+
@Override
356+
public GeometryColumns createFeatureTableWithMetadata(
357+
GeometryColumns geometryColumns, BoundingBox boundingBox,
358+
long srsId, List<FeatureColumn> columns) {
298359

299360
// Get the SRS
300361
SpatialReferenceSystem srs = getSrs(srsId);
@@ -303,11 +364,6 @@ public GeometryColumns createFeatureTableWithMetadata(
303364
createGeometryColumnsTable();
304365

305366
// Create the user feature table
306-
List<FeatureColumn> columns = new ArrayList<FeatureColumn>();
307-
columns.add(FeatureColumn.createPrimaryKeyColumn(0, "id"));
308-
columns.add(FeatureColumn.createGeometryColumn(1,
309-
geometryColumns.getColumnName(),
310-
geometryColumns.getGeometryType(), false, null));
311367
FeatureTable table = new FeatureTable(geometryColumns.getTableName(),
312368
columns);
313369
createFeatureTable(table);
@@ -752,7 +808,7 @@ public void verifyWritable() {
752808
public TableIndexDao getTableIndexDao() {
753809
return createDao(TableIndex.class);
754810
}
755-
811+
756812
/**
757813
* {@inheritDoc}
758814
*/
@@ -773,15 +829,15 @@ public boolean createTableIndexTable() {
773829
}
774830
return created;
775831
}
776-
832+
777833
/**
778834
* {@inheritDoc}
779835
*/
780836
@Override
781837
public GeometryIndexDao getGeometryIndexDao() {
782838
return createDao(GeometryIndex.class);
783839
}
784-
840+
785841
/**
786842
* {@inheritDoc}
787843
*/
@@ -802,5 +858,5 @@ public boolean createGeometryIndexTable() {
802858
}
803859
return created;
804860
}
805-
861+
806862
}

src/main/java/mil/nga/geopackage/schema/columns/DataColumnsDao.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,4 +185,20 @@ public List<DataColumns> queryByConstraintName(String constraintName)
185185
return queryForEq(DataColumns.COLUMN_CONSTRAINT_NAME, constraintName);
186186
}
187187

188+
/**
189+
* Get DataColumn by column name and table name
190+
*
191+
* @param tableName
192+
* table name to query for
193+
* @param columnName
194+
* column name to query for
195+
* @return DataColumns
196+
* @throws SQLException
197+
*/
198+
public DataColumns getDataColumn(String tableName, String columnName)
199+
throws SQLException {
200+
TableColumnKey id = new TableColumnKey(tableName, columnName);
201+
return queryForId(id);
202+
}
203+
188204
}

0 commit comments

Comments
 (0)