Java Code Examples for mil.nga.geopackage.tiles.matrix.TileMatrix#getMatrixWidth()

The following examples show how to use mil.nga.geopackage.tiles.matrix.TileMatrix#getMatrixWidth() . 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: TileDaoUtils.java    From geopackage-core-java with MIT License 6 votes vote down vote up
/**
 * Adjust the tile matrix lengths if needed. Check if the tile matrix width
 * and height need to expand to account for pixel * number of pixels fitting
 * into the tile matrix lengths
 * 
 * @param tileMatrixSet
 *            tile matrix set
 * @param tileMatrices
 *            tile matrices
 */
public static void adjustTileMatrixLengths(TileMatrixSet tileMatrixSet,
		List<TileMatrix> tileMatrices) {
	double tileMatrixWidth = tileMatrixSet.getMaxX()
			- tileMatrixSet.getMinX();
	double tileMatrixHeight = tileMatrixSet.getMaxY()
			- tileMatrixSet.getMinY();
	for (TileMatrix tileMatrix : tileMatrices) {
		int tempMatrixWidth = (int) (tileMatrixWidth / (tileMatrix
				.getPixelXSize() * tileMatrix.getTileWidth()));
		int tempMatrixHeight = (int) (tileMatrixHeight / (tileMatrix
				.getPixelYSize() * tileMatrix.getTileHeight()));
		if (tempMatrixWidth > tileMatrix.getMatrixWidth()) {
			tileMatrix.setMatrixWidth(tempMatrixWidth);
		}
		if (tempMatrixHeight > tileMatrix.getMatrixHeight()) {
			tileMatrix.setMatrixHeight(tempMatrixHeight);
		}
	}
}
 
Example 2
Source File: TileDao.java    From geopackage-android with MIT License 5 votes vote down vote up
/**
 * Determine if the tiles are in the XYZ tile coordinate format
 *
 * @return true if XYZ tile format
 * @since 3.5.0
 */
public boolean isXYZTiles() {

    // Convert the bounding box to wgs84
    BoundingBox boundingBox = tileMatrixSet.getBoundingBox();
    BoundingBox wgs84BoundingBox = boundingBox.transform(
            projection.getTransformation(
                    ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM));

    boolean xyzTiles = false;

    // Verify the bounds are the entire world
    if (wgs84BoundingBox.getMinLatitude() <= ProjectionConstants.WEB_MERCATOR_MIN_LAT_RANGE
            && wgs84BoundingBox.getMaxLatitude() >= ProjectionConstants.WEB_MERCATOR_MAX_LAT_RANGE
            && wgs84BoundingBox.getMinLongitude() <= -ProjectionConstants.WGS84_HALF_WORLD_LON_WIDTH
            && wgs84BoundingBox.getMaxLongitude() >= ProjectionConstants.WGS84_HALF_WORLD_LON_WIDTH) {

        xyzTiles = true;

        // Verify each tile matrix is the correct width and height
        for (TileMatrix tileMatrix : tileMatrices) {
            long zoomLevel = tileMatrix.getZoomLevel();
            long tilesPerSide = TileBoundingBoxUtils
                    .tilesPerSide((int) zoomLevel);
            if (tileMatrix.getMatrixWidth() != tilesPerSide
                    || tileMatrix.getMatrixHeight() != tilesPerSide) {
                xyzTiles = false;
                break;
            }
        }
    }

    return xyzTiles;
}
 
Example 3
Source File: TileDao.java    From geopackage-java with MIT License 5 votes vote down vote up
/**
 * Determine if the tiles are in the XYZ tile coordinate format
 * 
 * @return true if XYZ tile format
 * @since 3.5.0
 */
public boolean isXYZTiles() {

	// Convert the bounding box to wgs84
	BoundingBox boundingBox = tileMatrixSet.getBoundingBox();
	BoundingBox wgs84BoundingBox = boundingBox
			.transform(projection.getTransformation(
					ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM));

	boolean xyzTiles = false;

	// Verify the bounds are the entire world
	if (wgs84BoundingBox
			.getMinLatitude() <= ProjectionConstants.WEB_MERCATOR_MIN_LAT_RANGE
			&& wgs84BoundingBox
					.getMaxLatitude() >= ProjectionConstants.WEB_MERCATOR_MAX_LAT_RANGE
			&& wgs84BoundingBox
					.getMinLongitude() <= -ProjectionConstants.WGS84_HALF_WORLD_LON_WIDTH
			&& wgs84BoundingBox
					.getMaxLongitude() >= ProjectionConstants.WGS84_HALF_WORLD_LON_WIDTH) {

		xyzTiles = true;

		// Verify each tile matrix is the correct width and height
		for (TileMatrix tileMatrix : tileMatrices) {
			long zoomLevel = tileMatrix.getZoomLevel();
			long tilesPerSide = TileBoundingBoxUtils
					.tilesPerSide((int) zoomLevel);
			if (tileMatrix.getMatrixWidth() != tilesPerSide
					|| tileMatrix.getMatrixHeight() != tilesPerSide) {
				xyzTiles = false;
				break;
			}
		}
	}

	return xyzTiles;
}
 
Example 4
Source File: TestUtils.java    From geopackage-android-map with MIT License 4 votes vote down vote up
/**
 * Add rows to the tile table
 *
 * @param geoPackage
 * @param tileMatrix
 * @param tileData
 */
public static void addRowsToTileTable(GeoPackage geoPackage,
                                      TileMatrix tileMatrix, byte[] tileData) {

    TileDao dao = geoPackage.getTileDao(tileMatrix.getTableName());

    for (int column = 0; column < tileMatrix.getMatrixWidth(); column++) {

        for (int row = 0; row < tileMatrix.getMatrixHeight(); row++) {

            TileRow newRow = dao.newRow();

            newRow.setZoomLevel(tileMatrix.getZoomLevel());
            newRow.setTileColumn(column);
            newRow.setTileRow(row);
            newRow.setTileData(tileData);

            dao.create(newRow);
        }

    }

}
 
Example 5
Source File: TestUtils.java    From geopackage-android with MIT License 4 votes vote down vote up
/**
 * Add rows to the tile table
 *
 * @param geoPackage
 * @param tileMatrix
 * @param tileData
 */
public static void addRowsToTileTable(GeoPackage geoPackage,
                                      TileMatrix tileMatrix, byte[] tileData) {

    TileDao dao = geoPackage.getTileDao(tileMatrix.getTableName());

    for (int column = 0; column < tileMatrix.getMatrixWidth(); column++) {

        for (int row = 0; row < tileMatrix.getMatrixHeight(); row++) {

            TileRow newRow = dao.newRow();

            newRow.setZoomLevel(tileMatrix.getZoomLevel());
            newRow.setTileColumn(column);
            newRow.setTileRow(row);
            newRow.setTileData(tileData);

            dao.create(newRow);
        }

    }

}
 
Example 6
Source File: TestUtils.java    From geopackage-java with MIT License 4 votes vote down vote up
/**
 * Add rows to the tile table
 *
 * @param geoPackage
 * @param tileMatrix
 * @param tileData
 */
public static void addRowsToTileTable(GeoPackage geoPackage,
		TileMatrix tileMatrix, byte[] tileData) {

	TileDao dao = geoPackage.getTileDao(tileMatrix.getTableName());

	for (int column = 0; column < tileMatrix.getMatrixWidth(); column++) {

		for (int row = 0; row < tileMatrix.getMatrixHeight(); row++) {

			TileRow newRow = dao.newRow();

			newRow.setZoomLevel(tileMatrix.getZoomLevel());
			newRow.setTileColumn(column);
			newRow.setTileRow(row);
			newRow.setTileData(tileData);

			dao.create(newRow);
		}

	}

}