Java Code Examples for mil.nga.geopackage.tiles.matrixset.TileMatrixSetDao#queryForAll()
The following examples show how to use
mil.nga.geopackage.tiles.matrixset.TileMatrixSetDao#queryForAll() .
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: TileUtils.java From geopackage-java with MIT License | 5 votes |
/** * Test delete * * @param geoPackage * GeoPackage * @throws SQLException * upon error */ public static void testDelete(GeoPackage geoPackage) throws SQLException { TileMatrixSetDao tileMatrixSetDao = geoPackage.getTileMatrixSetDao(); if (tileMatrixSetDao.isTableExists()) { List<TileMatrixSet> results = tileMatrixSetDao.queryForAll(); for (TileMatrixSet tileMatrixSet : results) { TileDao dao = geoPackage.getTileDao(tileMatrixSet); TestCase.assertNotNull(dao); TileResultSet cursor = dao.queryForAll(); int count = cursor.getCount(); if (count > 0) { // Choose random tile int random = (int) (Math.random() * count); cursor.moveToPosition(random); TileRow tileRow = cursor.getRow(); cursor.close(); // Delete row TestCase.assertEquals(1, dao.delete(tileRow)); // Verify deleted TileRow queryTileRow = dao.queryForIdRow(tileRow.getId()); TestCase.assertNull(queryTileRow); cursor = dao.queryForAll(); TestCase.assertEquals(count - 1, cursor.getCount()); cursor.close(); } cursor.close(); } } }
Example 2
Source File: TileMatrixSetUtils.java From geopackage-android with MIT License | 4 votes |
/** * Test delete * * @param geoPackage * @throws SQLException */ public static void testDelete(GeoPackage geoPackage) throws SQLException { TileMatrixSetDao dao = geoPackage.getTileMatrixSetDao(); if (dao.isTableExists()) { List<TileMatrixSet> results = dao.queryForAll(); if (!results.isEmpty()) { // Choose random tile matrix set int random = (int) (Math.random() * results.size()); TileMatrixSet tileMatrixSet = results.get(random); // Delete the tile matrix set geoPackage.foreignKeys(false); dao.delete(tileMatrixSet); // Verify deleted TileMatrixSet queryTileMatrixSet = dao.queryForId(tileMatrixSet .getId()); TestCase.assertNull(queryTileMatrixSet); // Prepared deleted results = dao.queryForAll(); if (!results.isEmpty()) { // Choose random tile matrix set random = (int) (Math.random() * results.size()); tileMatrixSet = results.get(random); // Find which tile matrix set to delete QueryBuilder<TileMatrixSet, String> qb = dao.queryBuilder(); qb.where().eq(TileMatrixSet.COLUMN_SRS_ID, tileMatrixSet.getSrsId()); PreparedQuery<TileMatrixSet> query = qb.prepare(); List<TileMatrixSet> queryResults = dao.query(query); int count = queryResults.size(); // Delete DeleteBuilder<TileMatrixSet, String> db = dao .deleteBuilder(); db.where().eq(TileMatrixSet.COLUMN_SRS_ID, tileMatrixSet.getSrsId()); PreparedDelete<TileMatrixSet> deleteQuery = db.prepare(); int deleted = dao.delete(deleteQuery); TestCase.assertEquals(count, deleted); } } } }
Example 3
Source File: TileUtils.java From geopackage-android with MIT License | 4 votes |
/** * Test update * * @param testContext test context * @param geoPackage GeoPackage * @throws SQLException upon error * @throws IOException upon error */ public static void testUpdate(Context testContext, GeoPackage geoPackage) throws SQLException, IOException { TileMatrixSetDao tileMatrixSetDao = geoPackage.getTileMatrixSetDao(); if (tileMatrixSetDao.isTableExists()) { List<TileMatrixSet> results = tileMatrixSetDao.queryForAll(); for (TileMatrixSet tileMatrixSet : results) { TileDao dao = geoPackage.getTileDao(tileMatrixSet); testUpdate(testContext, dao); } } }
Example 4
Source File: TileUtils.java From geopackage-android with MIT License | 4 votes |
/** * Test delete * * @param geoPackage GeoPackage * @throws SQLException upon error */ public static void testDelete(GeoPackage geoPackage) throws SQLException { TileMatrixSetDao tileMatrixSetDao = geoPackage.getTileMatrixSetDao(); if (tileMatrixSetDao.isTableExists()) { List<TileMatrixSet> results = tileMatrixSetDao.queryForAll(); for (TileMatrixSet tileMatrixSet : results) { TileDao dao = geoPackage.getTileDao(tileMatrixSet); TestCase.assertNotNull(dao); TileCursor cursor = dao.queryForAll(); int count = cursor.getCount(); if (count > 0) { // Choose random tile int random = (int) (Math.random() * count); cursor.moveToPosition(random); TileRow tileRow = cursor.getRow(); cursor.close(); // Delete row try { TestCase.assertEquals(1, dao.delete(tileRow)); } catch (SQLiteException e) { if (TestUtils.isFutureSQLiteException(e)) { continue; } else { throw e; } } // Verify deleted TileRow queryTileRow = dao.queryForIdRow(tileRow.getId()); TestCase.assertNull(queryTileRow); cursor = dao.queryForAll(); TestCase.assertEquals(count - 1, cursor.getCount()); cursor.close(); } cursor.close(); } } }
Example 5
Source File: TileMatrixSetUtils.java From geopackage-java with MIT License | 4 votes |
/** * Test delete * * @param geoPackage * @throws SQLException */ public static void testDelete(GeoPackage geoPackage) throws SQLException { TileMatrixSetDao dao = geoPackage.getTileMatrixSetDao(); if (dao.isTableExists()) { List<TileMatrixSet> results = dao.queryForAll(); if (!results.isEmpty()) { // Choose random tile matrix set int random = (int) (Math.random() * results.size()); TileMatrixSet tileMatrixSet = results.get(random); // Delete the tile matrix set geoPackage.foreignKeys(false); dao.delete(tileMatrixSet); // Verify deleted TileMatrixSet queryTileMatrixSet = dao.queryForId(tileMatrixSet .getId()); TestCase.assertNull(queryTileMatrixSet); // Prepared deleted results = dao.queryForAll(); if (!results.isEmpty()) { // Choose random tile matrix set random = (int) (Math.random() * results.size()); tileMatrixSet = results.get(random); // Find which tile matrix set to delete QueryBuilder<TileMatrixSet, String> qb = dao.queryBuilder(); qb.where().eq(TileMatrixSet.COLUMN_SRS_ID, tileMatrixSet.getSrsId()); PreparedQuery<TileMatrixSet> query = qb.prepare(); List<TileMatrixSet> queryResults = dao.query(query); int count = queryResults.size(); // Delete DeleteBuilder<TileMatrixSet, String> db = dao .deleteBuilder(); db.where().eq(TileMatrixSet.COLUMN_SRS_ID, tileMatrixSet.getSrsId()); PreparedDelete<TileMatrixSet> deleteQuery = db.prepare(); int deleted = dao.delete(deleteQuery); TestCase.assertEquals(count, deleted); } } } }
Example 6
Source File: TileUtils.java From geopackage-java with MIT License | 4 votes |
/** * Test update * * @param geoPackage * GeoPackage * @throws SQLException * upon error * @throws IOException * upon error */ public static void testUpdate(GeoPackage geoPackage) throws SQLException, IOException { TileMatrixSetDao tileMatrixSetDao = geoPackage.getTileMatrixSetDao(); if (tileMatrixSetDao.isTableExists()) { List<TileMatrixSet> results = tileMatrixSetDao.queryForAll(); for (TileMatrixSet tileMatrixSet : results) { TileDao dao = geoPackage.getTileDao(tileMatrixSet); testUpdate(dao); } } }
Example 7
Source File: GeoPackageOverlayUtils.java From geopackage-android-map with MIT License | 3 votes |
/** * Test overlay * * @param geoPackage * @throws SQLException */ public static void testOverlay(GeoPackage geoPackage) throws SQLException { TileMatrixSetDao tileMatrixSetDao = geoPackage.getTileMatrixSetDao(); if (tileMatrixSetDao.isTableExists()) { List<TileMatrixSet> results = tileMatrixSetDao.queryForAll(); for (TileMatrixSet tileMatrixSet : results) { TileDao dao = geoPackage.getTileDao(tileMatrixSet); GeoPackageOverlay overlay = new GeoPackageOverlay(dao); for (int zoom = 0; zoom <= 21; zoom++) { int tileLength = (int) Math.pow(2, zoom); int column = (int) (Math.random() * tileLength); int row = (int) (Math.random() * tileLength); for (int maxColumns = Math.min(tileLength, column + 2); column < maxColumns; column++) { for (int maxRows = Math.min(tileLength, row + 2); row < maxRows; row++) { Tile tile = overlay.getTile(column, row, zoom); if (tile != null) { TestCase.assertTrue(tile.height > 0); TestCase.assertTrue(tile.width > 0); } } } } } } }
Example 8
Source File: TileUtils.java From geopackage-android with MIT License | 2 votes |
/** * Test getZoomLevel * * @param geoPackage GeoPackage * @throws SQLException upon error */ public static void testGetZoomLevel(GeoPackage geoPackage) throws SQLException { TileMatrixSetDao tileMatrixSetDao = geoPackage.getTileMatrixSetDao(); if (tileMatrixSetDao.isTableExists()) { List<TileMatrixSet> results = tileMatrixSetDao.queryForAll(); for (TileMatrixSet tileMatrixSet : results) { TileDao dao = geoPackage.getTileDao(tileMatrixSet); List<TileMatrix> tileMatrices = dao.getTileMatrices(); for (TileMatrix tileMatrix : tileMatrices) { double width = tileMatrix.getPixelXSize() * tileMatrix.getTileWidth(); double height = tileMatrix.getPixelYSize() * tileMatrix.getTileHeight(); long zoomLevel = dao.getZoomLevel(width); TestCase.assertEquals(tileMatrix.getZoomLevel(), zoomLevel); zoomLevel = dao.getZoomLevel(width, height); TestCase.assertEquals(tileMatrix.getZoomLevel(), zoomLevel); zoomLevel = dao.getZoomLevel(width + 1); TestCase.assertEquals(tileMatrix.getZoomLevel(), zoomLevel); zoomLevel = dao.getZoomLevel(width + 1, height + 1); TestCase.assertEquals(tileMatrix.getZoomLevel(), zoomLevel); zoomLevel = dao.getZoomLevel(width - 1); TestCase.assertEquals(tileMatrix.getZoomLevel(), zoomLevel); zoomLevel = dao.getZoomLevel(width - 1, height - 1); TestCase.assertEquals(tileMatrix.getZoomLevel(), zoomLevel); } } } }
Example 9
Source File: TileUtils.java From geopackage-java with MIT License | 2 votes |
/** * Test getZoomLevel * * @param geoPackage * GeoPackage * @throws SQLException * upon error */ public static void testGetZoomLevel(GeoPackage geoPackage) throws SQLException { TileMatrixSetDao tileMatrixSetDao = geoPackage.getTileMatrixSetDao(); if (tileMatrixSetDao.isTableExists()) { List<TileMatrixSet> results = tileMatrixSetDao.queryForAll(); for (TileMatrixSet tileMatrixSet : results) { TileDao dao = geoPackage.getTileDao(tileMatrixSet); List<TileMatrix> tileMatrices = dao.getTileMatrices(); for (TileMatrix tileMatrix : tileMatrices) { double width = tileMatrix.getPixelXSize() * tileMatrix.getTileWidth(); double height = tileMatrix.getPixelYSize() * tileMatrix.getTileHeight(); long zoomLevel = dao.getZoomLevel(width); TestCase.assertEquals(tileMatrix.getZoomLevel(), zoomLevel); zoomLevel = dao.getZoomLevel(width, height); TestCase.assertEquals(tileMatrix.getZoomLevel(), zoomLevel); zoomLevel = dao.getZoomLevel(width + 1); TestCase.assertEquals(tileMatrix.getZoomLevel(), zoomLevel); zoomLevel = dao.getZoomLevel(width + 1, height + 1); TestCase.assertEquals(tileMatrix.getZoomLevel(), zoomLevel); zoomLevel = dao.getZoomLevel(width - 1); TestCase.assertEquals(tileMatrix.getZoomLevel(), zoomLevel); zoomLevel = dao.getZoomLevel(width - 1, height - 1); TestCase.assertEquals(tileMatrix.getZoomLevel(), zoomLevel); } } } }