Add custom routing.xml for device

This commit is contained in:
Victor Shcherb 2012-07-09 00:35:06 +02:00
parent 02a44e0a27
commit f90027684c
2 changed files with 16 additions and 1 deletions

View file

@ -64,6 +64,7 @@ import android.view.WindowManager;
public class ResourceManager {
public static final String APP_DIR = "osmand/"; //$NON-NLS-1$
public static final String ROUTING_XML = APP_DIR + "routing.xml";
public static final String POI_PATH = APP_DIR + IndexConstants.POI_INDEX_DIR;
public static final String VOICE_PATH = APP_DIR + IndexConstants.VOICE_INDEX_DIR;
public static final String GPX_PATH = APP_DIR + "tracks";

View file

@ -1,5 +1,7 @@
package net.osmand.plus.routing;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
@ -30,6 +32,7 @@ import net.osmand.osm.LatLon;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.ResourceManager;
import net.osmand.plus.activities.ApplicationMode;
import net.osmand.plus.render.NativeOsmandLibrary;
import net.osmand.router.BinaryRoutePlanner;
@ -302,7 +305,18 @@ public class RouteProvider {
protected RouteCalculationResult findVectorMapsRoute(Location start, LatLon end, ApplicationMode mode, boolean fast, OsmandApplication app, boolean leftSide) throws IOException {
BinaryMapIndexReader[] files = app.getResourceManager().getRoutingMapFiles();
BinaryRoutePlanner router = new BinaryRoutePlanner(NativeOsmandLibrary.getLoadedLibrary(), files);
RoutingConfiguration.Builder config = RoutingConfiguration.getDefault();
File routingXml = app.getSettings().extendOsmandPath(ResourceManager.ROUTING_XML);
RoutingConfiguration.Builder config ;
if (routingXml.exists() && routingXml.canRead()) {
try {
config = RoutingConfiguration.parseFromInputStream(new FileInputStream(routingXml));
} catch (SAXException e) {
throw new IllegalStateException(e);
}
} else {
config = RoutingConfiguration.getDefault();
}
GeneralRouterProfile p ;
if (mode == ApplicationMode.BICYCLE) {
p = GeneralRouterProfile.BICYCLE;