Skip to content

Commit

Permalink
geodesic draw and index support
Browse files Browse the repository at this point in the history
  • Loading branch information
bosborn committed Mar 19, 2024
1 parent c5cdeee commit f82ac48
Show file tree
Hide file tree
Showing 23 changed files with 754 additions and 56 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Adheres to [Semantic Versioning](http://semver.org/).
* Ignored internal databases support for non GeoPackages (preconfigured to ignore ue3.db for Google Maps)
* Get abstract User DAO by table name
* Set User Custom DAO contents
* Feature Tiles geodesic draw support
* Feature Index Manager, RTree Index, Feature Table Index, Feature Indexer, and Manual query geodesic support

## [6.7.3](https://github.com/ngageoint/geopackage-android/releases/tag/6.7.3) (11-30-2023)

Expand Down
1 change: 1 addition & 0 deletions geopackage-sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ dependencies {
api 'ar.com.hjg:pngj:2.1.0'
api 'mil.nga:tiff:3.0.0'
api 'mil.nga:sqlite-android:3440200'
//noinspection GradleDependency
javadocDeps 'com.j256.ormlite:ormlite-android:6.1',
'mil.nga.geopackage:geopackage-core:6.6.7',
'ar.com.hjg:pngj:2.1.0',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,32 @@ public FeatureIndexerTest() {
*/
@Test
public void testIndexer() throws SQLException {
testIndexer(false);
}

/**
* Test indexer
*
* @throws java.sql.SQLException
*/
@Test
public void testIndexerGeodesic() throws SQLException {
testIndexer(true);
}

/**
* Test indexer
*
* @param geodesic index using geodesic bounds
* @throws java.sql.SQLException
*/
private void testIndexer(boolean geodesic) throws SQLException {

FeatureDao featureDao = FeatureTileUtils.createFeatureDao(geoPackage);

int initialFeatures = FeatureTileUtils.insertFeatures(geoPackage, featureDao);

FeatureIndexer indexer = new FeatureIndexer(activity, featureDao);
FeatureIndexer indexer = new FeatureIndexer(activity, featureDao, geodesic);

GeoPackageMetadataDb db = new GeoPackageMetadataDb(activity);
db.open();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,20 @@ public FeatureTableIndexCreateTest() {
@Test
public void testIndex() throws Exception {

FeatureTableIndexUtils.testIndex(geoPackage);
FeatureTableIndexUtils.testIndex(geoPackage, false);

}

/**
* Test index
*
* @throws Exception
* upon error
*/
@Test
public void testIndexGeodesic() throws Exception {

FeatureTableIndexUtils.testIndex(geoPackage, true);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,20 @@ public FeatureTableIndexExternalTest() {
@Test
public void testIndex() throws Exception {

FeatureTableIndexUtils.testIndex(geoPackage);
FeatureTableIndexUtils.testIndex(geoPackage, false);

}

/**
* Test index
*
* @throws Exception
* upon error
*/
@Test
public void testIndexGeodesic() throws Exception {

FeatureTableIndexUtils.testIndex(geoPackage, true);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,20 @@ public FeatureTableIndexImportTest() {
@Test
public void testIndex() throws Exception {

FeatureTableIndexUtils.testIndex(geoPackage);
FeatureTableIndexUtils.testIndex(geoPackage, false);

}

/**
* Test index
*
* @throws Exception
* upon error
*/
@Test
public void testIndexGeodesic() throws Exception {

FeatureTableIndexUtils.testIndex(geoPackage, true);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import mil.nga.proj.ProjectionTransform;
import mil.nga.sf.GeometryEnvelope;
import mil.nga.sf.Point;
import mil.nga.sf.proj.ProjectionGeometryUtils;
import mil.nga.sf.util.GeometryEnvelopeBuilder;

/**
Expand All @@ -37,18 +38,19 @@ public class FeatureTableIndexUtils {
/**
* Test read
*
* @param geoPackage
* @param geoPackage GeoPackage
* @param geodesic index using geodesic bounds
* @throws Exception
*/
public static void testIndex(GeoPackage geoPackage) throws Exception {
public static void testIndex(GeoPackage geoPackage, boolean geodesic) throws Exception {

// Test indexing each feature table
List<String> featureTables = geoPackage.getFeatureTables();
for (String featureTable : featureTables) {

FeatureDao featureDao = geoPackage.getFeatureDao(featureTable);
FeatureTableIndex featureTableIndex = new FeatureTableIndex(
geoPackage, featureDao);
geoPackage, featureDao, geodesic);

// Determine how many features have geometry envelopes or geometries
int expectedCount = 0;
Expand Down Expand Up @@ -107,7 +109,8 @@ public static void testIndex(GeoPackage geoPackage) throws Exception {
.query();
while (featureTableResults.hasNext()) {
GeometryIndex geometryIndex = featureTableResults.next();
validateGeometryIndex(featureTableIndex, geometryIndex);
validateGeometryIndex(featureTableIndex, geometryIndex,
geodesic);
resultCount++;
}
featureTableResults.close();
Expand All @@ -133,7 +136,8 @@ public static void testIndex(GeoPackage geoPackage) throws Exception {
featureTableResults = featureTableIndex.query(envelope);
while (featureTableResults.hasNext()) {
GeometryIndex geometryIndex = featureTableResults.next();
validateGeometryIndex(featureTableIndex, geometryIndex);
validateGeometryIndex(featureTableIndex, geometryIndex,
geodesic);
if (geometryIndex.getGeomId() == testFeatureRow.getId()) {
featureFound = true;
}
Expand Down Expand Up @@ -170,7 +174,8 @@ public static void testIndex(GeoPackage geoPackage) throws Exception {
transformedBoundingBox, projection);
while (featureTableResults.hasNext()) {
GeometryIndex geometryIndex = featureTableResults.next();
validateGeometryIndex(featureTableIndex, geometryIndex);
validateGeometryIndex(featureTableIndex, geometryIndex,
geodesic);
if (geometryIndex.getGeomId() == testFeatureRow.getId()) {
featureFound = true;
}
Expand Down Expand Up @@ -199,7 +204,8 @@ public static void testIndex(GeoPackage geoPackage) throws Exception {
featureTableResults = featureTableIndex.query(envelope);
while (featureTableResults.hasNext()) {
GeometryIndex geometryIndex = featureTableResults.next();
validateGeometryIndex(featureTableIndex, geometryIndex);
validateGeometryIndex(featureTableIndex, geometryIndex,
geodesic);
if (geometryIndex.getGeomId() == testFeatureRow.getId()) {
featureFound = true;
}
Expand Down Expand Up @@ -353,13 +359,18 @@ public static void testDeleteAll(GeoPackage geoPackage) throws SQLException {
* @param geometryIndex
*/
private static void validateGeometryIndex(
FeatureTableIndex featureTableIndex, GeometryIndex geometryIndex) {
FeatureTableIndex featureTableIndex, GeometryIndex geometryIndex,
boolean geodesic) {
FeatureRow featureRow = featureTableIndex.getFeatureRow(geometryIndex);
TestCase.assertNotNull(featureRow);
TestCase.assertEquals(featureTableIndex.getTableName(),
geometryIndex.getTableName());
TestCase.assertEquals(geometryIndex.getGeomId(), featureRow.getId());
GeometryEnvelope envelope = featureRow.getGeometryEnvelope();
if (geodesic) {
envelope = ProjectionGeometryUtils.geodesicEnvelope(envelope,
featureTableIndex.getProjection());
}

TestCase.assertNotNull(envelope);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,20 @@ public RTreeIndexExtensionCreateTest() {
@Test
public void testRTree() throws SQLException {

RTreeIndexExtensionUtils.testRTree(geoPackage);
RTreeIndexExtensionUtils.testRTree(geoPackage, false);

}

/**
* Test RTree with geodesic
*
* @throws SQLException
* upon error
*/
@Test
public void testRTreeGeodesic() throws SQLException {

RTreeIndexExtensionUtils.testRTree(geoPackage, true);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,20 @@ public RTreeIndexExtensionExternalTest() {
@Test
public void testRTree() throws SQLException {

RTreeIndexExtensionUtils.testRTree(geoPackage);
RTreeIndexExtensionUtils.testRTree(geoPackage, false);

}

/**
* Test RTree with geodesic
*
* @throws SQLException
* upon error
*/
@Test
public void testRTreeGeodesic() throws SQLException {

RTreeIndexExtensionUtils.testRTree(geoPackage, true);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,20 @@ public RTreeIndexExtensionImportTest() {
@Test
public void testRTree() throws SQLException {

RTreeIndexExtensionUtils.testRTree(geoPackage);
RTreeIndexExtensionUtils.testRTree(geoPackage, false);

}

/**
* Test RTree with geodesic
*
* @throws SQLException
* upon error
*/
@Test
public void testRTreeGeodesic() throws SQLException {

RTreeIndexExtensionUtils.testRTree(geoPackage, true);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ public class RTreeIndexExtensionUtils {
* Test RTree
*
* @param geoPackage GeoPackage
* @param geodesic index using geodesic bounds
* @throws SQLException upon error
*/
public static void testRTree(GeoPackage geoPackage) throws SQLException {
public static void testRTree(GeoPackage geoPackage, boolean geodesic) throws SQLException {

RTreeIndexExtension extension = new RTreeIndexExtension(geoPackage);
RTreeIndexExtension extension = new RTreeIndexExtension(geoPackage,
geodesic);

List<String> featureTables = geoPackage.getFeatureTables();
for (String featureTable : featureTables) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void testOpenData1h() throws SQLException {
}

/**
* Test flurstueck
* Test lakes
*
* @throws SQLException upon failure
*/
Expand Down Expand Up @@ -82,7 +82,7 @@ public void testRakennus() throws SQLException {
}

/**
* Test mage
* Test MAGE
*
* @throws SQLException upon failure
*/
Expand Down
Loading

0 comments on commit f82ac48

Please sign in to comment.