Java Code Examples for mil.nga.geopackage.tiles.matrixset.TileMatrixSetDao#isTableExists()
The following examples show how to use
mil.nga.geopackage.tiles.matrixset.TileMatrixSetDao#isTableExists() .
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: GeoPackageCoreImpl.java From geopackage-core-java with MIT License | 6 votes |
/** * {@inheritDoc} */ @Override public boolean createTileMatrixSetTable() { verifyWritable(); boolean created = false; TileMatrixSetDao dao = getTileMatrixSetDao(); try { if (!dao.isTableExists()) { created = tableCreator.createTileMatrixSet() > 0; } } catch (SQLException e) { throw new GeoPackageException( "Failed to check if " + TileMatrixSet.class.getSimpleName() + " table exists and create it", e); } return created; }
Example 2
Source File: ContentsDao.java From geopackage-core-java with MIT License | 6 votes |
/** * Verify the required tile tables exist * * @param dataType * data type * @throws SQLException * upon tiles verification error */ private void verifyTiles(ContentsDataType dataType) throws SQLException { // Tiles require Tile Matrix Set table (Spec Requirement 37) TileMatrixSetDao tileMatrixSetDao = getTileMatrixSetDao(); if (!tileMatrixSetDao.isTableExists()) { throw new GeoPackageException("A data type of " + dataType.getName() + " requires the " + TileMatrixSet.class.getSimpleName() + " table to first be created using the GeoPackage."); } // Tiles require Tile Matrix table (Spec Requirement 41) TileMatrixDao tileMatrixDao = getTileMatrixDao(); if (!tileMatrixDao.isTableExists()) { throw new GeoPackageException("A data type of " + dataType.getName() + " requires the " + TileMatrix.class.getSimpleName() + " table to first be created using the GeoPackage."); } }
Example 3
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 4
Source File: SpatialReferenceSystemDao.java From geopackage-core-java with MIT License | 5 votes |
/** * Delete the Spatial Reference System, cascading * * @param srs * spatial reference system * @return deleted count * @throws SQLException * upon deletion failure */ public int deleteCascade(SpatialReferenceSystem srs) throws SQLException { int count = 0; if (srs != null) { // Delete Contents ForeignCollection<Contents> contentsCollection = srs.getContents(); if (!contentsCollection.isEmpty()) { ContentsDao dao = getContentsDao(); dao.deleteCascade(contentsCollection); } // Delete Geometry Columns GeometryColumnsDao geometryColumnsDao = getGeometryColumnsDao(); if (geometryColumnsDao.isTableExists()) { ForeignCollection<GeometryColumns> geometryColumnsCollection = srs .getGeometryColumns(); if (!geometryColumnsCollection.isEmpty()) { geometryColumnsDao.delete(geometryColumnsCollection); } } // Delete Tile Matrix Set TileMatrixSetDao tileMatrixSetDao = getTileMatrixSetDao(); if (tileMatrixSetDao.isTableExists()) { ForeignCollection<TileMatrixSet> tileMatrixSetCollection = srs .getTileMatrixSet(); if (!tileMatrixSetCollection.isEmpty()) { tileMatrixSetDao.delete(tileMatrixSetCollection); } } // Delete count = delete(srs); } return count; }
Example 5
Source File: ContentsDao.java From geopackage-core-java with MIT License | 4 votes |
/** * Delete the Contents, cascading * * @param contents * contents * @return deleted count * @throws SQLException * upon deletion error */ public int deleteCascade(Contents contents) throws SQLException { int count = 0; if (contents != null) { ContentsDataType dataType = contents.getDataType(); if (dataType != null) { switch (dataType) { case FEATURES: // Delete Geometry Columns GeometryColumnsDao geometryColumnsDao = getGeometryColumnsDao(); if (geometryColumnsDao.isTableExists()) { GeometryColumns geometryColumns = contents .getGeometryColumns(); if (geometryColumns != null) { geometryColumnsDao.delete(geometryColumns); } } break; case TILES: case GRIDDED_COVERAGE: // Delete Tile Matrix collection TileMatrixDao tileMatrixDao = getTileMatrixDao(); if (tileMatrixDao.isTableExists()) { ForeignCollection<TileMatrix> tileMatrixCollection = contents .getTileMatrix(); if (!tileMatrixCollection.isEmpty()) { tileMatrixDao.delete(tileMatrixCollection); } } // Delete Tile Matrix Set TileMatrixSetDao tileMatrixSetDao = getTileMatrixSetDao(); if (tileMatrixSetDao.isTableExists()) { TileMatrixSet tileMatrixSet = contents .getTileMatrixSet(); if (tileMatrixSet != null) { tileMatrixSetDao.delete(tileMatrixSet); } } break; case ATTRIBUTES: dropTable(contents.getTableName()); break; } } else { dropTable(contents.getTableName()); } count = delete(contents); } return count; }
Example 6
Source File: GeoPackageTestUtils.java From geopackage-java with MIT License | 4 votes |
/** * Test deleting tables by name * * @param geoPackage * @throws SQLException */ public static void testDeleteTables(GeoPackage geoPackage) throws SQLException { GeometryColumnsDao geometryColumnsDao = geoPackage .getGeometryColumnsDao(); TileMatrixSetDao tileMatrixSetDao = geoPackage.getTileMatrixSetDao(); ContentsDao contentsDao = geoPackage.getContentsDao(); TestCase.assertTrue(geometryColumnsDao.isTableExists() || tileMatrixSetDao.isTableExists()); geoPackage.foreignKeys(false); if (geometryColumnsDao.isTableExists()) { TestCase.assertEquals(geoPackage.getFeatureTables().size(), geometryColumnsDao.countOf()); for (String featureTable : geoPackage.getFeatureTables()) { TestCase.assertTrue(geoPackage.isTable(featureTable)); TestCase.assertNotNull(contentsDao.queryForId(featureTable)); geoPackage.deleteTable(featureTable); TestCase.assertFalse(geoPackage.isTable(featureTable)); TestCase.assertNull(contentsDao.queryForId(featureTable)); } TestCase.assertEquals(0, geometryColumnsDao.countOf()); geoPackage.dropTable(GeometryColumns.TABLE_NAME); TestCase.assertFalse(geometryColumnsDao.isTableExists()); } if (tileMatrixSetDao.isTableExists()) { TileMatrixDao tileMatrixDao = geoPackage.getTileMatrixDao(); TestCase.assertTrue(tileMatrixSetDao.isTableExists()); TestCase.assertTrue(tileMatrixDao.isTableExists()); TestCase.assertEquals(geoPackage.getTables(ContentsDataType.TILES) .size() + geoPackage.getTables(ContentsDataType.GRIDDED_COVERAGE) .size(), tileMatrixSetDao.countOf()); for (String tileTable : geoPackage.getTileTables()) { TestCase.assertTrue(geoPackage.isTable(tileTable)); TestCase.assertNotNull(contentsDao.queryForId(tileTable)); geoPackage.deleteTable(tileTable); TestCase.assertFalse(geoPackage.isTable(tileTable)); TestCase.assertNull(contentsDao.queryForId(tileTable)); } TestCase.assertEquals(geoPackage .getTables(ContentsDataType.GRIDDED_COVERAGE).size(), tileMatrixSetDao.countOf()); geoPackage.dropTable(TileMatrix.TABLE_NAME); geoPackage.dropTable(TileMatrixSet.TABLE_NAME); TestCase.assertFalse(tileMatrixSetDao.isTableExists()); TestCase.assertFalse(tileMatrixDao.isTableExists()); } for (String attributeTable : geoPackage.getAttributesTables()) { TestCase.assertTrue(geoPackage.isTable(attributeTable)); TestCase.assertNotNull(contentsDao.queryForId(attributeTable)); geoPackage.deleteTable(attributeTable); TestCase.assertFalse(geoPackage.isTable(attributeTable)); TestCase.assertNull(contentsDao.queryForId(attributeTable)); } }
Example 7
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 8
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 9
Source File: TileMatrixSetUtils.java From geopackage-java with MIT License | 4 votes |
/** * Test create * * @param geoPackage * @throws SQLException */ public static void testCreate(GeoPackage geoPackage) throws SQLException { SpatialReferenceSystemDao srsDao = geoPackage .getSpatialReferenceSystemDao(); ContentsDao contentsDao = geoPackage.getContentsDao(); TileMatrixSetDao dao = geoPackage.getTileMatrixSetDao(); if (dao.isTableExists()) { // Get current count long count = dao.countOf(); TestCase.assertEquals(count, dao.getTileTables().size()); // Retrieve a random srs List<SpatialReferenceSystem> results = srsDao.queryForAll(); SpatialReferenceSystem srs = null; if (!results.isEmpty()) { int random = (int) (Math.random() * results.size()); srs = results.get(random); } // Create a new contents Contents contents = new Contents(); contents.setTableName("test_contents"); contents.setDataType(ContentsDataType.TILES); contents.setIdentifier("test_contents"); contents.setDescription(""); // contents.setLastChange(new Date()); contents.setMinX(-180.0); contents.setMinY(-90.0); contents.setMaxX(180.0); contents.setMaxY(90.0); contents.setSrs(srs); // Create the user tile table geoPackage.createTileTable(TestUtils.buildTileTable(contents .getTableName())); contentsDao.create(contents); // Create new matrix tile set TileMatrixSet tileMatrixSet = new TileMatrixSet(); tileMatrixSet.setContents(contents); tileMatrixSet.setSrs(contents.getSrs()); tileMatrixSet.setMinX(contents.getMinX()); tileMatrixSet.setMinY(contents.getMinY()); tileMatrixSet.setMaxX(contents.getMaxX()); tileMatrixSet.setMaxY(contents.getMaxY()); dao.create(tileMatrixSet); // Verify count long newCount = dao.countOf(); TestCase.assertEquals(count + 1, newCount); TestCase.assertEquals(newCount, dao.getTileTables().size()); TestCase.assertTrue(dao.getTileTables().contains( contents.getTableName())); // Verify saved matrix tile set TileMatrixSet queryTileMatrixSet = dao.queryForId(tileMatrixSet .getId()); TestCase.assertEquals(contents.getId(), queryTileMatrixSet.getTableName()); TestCase.assertEquals(contents.getSrsId().longValue(), queryTileMatrixSet.getSrsId()); TestCase.assertEquals(contents.getMinX(), queryTileMatrixSet.getMinX()); TestCase.assertEquals(contents.getMinY(), queryTileMatrixSet.getMinY()); TestCase.assertEquals(contents.getMaxX(), queryTileMatrixSet.getMaxX()); TestCase.assertEquals(contents.getMaxY(), queryTileMatrixSet.getMaxY()); TestCase.assertEquals(contents.getId(), queryTileMatrixSet .getContents().getId()); TestCase.assertEquals(contents.getSrsId().longValue(), queryTileMatrixSet.getSrs().getId()); } }
Example 10
Source File: GeoPackageTestUtils.java From geopackage-android with MIT License | 4 votes |
/** * Test deleting tables by name * * @param geoPackage * @throws SQLException */ public static void testDeleteTables(GeoPackage geoPackage) throws SQLException { GeometryColumnsDao geometryColumnsDao = geoPackage .getGeometryColumnsDao(); TileMatrixSetDao tileMatrixSetDao = geoPackage.getTileMatrixSetDao(); ContentsDao contentsDao = geoPackage.getContentsDao(); TestCase.assertTrue(geometryColumnsDao.isTableExists() || tileMatrixSetDao.isTableExists()); geoPackage.foreignKeys(false); if (geometryColumnsDao.isTableExists()) { TestCase.assertEquals(geoPackage.getFeatureTables().size(), geometryColumnsDao.countOf()); for (String featureTable : geoPackage.getFeatureTables()) { TestCase.assertTrue(geoPackage.isTable(featureTable)); TestCase.assertNotNull(contentsDao.queryForId(featureTable)); geoPackage.deleteTable(featureTable); TestCase.assertFalse(geoPackage.isTable(featureTable)); TestCase.assertNull(contentsDao.queryForId(featureTable)); } TestCase.assertEquals(0, geometryColumnsDao.countOf()); geoPackage.dropTable(GeometryColumns.TABLE_NAME); TestCase.assertFalse(geometryColumnsDao.isTableExists()); } if (tileMatrixSetDao.isTableExists()) { TileMatrixDao tileMatrixDao = geoPackage.getTileMatrixDao(); TestCase.assertTrue(tileMatrixSetDao.isTableExists()); TestCase.assertTrue(tileMatrixDao.isTableExists()); TestCase.assertEquals(geoPackage.getTables(ContentsDataType.TILES).size() + geoPackage.getTables(ContentsDataType.GRIDDED_COVERAGE).size(), tileMatrixSetDao.countOf()); for (String tileTable : geoPackage.getTileTables()) { TestCase.assertTrue(geoPackage.isTable(tileTable)); TestCase.assertNotNull(contentsDao.queryForId(tileTable)); geoPackage.deleteTable(tileTable); TestCase.assertFalse(geoPackage.isTable(tileTable)); TestCase.assertNull(contentsDao.queryForId(tileTable)); } TestCase.assertEquals(geoPackage.getTables(ContentsDataType.GRIDDED_COVERAGE).size(), tileMatrixSetDao.countOf()); geoPackage.dropTable(TileMatrix.TABLE_NAME); geoPackage.dropTable(TileMatrixSet.TABLE_NAME); TestCase.assertFalse(tileMatrixSetDao.isTableExists()); TestCase.assertFalse(tileMatrixDao.isTableExists()); } for (String attributeTable : geoPackage.getAttributesTables()) { TestCase.assertTrue(geoPackage.isTable(attributeTable)); TestCase.assertNotNull(contentsDao.queryForId(attributeTable)); geoPackage.deleteTable(attributeTable); TestCase.assertFalse(geoPackage.isTable(attributeTable)); TestCase.assertNull(contentsDao.queryForId(attributeTable)); } }
Example 11
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 12
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 13
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 14
Source File: TileMatrixSetUtils.java From geopackage-android with MIT License | 4 votes |
/** * Test create * * @param geoPackage * @throws SQLException */ public static void testCreate(GeoPackage geoPackage) throws SQLException { SpatialReferenceSystemDao srsDao = geoPackage .getSpatialReferenceSystemDao(); ContentsDao contentsDao = geoPackage.getContentsDao(); TileMatrixSetDao dao = geoPackage.getTileMatrixSetDao(); if (dao.isTableExists()) { // Get current count long count = dao.countOf(); TestCase.assertEquals(count, dao.getTileTables().size()); // Retrieve a random srs List<SpatialReferenceSystem> results = srsDao.queryForAll(); SpatialReferenceSystem srs = null; if (!results.isEmpty()) { int random = (int) (Math.random() * results.size()); srs = results.get(random); } // Create a new contents Contents contents = new Contents(); contents.setTableName("test_contents"); contents.setDataType(ContentsDataType.TILES); contents.setIdentifier("test_contents"); contents.setDescription(""); // contents.setLastChange(new Date()); contents.setMinX(-180.0); contents.setMinY(-90.0); contents.setMaxX(180.0); contents.setMaxY(90.0); contents.setSrs(srs); // Create the user tile table geoPackage.createTileTable(TestUtils.buildTileTable(contents .getTableName())); contentsDao.create(contents); // Create new matrix tile set TileMatrixSet tileMatrixSet = new TileMatrixSet(); tileMatrixSet.setContents(contents); tileMatrixSet.setSrs(contents.getSrs()); tileMatrixSet.setMinX(contents.getMinX()); tileMatrixSet.setMinY(contents.getMinY()); tileMatrixSet.setMaxX(contents.getMaxX()); tileMatrixSet.setMaxY(contents.getMaxY()); dao.create(tileMatrixSet); // Verify count long newCount = dao.countOf(); TestCase.assertEquals(count + 1, newCount); TestCase.assertEquals(newCount, dao.getTileTables().size()); TestCase.assertTrue(dao.getTileTables().contains( contents.getTableName())); // Verify saved matrix tile set TileMatrixSet queryTileMatrixSet = dao.queryForId(tileMatrixSet .getId()); TestCase.assertEquals(contents.getId(), queryTileMatrixSet.getTableName()); TestCase.assertEquals(contents.getSrsId().longValue(), queryTileMatrixSet.getSrsId()); TestCase.assertEquals(contents.getMinX(), queryTileMatrixSet.getMinX()); TestCase.assertEquals(contents.getMinY(), queryTileMatrixSet.getMinY()); TestCase.assertEquals(contents.getMaxX(), queryTileMatrixSet.getMaxX()); TestCase.assertEquals(contents.getMaxY(), queryTileMatrixSet.getMaxY()); TestCase.assertEquals(contents.getId(), queryTileMatrixSet .getContents().getId()); TestCase.assertEquals(contents.getSrsId().longValue(), queryTileMatrixSet.getSrs().getId()); } }
Example 15
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 16
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 17
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); } } } }