Skip to content

Commit

Permalink
upgrade to mapsforge 0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
PGWelch committed Feb 6, 2015
1 parent aaca128 commit 03d0d0d
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 8 deletions.
5 changes: 1 addition & 4 deletions com.opendoorlogistics.core/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@
<classpathentry exported="true" kind="lib" path="libs/jackson-annotations-2.4.1.jar"/>
<classpathentry exported="true" kind="lib" path="libs/jackson-core-2.4.1.jar" sourcepath="C:/Users/Phil/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.4.1/jackson-core-2.4.1-sources.jar"/>
<classpathentry exported="true" kind="lib" path="libs/jackson-databind-2.4.1.jar"/>
<classpathentry kind="lib" path="libs/mapsforge-core-0.4.0.jar" sourcepath="C:/Users/Phil/Dropbox/Business/DevelopmentSpace/3rdParty/mapsforge/release-0.4.0"/>
<classpathentry kind="lib" path="libs/mapsforge-map-0.4.0.jar" sourcepath="C:/Users/Phil/Dropbox/Business/DevelopmentSpace/3rdParty/mapsforge/release-0.4.0"/>
<classpathentry kind="lib" path="libs/mapsforge-map-awt-0.4.0.jar"/>
<classpathentry kind="lib" path="libs/mapsforge-map-reader-0.4.0.jar" sourcepath="C:/Users/Phil/Dropbox/Business/DevelopmentSpace/3rdParty/mapsforge/release-0.4.0"/>
<classpathentry kind="lib" path="libs/xercesImpl.jar" sourcepath="C:/Users/Phil/.m2/repository/xerces/xercesImpl/2.11.0/xercesImpl-2.11.0-sources.jar"/>
<classpathentry kind="lib" path="libs/xml-apis.jar"/>
<classpathentry kind="lib" path="libs/xmlbeans-2.6.0.jar"/>
Expand All @@ -47,5 +43,6 @@
<classpathentry kind="lib" path="libs/poi-ooxml-3.11-beta2-20140822.jar" sourcepath="C:/Users/Phil/Dropbox/Business/DevelopmentSpace/3rdParty/poi-3.11-beta2/src"/>
<classpathentry kind="lib" path="libs/poi-ooxml-schemas-3.11-beta2-20140822.jar"/>
<classpathentry kind="lib" path="libs/log4j-1.2.13.jar"/>
<classpathentry kind="lib" path="libs/mapsforge-SwingMapViewer-0.5.0.jar" sourcepath="C:/Users/Phil/Dropbox/Business/DevelopmentSpace/3rdParty/mapsforge-0.5.0"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ public BackgroundMapConfig(Properties properties) {

tileserverUrl = getStr(map, "tileserver.url", tileserverUrl);

mapsforgeFilename = getStr(map, "mapsforge.file", mapsforgeFilename);
// get mapsforge filename and remove any speech marks
String tmp = getStr(map, "mapsforge.file", mapsforgeFilename);
if(tmp!=null){
tmp=tmp.replaceAll("\"", "");
}
mapsforgeFilename = tmp;

String typeString = getStr(map, "type", type.name());
for (BackgroundType t : BackgroundType.values()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
import org.mapsforge.core.graphics.Canvas;
import org.mapsforge.core.graphics.TileBitmap;
import org.mapsforge.map.awt.AwtGraphicFactory;
import org.mapsforge.map.layer.cache.FileSystemTileCache;
import org.mapsforge.map.layer.cache.InMemoryTileCache;
import org.mapsforge.map.layer.cache.TileCache;
import org.mapsforge.map.layer.cache.TwoLevelTileCache;
import org.mapsforge.map.layer.renderer.DatabaseRenderer;
import org.mapsforge.map.layer.renderer.RendererJob;
import org.mapsforge.map.model.DisplayModel;
Expand Down Expand Up @@ -57,7 +61,7 @@ class MapsforgeTileFactory extends TileFactory {
this.fadeColour =fadeColour;
this.mapDatabase = mapDatabase;

databaseRenderer = new DatabaseRenderer(mapDatabase, AwtGraphicFactory.INSTANCE);
databaseRenderer = new DatabaseRenderer(mapDatabase, AwtGraphicFactory.INSTANCE,createTileCache());
renderTheme = InternalRenderTheme.OSMARENDER;
model = new DisplayModel();
model.setFixedTileSize(TILE_SIZE);
Expand Down Expand Up @@ -281,8 +285,8 @@ public BufferedImage call() {
}

// render the mapsforge tile
org.mapsforge.core.model.Tile mtile = new org.mapsforge.core.model.Tile(tile.getX(), tile.getY(), mapsforgeZoom);
RendererJob job = new RendererJob(mtile, mapFile, renderTheme, model, TEXT_SCALE, true);
org.mapsforge.core.model.Tile mtile = new org.mapsforge.core.model.Tile(tile.getX(), tile.getY(), mapsforgeZoom, TILE_SIZE);
RendererJob job = new RendererJob(mtile, mapFile, renderTheme, model, TEXT_SCALE, true, false);
TileBitmap bitmap = databaseRenderer.executeJob(job);

// copy it over onto an image (CompressedImage needs TYPE_INT_ARGB and anyway we can't access the buffered image internal to the tile)
Expand Down Expand Up @@ -363,6 +367,12 @@ private synchronized void cacheImage(int x, int y, int zoom, CompressedImage com
// cache.put(getTileId(x,y,zoom), compressed);
}

private TileCache createTileCache() {
TileCache firstLevelTileCache = new InMemoryTileCache(128);
File cacheDirectory = new File(System.getProperty("java.io.tmpdir"), "mapsforge");
TileCache secondLevelTileCache = new FileSystemTileCache(1024, cacheDirectory, AwtGraphicFactory.INSTANCE);
return new TwoLevelTileCache(firstLevelTileCache, secondLevelTileCache);
}


}
9 changes: 9 additions & 0 deletions com.opendoorlogistics.studio/config/backgroundmap.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# fade.a = 0

type = MAPSFORGE
mapsforge.file = "C:\Users\Phil\Dropbox\Business\Data\Mapsforge\maps-0.5\great_britain.map"
# tileserver.url = http://tile.openstreetmap.org
# tileserver.url = http://otile1.mqcdn.com/tiles/1.0.0/osm
# tileserver.url = http://otile1.mqcdn.com/tiles/1.0.0/sat
# tileserver.url = http://tile.thunderforest.com/landscape

0 comments on commit 03d0d0d

Please sign in to comment.