Closed sunshine0576 closed 4 years ago
spatialIndexClause=String.format("ROWID IN (SELECT $s FROM %s WHERE xmin < %s AND xmax > %s AND ymin < %s AND ymax > %s)", indexId,indexTable,minX,maxX,minY,maxY);
The bounds of the features are not stored in the geometry columns table or the feature table. To query on bounds, an index is needed. The best way to query the feature table is to use the FeatureIndexManager. The default query order based upon first indexed type found: RTree, GeoPackage Index, Metadata Index, Manual. The results can be used to iterate through the Features, in the most efficient way for each index type. The FeatureIndexManager can also be used to index the table, however RTree in Android is currently read only.
String featureTable = ...
BoundingBox boundingBox = ...
Projection projection = ...
FeatureDao featureDao = geoPackage.getFeatureDao(featureTable);
FeatureIndexManager featureIndexManager = new FeatureIndexManager(activity,
geoPackage, featureDao);
// Or shortcut...
// FeatureIndexManager featureIndexManager = new FeatureIndexManager(activity,
geoPackage, featureTable);
FeatureIndexResults featureIndexResults = featureIndexManager.query(
boundingBox, projection);
// Or query(), query(BoundingBox), query(GeometryEnvelope)
for (FeatureRow featureRow : featureIndexResults) {
// ...
}
featureIndexResults.close();
@bosborn You don't understand what I'm trying to say. select * from 【FeatureTable】where rowid in ( select rowid from 【IndexTable】 where xmin < %s AND xmax > %s AND ymin < %s AND ymax > %s )
If additional field queries are required in addition to range queries, I just need to solve the problem through an SQL statement. where =box_query+"and"+where;
The current query method is divided into two parts. First, the index is queried, and then the data is retrieved according to ID. If there are additional supplementary queries, each data need to be judged.