Java Code Examples for mil.nga.geopackage.tiles.matrix.TileMatrixDao#query()
The following examples show how to use
mil.nga.geopackage.tiles.matrix.TileMatrixDao#query() .
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: GeoPackageImpl.java From geopackage-android with MIT License | 4 votes |
/** * {@inheritDoc} */ @Override public TileDao getTileDao(TileMatrixSet tileMatrixSet) { if (tileMatrixSet == null) { throw new GeoPackageException("Non null " + TileMatrixSet.class.getSimpleName() + " is required to create " + TileDao.class.getSimpleName()); } // Get the Tile Matrix collection, order by zoom level ascending & pixel // size descending per requirement 51 List<TileMatrix> tileMatrices; try { TileMatrixDao tileMatrixDao = getTileMatrixDao(); QueryBuilder<TileMatrix, TileMatrixKey> qb = tileMatrixDao .queryBuilder(); qb.where().eq(TileMatrix.COLUMN_TABLE_NAME, tileMatrixSet.getTableName()); qb.orderBy(TileMatrix.COLUMN_ZOOM_LEVEL, true); qb.orderBy(TileMatrix.COLUMN_PIXEL_X_SIZE, false); qb.orderBy(TileMatrix.COLUMN_PIXEL_Y_SIZE, false); PreparedQuery<TileMatrix> query = qb.prepare(); tileMatrices = tileMatrixDao.query(query); } catch (SQLException e) { throw new GeoPackageException("Failed to retrieve " + TileDao.class.getSimpleName() + " for table name: " + tileMatrixSet.getTableName() + ". Exception retrieving " + TileMatrix.class.getSimpleName() + " collection.", e); } // Read the existing table and create the dao TileTableReader tableReader = new TileTableReader( tileMatrixSet.getTableName()); final TileTable tileTable = tableReader.readTable(database); tileTable.setContents(tileMatrixSet.getContents()); TileDao dao = new TileDao(getName(), database, tileMatrixSet, tileMatrices, tileTable); // Register the table name (with and without quotes) to wrap cursors with the tile cursor registerCursorWrapper(tileMatrixSet.getTableName(), new GeoPackageCursorWrapper() { @Override public Cursor wrapCursor(Cursor cursor) { return new TileCursor(tileTable, cursor); } }); return dao; }
Example 2
Source File: TileMatrixUtils.java From geopackage-android with MIT License | 4 votes |
/** * Test delete * * @param geoPackage * @throws SQLException */ public static void testDelete(GeoPackage geoPackage) throws SQLException { TileMatrixDao dao = geoPackage.getTileMatrixDao(); if (dao.isTableExists()) { List<TileMatrix> results = dao.queryForAll(); if (!results.isEmpty()) { // Choose random tile matrix int random = (int) (Math.random() * results.size()); TileMatrix tileMatrix = results.get(random); // Delete the tile matrix dao.delete(tileMatrix); // Verify deleted TileMatrix queryTileMatrix = dao.queryForId(tileMatrix.getId()); TestCase.assertNull(queryTileMatrix); // Prepared deleted results = dao.queryForAll(); if (!results.isEmpty()) { // Choose random tile matrix random = (int) (Math.random() * results.size()); tileMatrix = results.get(random); // Find which tile matrix to delete QueryBuilder<TileMatrix, TileMatrixKey> qb = dao .queryBuilder(); qb.where().eq(TileMatrix.COLUMN_ZOOM_LEVEL, tileMatrix.getZoomLevel()); PreparedQuery<TileMatrix> query = qb.prepare(); List<TileMatrix> queryResults = dao.query(query); int count = queryResults.size(); // Delete DeleteBuilder<TileMatrix, TileMatrixKey> db = dao .deleteBuilder(); db.where().eq(TileMatrix.COLUMN_ZOOM_LEVEL, tileMatrix.getZoomLevel()); PreparedDelete<TileMatrix> deleteQuery = db.prepare(); int deleted = dao.delete(deleteQuery); TestCase.assertEquals(count, deleted); } } } }
Example 3
Source File: GeoPackageImpl.java From geopackage-java with MIT License | 4 votes |
/** * {@inheritDoc} */ @Override public TileDao getTileDao(TileMatrixSet tileMatrixSet) { if (tileMatrixSet == null) { throw new GeoPackageException( "Non null " + TileMatrixSet.class.getSimpleName() + " is required to create " + TileDao.class.getSimpleName()); } // Get the Tile Matrix collection, order by zoom level ascending & pixel // size descending per requirement 51 List<TileMatrix> tileMatrices; try { TileMatrixDao tileMatrixDao = getTileMatrixDao(); QueryBuilder<TileMatrix, TileMatrixKey> qb = tileMatrixDao .queryBuilder(); qb.where().eq(TileMatrix.COLUMN_TABLE_NAME, tileMatrixSet.getTableName()); qb.orderBy(TileMatrix.COLUMN_ZOOM_LEVEL, true); qb.orderBy(TileMatrix.COLUMN_PIXEL_X_SIZE, false); qb.orderBy(TileMatrix.COLUMN_PIXEL_Y_SIZE, false); PreparedQuery<TileMatrix> query = qb.prepare(); tileMatrices = tileMatrixDao.query(query); } catch (SQLException e) { throw new GeoPackageException( "Failed to retrieve " + TileDao.class.getSimpleName() + " for table name: " + tileMatrixSet.getTableName() + ". Exception retrieving " + TileMatrix.class.getSimpleName() + " collection.", e); } // Read the existing table and create the dao TileTableReader tableReader = new TileTableReader( tileMatrixSet.getTableName()); final TileTable tileTable = tableReader.readTable(database); tileTable.setContents(tileMatrixSet.getContents()); TileDao dao = new TileDao(getName(), database, tileMatrixSet, tileMatrices, tileTable); return dao; }
Example 4
Source File: TileMatrixUtils.java From geopackage-java with MIT License | 4 votes |
/** * Test delete * * @param geoPackage * @throws SQLException */ public static void testDelete(GeoPackage geoPackage) throws SQLException { TileMatrixDao dao = geoPackage.getTileMatrixDao(); if (dao.isTableExists()) { List<TileMatrix> results = dao.queryForAll(); if (!results.isEmpty()) { // Choose random tile matrix int random = (int) (Math.random() * results.size()); TileMatrix tileMatrix = results.get(random); // Delete the tile matrix dao.delete(tileMatrix); // Verify deleted TileMatrix queryTileMatrix = dao.queryForId(tileMatrix.getId()); TestCase.assertNull(queryTileMatrix); // Prepared deleted results = dao.queryForAll(); if (!results.isEmpty()) { // Choose random tile matrix random = (int) (Math.random() * results.size()); tileMatrix = results.get(random); // Find which tile matrix to delete QueryBuilder<TileMatrix, TileMatrixKey> qb = dao .queryBuilder(); qb.where().eq(TileMatrix.COLUMN_ZOOM_LEVEL, tileMatrix.getZoomLevel()); PreparedQuery<TileMatrix> query = qb.prepare(); List<TileMatrix> queryResults = dao.query(query); int count = queryResults.size(); // Delete DeleteBuilder<TileMatrix, TileMatrixKey> db = dao .deleteBuilder(); db.where().eq(TileMatrix.COLUMN_ZOOM_LEVEL, tileMatrix.getZoomLevel()); PreparedDelete<TileMatrix> deleteQuery = db.prepare(); int deleted = dao.delete(deleteQuery); TestCase.assertEquals(count, deleted); } } } }