org.mapsforge.map.rendertheme.InternalRenderTheme Java Examples

The following examples show how to use org.mapsforge.map.rendertheme.InternalRenderTheme. 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: 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 #2
Source File: MapsforgeSimpleViewer.java    From hortonmachine with GNU General Public License v3.0 5 votes vote down vote up
private static TileRendererLayer createTileRendererLayer( TileCache tileCache, MapDataStore mapDataStore,
        IMapViewPosition mapViewPosition ) {
    TileRendererLayer tileRendererLayer = new TileRendererLayer(tileCache, mapDataStore, mapViewPosition, false, true, false,
            GRAPHIC_FACTORY){
        @Override
        public boolean onTap( LatLong tapLatLong, Point layerXY, Point tapXY ) {
            System.out.println("Tap on: " + tapLatLong);
            return true;
        }
    };
    tileRendererLayer.setXmlRenderTheme(InternalRenderTheme.DEFAULT);
    return tileRendererLayer;
}
 
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: Androzic.java    From Androzic with GNU General Public License v3.0 5 votes vote down vote up
private void initializeRenderTheme()
{
	try
	{
		AndroidSvgBitmapStore.clear();
		xmlRenderTheme = new BufferedAssetsRenderTheme(this, "", "renderthemes/rendertheme-v4.xml", this);
	}
	catch (IOException e)
	{
		e.printStackTrace();
		xmlRenderTheme = InternalRenderTheme.OSMARENDER;
	}
	ForgeMap.onRenderThemeChanged();
}
 
Example #5
Source File: MapsforgeActivity.java    From WhereYouGo with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.menu_refresh:
            refresh();
            return true;
        case R.id.menu_info:
            return true;

        case R.id.menu_info_map_file:
            if (this.mapGeneratorInternal == MapGeneratorInternal.DATABASE_RENDERER
                    && this.mapView.getMapFile() != null)
                showDialog(DIALOG_INFO_MAP_FILE);
            return true;

        case R.id.menu_info_about:
            startActivity(new Intent(this, InfoView.class));
            return true;

        case R.id.menu_position:
            return true;

        case R.id.menu_position_my_location_enable:
            enableShowMyLocation(true);
            onPrepareOptionsMenu(this.menu);
            return true;

        case R.id.menu_position_my_location_disable:
            disableShowMyLocation();
            onPrepareOptionsMenu(this.menu);
            return true;

        case R.id.menu_position_last_known:
            gotoLastKnownPosition();
            return true;

        case R.id.menu_position_target:
            GeoPoint geoPoint = navigationOverlay.getTarget();
            if (geoPoint != null)
                this.mapView.getMapViewPosition().setCenter(geoPoint);
            return true;

        case R.id.menu_position_enter_coordinates:
            showDialog(DIALOG_ENTER_COORDINATES);
            return true;

        case R.id.menu_position_map_center:
            if (this.mapGeneratorInternal == MapGeneratorInternal.DATABASE_RENDERER) {
                // disable GPS follow mode if it is enabled
                disableSnapToLocation(true);
                MapFileInfo mapFileInfo = this.mapView.getMapDatabase().getMapFileInfo();
                this.mapView.getMapViewPosition().setCenter(mapFileInfo.boundingBox.getCenterPoint());
            }
            return true;

        case R.id.menu_screenshot:
            return true;

        case R.id.menu_screenshot_jpeg:
            this.screenshotCapturer.captureScreenshot(CompressFormat.JPEG);
            return true;

        case R.id.menu_screenshot_png:
            this.screenshotCapturer.captureScreenshot(CompressFormat.PNG);
            return true;

        case R.id.menu_preferences:
            startActivity(new Intent(this, EditPreferences.class));
            return true;

        case R.id.menu_render_theme:
            return true;

        case R.id.menu_render_theme_osmarender:
            this.mapView.setRenderTheme(InternalRenderTheme.OSMARENDER);
            return true;

        case R.id.menu_render_theme_select_file:
            startRenderThemePicker();
            return true;

        case R.id.menu_mapfile:
            startMapFilePicker();
            return true;

        case R.id.menu_acquire_from_cgeo:
            checkOfflineMapFile(true);
            return true;

        case R.id.menu_mapgenerator:
            return true;

        default:
            return false;
    }
}
 
Example #6
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 #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
 * @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);
}