mil.nga.geopackage.tiles.features.FeatureTileGenerator Java Examples
The following examples show how to use
mil.nga.geopackage.tiles.features.FeatureTileGenerator.
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: LoadTilesTask.java From geopackage-mapcache-android with MIT License | 6 votes |
@Override protected String doInBackground(String... params) { try { int count = tileGenerator.generateTiles(); if(count == 0){ return "No tiles were generated for your new layer. This could be an issue with your tile URL or the tile server. Please verify the server URL and try again."; } if (count > 0) { active.setModified(true); } if (count < max && !(tileGenerator instanceof FeatureTileGenerator)) { return "Fewer tiles were generated than expected. Expected: " + max + ", Actual: " + count + ". This is likely an issue with the tile server or a slow / intermittent network connection."; } } catch (final Exception e) { return e.toString(); } return null; }
Example #2
Source File: GeoPackageExample.java From geopackage-android with MIT License | 5 votes |
private static void createFeatureTileLinkExtension(Context context, GeoPackage geoPackage) throws SQLException, IOException { List<String> featureTables = geoPackage.getFeatureTables(); for (String featureTable : featureTables) { FeatureDao featureDao = geoPackage.getFeatureDao(featureTable); FeatureTiles featureTiles = new DefaultFeatureTiles(context, geoPackage, featureDao, context.getResources().getDisplayMetrics().density); BoundingBox boundingBox = featureDao.getBoundingBox(); Projection projection = featureDao.getProjection(); Projection requestProjection = ProjectionFactory .getProjection(ProjectionConstants.EPSG_WEB_MERCATOR); ProjectionTransform transform = projection .getTransformation(requestProjection); BoundingBox requestBoundingBox = boundingBox.transform(transform); int zoomLevel = TileBoundingBoxUtils .getZoomLevel(requestBoundingBox); zoomLevel = Math.max(zoomLevel, 8); zoomLevel = Math.min(zoomLevel, 19); int minZoom = zoomLevel - 8; int maxZoom = zoomLevel + 2; TileGenerator tileGenerator = new FeatureTileGenerator(context, geoPackage, featureTable + "_tiles", featureTiles, minZoom, maxZoom, requestBoundingBox, requestProjection); tileGenerator.generateTiles(); featureTiles.close(); } }
Example #3
Source File: GeoPackageExample.java From geopackage-java with MIT License | 5 votes |
private static void createFeatureTileLinkExtension(GeoPackage geoPackage) throws SQLException, IOException { List<String> featureTables = geoPackage.getFeatureTables(); for (String featureTable : featureTables) { FeatureDao featureDao = geoPackage.getFeatureDao(featureTable); FeatureTiles featureTiles = new DefaultFeatureTiles(geoPackage, featureDao); BoundingBox boundingBox = featureDao.getBoundingBox(); Projection projection = featureDao.getProjection(); Projection requestProjection = ProjectionFactory .getProjection(ProjectionConstants.EPSG_WEB_MERCATOR); ProjectionTransform transform = projection .getTransformation(requestProjection); BoundingBox requestBoundingBox = boundingBox.transform(transform); int zoomLevel = TileBoundingBoxUtils .getZoomLevel(requestBoundingBox); zoomLevel = Math.max(zoomLevel, 8); zoomLevel = Math.min(zoomLevel, 19); int minZoom = zoomLevel - 8; int maxZoom = zoomLevel + 2; TileGenerator tileGenerator = new FeatureTileGenerator(geoPackage, featureTable + "_tiles", featureTiles, minZoom, maxZoom, requestBoundingBox, requestProjection); tileGenerator.generateTiles(); } }
Example #4
Source File: LoadTilesTask.java From geopackage-mapcache-android with MIT License | 4 votes |
/** * Load tiles from features * * @param activity * @param callback * @param active * @param geoPackage * @param tableName * @param featureTiles * @param minZoom * @param maxZoom * @param compressFormat * @param compressQuality * @param googleTiles * @param boundingBox * @param scaling * @param authority * @param code */ public static void loadTiles(Activity activity, ILoadTilesTask callback, GeoPackageDatabases active, GeoPackage geoPackage, String tableName, FeatureTiles featureTiles, int minZoom, int maxZoom, CompressFormat compressFormat, Integer compressQuality, boolean googleTiles, BoundingBox boundingBox, TileScaling scaling, String authority, String code) { GeoPackageUtils.prepareFeatureTiles(featureTiles); Projection projection = ProjectionFactory.getProjection(authority, code); BoundingBox bbox = transform(boundingBox, projection); TileGenerator tileGenerator = new FeatureTileGenerator(activity, geoPackage, tableName, featureTiles, minZoom, maxZoom, bbox, projection); setTileGenerator(activity, tileGenerator, minZoom, maxZoom, compressFormat, compressQuality, googleTiles, boundingBox, scaling); loadTiles(activity, callback, active, geoPackage, tableName, tileGenerator); }