Search in sources :

Example 1 with AtlasMapRendererConfiguration

use of net.osmand.core.jni.AtlasMapRendererConfiguration in project OsmAnd-tools by osmandapp.

the class QtCorePanel method init.

@Override
public void init(GLAutoDrawable drawable) {
    NativeEngineOptions options = new NativeEngineOptions();
    options.parseRenderingProperties(renderingProperties);
    MapStylesCollection mapStylesCollection = new MapStylesCollection();
    ResolvedMapStyle mapStyle = null;
    if (this.styleFile != null) {
        mapStylesCollection.addStyleFromFile(this.styleFile);
        System.out.println("Going to use map style from: " + this.styleFile);
        mapStyle = mapStylesCollection.getResolvedStyleByName((new File(this.styleFile)).getName());
    } else {
        System.out.println("Going to use embedded map style");
        mapStyle = mapStylesCollection.getResolvedStyleByName("default");
    }
    if (mapStyle == null) {
        System.err.println("Failed to resolve style");
        release();
        OsmAndCore.ReleaseCore();
        System.exit(0);
    }
    ObfsCollection obfsCollection = new ObfsCollection();
    String filesDir = DataExtractionSettings.getSettings().getBinaryFilesDir();
    obfsCollection.addDirectory(filesDir, false);
    MapPresentationEnvironment mapPresentationEnvironment = new MapPresentationEnvironment(mapStyle, options.density, 1.0f, options.symbolsScale / options.density, options.getLocaleLanguageId(), options.getLanguagePreference());
    referenceTileSize = 256 * options.density;
    int rasterTileSize = Integer.highestOneBit((int) referenceTileSize - 1) * 2;
    mapPresentationEnvironment.setSettings(options.getStyleSettings());
    MapPrimitiviser mapPrimitiviser = new MapPrimitiviser(mapPresentationEnvironment);
    ObfMapObjectsProvider obfMapObjectsProvider = new ObfMapObjectsProvider(obfsCollection);
    MapPrimitivesProvider mapPrimitivesProvider = new MapPrimitivesProvider(obfMapObjectsProvider, mapPrimitiviser, rasterTileSize);
    MapObjectsSymbolsProvider mapObjectsSymbolsProvider = new MapObjectsSymbolsProvider(mapPrimitivesProvider, rasterTileSize);
    MapRasterLayerProvider_Software mapRasterLayerProvider = new MapRasterLayerProvider_Software(mapPrimitivesProvider);
    mapRenderer = OsmAndCore.createMapRenderer(MapRendererClass.AtlasMapRenderer_OpenGL2plus);
    if (mapRenderer == null) {
        System.err.println("Failed to create map renderer 'AtlasMapRenderer_OpenGL2plus'");
        release();
        OsmAndCore.ReleaseCore();
        System.exit(0);
    }
    MapRendererSetupOptions rendererSetupOptions = new MapRendererSetupOptions();
    rendererSetupOptions.setGpuWorkerThreadEnabled(false);
    rendererSetupOptions.setFrameUpdateRequestCallback(callback.getBinding());
    mapRenderer.setup(rendererSetupOptions);
    AtlasMapRendererConfiguration atlasRendererConfiguration = AtlasMapRendererConfiguration.Casts.upcastFrom(mapRenderer.getConfiguration());
    atlasRendererConfiguration.setReferenceTileSizeOnScreenInPixels(referenceTileSize);
    mapRenderer.setConfiguration(AtlasMapRendererConfiguration.Casts.downcastTo_MapRendererConfiguration(atlasRendererConfiguration));
    mapRenderer.addSymbolsProvider(mapObjectsSymbolsProvider);
    mapRenderer.setAzimuth(0.0f);
    mapRenderer.setElevationAngle(90);
    mapRenderer.setDebugSettings(options.getDebugSettings());
    mapCanvas.updateRenderer();
    /*
		 * IMapRasterLayerProvider mapnik = OnlineTileSources.getBuiltIn().createProviderFor("Mapnik (OsmAnd)"); if
		 * (mapnik == null) Log.e(TAG, "Failed to create mapnik");
		 */
    mapRenderer.setMapLayerProvider(0, mapRasterLayerProvider);
}
Also used : ResolvedMapStyle(net.osmand.core.jni.ResolvedMapStyle) MapRasterLayerProvider_Software(net.osmand.core.jni.MapRasterLayerProvider_Software) AtlasMapRendererConfiguration(net.osmand.core.jni.AtlasMapRendererConfiguration) Point(java.awt.Point) MapPrimitiviser(net.osmand.core.jni.MapPrimitiviser) MapPresentationEnvironment(net.osmand.core.jni.MapPresentationEnvironment) MapPrimitivesProvider(net.osmand.core.jni.MapPrimitivesProvider) MapObjectsSymbolsProvider(net.osmand.core.jni.MapObjectsSymbolsProvider) MapRendererSetupOptions(net.osmand.core.jni.MapRendererSetupOptions) ObfsCollection(net.osmand.core.jni.ObfsCollection) File(java.io.File) ObfMapObjectsProvider(net.osmand.core.jni.ObfMapObjectsProvider) MapStylesCollection(net.osmand.core.jni.MapStylesCollection)

Aggregations

Point (java.awt.Point)1 File (java.io.File)1 AtlasMapRendererConfiguration (net.osmand.core.jni.AtlasMapRendererConfiguration)1 MapObjectsSymbolsProvider (net.osmand.core.jni.MapObjectsSymbolsProvider)1 MapPresentationEnvironment (net.osmand.core.jni.MapPresentationEnvironment)1 MapPrimitivesProvider (net.osmand.core.jni.MapPrimitivesProvider)1 MapPrimitiviser (net.osmand.core.jni.MapPrimitiviser)1 MapRasterLayerProvider_Software (net.osmand.core.jni.MapRasterLayerProvider_Software)1 MapRendererSetupOptions (net.osmand.core.jni.MapRendererSetupOptions)1 MapStylesCollection (net.osmand.core.jni.MapStylesCollection)1 ObfMapObjectsProvider (net.osmand.core.jni.ObfMapObjectsProvider)1 ObfsCollection (net.osmand.core.jni.ObfsCollection)1 ResolvedMapStyle (net.osmand.core.jni.ResolvedMapStyle)1