Search in sources :

Example 1 with FeatureTableData

use of mil.nga.geopackage.tiles.overlay.FeatureTableData 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)

Example 2 with FeatureTableData

use of mil.nga.geopackage.tiles.overlay.FeatureTableData in project geopackage-android-map by ngageoint.

the class FeatureOverlayQuery method buildMapClickTableData.

/**
 * Perform a query based upon the map click location and build feature table data
 *
 * @param latLng     location
 * @param view       view
 * @param map        Google Map
 * @param projection desired geometry projection
 * @return table data on what was clicked, or null
 * @since 1.2.7
 */
public FeatureTableData buildMapClickTableData(LatLng latLng, View view, GoogleMap map, Projection projection) {
    // Get the zoom level
    double zoom = MapUtils.getCurrentZoom(map);
    // Build a bounding box to represent the click location
    BoundingBox boundingBox = MapUtils.buildClickBoundingBox(latLng, view, map, screenClickPercentage);
    // Get the map click distance tolerance
    double tolerance = MapUtils.getToleranceDistance(latLng, view, map, screenClickPercentage);
    FeatureTableData tableData = buildMapClickTableData(latLng, zoom, boundingBox, tolerance, projection);
    return tableData;
}
Also used : FeatureTableData(mil.nga.geopackage.tiles.overlay.FeatureTableData) BoundingBox(mil.nga.geopackage.BoundingBox)

Example 3 with FeatureTableData

use of mil.nga.geopackage.tiles.overlay.FeatureTableData in project geopackage-android-map by ngageoint.

the class FeatureOverlayQuery method buildMapClickTableDataWithMapBounds.

/**
 * Perform a query based upon the map click location and build feature table data
 *
 * @param latLng     location
 * @param zoom       current zoom level
 * @param mapBounds  map view bounds
 * @param tolerance  distance tolerance
 * @param projection desired geometry projection
 * @return table data on what was clicked, or null
 * @since 2.0.0
 */
public FeatureTableData buildMapClickTableDataWithMapBounds(LatLng latLng, double zoom, BoundingBox mapBounds, double tolerance, Projection projection) {
    // Build a bounding box to represent the click location
    BoundingBox boundingBox = buildClickBoundingBox(latLng, mapBounds);
    FeatureTableData tableData = buildMapClickTableData(latLng, zoom, boundingBox, tolerance, projection);
    return tableData;
}
Also used : FeatureTableData(mil.nga.geopackage.tiles.overlay.FeatureTableData) BoundingBox(mil.nga.geopackage.BoundingBox)

Aggregations

FeatureTableData (mil.nga.geopackage.tiles.overlay.FeatureTableData)3 BoundingBox (mil.nga.geopackage.BoundingBox)2 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 Point (mil.nga.sf.Point)1