Java Code Examples for mil.nga.geopackage.tiles.matrixset.TileMatrixSet#getTableName()

The following examples show how to use mil.nga.geopackage.tiles.matrixset.TileMatrixSet#getTableName() . 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 5 votes vote down vote up
/**
 * Get a Tiled Gridded Coverage Data
 *
 * @param geoPackage        GeoPackage
 * @param tileDao           tile dao
 * @param width             coverage data response width
 * @param height            coverage data response height
 * @param requestProjection request projection
 * @return coverage data
 */
public static CoverageData<?> getCoverageData(GeoPackage geoPackage,
                                              TileDao tileDao, Integer width, Integer height,
                                              Projection requestProjection) {

    TileMatrixSet tileMatrixSet = tileDao.getTileMatrixSet();
    GriddedCoverageDao griddedCoverageDao = geoPackage
            .getGriddedCoverageDao();

    GriddedCoverage griddedCoverage = null;
    try {
        if (griddedCoverageDao.isTableExists()) {
            griddedCoverage = griddedCoverageDao.query(tileMatrixSet);
        }
    } catch (SQLException e) {
        throw new GeoPackageException(
                "Failed to get Gridded Coverage for table name: "
                        + tileMatrixSet.getTableName(), e);
    }

    CoverageData<?> coverageData = null;

    GriddedCoverageDataType dataType = griddedCoverage.getDataType();
    switch (dataType) {
        case INTEGER:
            coverageData = new CoverageDataPng(geoPackage, tileDao, width,
                    height, requestProjection);
            break;
        case FLOAT:
            coverageData = new CoverageDataTiff(geoPackage, tileDao, width,
                    height, requestProjection);
            break;
        default:
            throw new GeoPackageException(
                    "Unsupported Gridded Coverage Data Type: " + dataType);
    }

    return coverageData;
}
 
Example 2
Source File: GriddedCoverage.java    From geopackage-core-java with MIT License 5 votes vote down vote up
/**
 * Set the tile matrix set
 * 
 * @param tileMatrixSet
 *            tile matrix set
 */
public void setTileMatrixSet(TileMatrixSet tileMatrixSet) {
	this.tileMatrixSet = tileMatrixSet;
	if (tileMatrixSet != null) {
		tileMatrixSetName = tileMatrixSet.getTableName();
	} else {
		tileMatrixSetName = null;
	}
}
 
Example 3
Source File: CoverageData.java    From geopackage-java with MIT License 5 votes vote down vote up
/**
 * Get a Tiled Gridded Coverage Data
 * 
 * @param geoPackage
 *            GeoPackage
 * @param tileDao
 *            tile dao
 * @param width
 *            coverage data response width
 * @param height
 *            coverage data response height
 * @param requestProjection
 *            request projection
 * @return coverage data
 */
public static CoverageData<?> getCoverageData(GeoPackage geoPackage,
		TileDao tileDao, Integer width, Integer height,
		Projection requestProjection) {

	TileMatrixSet tileMatrixSet = tileDao.getTileMatrixSet();
	GriddedCoverageDao griddedCoverageDao = geoPackage
			.getGriddedCoverageDao();

	GriddedCoverage griddedCoverage = null;
	try {
		if (griddedCoverageDao.isTableExists()) {
			griddedCoverage = griddedCoverageDao.query(tileMatrixSet);
		}
	} catch (SQLException e) {
		throw new GeoPackageException(
				"Failed to get Gridded Coverage for table name: "
						+ tileMatrixSet.getTableName(), e);
	}

	CoverageData<?> coverageData = null;

	GriddedCoverageDataType dataType = griddedCoverage.getDataType();
	switch (dataType) {
	case INTEGER:
		coverageData = new CoverageDataPng(geoPackage, tileDao, width,
				height, requestProjection);
		break;
	case FLOAT:
		coverageData = new CoverageDataTiff(geoPackage, tileDao, width,
				height, requestProjection);
		break;
	default:
		throw new GeoPackageException(
				"Unsupported Gridded Coverage Data Type: " + dataType);
	}

	return coverageData;
}
 
Example 4
Source File: GeoPackageImpl.java    From geopackage-android with MIT License 4 votes vote down vote up
/**
 * {@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 5
Source File: GeoPackageImpl.java    From geopackage-java with MIT License 4 votes vote down vote up
/**
 * {@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 6
Source File: TileTableScaling.java    From geopackage-core-java with MIT License 2 votes vote down vote up
/**
 * Constructor
 * 
 * @param geoPackage
 *            GeoPackage
 * @param tileMatrixSet
 *            tile matrix set
 */
public TileTableScaling(GeoPackageCore geoPackage,
		TileMatrixSet tileMatrixSet) {
	this(geoPackage, tileMatrixSet.getTableName());
}