mil.nga.geopackage.tiles.TileGrid Java Examples
The following examples show how to use
mil.nga.geopackage.tiles.TileGrid.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CoverageData.java From geopackage-android with MIT License | 6 votes |
/** * Get the tile row results of coverage data tiles needed to create the * requested bounding box coverage data, sorted by row and then column * * @param projectedRequestBoundingBox bounding box projected to the coverage data * @param tileMatrix tile matrix * @return tile results or null */ private TileCursor retrieveSortedTileResults( BoundingBox projectedRequestBoundingBox, TileMatrix tileMatrix) { TileCursor tileResults = null; if (tileMatrix != null) { // Get the tile grid TileGrid tileGrid = TileBoundingBoxUtils.getTileGrid( coverageBoundingBox, tileMatrix.getMatrixWidth(), tileMatrix.getMatrixHeight(), projectedRequestBoundingBox); // Query for matching tiles in the tile grid tileResults = tileDao.queryByTileGrid(tileGrid, tileMatrix.getZoomLevel(), TileTable.COLUMN_TILE_ROW + "," + TileTable.COLUMN_TILE_COLUMN); } return tileResults; }
Example #2
Source File: FeatureTileGenerator.java From geopackage-android with MIT License | 6 votes |
/** * {@inheritDoc} */ @Override public BoundingBox getBoundingBox(int zoom) { ProjectionTransform projectionToWebMercator = projection .getTransformation(ProjectionConstants.EPSG_WEB_MERCATOR); BoundingBox webMercatorBoundingBox = boundingBox .transform(projectionToWebMercator); TileGrid tileGrid = TileBoundingBoxUtils.getTileGrid(webMercatorBoundingBox, zoom); BoundingBox tileBoundingBox = TileBoundingBoxUtils.getWebMercatorBoundingBox( tileGrid.getMinX(), tileGrid.getMinY(), zoom); BoundingBox expandedBoundingBox = featureTiles.expandBoundingBox(webMercatorBoundingBox, tileBoundingBox); BoundingBox zoomBoundingBox = expandedBoundingBox.transform(projectionToWebMercator.getInverseTransformation()); return zoomBoundingBox; }
Example #3
Source File: TileCreator.java From geopackage-android with MIT License | 6 votes |
/** * Get the tile row results of tiles needed to draw the requested bounding box tile * * @param projectedRequestBoundingBox bounding box projected to the tiles * @param tileMatrix * @return tile cursor results or null */ private TileCursor retrieveTileResults(BoundingBox projectedRequestBoundingBox, TileMatrix tileMatrix) { TileCursor tileResults = null; if (tileMatrix != null) { // Get the tile grid TileGrid tileGrid = TileBoundingBoxUtils.getTileGrid( tileSetBoundingBox, tileMatrix.getMatrixWidth(), tileMatrix.getMatrixHeight(), projectedRequestBoundingBox); // Query for matching tiles in the tile grid tileResults = tileDao.queryByTileGrid(tileGrid, tileMatrix.getZoomLevel()); } return tileResults; }
Example #4
Source File: CoverageData.java From geopackage-java with MIT License | 6 votes |
/** * Get the tile row results of coverage data tiles needed to create the * requested bounding box coverage data, sorted by row and then column * * @param projectedRequestBoundingBox * bounding box projected to the coverage data * @param tileMatrix * tile matrix * @return tile results or null */ private TileResultSet retrieveSortedTileResults( BoundingBox projectedRequestBoundingBox, TileMatrix tileMatrix) { TileResultSet tileResults = null; if (tileMatrix != null) { // Get the tile grid TileGrid tileGrid = TileBoundingBoxUtils.getTileGrid( coverageBoundingBox, tileMatrix.getMatrixWidth(), tileMatrix.getMatrixHeight(), projectedRequestBoundingBox); // Query for matching tiles in the tile grid tileResults = tileDao.queryByTileGrid(tileGrid, tileMatrix.getZoomLevel(), TileTable.COLUMN_TILE_ROW + "," + TileTable.COLUMN_TILE_COLUMN); } return tileResults; }
Example #5
Source File: FeatureTileGenerator.java From geopackage-java with MIT License | 6 votes |
/** * {@inheritDoc} */ @Override public BoundingBox getBoundingBox(int zoom) { ProjectionTransform projectionToWebMercator = projection .getTransformation(ProjectionConstants.EPSG_WEB_MERCATOR); BoundingBox webMercatorBoundingBox = boundingBox .transform(projectionToWebMercator); TileGrid tileGrid = TileBoundingBoxUtils.getTileGrid( webMercatorBoundingBox, zoom); BoundingBox tileBoundingBox = TileBoundingBoxUtils .getWebMercatorBoundingBox(tileGrid.getMinX(), tileGrid.getMinY(), zoom); BoundingBox expandedBoundingBox = featureTiles.expandBoundingBox( webMercatorBoundingBox, tileBoundingBox); BoundingBox zoomBoundingBox = expandedBoundingBox .transform(projectionToWebMercator.getInverseTransformation()); return zoomBoundingBox; }
Example #6
Source File: FeatureOverlayQuery.java From geopackage-android-map with MIT License | 5 votes |
/** * Determine if the feature overlay is on for the provided zoom level at the location * * @param zoom zoom level * @param latLng lat lon location * @return true if on * @since 1.2.6 */ public boolean isOnAtCurrentZoom(double zoom, LatLng latLng) { Point point = new Point(latLng.longitude, latLng.latitude); TileGrid tileGrid = TileBoundingBoxUtils.getTileGridFromWGS84(point, (int) zoom); boolean on = boundedOverlay.hasTile((int) tileGrid.getMinX(), (int) tileGrid.getMinY(), (int) zoom); return on; }
Example #7
Source File: TileDao.java From geopackage-android with MIT License | 5 votes |
/** * Get the bounding box of tiles * * @param zoomLevel zoom level * @return bounding box of zoom level, or null if no tiles * @since 1.1.1 */ public BoundingBox getBoundingBox(long zoomLevel) { BoundingBox boundingBox = null; TileMatrix tileMatrix = getTileMatrix(zoomLevel); if (tileMatrix != null) { TileGrid tileGrid = queryForTileGrid(zoomLevel); if (tileGrid != null) { BoundingBox matrixSetBoundingBox = getBoundingBox(); boundingBox = TileBoundingBoxUtils.getBoundingBox( matrixSetBoundingBox, tileMatrix, tileGrid); } } return boundingBox; }
Example #8
Source File: TileDao.java From geopackage-android with MIT License | 5 votes |
/** * Query by tile grid and zoom level * * @param tileGrid tile grid * @param zoomLevel zoom level * @param orderBy order by * @return cursor from query or null if the zoom level tile ranges do not * overlap the bounding box * @since 1.3.1 */ public TileCursor queryByTileGrid(TileGrid tileGrid, long zoomLevel, String orderBy) { TileCursor tileCursor = null; if (tileGrid != null) { StringBuilder where = new StringBuilder(); where.append(buildWhere(TileTable.COLUMN_ZOOM_LEVEL, zoomLevel)); where.append(" AND "); where.append(buildWhere(TileTable.COLUMN_TILE_COLUMN, tileGrid.getMinX(), ">=")); where.append(" AND "); where.append(buildWhere(TileTable.COLUMN_TILE_COLUMN, tileGrid.getMaxX(), "<=")); where.append(" AND "); where.append(buildWhere(TileTable.COLUMN_TILE_ROW, tileGrid.getMinY(), ">=")); where.append(" AND "); where.append(buildWhere(TileTable.COLUMN_TILE_ROW, tileGrid.getMaxY(), "<=")); String[] whereArgs = buildWhereArgs(new Object[]{zoomLevel, tileGrid.getMinX(), tileGrid.getMaxX(), tileGrid.getMinY(), tileGrid.getMaxY()}); tileCursor = query(where.toString(), whereArgs, null, null, orderBy); } return tileCursor; }
Example #9
Source File: TileDao.java From geopackage-java with MIT License | 5 votes |
/** * Get the bounding box of tiles * * @param zoomLevel * zoom level * @return bounding box of zoom level, or null if no tiles * @since 1.1.1 */ public BoundingBox getBoundingBox(long zoomLevel) { BoundingBox boundingBox = null; TileMatrix tileMatrix = getTileMatrix(zoomLevel); if (tileMatrix != null) { TileGrid tileGrid = queryForTileGrid(zoomLevel); if (tileGrid != null) { BoundingBox matrixSetBoundingBox = getBoundingBox(); boundingBox = TileBoundingBoxUtils.getBoundingBox( matrixSetBoundingBox, tileMatrix, tileGrid); } } return boundingBox; }
Example #10
Source File: TileDao.java From geopackage-java with MIT License | 5 votes |
/** * Query by tile grid and zoom level * * @param tileGrid * tile grid * @param zoomLevel * zoom level * @param orderBy * order by * @return cursor from query or null if the zoom level tile ranges do not * overlap the bounding box * @since 1.2.1 */ public TileResultSet queryByTileGrid(TileGrid tileGrid, long zoomLevel, String orderBy) { TileResultSet tileCursor = null; if (tileGrid != null) { StringBuilder where = new StringBuilder(); where.append(buildWhere(TileTable.COLUMN_ZOOM_LEVEL, zoomLevel)); where.append(" AND "); where.append(buildWhere(TileTable.COLUMN_TILE_COLUMN, tileGrid.getMinX(), ">=")); where.append(" AND "); where.append(buildWhere(TileTable.COLUMN_TILE_COLUMN, tileGrid.getMaxX(), "<=")); where.append(" AND "); where.append(buildWhere(TileTable.COLUMN_TILE_ROW, tileGrid.getMinY(), ">=")); where.append(" AND "); where.append(buildWhere(TileTable.COLUMN_TILE_ROW, tileGrid.getMaxY(), "<=")); String[] whereArgs = buildWhereArgs(new Object[] { zoomLevel, tileGrid.getMinX(), tileGrid.getMaxX(), tileGrid.getMinY(), tileGrid.getMaxY() }); tileCursor = query(where.toString(), whereArgs, null, null, orderBy); } return tileCursor; }
Example #11
Source File: UrlTileGeneratorUtils.java From geopackage-java with MIT License | 4 votes |
/** * Test generating tiles * * @param tileGenerator * @throws SQLException * @throws IOException */ private static void testGenerateTiles(TileGenerator tileGenerator) throws SQLException, IOException { GeoPackage geoPackage = tileGenerator.getGeoPackage(); String tableName = tileGenerator.getTableName(); int minZoom = tileGenerator.getMinZoom(); int maxZoom = tileGenerator.getMaxZoom(); BoundingBox webMercatorBoundingBox = tileGenerator.getBoundingBox(); TestGeoPackageProgress progress = new TestGeoPackageProgress(); tileGenerator.setProgress(progress); int count = tileGenerator.generateTiles(); long expected = expectedTiles(webMercatorBoundingBox, minZoom, maxZoom); TestCase.assertEquals(expected, count); TestCase.assertEquals(expected, progress.getProgress()); TileDao tileDao = geoPackage.getTileDao(tableName); TestCase.assertEquals(expected, tileDao.count()); TestCase.assertEquals(minZoom, tileDao.getMinZoom()); TestCase.assertEquals(maxZoom, tileDao.getMaxZoom()); BoundingBox tileMatrixSetBoundingBox = tileDao.getBoundingBox(); for (int zoom = minZoom; zoom <= maxZoom; zoom++) { TileGrid expectedTileGrid = TileBoundingBoxUtils.getTileGrid( webMercatorBoundingBox, zoom); BoundingBox expectedBoundingBox = TileBoundingBoxUtils .getWebMercatorBoundingBox(expectedTileGrid, zoom); BoundingBox zoomBoundingBox = tileDao.getBoundingBox(zoom); TestCase.assertEquals(expectedBoundingBox.getMinLongitude(), zoomBoundingBox.getMinLongitude(), .000001); TestCase.assertEquals(expectedBoundingBox.getMaxLongitude(), zoomBoundingBox.getMaxLongitude(), .000001); TestCase.assertEquals(expectedBoundingBox.getMinLatitude(), zoomBoundingBox.getMinLatitude(), .000001); TestCase.assertEquals(expectedBoundingBox.getMaxLatitude(), zoomBoundingBox.getMaxLatitude(), .000001); long expectedZoomTiles = expectedTiles(webMercatorBoundingBox, zoom); TestCase.assertEquals(expectedZoomTiles, tileDao.count(zoom)); TileMatrix tileMatrix = tileDao.getTileMatrix(zoom); TileGrid tileGrid = TileBoundingBoxUtils.getTileGrid( tileMatrixSetBoundingBox, tileMatrix.getMatrixWidth(), tileMatrix.getMatrixHeight(), zoomBoundingBox); TestCase.assertTrue(tileGrid.getMinX() >= 0); TestCase.assertTrue(tileGrid.getMaxX() < tileMatrix .getMatrixWidth()); TestCase.assertTrue(tileGrid.getMinY() >= 0); TestCase.assertTrue(tileGrid.getMaxY() < tileMatrix .getMatrixHeight()); TileResultSet resultSet = tileDao.queryForTile(zoom); TestCase.assertEquals(expectedZoomTiles, resultSet.getCount()); int resultCount = 0; while (resultSet.moveToNext()) { TileRow tileRow = resultSet.getRow(); resultCount++; byte[] tileData = tileRow.getTileData(); TestCase.assertNotNull(tileData); BufferedImage image = tileRow.getTileDataImage(); TestCase.assertNotNull(image); TestCase.assertEquals(tileMatrix.getTileWidth(), image.getWidth()); TestCase.assertEquals(tileMatrix.getTileHeight(), image.getHeight()); } TestCase.assertEquals(expectedZoomTiles, resultCount); } }
Example #12
Source File: UrlTileGeneratorUtils.java From geopackage-java with MIT License | 3 votes |
/** * Expected number of XYZ tiles at zoom and bounding box * * @param webMercatorBoundingBox * @param zoom * @return */ private static long expectedTiles(BoundingBox webMercatorBoundingBox, int zoom) { TileGrid tileGrid = TileBoundingBoxUtils.getTileGrid( webMercatorBoundingBox, zoom); return tileGrid.count(); }
Example #13
Source File: FeatureOverlayQuery.java From geopackage-android-map with MIT License | 2 votes |
/** * Get the count of features in the tile at the point coordinate and zoom level * * @param point point location * @param zoom zoom level * @return count */ public long tileFeatureCount(Point point, int zoom) { TileGrid tileGrid = TileBoundingBoxUtils.getTileGridFromWGS84(point, zoom); return featureTiles.queryIndexedFeaturesCount((int) tileGrid.getMinX(), (int) tileGrid.getMinY(), zoom); }
Example #14
Source File: TileDao.java From geopackage-android with MIT License | 2 votes |
/** * Query by tile grid and zoom level * * @param tileGrid tile grid * @param zoomLevel zoom level * @return cursor from query or null if the zoom level tile ranges do not * overlap the bounding box */ public TileCursor queryByTileGrid(TileGrid tileGrid, long zoomLevel) { return queryByTileGrid(tileGrid, zoomLevel, null); }
Example #15
Source File: TileDao.java From geopackage-java with MIT License | 2 votes |
/** * Query by tile grid and zoom level * * @param tileGrid * tile grid * @param zoomLevel * zoom level * @return cursor from query or null if the zoom level tile ranges do not * overlap the bounding box */ public TileResultSet queryByTileGrid(TileGrid tileGrid, long zoomLevel) { return queryByTileGrid(tileGrid, zoomLevel, null); }