本文整理汇总了Java中org.mapsforge.map.layer.renderer.DatabaseRenderer类的典型用法代码示例。如果您正苦于以下问题:Java DatabaseRenderer类的具体用法?Java DatabaseRenderer怎么用?Java DatabaseRenderer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DatabaseRenderer类属于org.mapsforge.map.layer.renderer包,在下文中一共展示了DatabaseRenderer类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: MapsforgeTileSource
import org.mapsforge.map.layer.renderer.DatabaseRenderer; //导入依赖的package包/类
/**
* 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 file
* @param xmlRenderTheme the themeFuture to render tiles with
*/
protected MapsforgeTileSource(Application app,
File file,
XmlRenderTheme xmlRenderTheme,
MultiMapDataStore.DataPolicy dataPolicy) {
AndroidGraphicFactory.createInstance(app);
// model.setFixedTileSize(256);
mapDatabase = new MultiMapDataStore(dataPolicy);
mapDatabase.addMapDataStore(new MapFile(file), false, false);
InMemoryTileCache tileCache = new InMemoryTileCache(5);
renderer = new DatabaseRenderer(mapDatabase, factory, tileCache,
new TileBasedLabelStore(tileCache.getCapacityFirstLevel()), true, true, null);
Log.d(TAG, "min=" + MIN_ZOOM + " max=" + MAX_ZOOM + " tilesize=" + TILE_SIZE_PIXELS);
themeFuture = new RenderThemeFuture(factory, xmlRenderTheme, model);
//super important!! without the following line, all rendering activities will block until the themeFuture is created.
new Thread(themeFuture).start();
}
示例2: MapsforgeOSMTileSource
import org.mapsforge.map.layer.renderer.DatabaseRenderer; //导入依赖的package包/类
public MapsforgeOSMTileSource(@NonNull Context context,
@NonNull String name,
@NonNull String mapFile,
@NonNull TileCache cache) {
this.context = context;
this.name = name;
this.mapFile = mapFile;
//this.tileCache = cache;
//this.tileWeakCache = new WeakHashMap<>();
MapDatabase mapDatabase = new MapDatabase();
mapGenerator = new DatabaseRenderer(mapDatabase, AndroidGraphicFactory.INSTANCE);
xmlRenderTheme = new RenderTheme();
displayModel = new Model().displayModel;
mapDatabase.closeFile();
mapDatabase.openFile(new File(mapFile));
mapBounds = mapDatabase.getMapFileInfo().boundingBox;
zoomBounds = -1;
}
示例3: MapsforgeTileFactory
import org.mapsforge.map.layer.renderer.DatabaseRenderer; //导入依赖的package包/类
MapsforgeTileFactory(TileFactoryInfo info, String xmlRenderThemeFilename,MapDataStore mapDatabase, FadeConfig fadeColour) {
super(info);
this.fadeColour =fadeColour;
this.mapDatabase = mapDatabase;
zoomLevelConverter = new ZoomLevelConverter(info);
databaseRenderer = new DatabaseRenderer(mapDatabase, AwtGraphicFactory.INSTANCE,createDummyTileCacheForMapsforgeLabelPlacementAlgorithm());
renderTheme =getRenderTheme(xmlRenderThemeFilename);
model = new DisplayModel();
model.setFixedTileSize(TILE_SIZE);
model.setBackgroundColor(backgroundMapColour().getRGB());
// use single thread at the moment as DatabaseRenderer is probably single threaded
service = Executors.newFixedThreadPool(1, new ThreadFactory() {
private int count = 0;
@Override
public Thread newThread(Runnable r) {
Thread t = new Thread(r, "mapsforge-tile-pool-" + count++);
t.setPriority(Thread.MIN_PRIORITY);
t.setDaemon(true);
return t;
}
});
}
示例4: getTile
import org.mapsforge.map.layer.renderer.DatabaseRenderer; //导入依赖的package包/类
private ByteBuf getTile(String themeName, byte zoom, int tx, int ty) throws Exception {
long begin = System.currentTimeMillis();
String action;
RenderThemeFuture rtf = getRenderThemeFuture(themeName);
TileCache tileCache = getTileCache(themeName);
RendererJob theJob = createJob(MAPDS, rtf, zoom, tx, ty);
if (!tileCache.containsKey(theJob)) {
action = "Draw tile";
TileBasedLabelStore tileBasedLabelStore = new TileBasedLabelStore(tileCache.getCapacityFirstLevel());
DatabaseRenderer renderer = new DatabaseRenderer(MAPDS, GRAPHIC_FACTORY, tileCache, tileBasedLabelStore, true, true, null);
TileBitmap tb = renderer.executeJob(theJob);
tileCache.put(theJob, tb);
} else {
action = "Use cached tile";
}
// Load tile as a Netty buffer.
String tilePath = String.format("%s/%s/%d/%d/%d.tile", SAVE_PATH, themeName, zoom, tx, ty);
InputStream tile = new FileInputStream(tilePath);
ByteBuf buffer = Unpooled.buffer();
buffer.writeBytes(tile, tile.available());
double elapsed = (System.currentTimeMillis() - begin) / 1000.0;
// TODO: Use logger.
System.out.printf("%s %s/%d/%d/%d. (%.3f seconds used)\n", action, themeName, zoom, tx, ty, elapsed);
return buffer;
}
示例5: initialize
import org.mapsforge.map.layer.renderer.DatabaseRenderer; //导入依赖的package包/类
public static boolean initialize(String locationOfMapFile,String renderThemeAddr, Context _context) {
Log.i(TAG, "Initilizing started");
mapFilePath = locationOfMapFile;
androidGraphicFactory = AndroidGraphicFactory.INSTANCE;
mapFile = new File(mapFilePath);
displayModel = new DisplayModel();
mapViewPosition = new MapViewPosition(displayModel);
mapDataStore = new MapFile(mapFile);
displayModel.setFixedTileSize(256);
TileCache tileCache = AndroidUtil.createTileCache(context, "111", 256, 1.0f, 1d);
// TileCache tileCache = null;
databaseRenderer = new DatabaseRenderer(mapDataStore, androidGraphicFactory, tileCache);
context = _context;
try {
xmlRenderTheme = new ExternalRenderTheme(new File(renderThemeAddr ));
Log.i(TAG, "xmlRenderTheme initialized successfully");
}
catch(Throwable e)
{
Log.i(TAG, "xmlRenderTheme error initializing ");
e.printStackTrace();
}
renderThemeFuture = new RenderThemeFuture(AndroidGraphicFactory.INSTANCE, xmlRenderTheme, displayModel);
new Thread(renderThemeFuture).run();
Log.i(TAG, "Mapsforge Initializing Ended");
return true;
}
示例6: initialize
import org.mapsforge.map.layer.renderer.DatabaseRenderer; //导入依赖的package包/类
@Override
public void initialize() throws MapSourceInitializationException {
GraphicFactory graphicFactory = AwtGraphicFactory.INSTANCE;
if (!mapFile.exists())
throw new MapSourceInitializationException("File does not exist: " + mapFile.getAbsolutePath());
multiMapDataStore = new MultiMapDataStore(MultiMapDataStore.DataPolicy.RETURN_FIRST);
multiMapDataStore.addMapDataStore(new MapFile(mapFile), true, true);
renderer = new DatabaseRenderer(multiMapDataStore, graphicFactory, tileCache);
renderThemeFuture = new RenderThemeFuture(graphicFactory, xmlRenderTheme, displayModel);
// new Thread(renderThemeFuture).start();
renderThemeFuture.run();
// renderThemeFuture = new RenderThemeFuture(graphicFactory, xmlRenderTheme, displayModel);
// renderThemeFuture.run();
}
示例7: OsmTilegenerator
import org.mapsforge.map.layer.renderer.DatabaseRenderer; //导入依赖的package包/类
public OsmTilegenerator( MapDataStore mapDatabase, final DatabaseRenderer renderer, final RenderThemeFuture renderTheme,
final DisplayModel displayModel, int tileSize ) {
this.mapDatabase = mapDatabase;
this.renderer = renderer;
this.theme = renderTheme;
this.model = displayModel;
this.tileSize = tileSize;
}
示例8: getTilegenerator
import org.mapsforge.map.layer.renderer.DatabaseRenderer; //导入依赖的package包/类
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);
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);
}