Skip to content

Commit

Permalink
geodesic support for feature tile drawing and indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
bosborn committed Feb 23, 2024
1 parent 6d511d8 commit 9c6ed1a
Show file tree
Hide file tree
Showing 16 changed files with 654 additions and 50 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:https://semver.org/).
* sqlite-jdbc version 3.45.1.0
* 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, and Manual query geodesic support

## [6.6.4](https://github.com/ngageoint/geopackage-java/releases/tag/6.6.4) (11-29-2023)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,24 @@ public class FeatureTableIndex extends FeatureTableCoreIndex {
* feature dao
*/
public FeatureTableIndex(GeoPackage geoPackage, FeatureDao featureDao) {
this(geoPackage, featureDao, false);
}

/**
* Constructor
*
* @param geoPackage
* GeoPackage
* @param featureDao
* feature dao
* @param geodesic
* index using geodesic bounds
* @since 6.6.5
*/
public FeatureTableIndex(GeoPackage geoPackage, FeatureDao featureDao,
boolean geodesic) {
super(geoPackage, featureDao.getTableName(),
featureDao.getGeometryColumnName());
featureDao.getGeometryColumnName(), geodesic);
this.featureDao = featureDao;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,19 @@ public RTreeIndexExtension(GeoPackage geoPackage) {
super(geoPackage);
}

/**
* Constructor
*
* @param geoPackage
* GeoPackage
* @param geodesic
* index using geodesic bounds
* @since 6.6.5
*/
public RTreeIndexExtension(GeoPackage geoPackage, boolean geodesic) {
super(geoPackage, geodesic);
}

/**
* {@inheritDoc}
*/
Expand Down Expand Up @@ -126,6 +139,10 @@ public Object execute(GeoPackageGeometryData data) {
Object value = null;
GeometryEnvelope envelope = getEnvelope(data);
if (envelope != null) {
int srsId = data.getSrsId();
if (srsId > 0) {
envelope = geodesicEnvelope(envelope, srsId);
}
value = envelope.getMinY();
}
return value;
Expand All @@ -144,6 +161,10 @@ public Object execute(GeoPackageGeometryData data) {
Object value = null;
GeometryEnvelope envelope = getEnvelope(data);
if (envelope != null) {
int srsId = data.getSrsId();
if (srsId > 0) {
envelope = geodesicEnvelope(envelope, srsId);
}
value = envelope.getMaxY();
}
return value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ public class FeatureIndexManager {
*/
private boolean continueOnError = true;

/**
* Index geometries using geodesic lines
*/
private boolean geodesic = false;

/**
* Constructor
*
Expand All @@ -102,12 +107,46 @@ public FeatureIndexManager(GeoPackage geoPackage, String featureTable) {
* feature DAO
*/
public FeatureIndexManager(GeoPackage geoPackage, FeatureDao featureDao) {
this(geoPackage, featureDao, false);
}

/**
* Constructor
*
* @param geoPackage
* GeoPackage
* @param featureTable
* feature table
* @param geodesic
* index using geodesic bounds
* @since 6.6.5
*/
public FeatureIndexManager(GeoPackage geoPackage, String featureTable,
boolean geodesic) {
this(geoPackage, geoPackage.getFeatureDao(featureTable), geodesic);
}

/**
* Constructor
*
* @param geoPackage
* GeoPackage
* @param featureDao
* feature DAO
* @param geodesic
* index using geodesic bounds
* @since 6.6.5
*/
public FeatureIndexManager(GeoPackage geoPackage, FeatureDao featureDao,
boolean geodesic) {
this.featureDao = featureDao;
featureTableIndex = new FeatureTableIndex(geoPackage, featureDao);
RTreeIndexExtension rTreeExtension = new RTreeIndexExtension(
geoPackage);
this.geodesic = geodesic;
featureTableIndex = new FeatureTableIndex(geoPackage, featureDao,
geodesic);
RTreeIndexExtension rTreeExtension = new RTreeIndexExtension(geoPackage,
geodesic);
rTreeIndexTableDao = rTreeExtension.getTableDao(featureDao);
manualFeatureQuery = new ManualFeatureQuery(featureDao);
manualFeatureQuery = new ManualFeatureQuery(featureDao, geodesic);

// Set the default indexed check and query order
indexLocationQueryOrder.add(FeatureIndexType.RTREE);
Expand Down Expand Up @@ -189,6 +228,30 @@ public void setContinueOnError(boolean continueOnError) {
this.continueOnError = continueOnError;
}

/**
* Geometries indexed using geodesic lines
*
* @return geodesic flag
* @since 6.6.5
*/
public boolean isGeodesic() {
return geodesic;
}

/**
* Set the geodestic flag, true to index geodesic geometries
*
* @param geodesic
* index geodesic geometries flag
* @since 6.6.5
*/
public void setGeodesic(boolean geodesic) {
this.geodesic = geodesic;
featureTableIndex.setGeodesic(geodesic);
rTreeIndexTableDao.getRTreeIndexExtension().setGeodesic(geodesic);
manualFeatureQuery.setGeodesic(geodesic);
}

/**
* Prioritize the query location order. All types are placed at the front of
* the query order in the order they are given. Omitting a location leaves
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import mil.nga.proj.Projection;
import mil.nga.sf.GeometryEnvelope;
import mil.nga.sf.proj.GeometryTransform;
import mil.nga.sf.proj.ProjectionGeometryUtils;

/**
* Performs manual brute force queries against feature rows. See
Expand All @@ -35,14 +36,33 @@ public class ManualFeatureQuery {
*/
protected double tolerance = .00000000000001;

/**
* Index geometries using geodesic lines
*/
private boolean geodesic = false;

/**
* Constructor
*
* @param featureDao
* feature DAO
*/
public ManualFeatureQuery(FeatureDao featureDao) {
this(featureDao, false);
}

/**
* Constructor
*
* @param featureDao
* feature DAO
* @param geodesic
* index using geodesic bounds
* @since 6.6.5
*/
public ManualFeatureQuery(FeatureDao featureDao, boolean geodesic) {
this.featureDao = featureDao;
this.geodesic = geodesic;
}

/**
Expand Down Expand Up @@ -92,6 +112,27 @@ public void setTolerance(double tolerance) {
this.tolerance = tolerance;
}

/**
* Geometries indexed using geodesic lines
*
* @return geodesic flag
* @since 6.6.5
*/
public boolean isGeodesic() {
return geodesic;
}

/**
* Set the geodestic flag, true to index geodesic geometries
*
* @param geodesic
* index geodesic geometries flag
* @since 6.6.5
*/
public void setGeodesic(boolean geodesic) {
this.geodesic = geodesic;
}

/**
* Query for features
*
Expand Down Expand Up @@ -561,6 +602,12 @@ public BoundingBox getBoundingBox() {
.getGeometryEnvelope();
if (featureEnvelope != null) {

if (geodesic) {
featureEnvelope = ProjectionGeometryUtils
.geodesicEnvelope(featureEnvelope,
featureDao.getProjection());
}

if (envelope == null) {
envelope = featureEnvelope;
} else {
Expand Down Expand Up @@ -2144,6 +2191,11 @@ public ManualFeatureQueryResults query(boolean distinct, String[] columns,
.getGeometryEnvelope();
if (envelope != null) {

if (geodesic) {
envelope = ProjectionGeometryUtils.geodesicEnvelope(
envelope, featureDao.getProjection());
}

double minXMax = Math.max(minX, envelope.getMinX());
double maxXMin = Math.min(maxX, envelope.getMaxX());
double minYMax = Math.max(minY, envelope.getMinY());
Expand Down Expand Up @@ -3596,6 +3648,11 @@ public ManualFeatureQueryResults queryForChunk(boolean distinct,
.getGeometryEnvelope();
if (envelope != null) {

if (geodesic) {
envelope = ProjectionGeometryUtils.geodesicEnvelope(
envelope, featureDao.getProjection());
}

double minXMax = Math.max(minX, envelope.getMinX());
double maxXMin = Math.min(maxX, envelope.getMaxX());
double minYMax = Math.max(minY, envelope.getMinY());
Expand Down
Loading

0 comments on commit 9c6ed1a

Please sign in to comment.