Java Code Examples for mil.nga.geopackage.GeoPackage#getTileTables()

The following examples show how to use mil.nga.geopackage.GeoPackage#getTileTables() . 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: GeoPackageExample.java    From geopackage-android with MIT License 6 votes vote down vote up
private static void createTileScalingExtension(GeoPackage geoPackage) {

        for (String tileTable : geoPackage.getTileTables()) {

            TileTableScaling tileTableScaling = new TileTableScaling(
                    geoPackage, tileTable);
            TileScaling tileScaling = new TileScaling();
            tileScaling.setZoomIn(2l);
            FeatureTileTableLinker linker = new FeatureTileTableLinker(
                    geoPackage);
            if (linker.has()
                    && !linker.getFeatureTablesForTileTable(tileTable)
                    .isEmpty()) {
                tileScaling.setScalingType(TileScalingType.IN);
            } else {
                tileScaling.setScalingType(TileScalingType.IN_OUT);
                tileScaling.setZoomOut(2l);
            }
            tileTableScaling.create(tileScaling);

        }

    }
 
Example 2
Source File: GeoPackageExample.java    From geopackage-java with MIT License 6 votes vote down vote up
private static void createTileScalingExtension(GeoPackage geoPackage) {

		for (String tileTable : geoPackage.getTileTables()) {

			TileTableScaling tileTableScaling = new TileTableScaling(geoPackage,
					tileTable);
			TileScaling tileScaling = new TileScaling();
			tileScaling.setZoomIn(2l);
			FeatureTileTableLinker linker = new FeatureTileTableLinker(
					geoPackage);
			if (linker.has() && !linker.getFeatureTablesForTileTable(tileTable)
					.isEmpty()) {
				tileScaling.setScalingType(TileScalingType.IN);
			} else {
				tileScaling.setScalingType(TileScalingType.IN_OUT);
				tileScaling.setZoomOut(2l);
			}
			tileTableScaling.create(tileScaling);

		}

	}
 
Example 3
Source File: GeoPackageMapTileModuleProvider.java    From osmdroid with Apache License 2.0 6 votes vote down vote up
/**
 * returns ALL available raster tile sources for all "imported" geopackage databases
 *
 * @return
 */
public List<GeopackageRasterTileSource> getTileSources() {
    List<GeopackageRasterTileSource> srcs = new ArrayList<>();

    List<String> databases = manager.databases();
    for (int i = 0; i < databases.size(); i++) {

        GeoPackage open = manager.open(databases.get(i));
        List<String> tileTables = open.getTileTables();
        for (int k = 0; k < tileTables.size(); k++) {
            TileDao tileDao = open.getTileDao(tileTables.get(k));

            ProjectionTransform transform = tileDao.getProjection().getTransformation(ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM);
            mil.nga.geopackage.BoundingBox boundingBox = transform.transform(tileDao.getBoundingBox());
            BoundingBox bounds = new BoundingBox(Math.min(tileSystem.getMaxLatitude(), boundingBox.getMaxLatitude()),
                boundingBox.getMaxLongitude(),
                Math.max(tileSystem.getMinLatitude(), boundingBox.getMinLatitude()),
                boundingBox.getMinLongitude());

            srcs.add(new GeopackageRasterTileSource(databases.get(i), tileTables.get(k), (int)tileDao.getMinZoom(), (int)tileDao.getMaxZoom(), bounds));
        }
        open.close();
    }

    return srcs;
}
 
Example 4
Source File: GeoPackageMapTileModuleProvider.java    From osmdroid with Apache License 2.0 6 votes vote down vote up
/**
 * returns ALL available raster tile sources for the specified database.
 * This will throw if the database doesn't exist or isn't registered
 *
 * @return
 */
public List<GeopackageRasterTileSource> getTileSources(String database) {
    List<GeopackageRasterTileSource> srcs = new ArrayList<>();

    GeoPackage open = manager.open(database);
    List<String> tileTables = open.getTileTables();
    for (int k = 0; k < tileTables.size(); k++) {
        TileDao tileDao = open.getTileDao(tileTables.get(k));

        ProjectionTransform transform = tileDao.getProjection().getTransformation(ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM);
        mil.nga.geopackage.BoundingBox boundingBox = transform.transform(tileDao.getBoundingBox());

        BoundingBox bounds = new BoundingBox(Math.min(tileSystem.getMaxLatitude(), boundingBox.getMaxLatitude()),
            boundingBox.getMaxLongitude(),
            Math.max(tileSystem.getMinLatitude(), boundingBox.getMinLatitude()),
            boundingBox.getMinLongitude());
        srcs.add(new GeopackageRasterTileSource(database, tileTables.get(k), (int)tileDao.getMinZoom(), (int)tileDao.getMaxZoom(), bounds));

    }
    open.close();

    return srcs;
}
 
Example 5
Source File: GeoPackageRepository.java    From geopackage-mapcache-android with MIT License 5 votes vote down vote up
/**
 * Returns the list of tile tables for a geopackage
 */
public List<String> getTileTables(String database){
    GeoPackage geo = manager.open(database);
    if(geo != null) {
        List<String> tiles = geo.getTileTables();
        geo.close();
        return tiles;
    }
    return null;
}
 
Example 6
Source File: GeoPackageTestUtils.java    From geopackage-android with MIT License 4 votes vote down vote up
/**
 * 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: GeoPackageTestUtils.java    From geopackage-java with MIT License 4 votes vote down vote up
/**
 * 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));

	}

}