Java Code Examples for mil.nga.geopackage.extension.coverage.GriddedTile#setTableId()
The following examples show how to use
mil.nga.geopackage.extension.coverage.GriddedTile#setTableId() .
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 | 4 votes |
private static void createCoverageDataPngExtension(GeoPackage geoPackage) throws SQLException { BoundingBox bbox = new BoundingBox(-11667347.997449303, 4824705.2253603265, -11666125.00499674, 4825928.217812888); int contentsEpsg = ProjectionConstants.EPSG_WEB_MERCATOR; int tileMatrixSetEpsg = ProjectionConstants.EPSG_WEB_MERCATOR; SpatialReferenceSystemDao srsDao = geoPackage .getSpatialReferenceSystemDao(); srsDao.getOrCreateFromEpsg(ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM_GEOGRAPHICAL_3D); SpatialReferenceSystem contentsSrs = srsDao .getOrCreateFromEpsg(contentsEpsg); SpatialReferenceSystem tileMatrixSetSrs = srsDao .getOrCreateFromEpsg(tileMatrixSetEpsg); ProjectionTransform transform = tileMatrixSetSrs.getProjection() .getTransformation(contentsSrs.getProjection()); BoundingBox contentsBoundingBox = bbox; if (!transform.isSameProjection()) { contentsBoundingBox = bbox.transform(transform); } CoverageDataPng coverageData = CoverageDataPng .createTileTableWithMetadata(geoPackage, "coverage_png", contentsBoundingBox, contentsSrs.getId(), bbox, tileMatrixSetSrs.getId()); TileDao tileDao = coverageData.getTileDao(); TileMatrixSet tileMatrixSet = coverageData.getTileMatrixSet(); GriddedCoverageDao griddedCoverageDao = coverageData .getGriddedCoverageDao(); GriddedCoverage griddedCoverage = new GriddedCoverage(); griddedCoverage.setTileMatrixSet(tileMatrixSet); griddedCoverage.setDataType(GriddedCoverageDataType.INTEGER); griddedCoverage.setDataNull(new Double(Short.MAX_VALUE - Short.MIN_VALUE)); griddedCoverage .setGridCellEncodingType(GriddedCoverageEncodingType.CENTER); griddedCoverageDao.create(griddedCoverage); GriddedTileDao griddedTileDao = coverageData.getGriddedTileDao(); int width = 1; int height = 1; int tileWidth = 3; int tileHeight = 3; short[][] tilePixels = new short[tileHeight][tileWidth]; tilePixels[0][0] = (short) 1661.95; tilePixels[0][1] = (short) 1665.40; tilePixels[0][2] = (short) 1668.19; tilePixels[1][0] = (short) 1657.18; tilePixels[1][1] = (short) 1663.39; tilePixels[1][2] = (short) 1669.65; tilePixels[2][0] = (short) 1654.78; tilePixels[2][1] = (short) 1660.31; tilePixels[2][2] = (short) 1666.44; byte[] imageBytes = coverageData.drawTileData(tilePixels); TileMatrixDao tileMatrixDao = geoPackage.getTileMatrixDao(); TileMatrix tileMatrix = new TileMatrix(); tileMatrix.setContents(tileMatrixSet.getContents()); tileMatrix.setMatrixHeight(height); tileMatrix.setMatrixWidth(width); tileMatrix.setTileHeight(tileHeight); tileMatrix.setTileWidth(tileWidth); tileMatrix.setPixelXSize((bbox.getMaxLongitude() - bbox .getMinLongitude()) / width / tileWidth); tileMatrix .setPixelYSize((bbox.getMaxLatitude() - bbox.getMinLatitude()) / height / tileHeight); tileMatrix.setZoomLevel(15); tileMatrixDao.create(tileMatrix); TileRow tileRow = tileDao.newRow(); tileRow.setTileColumn(0); tileRow.setTileRow(0); tileRow.setZoomLevel(tileMatrix.getZoomLevel()); tileRow.setTileData(imageBytes); long tileId = tileDao.create(tileRow); GriddedTile griddedTile = new GriddedTile(); griddedTile.setContents(tileMatrixSet.getContents()); griddedTile.setTableId(tileId); griddedTileDao.create(griddedTile); }
Example 2
Source File: GeoPackageExample.java From geopackage-java with MIT License | 4 votes |
private static void createCoverageDataPngExtension(GeoPackage geoPackage) throws SQLException { BoundingBox bbox = new BoundingBox(-11667347.997449303, 4824705.2253603265, -11666125.00499674, 4825928.217812888); int contentsEpsg = ProjectionConstants.EPSG_WEB_MERCATOR; int tileMatrixSetEpsg = ProjectionConstants.EPSG_WEB_MERCATOR; SpatialReferenceSystemDao srsDao = geoPackage .getSpatialReferenceSystemDao(); srsDao.getOrCreateFromEpsg( ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM_GEOGRAPHICAL_3D); SpatialReferenceSystem contentsSrs = srsDao .getOrCreateFromEpsg(contentsEpsg); SpatialReferenceSystem tileMatrixSetSrs = srsDao .getOrCreateFromEpsg(tileMatrixSetEpsg); ProjectionTransform transform = tileMatrixSetSrs.getProjection() .getTransformation(contentsSrs.getProjection()); BoundingBox contentsBoundingBox = bbox; if (!transform.isSameProjection()) { contentsBoundingBox = bbox.transform(transform); } CoverageDataPng coverageData = CoverageDataPng .createTileTableWithMetadata(geoPackage, "coverage_png", contentsBoundingBox, contentsSrs.getId(), bbox, tileMatrixSetSrs.getId()); TileDao tileDao = coverageData.getTileDao(); TileMatrixSet tileMatrixSet = coverageData.getTileMatrixSet(); GriddedCoverageDao griddedCoverageDao = coverageData .getGriddedCoverageDao(); GriddedCoverage griddedCoverage = new GriddedCoverage(); griddedCoverage.setTileMatrixSet(tileMatrixSet); griddedCoverage.setDataType(GriddedCoverageDataType.INTEGER); griddedCoverage .setDataNull(new Double(Short.MAX_VALUE - Short.MIN_VALUE)); griddedCoverage .setGridCellEncodingType(GriddedCoverageEncodingType.CENTER); griddedCoverageDao.create(griddedCoverage); GriddedTileDao griddedTileDao = coverageData.getGriddedTileDao(); int width = 1; int height = 1; int tileWidth = 3; int tileHeight = 3; short[][] tilePixels = new short[tileHeight][tileWidth]; tilePixels[0][0] = (short) 1661.95; tilePixels[0][1] = (short) 1665.40; tilePixels[0][2] = (short) 1668.19; tilePixels[1][0] = (short) 1657.18; tilePixels[1][1] = (short) 1663.39; tilePixels[1][2] = (short) 1669.65; tilePixels[2][0] = (short) 1654.78; tilePixels[2][1] = (short) 1660.31; tilePixels[2][2] = (short) 1666.44; byte[] imageBytes = coverageData.drawTileData(tilePixels); TileMatrixDao tileMatrixDao = geoPackage.getTileMatrixDao(); TileMatrix tileMatrix = new TileMatrix(); tileMatrix.setContents(tileMatrixSet.getContents()); tileMatrix.setMatrixHeight(height); tileMatrix.setMatrixWidth(width); tileMatrix.setTileHeight(tileHeight); tileMatrix.setTileWidth(tileWidth); tileMatrix .setPixelXSize((bbox.getMaxLongitude() - bbox.getMinLongitude()) / width / tileWidth); tileMatrix.setPixelYSize((bbox.getMaxLatitude() - bbox.getMinLatitude()) / height / tileHeight); tileMatrix.setZoomLevel(15); tileMatrixDao.create(tileMatrix); TileRow tileRow = tileDao.newRow(); tileRow.setTileColumn(0); tileRow.setTileRow(0); tileRow.setZoomLevel(tileMatrix.getZoomLevel()); tileRow.setTileData(imageBytes); long tileId = tileDao.create(tileRow); GriddedTile griddedTile = new GriddedTile(); griddedTile.setContents(tileMatrixSet.getContents()); griddedTile.setTableId(tileId); griddedTileDao.create(griddedTile); }