use of mil.nga.geopackage.tiles.overlay.FeatureRowData in project geopackage-android-map by ngageoint.
the class FeatureInfoBuilder method buildTableDataAndClose.
/**
* Build a feature results information message
*
* @param results feature index results
* @param tolerance distance tolerance
* @param clickLocation map click location
* @param projection desired geometry projection
* @return feature table data or null if not results
*/
public FeatureTableData buildTableDataAndClose(FeatureIndexResults results, double tolerance, LatLng clickLocation, Projection projection) {
FeatureTableData tableData = null;
// Fine filter results so that the click location is within the tolerance of each feature row result
FeatureIndexResults filteredResults = fineFilterResults(results, tolerance, clickLocation);
long featureCount = filteredResults.count();
if (featureCount > 0) {
int maxFeatureInfo = 0;
if (geometryType == GeometryType.POINT) {
maxFeatureInfo = maxPointDetailedInfo;
} else {
maxFeatureInfo = maxFeatureDetailedInfo;
}
if (featureCount <= maxFeatureInfo) {
DataColumnsDao dataColumnsDao = getDataColumnsDao();
List<FeatureRowData> rows = new ArrayList<>();
for (FeatureRow featureRow : filteredResults) {
Map<String, Object> values = new HashMap<>();
String geometryColumnName = null;
int geometryColumn = featureRow.getGeometryColumnIndex();
for (int i = 0; i < featureRow.columnCount(); i++) {
Object value = featureRow.getValue(i);
String columnName = featureRow.getColumnName(i);
columnName = getColumnName(dataColumnsDao, featureRow, columnName);
if (i == geometryColumn) {
geometryColumnName = columnName;
if (projection != null && value != null) {
GeoPackageGeometryData geomData = (GeoPackageGeometryData) value;
projectGeometry(geomData, projection);
}
}
if (value != null) {
values.put(columnName, value);
}
}
FeatureRowData featureRowData = new FeatureRowData(values, geometryColumnName);
rows.add(featureRowData);
}
tableData = new FeatureTableData(featureDao.getTableName(), featureCount, rows);
} else {
tableData = new FeatureTableData(featureDao.getTableName(), featureCount);
}
}
results.close();
return tableData;
}
Aggregations