org.mapsforge.map.rendertheme.XmlRenderTheme Java Examples
The following examples show how to use
org.mapsforge.map.rendertheme.XmlRenderTheme.
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: MapsforgeTilesGenerator.java From hortonmachine with GNU General Public License v3.0 | 5 votes |
/** * Constructor. * * @param mapsforgeFiles mapsforge map files. * @param tileSize optional tilesize, defaults to 256. * @param scaleFactor optional scale factor for labels, defaults to 1. * @param cacheDir optional cachdir. If null, in-memory is used. * @param theme optional rendertheme. * @throws IOException */ public MapsforgeTilesGenerator( File[] mapsforgeFiles, Integer tileSize, Float scaleFactor, File cacheDir, XmlRenderTheme theme ) throws IOException { if (tileSize != null) this.tileSize = tileSize; if (scaleFactor != null) this.scaleFactor = scaleFactor; if (theme == null) { theme = InternalRenderTheme.DEFAULT; } DataPolicy dataPolicy = DataPolicy.RETURN_ALL; mapDataStore = new MultiMapDataStore(dataPolicy); for( int i = 0; i < mapsforgeFiles.length; i++ ) mapDataStore.addMapDataStore(new MapFile(mapsforgeFiles[i]), false, false); GraphicFactory graphicFactory = AwtGraphicFactory.INSTANCE; displayModel = new FixedTileSizeDisplayModel(this.tileSize); renderTheme = new RenderThemeFuture(graphicFactory, theme, displayModel); if (cacheDir == null) { tileCache = new InMemoryTileCache(200); } else { tileCache = new FileSystemTileCache(10, cacheDir, graphicFactory, false); } TileBasedLabelStore tileBasedLabelStore = new TileBasedLabelStore(tileCache.getCapacityFirstLevel()); renderer = new DatabaseRenderer(mapDataStore, graphicFactory, tileCache, tileBasedLabelStore, true, true, null); new Thread(renderTheme).start(); }
Example #2
Source File: MapsforgeTileProviderSample.java From osmdroid with Apache License 2.0 | 4 votes |
@Override public void addOverlays() { super.addOverlays(); //first let's up our map source, mapsforge needs you to explicitly specify which map files to load //this bit does some basic file system scanning Set<File> mapfiles = findMapFiles(); //do a simple scan of local storage for .map files. File[] maps = new File[mapfiles.size()]; maps = mapfiles.toArray(maps); if (maps == null || maps.length == 0) { //show a warning that no map files were found AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder( getContext()); // set title alertDialogBuilder.setTitle("No Mapsforge files found"); // set dialog message alertDialogBuilder .setMessage("In order to render map tiles, you'll need to either create or obtain mapsforge .map files. See https://github.com/mapsforge/mapsforge for more info. Store them in " + Configuration.getInstance().getOsmdroidBasePath().getAbsolutePath()) .setCancelable(false) .setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { if (alertDialog != null) alertDialog.dismiss(); } }); // create alert dialog alertDialog = alertDialogBuilder.create(); // show it alertDialog.show(); } else { Toast.makeText(getContext(), "Loaded " + maps.length + " map files", Toast.LENGTH_LONG).show(); //this creates the forge provider and tile sources //protip: when changing themes, you should also change the tile source name to prevent cached tiles //null is ok here, uses the default rendering theme if it's not set XmlRenderTheme theme = null; try { theme = new AssetsRenderTheme(getContext().getApplicationContext(), "renderthemes/", "rendertheme-v4.xml"); } catch (Exception ex) { ex.printStackTrace(); } fromFiles = MapsForgeTileSource.createFromFiles(maps, theme, "rendertheme-v4"); forge = new MapsForgeTileProvider( new SimpleRegisterReceiver(getContext()), fromFiles, null); mMapView.setTileProvider(forge); //now for a magic trick //since we have no idea what will be on the //user's device and what geographic area it is, this will attempt to center the map //on whatever the map data provides mMapView.getController().setZoom(fromFiles.getMinimumZoomLevel()); mMapView.zoomToBoundingBox(fromFiles.getBoundsOsmdroid(), true); } }
Example #3
Source File: ForgeMap.java From Androzic with GNU General Public License v3.0 | 4 votes |
private static void compileRenderTheme(XmlRenderTheme xmlRenderTheme) { renderTheme = new RenderThemeFuture(AndroidGraphicFactory.INSTANCE, xmlRenderTheme, displayModel); new Thread(renderTheme).run(); }
Example #4
Source File: MapsForgeTileSource.java From osmdroid with Apache License 2.0 | 3 votes |
/** * Creates a new MapsForgeTileSource from file[]. * <p></p> * Parameters minZoom and maxZoom are obtained from the * database. If they cannot be obtained from the DB, the default values as * defined by this class are used, which is zoom = 3-20 * * @param file * @param theme this can be null, in which case the default them will be used * @param themeName when using a custom theme, this sets up the osmdroid caching correctly * @return */ public static MapsForgeTileSource createFromFiles(File[] file, XmlRenderTheme theme, String themeName) { //these settings are ignored and are set based on .map file info int minZoomLevel = MIN_ZOOM; int maxZoomLevel = MAX_ZOOM; int tileSizePixels = TILE_SIZE_PIXELS; return new MapsForgeTileSource(themeName, minZoomLevel, maxZoomLevel, tileSizePixels, file, theme, MultiMapDataStore.DataPolicy.RETURN_ALL, null, null); }
Example #5
Source File: MapsForgeTileSource.java From osmdroid with Apache License 2.0 | 3 votes |
/** * Creates a new MapsForgeTileSource from file[]. * <p></p> * Parameters minZoom and maxZoom are obtained from the * database. If they cannot be obtained from the DB, the default values as * defined by this class are used, which is zoom = 3-20 * * @param file * @param theme this can be null, in which case the default them will be used * @param themeName when using a custom theme, this sets up the osmdroid caching correctly * @param language preferred language for map labels as defined in ISO 639-1 or ISO 639-2 (can be null) * @return */ public static MapsForgeTileSource createFromFiles(File[] file, XmlRenderTheme theme, String themeName, final String language) { //these settings are ignored and are set based on .map file info int minZoomLevel = MIN_ZOOM; int maxZoomLevel = MAX_ZOOM; int tileSizePixels = TILE_SIZE_PIXELS; return new MapsForgeTileSource(themeName, minZoomLevel, maxZoomLevel, tileSizePixels, file, theme, MultiMapDataStore.DataPolicy.RETURN_ALL, null, language); }
Example #6
Source File: MapsForgeTileSource.java From osmdroid with Apache License 2.0 | 3 votes |
/** * Creates a new MapsForgeTileSource from file[]. * <p></p> * Parameters minZoom and maxZoom are obtained from the * database. If they cannot be obtained from the DB, the default values as * defined by this class are used, which is zoom = 3-20 * * @param file * @param theme this can be null, in which case the default them will be used * @param themeName when using a custom theme, this sets up the osmdroid caching correctly * @param dataPolicy use this to override the default, which is "RETURN_ALL" * @param hillsRenderConfig the hillshading setup to be used (can be null) * @return */ public static MapsForgeTileSource createFromFiles(File[] file, XmlRenderTheme theme, String themeName, MultiMapDataStore.DataPolicy dataPolicy, HillsRenderConfig hillsRenderConfig) { //these settings are ignored and are set based on .map file info int minZoomLevel = MIN_ZOOM; int maxZoomLevel = MAX_ZOOM; int tileSizePixels = TILE_SIZE_PIXELS; return new MapsForgeTileSource(themeName, minZoomLevel, maxZoomLevel, tileSizePixels, file, theme, dataPolicy, hillsRenderConfig, null); }
Example #7
Source File: MapsForgeTileSource.java From osmdroid with Apache License 2.0 | 3 votes |
/** * Creates a new MapsForgeTileSource from file[]. * <p></p> * Parameters minZoom and maxZoom are obtained from the * database. If they cannot be obtained from the DB, the default values as * defined by this class are used, which is zoom = 3-20 * * @param file * @param theme this can be null, in which case the default them will be used * @param themeName when using a custom theme, this sets up the osmdroid caching correctly * @param dataPolicy use this to override the default, which is "RETURN_ALL" * @param hillsRenderConfig the hillshading setup to be used (can be null) * @param language preferred language for map labels as defined in ISO 639-1 or ISO 639-2 (can be null) * @return */ public static MapsForgeTileSource createFromFiles(File[] file, XmlRenderTheme theme, String themeName, MultiMapDataStore.DataPolicy dataPolicy, HillsRenderConfig hillsRenderConfig, final String language) { //these settings are ignored and are set based on .map file info int minZoomLevel = MIN_ZOOM; int maxZoomLevel = MAX_ZOOM; int tileSizePixels = TILE_SIZE_PIXELS; return new MapsForgeTileSource(themeName, minZoomLevel, maxZoomLevel, tileSizePixels, file, theme, dataPolicy, hillsRenderConfig, language); }
Example #8
Source File: MapsforgeTilesGenerator.java From hortonmachine with GNU General Public License v3.0 | 2 votes |
/** * Constructor. * * @param mapsforgeFolder folder containing mapsforge maps. * @param tileSize optional tilesize, defaults to 256. * @param scaleFactor optional scale factor for labels, defaults to 1. * @param cacheDir optional cachdir. If null, in-memory is used. * @param theme optional rendertheme. * @throws IOException */ public MapsforgeTilesGenerator( File mapsforgeFolder, Integer tileSize, Float scaleFactor, File cacheDir, XmlRenderTheme theme ) throws IOException { this(getMapFiles(mapsforgeFolder), tileSize, scaleFactor, cacheDir, theme); }
Example #9
Source File: MapsForgeTileSource.java From osmdroid with Apache License 2.0 | 2 votes |
/** * The reason this constructor is protected is because all parameters, * except file should be determined from the archive file. Therefore a * factory method is necessary. * * @param cacheTileSourceName * @param minZoom * @param maxZoom * @param tileSizePixels * @param file * @param xmlRenderTheme the theme to render tiles with * @param hillsRenderConfig the hillshading setup to be used (can be null) */ protected MapsForgeTileSource(String cacheTileSourceName, int minZoom, int maxZoom, int tileSizePixels, File[] file, XmlRenderTheme xmlRenderTheme, MultiMapDataStore.DataPolicy dataPolicy, HillsRenderConfig hillsRenderConfig) { this(cacheTileSourceName, minZoom, maxZoom, tileSizePixels, file, xmlRenderTheme, dataPolicy, hillsRenderConfig, null); }