Search in sources :

Example 1 with FeatureRowData

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;
}
Also used : GeoPackageGeometryData(mil.nga.geopackage.geom.GeoPackageGeometryData) FeatureTableData(mil.nga.geopackage.tiles.overlay.FeatureTableData) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) DataColumnsDao(mil.nga.geopackage.extension.schema.columns.DataColumnsDao) Point(mil.nga.sf.Point) FeatureRowData(mil.nga.geopackage.tiles.overlay.FeatureRowData) FeatureRow(mil.nga.geopackage.features.user.FeatureRow) FeatureIndexResults(mil.nga.geopackage.features.index.FeatureIndexResults)

Aggregations

ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 DataColumnsDao (mil.nga.geopackage.extension.schema.columns.DataColumnsDao)1 FeatureIndexResults (mil.nga.geopackage.features.index.FeatureIndexResults)1 FeatureRow (mil.nga.geopackage.features.user.FeatureRow)1 GeoPackageGeometryData (mil.nga.geopackage.geom.GeoPackageGeometryData)1 FeatureRowData (mil.nga.geopackage.tiles.overlay.FeatureRowData)1 FeatureTableData (mil.nga.geopackage.tiles.overlay.FeatureTableData)1 Point (mil.nga.sf.Point)1