org.mapsforge.map.datastore.MultiMapDataStore Java Examples

The following examples show how to use org.mapsforge.map.datastore.MultiMapDataStore. 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: MapsforgeNwwLayer.java    From hortonmachine with GNU General Public License v3.0 5 votes vote down vote up
public MapsforgeNwwLayer(String layerName, File[] mapsforgeFiles, Integer tileSize, Float scaleFactor)
		throws Exception {
	super(makeLevels(layerName, getTilegenerator(mapsforgeFiles, tileSize, scaleFactor), tileSize));
	this.layerName = layerName;
	this.setUseTransparentTextures(true);

	MultiMapDataStore mapDatabase = new MultiMapDataStore(DataPolicy.RETURN_ALL);
	for (int i = 0; i < mapsforgeFiles.length; i++)
		mapDatabase.addMapDataStore(new MapFile(mapsforgeFiles[i]), false, false);
	BoundingBox boundingBox = mapDatabase.boundingBox();
	LatLong centerPoint = boundingBox.getCenterPoint();
	centerCoordinate = new Coordinate(centerPoint.longitude, centerPoint.latitude);
	mapDatabase.close();
}
 
Example #2
Source File: Mapsforge2MbtilesConverter.java    From hortonmachine with GNU General Public License v3.0 5 votes vote down vote up
private OsmTilegenerator getGenerator( ReferencedEnvelope llBounds ) {
//        MapWorkerPool.NUMBER_OF_THREADS = 4;
//        // Map buffer size
//        ReadBuffer.setMaximumBufferSize(6500000);
//        // Square frame buffer
//        FrameBufferController.setUseSquareFrameBuffer(false);

        DisplayModel model = new DisplayModel();
        model.setUserScaleFactor(pScaleFactor);
        model.setFixedTileSize(pTilesize);

        DataPolicy dataPolicy = DataPolicy.RETURN_ALL;
        MultiMapDataStore mapDatabase = new MultiMapDataStore(dataPolicy);
        for( int i = 0; i < inMapFiles.length; i++ )
            mapDatabase.addMapDataStore(new MapFile(inMapFiles[i]), false, false);

        if (llBounds != null) {
            BoundingBox bb = mapDatabase.boundingBox();
            llBounds.expandToInclude(new Envelope(bb.minLongitude, bb.maxLongitude, bb.minLatitude, bb.maxLatitude));
        }

        InMemoryTileCache tileCache = new InMemoryTileCache(200);
        DatabaseRenderer renderer = new DatabaseRenderer(mapDatabase, AwtGraphicFactory.INSTANCE, tileCache,
                new TileBasedLabelStore(tileCache.getCapacityFirstLevel()), true, true, null);
        InternalRenderTheme xmlRenderTheme = InternalRenderTheme.DEFAULT;
        RenderThemeFuture theme = new RenderThemeFuture(AwtGraphicFactory.INSTANCE, xmlRenderTheme, model);
        // super important!! without the following line, all rendering
        // activities will block until the theme is created.
        new Thread(theme).start();
        OsmTilegenerator osmTilegenerator = new OsmTilegenerator(mapDatabase, renderer, theme, model, pTilesize);
        return osmTilegenerator;
    }
 
Example #3
Source File: MapsforgeTilesGenerator.java    From hortonmachine with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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 #4
Source File: MapsforgeNwwLayer.java    From hortonmachine with GNU General Public License v3.0 4 votes vote down vote up
private static OsmTilegenerator getTilegenerator(File[] mapsforgeFiles, Integer tileSize, Float scaleFactor) {
		if (tileSize == null || tileSize < 256) {
			tileSize = TILESIZE;
		}
		if (scaleFactor == null)
			scaleFactor = 1.5f;

//		MapWorkerPool.NUMBER_OF_THREADS = 4;
//		// Map buffer size
//		ReadBuffer.setMaximumBufferSize(6500000);
//		// Square frame buffer
//		FrameBufferController.setUseSquareFrameBuffer(false);

		DisplayModel model = new DisplayModel();
		model.setUserScaleFactor(scaleFactor);
		model.setFixedTileSize(tileSize);

		DataPolicy dataPolicy = DataPolicy.RETURN_ALL;
		MultiMapDataStore mapDatabase = new MultiMapDataStore(dataPolicy);
		for (int i = 0; i < mapsforgeFiles.length; i++)
			mapDatabase.addMapDataStore(new MapFile(mapsforgeFiles[i]), false, false);

		InMemoryTileCache tileCache = new InMemoryTileCache(200);
		DatabaseRenderer renderer = new DatabaseRenderer(mapDatabase, AwtGraphicFactory.INSTANCE, tileCache,
				new TileBasedLabelStore(tileCache.getCapacityFirstLevel()), true, true, null);
		InternalRenderTheme xmlRenderTheme = InternalRenderTheme.DEFAULT;
		RenderThemeFuture theme = new RenderThemeFuture(AwtGraphicFactory.INSTANCE, xmlRenderTheme, model);
		// super important!! without the following line, all rendering
		// activities will block until the theme is created.
		new Thread(theme).start();

		// TODO get back external themes
		// DatabaseRenderer dbRenderer = null;
		// XmlRenderTheme xmlRenderTheme = null;
		// DisplayModel displayModel = null;
		// if (mapsforgeFile.exists()) {
		// mapDatabase.openFile(mapsforgeFile);
		// dbRenderer = new DatabaseRenderer(mapDatabase, graphicFactory);
		//
		// String mapName =
		// FileUtilities.getNameWithoutExtention(mapsforgeFiles[0]);
		// File xmlStyleFile = new File(mapsforgeFiles[0].getParentFile(),
		// mapName + ".xml");
		// if (xmlStyleFile.exists()) {
		// try {
		// xmlRenderTheme = new ExternalRenderTheme(xmlStyleFile);
		// } catch (Exception e) {
		// xmlRenderTheme = InternalRenderTheme.OSMARENDER;
		// }
		// } else {
		// xmlRenderTheme = InternalRenderTheme.OSMARENDER;
		// }
		// displayModel = new DisplayModel();
		// displayModel.setUserScaleFactor(tileSize / 256f);
		// }

		return new OsmTilegenerator(mapDatabase, renderer, theme, model, tileSize);
	}
 
Example #5
Source File: MapsForgeTileSource.java    From osmdroid with Apache License 2.0 3 votes vote down vote up
/**
 * 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
 * @return the tile source
 */
public static MapsForgeTileSource createFromFiles(File[] file) {
    //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(InternalRenderTheme.OSMARENDER.name(), minZoomLevel, maxZoomLevel, tileSizePixels, file, InternalRenderTheme.OSMARENDER, MultiMapDataStore.DataPolicy.RETURN_ALL, null, null);
}
 
Example #6
Source File: MapsForgeTileSource.java    From osmdroid with Apache License 2.0 3 votes vote down vote up
/**
 * 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 #7
Source File: MapsForgeTileSource.java    From osmdroid with Apache License 2.0 3 votes vote down vote up
/**
 * 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 #8
Source File: MapsForgeTileSource.java    From osmdroid with Apache License 2.0 3 votes vote down vote up
/**
 * 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 #9
Source File: MapsForgeTileSource.java    From osmdroid with Apache License 2.0 3 votes vote down vote up
/**
 * 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 #10
Source File: MapsForgeTileSource.java    From osmdroid with Apache License 2.0 2 votes vote down vote up
/**
 * 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);
}