use of net.osmand.core.jni.MapRendererSetupOptions 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);
}
Aggregations