initial commit of BRouter Version 0.98

This commit is contained in:
Arndt Brenschede 2014-01-18 15:29:05 +01:00
parent e4ae2b37d3
commit 91e62f1164
120 changed files with 15382 additions and 0 deletions

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1"
android:versionName="1.0" package="btools.routingapp">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".BRouterActivity"
android:label="@string/app_name"
android:screenOrientation="portrait" android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service
android:exported="true"
android:name=".BRouterService"
android:enabled="true"
android:process=":brouter_service">
</service>
</application>
<uses-sdk android:minSdkVersion="5"></uses-sdk>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.permission.WAKE_LOCK"></uses-permission>
</manifest>

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>

View file

@ -0,0 +1,5 @@
package btools.routingapp;
public final class BuildConfig {
public static final boolean DEBUG = true;
}

View file

@ -0,0 +1,136 @@
/*
* This file is auto-generated. DO NOT MODIFY.
* Original file: C:\\brouter\\brouter-routing-app\\src\\main\\java\\btools\\routingapp\\IBRouterService.aidl
*/
package btools.routingapp;
public interface IBRouterService extends android.os.IInterface
{
/** Local-side IPC implementation stub class. */
public static abstract class Stub extends android.os.Binder implements btools.routingapp.IBRouterService
{
private static final java.lang.String DESCRIPTOR = "btools.routingapp.IBRouterService";
/** Construct the stub at attach it to the interface. */
public Stub()
{
this.attachInterface(this, DESCRIPTOR);
}
/**
* Cast an IBinder object into an btools.routingapp.IBRouterService interface,
* generating a proxy if needed.
*/
public static btools.routingapp.IBRouterService asInterface(android.os.IBinder obj)
{
if ((obj==null)) {
return null;
}
android.os.IInterface iin = obj.queryLocalInterface(DESCRIPTOR);
if (((iin!=null)&&(iin instanceof btools.routingapp.IBRouterService))) {
return ((btools.routingapp.IBRouterService)iin);
}
return new btools.routingapp.IBRouterService.Stub.Proxy(obj);
}
@Override public android.os.IBinder asBinder()
{
return this;
}
@Override public boolean onTransact(int code, android.os.Parcel data, android.os.Parcel reply, int flags) throws android.os.RemoteException
{
switch (code)
{
case INTERFACE_TRANSACTION:
{
reply.writeString(DESCRIPTOR);
return true;
}
case TRANSACTION_getTrackFromParams:
{
data.enforceInterface(DESCRIPTOR);
android.os.Bundle _arg0;
if ((0!=data.readInt())) {
_arg0 = android.os.Bundle.CREATOR.createFromParcel(data);
}
else {
_arg0 = null;
}
java.lang.String _result = this.getTrackFromParams(_arg0);
reply.writeNoException();
reply.writeString(_result);
return true;
}
}
return super.onTransact(code, data, reply, flags);
}
private static class Proxy implements btools.routingapp.IBRouterService
{
private android.os.IBinder mRemote;
Proxy(android.os.IBinder remote)
{
mRemote = remote;
}
@Override public android.os.IBinder asBinder()
{
return mRemote;
}
public java.lang.String getInterfaceDescriptor()
{
return DESCRIPTOR;
}
//param params--> Map of params:
// "pathToFileResult"-->String with the path to where the result must be saved, including file name and extension
// -->if null, the track is passed via the return argument
// "maxRunningTime"-->String with a number of seconds for the routing timeout, default = 60
// "trackFormat"-->[kml|gpx] default = gpx
// "lats"-->double[] array of latitudes; 2 values at least.
// "lons"-->double[] array of longitudes; 2 values at least.
// "nogoLats"-->double[] array of nogo latitudes; may be null.
// "nogoLons"-->double[] array of nogo longitudes; may be null.
// "nogoRadi"-->double[] array of nogo radius in meters; may be null.
// "fast"-->[0|1]
// "v"-->[motorcar|bicycle|foot]
//return null if all ok and no path given, the track if ok and path given, an error message if it was wrong
//call in a background thread, heavy task!
@Override public java.lang.String getTrackFromParams(android.os.Bundle params) throws android.os.RemoteException
{
android.os.Parcel _data = android.os.Parcel.obtain();
android.os.Parcel _reply = android.os.Parcel.obtain();
java.lang.String _result;
try {
_data.writeInterfaceToken(DESCRIPTOR);
if ((params!=null)) {
_data.writeInt(1);
params.writeToParcel(_data, 0);
}
else {
_data.writeInt(0);
}
mRemote.transact(Stub.TRANSACTION_getTrackFromParams, _data, _reply, 0);
_reply.readException();
_result = _reply.readString();
}
finally {
_reply.recycle();
_data.recycle();
}
return _result;
}
}
static final int TRANSACTION_getTrackFromParams = (android.os.IBinder.FIRST_CALL_TRANSACTION + 0);
}
//param params--> Map of params:
// "pathToFileResult"-->String with the path to where the result must be saved, including file name and extension
// -->if null, the track is passed via the return argument
// "maxRunningTime"-->String with a number of seconds for the routing timeout, default = 60
// "trackFormat"-->[kml|gpx] default = gpx
// "lats"-->double[] array of latitudes; 2 values at least.
// "lons"-->double[] array of longitudes; 2 values at least.
// "nogoLats"-->double[] array of nogo latitudes; may be null.
// "nogoLons"-->double[] array of nogo longitudes; may be null.
// "nogoRadi"-->double[] array of nogo radius in meters; may be null.
// "fast"-->[0|1]
// "v"-->[motorcar|bicycle|foot]
//return null if all ok and no path given, the track if ok and path given, an error message if it was wrong
//call in a background thread, heavy task!
public java.lang.String getTrackFromParams(android.os.Bundle params) throws android.os.RemoteException;
}

View file

@ -0,0 +1,22 @@
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/
package btools.routingapp;
public final class R {
public static final class attr {
}
public static final class drawable {
public static final int icon=0x7f020000;
}
public static final class layout {
public static final int main=0x7f030000;
}
public static final class string {
public static final int app_name=0x7f040000;
}
}

View file

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.btools</groupId>
<artifactId>brouter</artifactId>
<version>0.98</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>brouter-routing-app</artifactId>
<packaging>apk</packaging>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>4.1.1.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.btools</groupId>
<artifactId>brouter-core</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

View file

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>AccelerometerPlay</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View file

@ -0,0 +1,11 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "ant.properties", and override values to adapt the script to your
# project structure.
# Project target.
target=android-10

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

View file

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2010 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
</LinearLayout>

View file

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2010 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<resources>
<string name="app_name">BRouter</string>
</resources>

View file

@ -0,0 +1,375 @@
package btools.routingapp;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.speech.tts.TextToSpeech.OnInitListener;
import android.view.Display;
import android.view.WindowManager;
import android.widget.EditText;
import btools.router.OsmNodeNamed;
public class BRouterActivity extends Activity implements OnInitListener {
private static final int DIALOG_SELECTPROFILE_ID = 1;
private static final int DIALOG_EXCEPTION_ID = 2;
private static final int DIALOG_WARNEXPIRY_ID = 3;
private static final int DIALOG_TEXTENTRY_ID = 4;
private static final int DIALOG_VIASELECT_ID = 5;
private static final int DIALOG_NOGOSELECT_ID = 6;
private static final int DIALOG_SHOWRESULT_ID = 7;
private static final int DIALOG_ROUTINGMODES_ID = 8;
private static final int DIALOG_MODECONFIGOVERVIEW_ID = 9;
private static final int DIALOG_PICKWAYPOINT_ID = 10;
private BRouterView mBRouterView;
private PowerManager mPowerManager;
private WindowManager mWindowManager;
private Display mDisplay;
private WakeLock mWakeLock;
/** Called when the activity is first created. */
@Override
@SuppressWarnings("deprecation")
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Get an instance of the PowerManager
mPowerManager = (PowerManager) getSystemService(POWER_SERVICE);
// Get an instance of the WindowManager
mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
mDisplay = mWindowManager.getDefaultDisplay();
// Create a bright wake lock
mWakeLock = mPowerManager.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, getClass()
.getName());
// instantiate our simulation view and set it as the activity's content
mBRouterView = new BRouterView(this);
setContentView(mBRouterView);
}
@Override
@SuppressWarnings("deprecation")
protected Dialog onCreateDialog(int id)
{
AlertDialog.Builder builder;
switch(id)
{
case DIALOG_SELECTPROFILE_ID:
builder = new AlertDialog.Builder(this);
builder.setTitle("Select a routing profile");
builder.setItems(availableProfiles, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
selectedProfile = availableProfiles[item];
mBRouterView.startProcessing(selectedProfile);
}
});
return builder.create();
case DIALOG_ROUTINGMODES_ID:
builder = new AlertDialog.Builder(this);
builder.setTitle( message );
builder.setMultiChoiceItems(routingModes, routingModesChecked, new DialogInterface.OnMultiChoiceClickListener() {
@Override
public void onClick(DialogInterface dialog, int which,
boolean isChecked) {
routingModesChecked[which] = isChecked;
}
});
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
mBRouterView.configureService(routingModes,routingModesChecked);
}
});
return builder.create();
case DIALOG_EXCEPTION_ID:
builder = new AlertDialog.Builder(this);
builder.setTitle( "An Error occured" )
.setMessage( errorMessage )
.setPositiveButton( "OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
mBRouterView.continueProcessing();
}
});
return builder.create();
case DIALOG_WARNEXPIRY_ID:
builder = new AlertDialog.Builder(this);
builder.setMessage( errorMessage )
.setPositiveButton( "OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
mBRouterView.startProcessing(selectedProfile);
}
});
return builder.create();
case DIALOG_TEXTENTRY_ID:
builder = new AlertDialog.Builder(this);
builder.setTitle("Enter SDCARD base dir:");
builder.setMessage(message);
final EditText input = new EditText(this);
input.setText( defaultbasedir );
builder.setView(input);
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String basedir = input.getText().toString();
mBRouterView.startSetup(basedir, true );
}
});
return builder.create();
case DIALOG_VIASELECT_ID:
builder = new AlertDialog.Builder(this);
builder.setTitle("Check VIA Selection:");
builder.setMultiChoiceItems(availableVias, getCheckedBooleanArray( availableVias.length ),
new DialogInterface.OnMultiChoiceClickListener() {
@Override
public void onClick(DialogInterface dialog, int which,
boolean isChecked) {
if (isChecked)
{
selectedVias.add(availableVias[which]);
}
else
{
selectedVias.remove(availableVias[which]);
}
}
});
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
mBRouterView.updateViaList( selectedVias );
mBRouterView.startProcessing(selectedProfile);
}
});
return builder.create();
case DIALOG_NOGOSELECT_ID:
builder = new AlertDialog.Builder(this);
builder.setTitle("Check NoGo Selection:");
String[] nogoNames = new String[nogoList.size()];
for( int i=0; i<nogoList.size(); i++ ) nogoNames[i] = nogoList.get(i).name;
final boolean[] nogoEnabled = getCheckedBooleanArray(nogoList.size());
builder.setMultiChoiceItems(nogoNames, getCheckedBooleanArray( nogoNames.length ),
new DialogInterface.OnMultiChoiceClickListener() {
@Override
public void onClick(DialogInterface dialog, int which, boolean isChecked) {
nogoEnabled[which] = isChecked;
}
});
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
mBRouterView.updateNogoList( nogoEnabled );
mBRouterView.startProcessing(selectedProfile);
}
});
return builder.create();
case DIALOG_SHOWRESULT_ID:
String leftLabel = wpCount < 0 ? "Exit" : ( wpCount == 0 ? "Select from" : "Select to/via" );
String rightLabel = wpCount < 2 ? "Server-Mode" : "Calc Route";
builder = new AlertDialog.Builder(this);
builder.setTitle( title )
.setMessage( errorMessage )
.setPositiveButton( leftLabel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
if ( wpCount < 0 ) finish();
else mBRouterView.pickWaypoints();
}
})
.setNegativeButton( rightLabel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
if ( wpCount < 2 ) mBRouterView.startConfigureService();
else
{
mBRouterView.finishWaypointSelection();
mBRouterView.startProcessing(selectedProfile);
}
}
});
return builder.create();
case DIALOG_MODECONFIGOVERVIEW_ID:
builder = new AlertDialog.Builder(this);
builder.setTitle( "Success" )
.setMessage( message )
.setPositiveButton( "Exit", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
finish();
}
});
return builder.create();
case DIALOG_PICKWAYPOINT_ID:
builder = new AlertDialog.Builder(this);
builder.setTitle( wpCount > 0 ? "Select to/via" : "Select from" );
builder.setItems(availableWaypoints, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
mBRouterView.updateWaypointList( availableWaypoints[item] );
mBRouterView.startProcessing(selectedProfile);
}
});
return builder.create();
default:
return null;
}
}
private boolean[] getCheckedBooleanArray( int size )
{
boolean[] checked = new boolean[size];
for( int i=0; i<checked.length; i++ ) checked[i] = true;
return checked;
}
private String[] availableProfiles;
private String selectedProfile = null;
private String[] availableWaypoints;
private String selectedWaypoint = null;
private String[] routingModes;
private boolean[] routingModesChecked;
private String defaultbasedir = null;
private String message = null;
private String[] availableVias;
private Set<String> selectedVias;
private List<OsmNodeNamed> nogoList;
@SuppressWarnings("deprecation")
public void selectProfile( String[] items )
{
availableProfiles = items;
showDialog( DIALOG_SELECTPROFILE_ID );
}
@SuppressWarnings("deprecation")
public void selectRoutingModes( String[] modes, boolean[] modesChecked, String message )
{
routingModes = modes;
routingModesChecked = modesChecked;
this.message = message;
showDialog( DIALOG_ROUTINGMODES_ID );
}
@SuppressWarnings("deprecation")
public void showModeConfigOverview( String message )
{
this.message = message;
showDialog( DIALOG_MODECONFIGOVERVIEW_ID );
}
@SuppressWarnings("deprecation")
public void selectBasedir( String defaultBasedir, String message )
{
this.defaultbasedir = defaultBasedir;
this.message = message;
showDialog( DIALOG_TEXTENTRY_ID );
}
@SuppressWarnings("deprecation")
public void selectVias( String[] items )
{
availableVias = items;
selectedVias = new HashSet<String>(availableVias.length);
for( String via : items ) selectedVias.add( via );
showDialog( DIALOG_VIASELECT_ID );
}
@SuppressWarnings("deprecation")
public void selectWaypoint( String[] items )
{
availableWaypoints = items;
showNewDialog( DIALOG_PICKWAYPOINT_ID );
}
@SuppressWarnings("deprecation")
public void selectNogos( List<OsmNodeNamed> nogoList )
{
this.nogoList = nogoList;
showDialog( DIALOG_NOGOSELECT_ID );
}
private Set<Integer> dialogIds = new HashSet<Integer>();
private void showNewDialog( int id )
{
if ( dialogIds.contains( new Integer( id ) ) )
{
removeDialog( id );
}
dialogIds.add( new Integer( id ) );
showDialog( id );
}
private String errorMessage;
private String title;
private int wpCount;
@SuppressWarnings("deprecation")
public void showErrorMessage( String msg )
{
errorMessage = msg;
showNewDialog( DIALOG_EXCEPTION_ID );
}
@SuppressWarnings("deprecation")
public void showResultMessage( String title, String msg, int wpCount )
{
errorMessage = msg;
this.title = title;
this.wpCount = wpCount;
showNewDialog( DIALOG_SHOWRESULT_ID );
}
@Override
protected void onResume() {
super.onResume();
/*
* when the activity is resumed, we acquire a wake-lock so that the
* screen stays on, since the user will likely not be fiddling with the
* screen or buttons.
*/
mWakeLock.acquire();
// Start the simulation
mBRouterView.startSimulation();
}
@Override
protected void onPause() {
super.onPause();
/*
* When the activity is paused, we make sure to stop the simulation,
* release our sensor resources and wake locks
*/
// Stop the simulation
mBRouterView.stopSimulation();
// and release our wake-lock
mWakeLock.release();
}
@Override
public void onInit(int i)
{
}
}

View file

@ -0,0 +1,146 @@
package btools.routingapp;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.StringTokenizer;
import android.app.Service;
import android.content.Intent;
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;
import btools.router.OsmNodeNamed;
public class BRouterService extends Service
{
@Override
public IBinder onBind(Intent arg0) {
Log.d(getClass().getSimpleName(), "onBind()");
return myBRouterServiceStub;
}
private IBRouterService.Stub myBRouterServiceStub = new IBRouterService.Stub()
{
@Override
public String getTrackFromParams(Bundle params) throws RemoteException
{
BRouterWorker worker = new BRouterWorker();
// get base dir from private file
String baseDir = null;
InputStream configInput = null;
try
{
configInput = openFileInput( "config.dat" );
BufferedReader br = new BufferedReader( new InputStreamReader (configInput ) );
baseDir = br.readLine();
}
catch( Exception e ) {}
finally
{
if ( configInput != null ) try { configInput.close(); } catch( Exception ee ) {}
}
String fast = params.getString( "fast" );
boolean isFast = "1".equals( fast ) || "true".equals( fast ) || "yes".equals( fast );
String mode_key = params.getString( "v" ) + "_" + (isFast ? "fast" : "short");
boolean configFound = false;
BufferedReader br = null;
try
{
String modesFile = baseDir + "/brouter/modes/serviceconfig.dat";
br = new BufferedReader( new FileReader (modesFile ) );
worker.segmentDir = baseDir + "/brouter/segments2";
for(;;)
{
String line = br.readLine();
if ( line == null ) break;
ServiceModeConfig smc = new ServiceModeConfig( line );
if ( !smc.mode.equals( mode_key ) ) continue;
worker.profilePath = baseDir + "/brouter/profiles2/" + smc.profile + ".brf";
worker.rawTrackPath = baseDir + "/brouter/modes/" + mode_key + "_rawtrack.dat";
CoordinateReader cor = CoordinateReader.obtainValidReader( baseDir );
worker.nogoList = new ArrayList<OsmNodeNamed>();
// veto nogos by profiles veto list
for(OsmNodeNamed nogo : cor.nogopoints )
{
if ( !smc.nogoVetos.contains( nogo.ilon + "," + nogo.ilat ) )
{
worker.nogoList.add( nogo );
}
}
configFound = true;
}
}
catch( Exception e )
{
return "no brouter service config found, mode " + mode_key;
}
finally
{
if ( br != null ) try { br.close(); } catch( Exception ee ) {}
}
if ( !configFound )
{
return "no brouter service config found for mode " + mode_key;
}
try
{
return worker.getTrackFromParams(params);
}
catch( IllegalArgumentException iae )
{
return iae.getMessage();
}
}
};
@Override
public void onCreate()
{
super.onCreate();
Log.d(getClass().getSimpleName(),"onCreate()");
}
@Override
public void onDestroy()
{
super.onDestroy();
Log.d(getClass().getSimpleName(),"onDestroy()");
}
// This is the old onStart method that will be called on the pre-2.0
// platform. On 2.0 or later we override onStartCommand() so this
// method will not be called.
@Override
@SuppressWarnings("deprecation")
public void onStart(Intent intent, int startId)
{
Log.d(getClass().getSimpleName(), "onStart()");
handleStart(intent, startId);
}
@Override
public int onStartCommand(Intent intent, int flags, int startId)
{
handleStart(intent, startId);
return START_STICKY;
}
void handleStart(Intent intent, int startId)
{
}
}

View file

@ -0,0 +1,760 @@
package btools.routingapp;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Environment;
import android.util.DisplayMetrics;
import android.view.View;
import android.widget.Toast;
import btools.expressions.BExpressionContext;
import btools.mapaccess.OsmNode;
import btools.router.OsmNodeNamed;
import btools.router.OsmTrack;
import btools.router.RoutingContext;
import btools.router.RoutingEngine;
public class BRouterView extends View
{
RoutingEngine cr;
private int imgw;
private int imgh;
private int centerLon;
private int centerLat;
private double scaleLon;
private double scaleLat;
private List<OsmNodeNamed> wpList;
private List<OsmNodeNamed> nogoList;
private List<OsmNodeNamed> nogoVetoList;
private OsmTrack rawTrack;
private String modesDir;
private String tracksDir;
private String segmentDir;
private String profileDir;
private String profilePath;
private String profileName;
private String sourceHint;
private boolean waitingForSelection = false;
private boolean needsViaSelection;
private boolean needsNogoSelection;
private boolean needsWaypointSelection;
private long lastDataTime = System.currentTimeMillis();
private CoordinateReader cor;
private int[] imgPixels;
public void startSimulation() {
}
public void stopSimulation() {
if ( cr != null ) cr.terminate();
}
public BRouterView(Context context) {
super(context);
DisplayMetrics metrics = new DisplayMetrics();
((Activity)getContext()).getWindowManager().getDefaultDisplay().getMetrics(metrics);
imgw = metrics.widthPixels;
imgh = metrics.heightPixels;
// get base dir from private file
String baseDir = null;
InputStream configInput = null;
try
{
configInput = getContext().openFileInput( "config.dat" );
BufferedReader br = new BufferedReader( new InputStreamReader (configInput ) );
baseDir = br.readLine();
}
catch( Exception e ) {}
finally
{
if ( configInput != null ) try { configInput.close(); } catch( Exception ee ) {}
}
// check if valid
boolean bdValid = false;
if ( baseDir != null )
{
File bd = new File( baseDir );
bdValid = bd.isDirectory();
File brd = new File( bd, "brouter" );
if ( brd.isDirectory() )
{
startSetup( baseDir, false );
return;
}
}
String message = baseDir == null ?
"(no basedir configured previously)" :
"(previous basedir " + baseDir +
( bdValid ? " does not contain 'brouter' subfolder)"
: " is not valid)" );
((BRouterActivity)getContext()).selectBasedir( guessBaseDir(), message );
waitingForSelection = true;
}
public void startSetup( String baseDir, boolean storeBasedir )
{
File fbd = new File( baseDir );
if ( !fbd.isDirectory() )
{
throw new IllegalArgumentException( "Base-directory " + baseDir + " is not a directory " );
}
String basedir = fbd.getAbsolutePath();
if ( storeBasedir )
{
BufferedWriter bw = null;
try
{
OutputStream configOutput = getContext().openFileOutput( "config.dat", Context.MODE_PRIVATE );
bw = new BufferedWriter( new OutputStreamWriter (configOutput ) );
bw.write( baseDir );
bw.write( '\n' );
}
catch( Exception e ) {}
finally
{
if ( bw != null ) try { bw.close(); } catch( Exception ee ) {}
}
}
cor = null;
try
{
// create missing directories
assertDirectoryExists( "project directory", basedir + "/brouter" );
segmentDir = basedir + "/brouter/segments2";
assertDirectoryExists( "map directory", segmentDir );
profileDir = basedir + "/brouter/profiles2";
assertDirectoryExists( "profile directory", profileDir );
modesDir = basedir + "/brouter/modes";
assertDirectoryExists( "modes directory", modesDir );
cor = CoordinateReader.obtainValidReader( basedir );
wpList = cor.waypoints;
nogoList = cor.nogopoints;
nogoVetoList = new ArrayList<OsmNodeNamed>();
sourceHint = "(coordinate-source: " + cor.basedir + cor.rootdir + ")";
needsViaSelection = wpList.size() > 2;
needsNogoSelection = nogoList.size() > 0;
needsWaypointSelection = wpList.size() == 0;
if ( cor.tracksdir != null )
{
tracksDir = cor.basedir + cor.tracksdir;
assertDirectoryExists( "track directory", tracksDir );
// output redirect: look for a pointerfile in tracksdir
File tracksDirPointer = new File( tracksDir + "/brouter.redirect" );
if ( tracksDirPointer.isFile() )
{
tracksDir = readSingleLineFile( tracksDirPointer );
if ( tracksDir == null ) throw new IllegalArgumentException( "redirect pointer file is empty: " + tracksDirPointer );
if ( !(new File( tracksDir ).isDirectory()) ) throw new IllegalArgumentException(
"redirect pointer file " + tracksDirPointer + " does not point to a directory: " + tracksDir );
}
}
boolean segmentFound = false;
String[] fileNames = new File( segmentDir ).list();
for( String fileName : fileNames )
{
if ( fileName.endsWith( ".rd5" ) ) segmentFound = true;
}
File carSubset = new File( segmentDir, "carsubset" );
if ( carSubset.isDirectory() )
{
fileNames = carSubset.list();
for( String fileName : fileNames )
{
if ( fileName.endsWith( ".cd5" ) ) segmentFound = true;
}
}
if ( !segmentFound )
{
throw new IllegalArgumentException( "The segments-directory " + segmentDir
+ " contains no routing data files (*.rd5)."
+ " see www.dr-brenschede.de/brouter for setup instructions." );
}
fileNames = new File( profileDir ).list();
ArrayList<String> profiles = new ArrayList<String>();
boolean lookupsFound = false;
for( String fileName : fileNames )
{
if ( fileName.endsWith( ".brf" ) )
{
profiles.add( fileName.substring( 0, fileName.length()-4 ) );
}
if ( fileName.equals( "lookups.dat" ) ) lookupsFound = true;
}
if ( !lookupsFound )
{
throw new IllegalArgumentException( "The profile-directory " + profileDir
+ " does not contain the lookups.dat file."
+ " see www.dr-brenschede.de/brouter for setup instructions." );
}
if ( profiles.size() == 0 )
{
throw new IllegalArgumentException( "The profile-directory " + profileDir
+ " contains no routing profiles (*.brf)."
+ " see www.dr-brenschede.de/brouter for setup instructions." );
}
((BRouterActivity)getContext()).selectProfile( profiles.toArray( new String[0]) );
}
catch( Exception e )
{
String msg = e instanceof IllegalArgumentException
? e.getMessage() + ( cor == null ? "" : " (coordinate-source: " + cor.basedir + cor.rootdir + ")" )
: e.toString();
((BRouterActivity)getContext()).showErrorMessage( msg );
}
waitingForSelection = true;
}
public void continueProcessing()
{
waitingForSelection = false;
invalidate();
}
public void updateViaList( Set<String> selectedVias )
{
ArrayList<OsmNodeNamed> filtered = new ArrayList<OsmNodeNamed>(wpList.size());
for( OsmNodeNamed n : wpList )
{
String name = n.name;
if ( "from".equals( name ) || "to".equals(name) || selectedVias.contains( name ) )
filtered.add( n );
}
wpList = filtered;
}
public void updateNogoList( boolean[] enabled )
{
for( int i=nogoList.size()-1; i >= 0; i-- )
{
if ( !enabled[i] )
{
nogoVetoList.add( nogoList.get(i) );
nogoList.remove( i );
}
}
}
public void pickWaypoints()
{
String msg = null;
Map<String,OsmNodeNamed> allpoints = cor.allpoints;
if ( allpoints == null )
{
allpoints = new TreeMap<String,OsmNodeNamed>();
cor.allpoints = allpoints;
try { cor.readFromTo(); } catch ( Exception e ) { msg = "Error reading waypoints: " + e.toString(); }
if ( allpoints.size() < 2 ) msg = "coordinate source does not contain enough waypoints: " + allpoints.size();
if ( allpoints.size() > 100 ) msg = "coordinate source contains too much waypoints: " + allpoints.size() + "(please use from/to/via names)";
}
if ( allpoints.size() < 1 ) msg = "no more wayoints available!";
if ( msg != null )
{
((BRouterActivity)getContext()).showErrorMessage( msg );
}
else
{
String[] wpts = new String[allpoints.size()];
int i = 0;
for( OsmNodeNamed wp : allpoints.values() ) wpts[i++] = wp.name;
System.out.println( "calling selectWaypoint..." );
((BRouterActivity)getContext()).selectWaypoint( wpts );
}
}
public void updateWaypointList( String waypoint )
{
wpList.add( cor.allpoints.get( waypoint ) );
cor.allpoints.remove( waypoint );
System.out.println( "updateWaypointList: " + waypoint + " wpList.size()=" + wpList.size() );
}
public void finishWaypointSelection()
{
needsWaypointSelection = false;
}
public void startProcessing( String profile )
{
profilePath = profileDir + "/" + profile + ".brf";
profileName = profile;
if ( needsViaSelection )
{
needsViaSelection = false;
String[] availableVias = new String[wpList.size()-2];
for( int viaidx=0; viaidx<wpList.size()-2; viaidx++ )
availableVias[viaidx] = wpList.get( viaidx+1 ).name;
((BRouterActivity)getContext()).selectVias( availableVias );
return;
}
if ( needsNogoSelection )
{
needsNogoSelection = false;
((BRouterActivity)getContext()).selectNogos( nogoList );
return;
}
if ( needsWaypointSelection )
{
String msg;
if ( wpList.size() == 0 )
{
msg = "no from/to found\n" + sourceHint;
}
else
{
msg = "current waypoint selection:\n";
for ( int i=0; i< wpList.size(); i++ ) msg += (i>0?"->" : "") + wpList.get(i).name;
}
((BRouterActivity)getContext()).showResultMessage( "Select Action", msg, wpList.size() );
return;
}
try
{
waitingForSelection = false;
RoutingContext rc = new RoutingContext();
// TODO: TEST!
// rc.rawTrackPath = "/mnt/sdcard/brouter/modes/bicycle_fast_rawtrack.dat";
rc.localFunction = profilePath;
int plain_distance = 0;
int maxlon = Integer.MIN_VALUE;
int minlon = Integer.MAX_VALUE;
int maxlat = Integer.MIN_VALUE;
int minlat = Integer.MAX_VALUE;
OsmNode prev = null;
for( OsmNode n : wpList )
{
maxlon = n.ilon > maxlon ? n.ilon : maxlon;
minlon = n.ilon < minlon ? n.ilon : minlon;
maxlat = n.ilat > maxlat ? n.ilat : maxlat;
minlat = n.ilat < minlat ? n.ilat : minlat;
if ( prev != null )
{
plain_distance += n.calcDistance( prev );
}
prev = n;
}
toast( "Plain distance = " + plain_distance/1000. + " km" );
centerLon = (maxlon + minlon)/2;
centerLat = (maxlat + minlat)/2;
double coslat = Math.cos( ((centerLat / 1000000.) - 90.) / 57.3 ) ;
double difflon = maxlon - minlon;
double difflat = maxlat - minlat;
scaleLon = imgw / (difflon*1.5);
scaleLat = imgh / (difflat*1.5);
if ( scaleLon < scaleLat*coslat ) scaleLat = scaleLon/coslat;
else scaleLon = scaleLat*coslat;
startTime = System.currentTimeMillis();
rc.prepareNogoPoints( nogoList );
rc.nogopoints = nogoList;
cr = new RoutingEngine( tracksDir + "/brouter", null, segmentDir, wpList, rc );
cr.start();
invalidate();
}
catch( Exception e )
{
String msg = e instanceof IllegalArgumentException ? e.getMessage() : e.toString();
toast( msg );
}
}
private void assertDirectoryExists( String message, String path )
{
File f = new File( path );
f.mkdirs();
if ( !f.exists() || !f.isDirectory() ) throw new IllegalArgumentException( message + ": " + path + " cannot be created" );
}
private void paintPosition( int ilon, int ilat, int color, int with )
{
int lon = ilon - centerLon;
int lat = ilat - centerLat;
int x = imgw/2 + (int)(scaleLon*lon);
int y = imgh/2 - (int)(scaleLat*lat);
for( int nx=x-with; nx<=x+with; nx++)
for( int ny=y-with; ny<=y+with; ny++)
{
if ( nx >= 0 && nx < imgw && ny >= 0 && ny < imgh )
{
imgPixels[ nx+imgw*ny] = color;
}
}
}
private void paintCircle( Canvas canvas, OsmNodeNamed n, int color, int minradius )
{
int lon = n.ilon - centerLon;
int lat = n.ilat - centerLat;
int x = imgw/2 + (int)(scaleLon*lon);
int y = imgh/2 - (int)(scaleLat*lat);
int ir = (int)(n.radius * 1000000. * scaleLat);
if ( ir > minradius )
{
Paint paint = new Paint();
paint.setColor( Color.RED );
paint.setStyle( Paint.Style.STROKE );
canvas.drawCircle( (float)x, (float)y, (float)ir, paint );
}
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
}
private void toast( String msg )
{
Toast.makeText(getContext(), msg, Toast.LENGTH_LONG ).show();
lastDataTime += 4000; // give time for the toast before exiting
}
private long lastTs = System.currentTimeMillis();
private long startTime = 0L;
@Override
protected void onDraw(Canvas canvas) {
try
{
_onDraw( canvas );
}
catch( Throwable t )
{
// on out of mem, try to stop the show
String hint = "";
if ( cr != null ) hint = cr.cleanOnOOM();
cr = null;
try { Thread.sleep( 2000 ); } catch( InterruptedException ie ) {}
((BRouterActivity)getContext()).showErrorMessage( t.toString() + hint );
waitingForSelection = true;
}
}
private void _onDraw(Canvas canvas) {
if ( waitingForSelection ) return;
long currentTs = System.currentTimeMillis();
long diffTs = currentTs - lastTs;
long sleeptime = 500 - diffTs;
while ( sleeptime < 200 ) sleeptime += 500;
try { Thread.sleep( sleeptime ); } catch ( InterruptedException ie ) {}
lastTs = System.currentTimeMillis();
if ( cr == null || cr.isFinished() )
{
if ( cr != null )
{
if ( cr.getErrorMessage() != null )
{
((BRouterActivity)getContext()).showErrorMessage( cr.getErrorMessage() );
cr = null;
waitingForSelection = true;
return;
}
else
{
String result = "version = BRouter-0.98\n"
+ "distance = " + cr.getDistance()/1000. + " km\n"
+ "filtered ascend = " + cr.getAscend() + " m\n"
+ "plain ascend = " + cr.getPlainAscend();
rawTrack = cr.getFoundRawTrack();
String title = "Success";
if ( cr.getAlternativeIndex() > 0 ) title += " / " + cr.getAlternativeIndex() + ". Alternative";
((BRouterActivity)getContext()).showResultMessage( title, result, -1 );
cr = null;
waitingForSelection = true;
return;
}
}
else if ( System.currentTimeMillis() > lastDataTime )
{
System.exit(0);
}
}
else
{
lastDataTime = System.currentTimeMillis();
imgPixels = new int[imgw*imgh];
int[] openSet = cr.getOpenSet();
for( int si = 0; si < openSet.length; si += 2 )
{
paintPosition( openSet[si], openSet[si+1], 0xffffff, 1 );
}
// paint nogos on top (red)
for( int ngi=0; ngi<nogoList.size(); ngi++ )
{
OsmNodeNamed n = nogoList.get(ngi);
int color = 0xff0000;
paintPosition( n.ilon, n.ilat, color, 4 );
}
// paint start/end/vias on top (yellow/green/blue)
for( int wpi=0; wpi<wpList.size(); wpi++ )
{
OsmNodeNamed n = wpList.get(wpi);
int color = wpi == 0 ? 0xffff00 : wpi < wpList.size()-1 ? 0xff : 0xff00;
paintPosition( n.ilon, n.ilat, color, 4 );
}
canvas.drawBitmap(imgPixels, 0, imgw, (float)0., (float)0., imgw, imgh, false, null);
// nogo circles if any
for( int ngi=0; ngi<nogoList.size(); ngi++ )
{
OsmNodeNamed n = nogoList.get(ngi);
int color = 0xff0000;
paintCircle( canvas, n, color, 4 );
}
Paint paint = new Paint();
paint.setColor(Color.WHITE);
paint.setTextSize(20);
long mseconds = System.currentTimeMillis() - startTime;
long links = cr.getLinksProcessed();
long perS = (1000*links)/mseconds;
String msg = "Links: " + cr.getLinksProcessed() + " in " + (mseconds/1000) + "s (" + perS + " l/s)";
canvas.drawText( msg, 10, 25, paint);
}
// and make sure to redraw asap
invalidate();
}
private String guessBaseDir()
{
File basedir = Environment.getExternalStorageDirectory();
try
{
File bd2 = new File( basedir, "external_sd" );
ArrayList<String> basedirGuesses = new ArrayList<String>();
basedirGuesses.add( basedir.getAbsolutePath() );
if ( bd2.exists() )
{
basedir = bd2;
basedirGuesses.add( basedir.getAbsolutePath() );
}
ArrayList<CoordinateReader> rl = new ArrayList<CoordinateReader>();
for( String bdg : basedirGuesses )
{
rl.add( new CoordinateReaderOsmAnd(bdg) );
rl.add( new CoordinateReaderLocus(bdg) );
rl.add( new CoordinateReaderOrux(bdg) );
}
long tmax = 0;
CoordinateReader cor = null;
for( CoordinateReader r : rl )
{
long t = r.getTimeStamp();
if ( t > tmax )
{
tmax = t;
cor = r;
}
}
if ( cor != null )
{
return cor.basedir;
}
}
catch( Exception e )
{
System.out.println( "guessBaseDir:" + e );
}
return basedir.getAbsolutePath();
}
public void writeRawTrackToMode( String mode )
{
// plus eventually the raw track for re-use
String rawTrackPath = modesDir + "/" + mode + "_rawtrack.dat";
if ( rawTrack != null )
{
try
{
rawTrack.writeBinary( rawTrackPath );
}
catch( Exception e ) {}
}
else
{
new File( rawTrackPath ).delete();
}
}
public void startConfigureService()
{
String[] modes = new String[] {
"foot_short", "foot_fast",
"bicycle_short", "bicycle_fast",
"motorcar_short", "motorcar_fast"
};
boolean[] modesChecked = new boolean[6];
// parse global section of profile for mode preselection
BExpressionContext expctxGlobal = new BExpressionContext( "global" );
expctxGlobal.readMetaData( new File( profileDir, "lookups.dat" ) );
expctxGlobal.parseFile( new File( profilePath ), null );
expctxGlobal.evaluate( 1L, null );
boolean isFoot = 0.f != expctxGlobal.getVariableValue( "validForFoot" );
boolean isBike = 0.f != expctxGlobal.getVariableValue( "validForBikes" );
boolean isCar = 0.f != expctxGlobal.getVariableValue( "validForCars" );
if ( isFoot || isBike || isCar )
{
modesChecked[ 0 ] = isFoot;
modesChecked[ 1 ] = isFoot;
modesChecked[ 2 ] = isBike;
modesChecked[ 3 ] = isBike;
modesChecked[ 4 ] = isCar;
modesChecked[ 5 ] = isCar;
}
else
{
for( int i=0; i<6; i++)
{
modesChecked[i] = true;
}
}
String msg = "Choose service-modes to configure (" + profileName + " [" + nogoVetoList.size() + "])";
((BRouterActivity)getContext()).selectRoutingModes( modes, modesChecked, msg );
}
public void configureService(String[] routingModes, boolean[] checkedModes)
{
// read in current config
TreeMap<String,ServiceModeConfig> map = new TreeMap<String,ServiceModeConfig>();
BufferedReader br = null;
String modesFile = modesDir + "/serviceconfig.dat";
try
{
br = new BufferedReader( new FileReader (modesFile ) );
for(;;)
{
String line = br.readLine();
if ( line == null ) break;
ServiceModeConfig smc = new ServiceModeConfig( line );
map.put( smc.mode, smc );
}
}
catch( Exception e ) {}
finally
{
if ( br != null ) try { br.close(); } catch( Exception ee ) {}
}
// replace selected modes
for( int i=0; i<6; i++)
{
if ( checkedModes[i] )
{
writeRawTrackToMode( routingModes[i] );
ServiceModeConfig smc = new ServiceModeConfig( routingModes[i], profileName);
for( OsmNodeNamed nogo : nogoVetoList)
{
smc.nogoVetos.add( nogo.ilon + "," + nogo.ilat );
}
map.put( smc.mode, smc );
}
}
// no write new config
BufferedWriter bw = null;
StringBuilder msg = new StringBuilder( "Mode mapping is now:\n" );
msg.append( "( [..] counts nogo-vetos)\n" );
try
{
bw = new BufferedWriter( new FileWriter ( modesFile ) );
for( ServiceModeConfig smc : map.values() )
{
bw.write( smc.toLine() );
bw.write( '\n' );
msg.append( smc.toString() ).append( '\n' );
}
}
catch( Exception e ) {}
finally
{
if ( bw != null ) try { bw.close(); } catch( Exception ee ) {}
}
((BRouterActivity)getContext()).showModeConfigOverview( msg.toString() );
}
private String readSingleLineFile( File f )
{
BufferedReader br = null;
try
{
br = new BufferedReader( new InputStreamReader ( new FileInputStream( f ) ) );
return br.readLine();
}
catch( Exception e ) { return null; }
finally
{
if ( br != null ) try { br.close(); } catch( Exception ee ) {}
}
}
}

View file

@ -0,0 +1,139 @@
package btools.routingapp;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import android.os.Bundle;
import btools.router.RoutingEngine;
import btools.router.OsmNodeNamed;
import btools.router.OsmTrack;
import btools.router.RoutingContext;
public class BRouterWorker
{
public String segmentDir;
public String profilePath;
public String rawTrackPath;
public List<OsmNodeNamed> nogoList;
public String getTrackFromParams(Bundle params)
{
String pathToFileResult = params.getString("pathToFileResult");
if (pathToFileResult != null)
{
File f = new File (pathToFileResult);
File dir = f.getParentFile();
if (!dir.exists() || !dir.canWrite()){
return "file folder does not exists or can not be written!";
}
}
long maxRunningTime = 60000;
String sMaxRunningTime = params.getString( "maxRunningTime" );
if ( sMaxRunningTime != null )
{
maxRunningTime = Integer.parseInt( sMaxRunningTime ) * 1000;
}
RoutingContext rc = new RoutingContext();
rc.rawTrackPath = rawTrackPath;
rc.localFunction = profilePath;
if ( nogoList != null )
{
rc.prepareNogoPoints( nogoList );
rc.nogopoints = nogoList;
}
readNogos( params ); // add interface provides nogos
RoutingEngine cr = new RoutingEngine( null, null, segmentDir, readPositions(params), rc );
cr.quite = true;
cr.doRun( maxRunningTime );
if ( cr.getErrorMessage() != null )
{
return cr.getErrorMessage();
}
// store new reference track if any
if ( cr.getFoundRawTrack() != null )
{
try
{
cr.getFoundRawTrack().writeBinary( rawTrackPath );
}
catch( Exception e ) {}
}
String format = params.getString("trackFormat");
boolean writeKml = format != null && "kml".equals( format );
OsmTrack track = cr.getFoundTrack();
if ( track != null )
{
if ( pathToFileResult == null )
{
if ( writeKml ) return track.formatAsKml();
return track.formatAsGpx();
}
try
{
if ( writeKml ) track.writeKml(pathToFileResult);
else track.writeGpx(pathToFileResult);
}
catch( Exception e )
{
return "error writing file: " + e;
}
}
return null;
}
private List<OsmNodeNamed> readPositions( Bundle params )
{
List<OsmNodeNamed> wplist = new ArrayList<OsmNodeNamed>();
double[] lats = params.getDoubleArray("lats");
double[] lons = params.getDoubleArray("lons");
if (lats == null || lats.length < 2 || lons == null || lons.length < 2)
{
throw new IllegalArgumentException( "we need two lat/lon points at least!" );
}
for( int i=0; i<lats.length && i<lons.length; i++ )
{
OsmNodeNamed n = new OsmNodeNamed();
n.name = "via" + i;
n.ilon = (int)( ( lons[i] + 180. ) *1000000. + 0.5);
n.ilat = (int)( ( lats[i] + 90. ) *1000000. + 0.5);
wplist.add( n );
}
wplist.get(0).name = "from";
wplist.get(wplist.size()-1).name = "to";
return wplist;
}
private void readNogos( Bundle params )
{
double[] lats = params.getDoubleArray("nogoLats");
double[] lons = params.getDoubleArray("nogoLons");
double[] radi = params.getDoubleArray("nogoRadi");
if ( lats == null || lons == null || radi == null ) return;
for( int i=0; i<lats.length && i<lons.length && i<radi.length; i++ )
{
OsmNodeNamed n = new OsmNodeNamed();
n.name = "nogo" + (int)radi[i];
n.ilon = (int)( ( lons[i] + 180. ) *1000000. + 0.5);
n.ilat = (int)( ( lats[i] + 90. ) *1000000. + 0.5);
n.isNogo = true;
nogoList.add( n );
}
}
}

View file

@ -0,0 +1,137 @@
package btools.routingapp;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import android.os.Environment;
import btools.router.OsmNodeNamed;
/**
* Read coordinates from a gpx-file
*/
public abstract class CoordinateReader
{
public List<OsmNodeNamed> waypoints;
public List<OsmNodeNamed> nogopoints;
public String basedir;
public String rootdir;
public String tracksdir;
public Map<String,OsmNodeNamed> allpoints;
private HashMap<String,OsmNodeNamed> pointmap;
protected static String[] posnames
= new String[]{ "from", "via1", "via2", "via3", "via4", "via5", "via6", "via7", "via8", "via9", "to" };
public CoordinateReader( String basedir )
{
this.basedir = basedir;
}
public abstract long getTimeStamp() throws Exception;
/*
* read the from, to and via-positions from a gpx-file
*/
public void readFromTo() throws Exception
{
pointmap = new HashMap<String,OsmNodeNamed>();
waypoints = new ArrayList<OsmNodeNamed>();
nogopoints = new ArrayList<OsmNodeNamed>();
readPointmap();
boolean fromToMissing = false;
for( int i=0; i<posnames.length; i++ )
{
String name = posnames[i];
OsmNodeNamed n = pointmap.get(name);
if ( n != null )
{
waypoints.add( n );
}
else
{
if ( "from".equals( name ) ) fromToMissing = true;
if ( "to".equals( name ) ) fromToMissing = true;
}
}
if ( fromToMissing ) waypoints.clear();
}
protected void checkAddPoint( OsmNodeNamed n )
{
if ( allpoints != null )
{
allpoints.put( n.name, n );
return;
}
boolean isKnown = false;
for( int i=0; i<posnames.length; i++ )
{
if ( posnames[i].equals( n.name ) )
{
isKnown = true;
break;
}
}
if ( isKnown )
{
if ( pointmap.put( n.name, n ) != null )
{
throw new IllegalArgumentException( "multiple " + n.name + "-positions!" );
}
}
else if ( n.name != null && n.name.startsWith( "nogo" ) )
{
n.isNogo = true;
nogopoints.add( n );
}
}
protected abstract void readPointmap() throws Exception;
public static CoordinateReader obtainValidReader( String basedir ) throws Exception
{
CoordinateReader cor = null;
ArrayList<CoordinateReader> rl = new ArrayList<CoordinateReader>();
rl.add( new CoordinateReaderOsmAnd(basedir) );
rl.add( new CoordinateReaderLocus(basedir) );
rl.add( new CoordinateReaderOrux(basedir) );
// eventually add standard-sd
File standardbase = Environment.getExternalStorageDirectory();
if ( standardbase != null )
{
String base2 = standardbase.getAbsolutePath();
if ( !base2.equals( basedir ) )
{
rl.add( new CoordinateReaderOsmAnd(base2) );
rl.add( new CoordinateReaderLocus(base2) );
rl.add( new CoordinateReaderOrux(base2) );
}
}
long tmax = 0;
for( CoordinateReader r : rl )
{
long t = r.getTimeStamp();
if ( t > tmax )
{
tmax = t;
cor = r;
}
}
if ( cor == null )
{
cor = new CoordinateReaderNone();
}
cor.readFromTo();
return cor;
}
}

View file

@ -0,0 +1,53 @@
package btools.routingapp;
import java.io.File;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
import btools.router.OsmNodeNamed;
/**
* Read coordinates from a gpx-file
*/
public class CoordinateReaderLocus extends CoordinateReader
{
public CoordinateReaderLocus( String basedir )
{
super( basedir );
tracksdir = "/Locus/mapItems";
rootdir = "/Locus";
}
@Override
public long getTimeStamp() throws Exception
{
long t1 = new File( basedir + "/Locus/data/database/waypoints.db" ).lastModified();
return t1;
}
/*
* read the from and to position from a ggx-file
* (with hardcoded name for now)
*/
@Override
public void readPointmap() throws Exception
{
_readPointmap( basedir + "/Locus/data/database/waypoints.db" );
}
private void _readPointmap( String filename ) throws Exception
{
SQLiteDatabase myDataBase = SQLiteDatabase.openDatabase( filename, null, SQLiteDatabase.OPEN_READONLY);
Cursor c = myDataBase.rawQuery("SELECT name, longitude, latitude FROM waypoints", null);
while (c.moveToNext())
{
OsmNodeNamed n = new OsmNodeNamed();
n.name = c.getString(0);
n.ilon = (int)( ( Double.parseDouble( c.getString(1) ) + 180. )*1000000. + 0.5);
n.ilat = (int)( ( Double.parseDouble( c.getString(2) ) + 90. )*1000000. + 0.5);
checkAddPoint( n );
}
myDataBase.close();
}
}

View file

@ -0,0 +1,26 @@
package btools.routingapp;
/**
* Dummy coordinate reader if none found
*/
public class CoordinateReaderNone extends CoordinateReader
{
public CoordinateReaderNone()
{
super( "" );
rootdir = "none";
}
@Override
public long getTimeStamp() throws Exception
{
return 0L;
}
@Override
public void readPointmap() throws Exception
{
}
}

View file

@ -0,0 +1,52 @@
package btools.routingapp;
import java.io.File;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import btools.router.OsmNodeNamed;
/**
* Read coordinates from a gpx-file
*/
public class CoordinateReaderOrux extends CoordinateReader
{
public CoordinateReaderOrux( String basedir )
{
super( basedir );
tracksdir = "/oruxmaps/tracklogs";
rootdir = "/oruxmaps";
}
@Override
public long getTimeStamp() throws Exception
{
long t1 = new File( basedir + "/oruxmaps/tracklogs/oruxmapstracks.db" ).lastModified();
return t1;
}
/*
* read the from and to position from a ggx-file
* (with hardcoded name for now)
*/
@Override
public void readPointmap() throws Exception
{
_readPointmap( basedir + "/oruxmaps/tracklogs/oruxmapstracks.db" );
}
private void _readPointmap( String filename ) throws Exception
{
SQLiteDatabase myDataBase = SQLiteDatabase.openDatabase( filename, null, SQLiteDatabase.OPEN_READONLY);
Cursor c = myDataBase.rawQuery("SELECT poiname, poilon, poilat FROM pois", null);
while (c.moveToNext())
{
OsmNodeNamed n = new OsmNodeNamed();
n.name = c.getString(0);
n.ilon = (int)( ( Double.parseDouble( c.getString(1) ) + 180. )*1000000. + 0.5);
n.ilat = (int)( ( Double.parseDouble( c.getString(2) ) + 90. )*1000000. + 0.5);
checkAddPoint( n );
}
myDataBase.close();
}
}

View file

@ -0,0 +1,87 @@
package btools.routingapp;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import btools.router.OsmNodeNamed;
/**
* Read coordinates from a gpx-file
*/
public class CoordinateReaderOsmAnd extends CoordinateReader
{
public CoordinateReaderOsmAnd( String basedir )
{
super( basedir );
tracksdir = "/osmand/tracks";
rootdir = "/osmand";
}
@Override
public long getTimeStamp() throws Exception
{
long t1 = new File( basedir + "/osmand/favourites_bak.gpx" ).lastModified();
long t2 = new File( basedir + "/osmand/favourites.gpx" ).lastModified();
return t1 > t2 ? t1 : t2;
}
/*
* read the from and to position from a gpx-file
* (with hardcoded name for now)
*/
@Override
public void readPointmap() throws Exception
{
try
{
_readPointmap( basedir + "/osmand/favourites_bak.gpx" );
}
catch( Exception e )
{
_readPointmap( basedir + "/osmand/favourites.gpx" );
}
}
private void _readPointmap( String filename ) throws Exception
{
BufferedReader br = new BufferedReader(
new InputStreamReader(
new FileInputStream( filename ) ) );
OsmNodeNamed n = null;
for(;;)
{
String line = br.readLine();
if ( line == null ) break;
int idx0 = line.indexOf( "<wpt lat=\"" );
int idx10 = line.indexOf( "<name>" );
if ( idx0 >= 0 )
{
n = new OsmNodeNamed();
idx0 += 10;
int idx1 = line.indexOf( '"', idx0 );
n.ilat = (int)( (Double.parseDouble( line.substring( idx0, idx1 ) ) + 90. )*1000000. + 0.5);
int idx2 = line.indexOf( " lon=\"" );
if ( idx2 < 0 ) continue;
idx2 += 6;
int idx3 = line.indexOf( '"', idx2 );
n.ilon = (int)( ( Double.parseDouble( line.substring( idx2, idx3 ) ) + 180. )*1000000. + 0.5);
continue;
}
if ( n != null && idx10 >= 0 )
{
idx10 += 6;
int idx11 = line.indexOf( "</name>", idx10 );
if ( idx11 >= 0 )
{
n.name = line.substring( idx10, idx11 ).trim();
checkAddPoint( n );
}
}
}
br.close();
}
}

View file

@ -0,0 +1,23 @@
package btools.routingapp;
interface IBRouterService {
//param params--> Map of params:
// "pathToFileResult"-->String with the path to where the result must be saved, including file name and extension
// -->if null, the track is passed via the return argument
// "maxRunningTime"-->String with a number of seconds for the routing timeout, default = 60
// "trackFormat"-->[kml|gpx] default = gpx
// "lats"-->double[] array of latitudes; 2 values at least.
// "lons"-->double[] array of longitudes; 2 values at least.
// "nogoLats"-->double[] array of nogo latitudes; may be null.
// "nogoLons"-->double[] array of nogo longitudes; may be null.
// "nogoRadi"-->double[] array of nogo radius in meters; may be null.
// "fast"-->[0|1]
// "v"-->[motorcar|bicycle|foot]
//return null if all ok and no path given, the track if ok and path given, an error message if it was wrong
//call in a background thread, heavy task!
String getTrackFromParams(in Bundle params);
}

View file

@ -0,0 +1,50 @@
package btools.routingapp;
import java.util.StringTokenizer;
import java.util.TreeSet;
/**
* Decsription of a service config
*/
public class ServiceModeConfig
{
public String mode;
public String profile;
public TreeSet<String> nogoVetos;
public ServiceModeConfig( String line )
{
StringTokenizer tk = new StringTokenizer( line );
mode = tk.nextToken();
profile = tk.nextToken();
nogoVetos = new TreeSet<String>();
while( tk.hasMoreTokens() )
{
nogoVetos.add( tk.nextToken() );
}
}
public ServiceModeConfig( String mode, String profile )
{
this.mode = mode;
this.profile = profile;
nogoVetos = new TreeSet<String>();
}
public String toLine()
{
StringBuilder sb = new StringBuilder( 100 );
sb.append( mode ).append( ' ' ).append( profile );
for( String veto: nogoVetos ) sb.append( ' ' ).append( veto );
return sb.toString();
}
public String toString()
{
StringBuilder sb = new StringBuilder( 100 );
sb.append( mode ).append( "->" ).append( profile );
sb.append ( " [" + nogoVetos.size() + "]" );
return sb.toString();
}
}

View file

@ -0,0 +1,105 @@
#
# Car-Routing is experimantal !!!
#
# DO NOT USE FOR ACTUAL NAVIGATION
#
# Turn restrictions are missing, leading to wrong routes
#
---context:global
assign downhillcost 0
assign downhillcutoff 0
assign uphillcost 0
assign uphillcutoff 0
---context:way # following code refers to way-tags
assign turncost 200
assign initialcost switch highway=ferry 20000 0
#
# calculate logical car access
#
assign caraccess
switch motorcar=
switch motor_vehicle=
switch vehicle=
switch access=
switch or highway=motorway highway=motorway_link 1
switch or highway=trunk highway=trunk_link 1
switch or highway=primary highway=primary_link 1
switch or highway=secondary highway=secondary_link 1
switch or highway=tertiary highway=tertiary_link 1
switch highway=unclassified 1
switch highway=ferry 1
switch or highway=residential highway=living_street 1
switch highway=service 1
0
or access=yes or access=designated access=destination
or vehicle=yes or vehicle=designated vehicle=destination
or motor_vehicle=yes or motor_vehicle=designated motor_vehicle=destination
or motorcar=yes or motorcar=designated motorcar=destination
assign accesspenalty
switch caraccess
0
10000
assign onewaypenalty
switch switch reversedirection=yes
switch oneway=
junction=roundabout
or oneway=yes or oneway=true oneway=1
oneway=-1
10000
0.0
assign ispaved or surface=paved or surface=asphalt or surface=concrete surface=paving_stones
assign costfactor
add max onewaypenalty accesspenalty
switch or highway=motorway highway=motorway_link 1
switch or highway=trunk highway=trunk_link 1
switch or highway=primary highway=primary_link switch maxspeed=30 2.0 switch maxspeed=50 1.5 1.2
switch or highway=secondary highway=secondary_link 1.3
switch or highway=tertiary highway=tertiary_link 1.4
switch highway=unclassified 1.5
switch highway=ferry 5.67
switch highway=bridleway 5
switch or highway=residential highway=living_street 2
switch highway=service 2
switch or highway=track or highway=road highway=path
switch tracktype=grade1 5
switch ispaved 5
30
10000
---context:node # following code refers to node tags
#
# calculate logical car access to nodes
#
assign caraccess
switch motorcar=
switch motor_vehicle=
switch vehicle=
switch access=
switch barrier=gate 0
switch barrier=bollard 0
switch barrier=lift_gate 0
switch barrier=cycle_barrier 0
1
or access=yes or access=designated access=destination
or vehicle=yes or vehicle=designated vehicle=destination
or motor_vehicle=yes or motor_vehicle=designated motor_vehicle=destination
or motorcar=yes or motorcar=designated motorcar=destination
assign initialcost
switch caraccess
0
1000000

View file

@ -0,0 +1,164 @@
#
# A fastbike could be a racing bike or a speed pedelec.
# But also at night or in rainy whether you might want
# to fallback to this one.
#
# Structure is similar to trekking.brf, see this for documenation.
#
---context:global # following code refers to global config
# Use the following switches to change behaviour
# (1=yes, 0=no):
assign consider_elevation 1 # set to 0 to ignore elevation in routing
assign allow_steps 1 # set to 0 to disallow steps
assign allow_ferries 1 # set to 0 to disallow ferries
assign ignore_cycleroutes 0 # set to 1 for better elevation results
assign stick_to_cycleroutes 0 # set to 1 to just follow cycleroutes
assign avoid_unsafe 0 # set to 1 to avoid standard highways
# the elevation parameters
assign downhillcost switch consider_elevation 60 0
assign downhillcutoff 1.5
assign uphillcost 0
assign uphillcutoff 1.5
---context:way # following code refers to way-tags
assign ispaved or surface=paved or surface=asphalt or surface=concrete surface=paving_stones
assign isunpaved not or surface= or ispaved or surface=fine_gravel surface=cobblestone
assign turncost 90
assign initialcost switch highway=ferry 10000 0
#
# implicit access here just from the motorroad tag
# (implicit access rules from highway tag handled elsewhere)
#
assign defaultaccess
switch access=
not motorroad=yes
switch or access=private access=no
0
1
#
# calculate logical bike access
#
assign bikeaccess
or longdistancecycleway=yes
switch bicycle=
switch vehicle=
defaultaccess
switch or vehicle=private vehicle=no
0
1
not or bicycle=private or bicycle=no bicycle=dismount
#
# calculate logical foot access
#
assign footaccess
or bikeaccess
or bicycle=dismount
switch foot=
defaultaccess
not or foot=private foot=no
#
# if not bike-, but foot-acess, just a moderate penalty,
# otherwise access is forbidden
#
assign accesspenalty
switch bikeaccess
0
switch footaccess
6
100000
#
# handle one-ways. On primary roads, wrong-oneways should
# be close to forbidden, while on other ways we just add
# 4 to the costfactor (making it at least 5 - you are allowed
# to push your bike)
#
assign oneway
switch oneway=
junction=roundabout
or oneway=yes or oneway=true oneway=1
assign onewaypenalty
switch switch reversedirection=yes oneway oneway=-1
switch or cycleway=opposite or cycleway=opposite_lane cycleway=opposite_track 0
switch or highway=primary highway=primary_link 50
switch or highway=secondary highway=secondary_link 30
switch or highway=tertiary highway=tertiary_link 20
6.0
0.0
assign costfactor
add max onewaypenalty accesspenalty
switch or highway=motorway highway=motorway_link 100000
switch highway=proposed 100000
switch or highway=trunk highway=trunk_link 10
switch or highway=primary highway=primary_link 1.2
switch or highway=secondary highway=secondary_link 1.1
switch or highway=tertiary highway=tertiary_link 1.0
switch highway=unclassified 1.1
switch highway=pedestrian 10
switch highway=steps 1000
switch highway=ferry 5.67
switch highway=bridleway 5
switch highway=cycleway 1.3
switch or highway=residential highway=living_street switch isunpaved 10 1.2
switch highway=service switch isunpaved 10 1.2
switch or highway=track or highway=road or highway=path highway=footway
switch tracktype=grade1 switch isunpaved 3 1.2
switch tracktype=grade2 switch isunpaved 10 3
switch tracktype=grade3 10.0
switch tracktype=grade4 20.0
switch tracktype=grade5 30.0
switch ispaved 2.0 100.0
10.0
---context:node # following code refers to node tags
assign defaultaccess
switch access=
1 # add default barrier restrictions here!
switch or access=private access=no
0
1
assign bikeaccess
or or longdistancecycleway=yes lcn=yes
switch bicycle=
switch vehicle=
defaultaccess
switch or vehicle=private vehicle=no
0
1
switch or bicycle=private or bicycle=no bicycle=dismount
0
1
assign footaccess
or bicycle=dismount
switch foot=
defaultaccess
switch or foot=private foot=no
0
1
assign initialcost
switch bikeaccess
0
switch footaccess
300
1000000

View file

@ -0,0 +1,317 @@
---lookupversion:2
---context:way
highway;0001731794 track
highway;0001457935 residential
highway;0000968516 service
highway;0000756237 footway
highway;0000521566 path
highway;0000261772 unclassified
highway;0000220315 secondary
highway;0000207585 tertiary
highway;0000103445 steps
highway;0000102114 primary
highway;0000094484 cycleway
highway;0000090388 living_street
highway;0000035041 motorway
highway;0000029965 pedestrian
highway;0000026875 motorway_link
highway;0000015054 trunk
highway;0000014604 primary_link
highway;0000012211 road
highway;0000011822 trunk_link
highway;0000005882 construction
highway;0000005425 bridleway
highway;0000005180 secondary_link
highway;0000003360 platform
highway;0000002616 proposed abandoned
highway;0000001374 tertiary_link
highway;0000000760 ferry
highway;0000000541 raceway
highway;0000000346 rest_area
highway;0000000300 bus_stop
highway;0000000184 services
tracktype;0000356503 grade2
tracktype;0000353482 grade3
tracktype;0000281625 grade1
tracktype;0000245193 grade4
tracktype;0000179135 grade5
surface;0000363915 asphalt
surface;0000303589 paved
surface;0000196783 gravel
surface;0000137371 ground
surface;0000128215 grass
surface;0000092748 unpaved
surface;0000086579 paving_stones
surface;0000066111 cobblestone
surface;0000042061 dirt
surface;0000026551 concrete
surface;0000025631 compacted
surface;0000019861 sand
surface;0000009400 pebblestone
surface;0000003197 fine_gravel
maxspeed;0000402224 30
maxspeed;0000224685 50
maxspeed;0000045177 100
maxspeed;0000037529 70
maxspeed;0000014237 none
maxspeed;0000014022 60
maxspeed;0000011530 80
maxspeed;0000009951 10
maxspeed;0000008056 20
maxspeed;0000005772 120
maxspeed;0000003165 40
maxspeed;0000002987 7
maxspeed;0000002826 signals
maxspeed;0000001933 130
service;0000221481 parking_aisle
service;0000157110 driveway
lit;0000132495 yes
lanes;0000098207 2
lanes;0000042192 1
lanes;0000018533 3
lanes;0000004577 4
lanes;0000000448 5
lanes;0000000318 1.5
access;0000044859 yes permissive
access;0000008452 designated official
access;0000028727 destination customers
access;0000076985 agricultural forestry
access;0000116270 private
access;0000028044 no
foot;0000339384 yes allowed Yes
foot;0000125339 designated official
foot;0000018945 no
foot;0000001562 private
foot;0000000279 destination
foot;0000008172 permissive
bicycle;0000302789 yes allowed permissive
bicycle;0000108056 designated official
bicycle;0000000265 destination
bicycle;0000003593 dismount
bicycle;0000001426 private
bicycle;0000070179 no
motorcar;0000010111 yes permissive
motorcar;0000001537 designated official
motorcar;0000007102 destination
motorcar;0000016706 agricultural forestry agriculture
motorcar;0000002178 private
motorcar;0000077771 no
motor_vehicle;0000013813 yes permissive
motor_vehicle;0000002098 designated official
motor_vehicle;0000009792 destination
motor_vehicle;0000019301 agricultural forestry
motor_vehicle;0000006563 private
motor_vehicle;0000025491 no
motorcycle;0000005750 yes permissive
motorcycle;0000001158 designated official
motorcycle;0000005805 destination
motorcycle;0000012401 agricultural forestry
motorcycle;0000001180 private
motorcycle;0000053955 no
vehicle;0000000505 yes permissive
vehicle;0000000027 designated
vehicle;0000007582 destination
vehicle;0000004357 agricultural forestry
vehicle;0000001155 private
vehicle;0000006487 no
cycleway;0000033575 track
cycleway;0000012829 no
cycleway;0000011604 lane
cycleway;0000008938 opposite
cycleway;0000001503 none
cycleway;0000001146 right
cycleway;0000001031 opposite_track
cycleway;0000001029 yes
cycleway;0000000856 opposite_lane
cycleway;0000000675 both
cycleway;0000000665 left
cycleway;0000000521 shared
cycleway;0000000383 street
cycleway;0000000176 segregated
mtb:scale;0000043968 0
mtb:scale;0000019705 1
mtb:scale;0000006436 2
mtb:scale;0000002702 3
mtb:scale;0000001083 4
mtb:scale;0000000329 5
sac_scale;0000049626 hiking
sac_scale;0000007933 mountain_hiking
sac_scale;0000001160 demanding_mountain_hiking
sac_scale;0000000523 yes
sac_scale;0000000364 alpine_hiking
sac_scale;0000000117 demanding_alpine_hiking
noexit;0000058492 yes
motorroad;0000019250 yes
oneway;0000330245 yes
oneway;0000075148 no
oneway;0000003679 -1
oneway;0000000001 true
oneway;0000000001 1
junction;0000015929 roundabout
bridge;0000182649 yes viaduct true suspension
tunnel;0000031626 yes
lcn;0000018999 yes
longdistancecycleway;0000000001 yes
reversedirection;0000000001 yes
---context:node
highway;0000100947 turning_circle
highway;0000067645 traffic_signals
highway;0000047209 crossing
highway;0000037164 bus_stop
highway;0000006577 motorway_junction
highway;0000003811 stop
highway;0000002331 mini_roundabout
highway;0000001789 milestone
highway;0000001692 passing_place
highway;0000001289 give_way
highway;0000001092 emergency_access_point
highway;0000000683 speed_camera
highway;0000000672 steps
highway;0000000658 incline_steep
highway;0000000620 elevator
highway;0000000506 street_lamp
highway;0000000490 ford
highway;0000000458 incline
highway;0000000135 rest_area
highway;0000000105 path
highway;0000000098 emergency_bay
highway;0000000096 road
highway;0000000087 platform
highway;0000000074 services
highway;0000000058 track
highway;0000000055 service
highway;0000000054 footway
highway;0000000053 traffic_calming
highway;0000000046 toll_bridge
highway;0000000037 city_entry
barrier;0000076979 gate
barrier;0000069308 bollard
barrier;0000028131 lift_gate
barrier;0000017332 cycle_barrier
barrier;0000005693 entrance
barrier;0000002885 block
barrier;0000001065 kissing_gate
barrier;0000000828 cattle_grid
barrier;0000000602 stile
barrier;0000000561 turnstile
barrier;0000000512 no
barrier;0000000463 fence
barrier;0000000417 bump_gate
barrier;0000000324 sally_port
barrier;0000000283 yes
barrier;0000000283 hampshire_gate
barrier;0000000236 swing_gate
barrier;0000000203 chain
barrier;0000000181 toll_booth
barrier;0000000180 door
barrier;0000000104 chicane
barrier;0000000096 tree
barrier;0000000087 border_control
barrier;0000000077 log
barrier;0000000076 traffic_crossing_pole
barrier;0000000063 wall
barrier;0000000060 fallen_tree
barrier;0000000052 stone
barrier;0000000048 ditch
barrier;0000000031 spikes
access;0000001309 yes permissive
access;0000000118 designated official
access;0000000405 destination customers
access;0000000276 agricultural forestry
access;0000008574 private
access;0000002145 no
foot;0000080681 yes permissive
foot;0000000326 designated official
foot;0000000023 destination
foot;0000000156 private
foot;0000009170 no
bicycle;0000076717 yes permissive
bicycle;0000000406 designated official
bicycle;0000000018 destination
bicycle;0000000081 dismount
bicycle;0000000051 private
bicycle;0000016121 no
motorcar;0000005785 yes permissive
motorcar;0000000026 designated official
motorcar;0000000080 destination
motorcar;0000000112 agricultural forestry
motorcar;0000000171 private
motorcar;0000001817 no
motor_vehicle;0000000066 yes permissive
motor_vehicle;0000000000 designated official
motor_vehicle;0000000030 destination
motor_vehicle;0000000073 agricultural forestry
motor_vehicle;0000000136 private
motor_vehicle;0000000469 no
motorcycle;0000004515 yes permissive
motorcycle;0000000007 designated official
motorcycle;0000000054 destination
motorcycle;0000000027 agricultural forestry
motorcycle;0000000063 private
motorcycle;0000001637 no
vehicle;0000000058 yes permissive
vehicle;0000000000 designated
vehicle;0000000081 destination
vehicle;0000000038 agricultural forestry
vehicle;0000000041 private
vehicle;0000000271 no
crossing;0000032485 traffic_signals
crossing;0000014300 uncontrolled
crossing;0000005086 island
crossing;0000001565 unmarked
crossing;0000001066 no
crossing;0000000333 zebra
railway;0000034039 level_crossing
railway;0000010175 crossing
noexit;0000043010 yes
entrance;0000015094 yes
entrance;0000007079 main
entrance;0000000554 service
entrance;0000000169 emergency
entrance;0000000063 exit
entrance;0000000008 private
lcn;0000018999 yes
longdistancecycleway;0000000001 yes

View file

@ -0,0 +1,119 @@
#
# Moped-Routing is experimantal !!!
#
# DO NOT USE FOR ACTUAL NAVIGATION
#
# Turn restrictions are missing, leading to wrong routes
#
---context:global
assign downhillcost 0
assign downhillcutoff 0
assign uphillcost 0
assign uphillcutoff 0
---context:way # following code refers to way-tags
assign turncost 90
assign initialcost switch highway=ferry 20000 0
#
# calculate logical car access
#
assign motorverhicleaccess
switch motor_vehicle=
switch vehicle=
switch access=
switch or highway=trunk highway=trunk_link 1
switch or highway=primary highway=primary_link 1
switch or highway=secondary highway=secondary_link 1
switch or highway=tertiary highway=tertiary_link 1
switch highway=unclassified 1
switch highway=ferry 1
switch or highway=residential highway=living_street 1
switch highway=service 1
0
or access=yes or access=designated access=destination
or vehicle=yes or vehicle=designated vehicle=destination
or motor_vehicle=yes or motor_vehicle=designated motor_vehicle=destination
assign caraccess
switch motorcar=
motorverhicleaccess
or motorcar=yes or motorcar=designated motorcar=destination
assign motorcycleaccess
switch motorcycle=
motorverhicleaccess
or motorcycle=yes or motorcycle=designated motorcycle=destination
assign accesspenalty
switch or caraccess motorcycleaccess
switch motorroad=yes 10000 0
10000
assign onewaypenalty
switch switch reversedirection=yes
switch oneway=
junction=roundabout
or oneway=yes or oneway=true oneway=1
oneway=-1
10000
0.0
assign ispaved or surface=paved or surface=asphalt or surface=concrete surface=paving_stones
assign costfactor
add max onewaypenalty accesspenalty
switch or highway=trunk highway=trunk_link 1.5
switch or highway=primary highway=primary_link switch maxspeed=30 2.0 switch maxspeed=50 1.5 1.2
switch or highway=secondary highway=secondary_link 1.4
switch or highway=tertiary highway=tertiary_link 1.3
switch highway=unclassified 1.2
switch highway=ferry 5.67
switch highway=bridleway 5
switch or highway=residential highway=living_street 2
switch highway=service 2
switch or highway=track or highway=road highway=path
switch tracktype=grade1 5
switch ispaved 5
30
10000
---context:node # following code refers to node tags
#
# calculate logical car access to nodes
#
assign motorvehicleaccess
switch motor_vehicle=
switch vehicle=
switch access=
switch barrier=gate 0
switch barrier=bollard 0
switch barrier=lift_gate 0
switch barrier=cycle_barrier 0
1
or access=yes or access=designated access=destination
or vehicle=yes or vehicle=designated vehicle=destination
or motor_vehicle=yes or motor_vehicle=designated motor_vehicle=destination
assign caraccess
switch motorcar=
motorvehicleaccess
or motorcar=yes or motorcar=designated motorcar=destination
assign motorcycleaccess
switch motorcycle=
motorvehicleaccess
or motorcycle=yes or motorcycle=designated motorcycle=destination
assign initialcost
switch or caraccess motorcycleaccess
0
1000000

View file

@ -0,0 +1,223 @@
# *** The trekking profile is for slow travel
# *** and avoiding car traffic, but still with
# *** a focus on approaching your destination
# *** efficiently.
---context:global # following code refers to global config
# Use the following switches to change behaviour
# (1=yes, 0=no):
assign consider_elevation 1 # set to 0 to ignore elevation in routing
assign allow_steps 1 # set to 0 to disallow steps
assign allow_ferries 1 # set to 0 to disallow ferries
assign ignore_cycleroutes 0 # set to 1 for better elevation results
assign stick_to_cycleroutes 0 # set to 1 to just follow cycleroutes
assign avoid_unsafe 1 # set to 1 to avoid standard highways
# the elevation parameters
assign downhillcost switch consider_elevation 60 0
assign downhillcutoff 1.5
assign uphillcost 0
assign uphillcutoff 1.5
---context:way # following code refers to way-tags
#
# pre-calculate some logical expressions
#
assign is_ldcr and longdistancecycleway=yes not ignore_cycleroutes
assign isbike or bicycle=yes or bicycle=designated lcn=yes
assign ispaved or surface=paved or surface=asphalt or surface=concrete surface=paving_stones
assign isunpaved not or surface= or ispaved or surface=fine_gravel surface=cobblestone
assign probablyGood or ispaved and isbike not isunpaved
#
# this is the cost (in Meter) for a 90-degree turn
# The actual cost is calculated as turncost*cos(angle)
# (Suppressing turncost while following longdistance-cycleways
# makes them a little bit more magnetic)
#
assign turncost switch is_ldcr 0 90
#
# calculate the initial cost
# this is added to the total cost each time the costfactor
# changed
#
assign initialcost switch highway=ferry 10000 0
#
# implicit access here just from the motorroad tag
# (implicit access rules from highway tag handled elsewhere)
#
assign defaultaccess
switch access=
not motorroad=yes
switch or access=private access=no
0
1
#
# calculate logical bike access
#
assign bikeaccess
or longdistancecycleway=yes
switch bicycle=
switch vehicle=
defaultaccess
switch or vehicle=private vehicle=no
0
1
not or bicycle=private or bicycle=no bicycle=dismount
#
# calculate logical foot access
#
assign footaccess
or bikeaccess
or bicycle=dismount
switch foot=
defaultaccess
not or foot=private foot=no
#
# if not bike-, but foot-acess, just a moderate penalty,
# otherwise access is forbidden
#
assign accesspenalty
switch bikeaccess
0
switch footaccess
4
100000
#
# handle one-ways. On primary roads, wrong-oneways should
# be close to forbidden, while on other ways we just add
# 4 to the costfactor (making it at least 5 - you are allowed
# to push your bike)
#
assign oneway
switch oneway=
junction=roundabout
or oneway=yes or oneway=true oneway=1
assign onewaypenalty
switch switch reversedirection=yes oneway oneway=-1
switch or cycleway=opposite or cycleway=opposite_lane cycleway=opposite_track 0
switch or highway=primary highway=primary_link 50
switch or highway=secondary highway=secondary_link 30
switch or highway=tertiary highway=tertiary_link 20
4.0
0.0
#
# calculate the cost-factor, which is the factor
# by which the distance of a way-segment is multiplied
# to calculate the cost of that segment. The costfactor
# must be >=1 and it's supposed to be close to 1 for
# the type of way the routing profile is searching for
#
assign costfactor
add max onewaypenalty accesspenalty
#
# steps and ferries are special. Note this is handled
# before the longdistancecycleway-switch, to be able
# to really exlude them be setting cost to infinity
#
switch highway=steps switch allow_steps 40 100000
switch highway=ferry switch allow_ferries 5.67 100000
#
# handle long-distance cycle-routes.
#
switch is_ldcr 1 # always treated as perfect (=1)
add switch stick_to_cycleroutes 0.5 0.05 # everything else somewhat up
#
# some other highway types
#
switch highway=pedestrian 3
switch highway=bridleway 5
switch highway=cycleway 1
switch or highway=residential highway=living_street switch isunpaved 1.5 1.1
switch highway=service switch isunpaved 1.6 1.3
#
# tracks and track-like ways are rated mainly be tracktype/grade
# But note that if no tracktype is given (mainly for road/path/footway)
# it can be o.k. if there's any other hint for quality
#
switch or highway=track or highway=road or highway=path highway=footway
switch tracktype=grade1 switch probablyGood 1.0 1.3
switch tracktype=grade2 switch probablyGood 1.1 2.0
switch tracktype=grade3 switch probablyGood 1.5 3.0
switch tracktype=grade4 switch probablyGood 2.0 5.0
switch tracktype=grade5 switch probablyGood 3.0 5.0
switch probablyGood 1.0 5.0
#
# When avoiding unsafe ways, avoid highways without a bike hint
#
add switch and avoid_unsafe not isbike 2 0
#
# exclude motorways and proposed roads
#
switch or highway=motorway highway=motorway_link 100000
switch highway=proposed 100000
#
# actuals roads are o.k. if we have a bike hint
#
switch or highway=trunk highway=trunk_link switch isbike 1.5 10
switch or highway=primary highway=primary_link switch isbike 1.2 3
switch or highway=secondary highway=secondary_link switch isbike 1.1 1.6
switch or highway=tertiary highway=tertiary_link switch isbike 1.0 1.4
switch highway=unclassified switch isbike 1.0 1.3
#
# default for any other highway type not handled above
#
2.0
---context:node # following code refers to node tags
assign defaultaccess
switch access=
1 # add default barrier restrictions here!
switch or access=private access=no
0
1
assign bikeaccess
or or longdistancecycleway=yes lcn=yes
switch bicycle=
switch vehicle=
defaultaccess
switch or vehicle=private vehicle=no
0
1
switch or bicycle=private or bicycle=no bicycle=dismount
0
1
assign footaccess
or bicycle=dismount
switch foot=
defaultaccess
switch or foot=private foot=no
0
1
assign initialcost
switch bikeaccess
0
switch footaccess
100
1000000

View file

@ -0,0 +1,89 @@
---context:global # following code refers to global config
# the elevation parameters
assign downhillcost 0
assign downhillcutoff 1.5
assign uphillcost 0
assign uphillcutoff 1.5
---context:way # following code refers to way-tags
assign turncost 0
assign initialcost switch highway=ferry 10000 0
#
# implicit access here just from the motorroad tag
# (implicit access rules from highway tag handled elsewhere)
#
assign defaultaccess
switch access=
not motorroad=yes
switch or access=private access=no
0
1
#
# calculate logical bike access
#
assign bikeaccess
or longdistancecycleway=yes
switch bicycle=
switch vehicle=
defaultaccess
switch or vehicle=private vehicle=no
0
1
not or bicycle=private or bicycle=no bicycle=dismount
#
# calculate logical foot access
#
assign footaccess
or bikeaccess
or bicycle=dismount
switch foot=
defaultaccess
not or foot=private foot=no
assign accesspenalty switch or bikeaccess footaccess 0 100000
assign costfactor
add accesspenalty
switch highway=ferry 5.67
switch or highway=motorway highway=motorway_link 100000
switch highway=proposed 100000
1
---context:node # following code refers to node tags
assign defaultaccess
switch access=
1 # add default barrier restrictions here!
switch or access=private access=no
0
1
assign bikeaccess
or or longdistancecycleway=yes lcn=yes
switch bicycle=
switch vehicle=
defaultaccess
switch or vehicle=private vehicle=no
0
1
switch or bicycle=private or bicycle=no bicycle=dismount
0
1
assign footaccess
or bicycle=dismount
switch foot=
defaultaccess
switch or foot=private foot=no
0
1
assign initialcost switch or bikeaccess footaccess 0 1000000

View file

@ -0,0 +1,223 @@
# *** The trekking profile is for slow travel
# *** and avoiding car traffic, but still with
# *** a focus on approaching your destination
# *** efficiently.
---context:global # following code refers to global config
# Use the following switches to change behaviour
# (1=yes, 0=no):
assign consider_elevation 1 # set to 0 to ignore elevation in routing
assign allow_steps 1 # set to 0 to disallow steps
assign allow_ferries 1 # set to 0 to disallow ferries
assign ignore_cycleroutes 1 # set to 1 for better elevation results
assign stick_to_cycleroutes 0 # set to 1 to just follow cycleroutes
assign avoid_unsafe 0 # set to 1 to avoid standard highways
# the elevation parameters
assign downhillcost switch consider_elevation 60 0
assign downhillcutoff 1.5
assign uphillcost 0
assign uphillcutoff 1.5
---context:way # following code refers to way-tags
#
# pre-calculate some logical expressions
#
assign is_ldcr and longdistancecycleway=yes not ignore_cycleroutes
assign isbike or bicycle=yes or bicycle=designated lcn=yes
assign ispaved or surface=paved or surface=asphalt or surface=concrete surface=paving_stones
assign isunpaved not or surface= or ispaved or surface=fine_gravel surface=cobblestone
assign probablyGood or ispaved and isbike not isunpaved
#
# this is the cost (in Meter) for a 90-degree turn
# The actual cost is calculated as turncost*cos(angle)
# (Suppressing turncost while following longdistance-cycleways
# makes them a little bit more magnetic)
#
assign turncost switch is_ldcr 0 90
#
# calculate the initial cost
# this is added to the total cost each time the costfactor
# changed
#
assign initialcost switch highway=ferry 10000 0
#
# implicit access here just from the motorroad tag
# (implicit access rules from highway tag handled elsewhere)
#
assign defaultaccess
switch access=
not motorroad=yes
switch or access=private access=no
0
1
#
# calculate logical bike access
#
assign bikeaccess
or longdistancecycleway=yes
switch bicycle=
switch vehicle=
defaultaccess
switch or vehicle=private vehicle=no
0
1
not or bicycle=private or bicycle=no bicycle=dismount
#
# calculate logical foot access
#
assign footaccess
or bikeaccess
or bicycle=dismount
switch foot=
defaultaccess
not or foot=private foot=no
#
# if not bike-, but foot-acess, just a moderate penalty,
# otherwise access is forbidden
#
assign accesspenalty
switch bikeaccess
0
switch footaccess
4
100000
#
# handle one-ways. On primary roads, wrong-oneways should
# be close to forbidden, while on other ways we just add
# 4 to the costfactor (making it at least 5 - you are allowed
# to push your bike)
#
assign oneway
switch oneway=
junction=roundabout
or oneway=yes or oneway=true oneway=1
assign onewaypenalty
switch switch reversedirection=yes oneway oneway=-1
switch or cycleway=opposite or cycleway=opposite_lane cycleway=opposite_track 0
switch or highway=primary highway=primary_link 50
switch or highway=secondary highway=secondary_link 30
switch or highway=tertiary highway=tertiary_link 20
4.0
0.0
#
# calculate the cost-factor, which is the factor
# by which the distance of a way-segment is multiplied
# to calculate the cost of that segment. The costfactor
# must be >=1 and it's supposed to be close to 1 for
# the type of way the routing profile is searching for
#
assign costfactor
add max onewaypenalty accesspenalty
#
# steps and ferries are special. Note this is handled
# before the longdistancecycleway-switch, to be able
# to really exlude them be setting cost to infinity
#
switch highway=steps switch allow_steps 40 100000
switch highway=ferry switch allow_ferries 5.67 100000
#
# handle long-distance cycle-routes.
#
switch is_ldcr 1 # always treated as perfect (=1)
add switch stick_to_cycleroutes 0.5 0.05 # everything else somewhat up
#
# some other highway types
#
switch highway=pedestrian 3
switch highway=bridleway 5
switch highway=cycleway 1
switch or highway=residential highway=living_street switch isunpaved 1.5 1.1
switch highway=service switch isunpaved 1.6 1.3
#
# tracks and track-like ways are rated mainly be tracktype/grade
# But note that if no tracktype is given (mainly for road/path/footway)
# it can be o.k. if there's any other hint for quality
#
switch or highway=track or highway=road or highway=path highway=footway
switch tracktype=grade1 switch probablyGood 1.0 1.3
switch tracktype=grade2 switch probablyGood 1.1 2.0
switch tracktype=grade3 switch probablyGood 1.5 3.0
switch tracktype=grade4 switch probablyGood 2.0 5.0
switch tracktype=grade5 switch probablyGood 3.0 5.0
switch probablyGood 1.0 5.0
#
# When avoiding unsafe ways, avoid highways without a bike hint
#
add switch and avoid_unsafe not isbike 2 0
#
# exclude motorways and proposed roads
#
switch or highway=motorway highway=motorway_link 100000
switch highway=proposed 100000
#
# actuals roads are o.k. if we have a bike hint
#
switch or highway=trunk highway=trunk_link switch isbike 1.5 10
switch or highway=primary highway=primary_link switch isbike 1.2 3
switch or highway=secondary highway=secondary_link switch isbike 1.1 1.6
switch or highway=tertiary highway=tertiary_link switch isbike 1.0 1.4
switch highway=unclassified switch isbike 1.0 1.3
#
# default for any other highway type not handled above
#
2.0
---context:node # following code refers to node tags
assign defaultaccess
switch access=
1 # add default barrier restrictions here!
switch or access=private access=no
0
1
assign bikeaccess
or or longdistancecycleway=yes lcn=yes
switch bicycle=
switch vehicle=
defaultaccess
switch or vehicle=private vehicle=no
0
1
switch or bicycle=private or bicycle=no bicycle=dismount
0
1
assign footaccess
or bicycle=dismount
switch foot=
defaultaccess
switch or foot=private foot=no
0
1
assign initialcost
switch bikeaccess
0
switch footaccess
100
1000000

View file

@ -0,0 +1,223 @@
# *** The trekking profile is for slow travel
# *** and avoiding car traffic, but still with
# *** a focus on approaching your destination
# *** efficiently.
---context:global # following code refers to global config
# Use the following switches to change behaviour
# (1=yes, 0=no):
assign consider_elevation 1 # set to 0 to ignore elevation in routing
assign allow_steps 1 # set to 0 to disallow steps
assign allow_ferries 0 # set to 0 to disallow ferries
assign ignore_cycleroutes 0 # set to 1 for better elevation results
assign stick_to_cycleroutes 0 # set to 1 to just follow cycleroutes
assign avoid_unsafe 0 # set to 1 to avoid standard highways
# the elevation parameters
assign downhillcost switch consider_elevation 60 0
assign downhillcutoff 1.5
assign uphillcost 0
assign uphillcutoff 1.5
---context:way # following code refers to way-tags
#
# pre-calculate some logical expressions
#
assign is_ldcr and longdistancecycleway=yes not ignore_cycleroutes
assign isbike or bicycle=yes or bicycle=designated lcn=yes
assign ispaved or surface=paved or surface=asphalt or surface=concrete surface=paving_stones
assign isunpaved not or surface= or ispaved or surface=fine_gravel surface=cobblestone
assign probablyGood or ispaved and isbike not isunpaved
#
# this is the cost (in Meter) for a 90-degree turn
# The actual cost is calculated as turncost*cos(angle)
# (Suppressing turncost while following longdistance-cycleways
# makes them a little bit more magnetic)
#
assign turncost switch is_ldcr 0 90
#
# calculate the initial cost
# this is added to the total cost each time the costfactor
# changed
#
assign initialcost switch highway=ferry 10000 0
#
# implicit access here just from the motorroad tag
# (implicit access rules from highway tag handled elsewhere)
#
assign defaultaccess
switch access=
not motorroad=yes
switch or access=private access=no
0
1
#
# calculate logical bike access
#
assign bikeaccess
or longdistancecycleway=yes
switch bicycle=
switch vehicle=
defaultaccess
switch or vehicle=private vehicle=no
0
1
not or bicycle=private or bicycle=no bicycle=dismount
#
# calculate logical foot access
#
assign footaccess
or bikeaccess
or bicycle=dismount
switch foot=
defaultaccess
not or foot=private foot=no
#
# if not bike-, but foot-acess, just a moderate penalty,
# otherwise access is forbidden
#
assign accesspenalty
switch bikeaccess
0
switch footaccess
4
100000
#
# handle one-ways. On primary roads, wrong-oneways should
# be close to forbidden, while on other ways we just add
# 4 to the costfactor (making it at least 5 - you are allowed
# to push your bike)
#
assign oneway
switch oneway=
junction=roundabout
or oneway=yes or oneway=true oneway=1
assign onewaypenalty
switch switch reversedirection=yes oneway oneway=-1
switch or cycleway=opposite or cycleway=opposite_lane cycleway=opposite_track 0
switch or highway=primary highway=primary_link 50
switch or highway=secondary highway=secondary_link 30
switch or highway=tertiary highway=tertiary_link 20
4.0
0.0
#
# calculate the cost-factor, which is the factor
# by which the distance of a way-segment is multiplied
# to calculate the cost of that segment. The costfactor
# must be >=1 and it's supposed to be close to 1 for
# the type of way the routing profile is searching for
#
assign costfactor
add max onewaypenalty accesspenalty
#
# steps and ferries are special. Note this is handled
# before the longdistancecycleway-switch, to be able
# to really exlude them be setting cost to infinity
#
switch highway=steps switch allow_steps 40 100000
switch highway=ferry switch allow_ferries 5.67 100000
#
# handle long-distance cycle-routes.
#
switch is_ldcr 1 # always treated as perfect (=1)
add switch stick_to_cycleroutes 0.5 0.05 # everything else somewhat up
#
# some other highway types
#
switch highway=pedestrian 3
switch highway=bridleway 5
switch highway=cycleway 1
switch or highway=residential highway=living_street switch isunpaved 1.5 1.1
switch highway=service switch isunpaved 1.6 1.3
#
# tracks and track-like ways are rated mainly be tracktype/grade
# But note that if no tracktype is given (mainly for road/path/footway)
# it can be o.k. if there's any other hint for quality
#
switch or highway=track or highway=road or highway=path highway=footway
switch tracktype=grade1 switch probablyGood 1.0 1.3
switch tracktype=grade2 switch probablyGood 1.1 2.0
switch tracktype=grade3 switch probablyGood 1.5 3.0
switch tracktype=grade4 switch probablyGood 2.0 5.0
switch tracktype=grade5 switch probablyGood 3.0 5.0
switch probablyGood 1.0 5.0
#
# When avoiding unsafe ways, avoid highways without a bike hint
#
add switch and avoid_unsafe not isbike 2 0
#
# exclude motorways and proposed roads
#
switch or highway=motorway highway=motorway_link 100000
switch highway=proposed 100000
#
# actuals roads are o.k. if we have a bike hint
#
switch or highway=trunk highway=trunk_link switch isbike 1.5 10
switch or highway=primary highway=primary_link switch isbike 1.2 3
switch or highway=secondary highway=secondary_link switch isbike 1.1 1.6
switch or highway=tertiary highway=tertiary_link switch isbike 1.0 1.4
switch highway=unclassified switch isbike 1.0 1.3
#
# default for any other highway type not handled above
#
2.0
---context:node # following code refers to node tags
assign defaultaccess
switch access=
1 # add default barrier restrictions here!
switch or access=private access=no
0
1
assign bikeaccess
or or longdistancecycleway=yes lcn=yes
switch bicycle=
switch vehicle=
defaultaccess
switch or vehicle=private vehicle=no
0
1
switch or bicycle=private or bicycle=no bicycle=dismount
0
1
assign footaccess
or bicycle=dismount
switch foot=
defaultaccess
switch or foot=private foot=no
0
1
assign initialcost
switch bikeaccess
0
switch footaccess
100
1000000

View file

@ -0,0 +1,223 @@
# *** The trekking profile is for slow travel
# *** and avoiding car traffic, but still with
# *** a focus on approaching your destination
# *** efficiently.
---context:global # following code refers to global config
# Use the following switches to change behaviour
# (1=yes, 0=no):
assign consider_elevation 1 # set to 0 to ignore elevation in routing
assign allow_steps 0 # set to 0 to disallow steps
assign allow_ferries 1 # set to 0 to disallow ferries
assign ignore_cycleroutes 0 # set to 1 for better elevation results
assign stick_to_cycleroutes 0 # set to 1 to just follow cycleroutes
assign avoid_unsafe 0 # set to 1 to avoid standard highways
# the elevation parameters
assign downhillcost switch consider_elevation 60 0
assign downhillcutoff 1.5
assign uphillcost 0
assign uphillcutoff 1.5
---context:way # following code refers to way-tags
#
# pre-calculate some logical expressions
#
assign is_ldcr and longdistancecycleway=yes not ignore_cycleroutes
assign isbike or bicycle=yes or bicycle=designated lcn=yes
assign ispaved or surface=paved or surface=asphalt or surface=concrete surface=paving_stones
assign isunpaved not or surface= or ispaved or surface=fine_gravel surface=cobblestone
assign probablyGood or ispaved and isbike not isunpaved
#
# this is the cost (in Meter) for a 90-degree turn
# The actual cost is calculated as turncost*cos(angle)
# (Suppressing turncost while following longdistance-cycleways
# makes them a little bit more magnetic)
#
assign turncost switch is_ldcr 0 90
#
# calculate the initial cost
# this is added to the total cost each time the costfactor
# changed
#
assign initialcost switch highway=ferry 10000 0
#
# implicit access here just from the motorroad tag
# (implicit access rules from highway tag handled elsewhere)
#
assign defaultaccess
switch access=
not motorroad=yes
switch or access=private access=no
0
1
#
# calculate logical bike access
#
assign bikeaccess
or longdistancecycleway=yes
switch bicycle=
switch vehicle=
defaultaccess
switch or vehicle=private vehicle=no
0
1
not or bicycle=private or bicycle=no bicycle=dismount
#
# calculate logical foot access
#
assign footaccess
or bikeaccess
or bicycle=dismount
switch foot=
defaultaccess
not or foot=private foot=no
#
# if not bike-, but foot-acess, just a moderate penalty,
# otherwise access is forbidden
#
assign accesspenalty
switch bikeaccess
0
switch footaccess
4
100000
#
# handle one-ways. On primary roads, wrong-oneways should
# be close to forbidden, while on other ways we just add
# 4 to the costfactor (making it at least 5 - you are allowed
# to push your bike)
#
assign oneway
switch oneway=
junction=roundabout
or oneway=yes or oneway=true oneway=1
assign onewaypenalty
switch switch reversedirection=yes oneway oneway=-1
switch or cycleway=opposite or cycleway=opposite_lane cycleway=opposite_track 0
switch or highway=primary highway=primary_link 50
switch or highway=secondary highway=secondary_link 30
switch or highway=tertiary highway=tertiary_link 20
4.0
0.0
#
# calculate the cost-factor, which is the factor
# by which the distance of a way-segment is multiplied
# to calculate the cost of that segment. The costfactor
# must be >=1 and it's supposed to be close to 1 for
# the type of way the routing profile is searching for
#
assign costfactor
add max onewaypenalty accesspenalty
#
# steps and ferries are special. Note this is handled
# before the longdistancecycleway-switch, to be able
# to really exlude them be setting cost to infinity
#
switch highway=steps switch allow_steps 40 100000
switch highway=ferry switch allow_ferries 5.67 100000
#
# handle long-distance cycle-routes.
#
switch is_ldcr 1 # always treated as perfect (=1)
add switch stick_to_cycleroutes 0.5 0.05 # everything else somewhat up
#
# some other highway types
#
switch highway=pedestrian 3
switch highway=bridleway 5
switch highway=cycleway 1
switch or highway=residential highway=living_street switch isunpaved 1.5 1.1
switch highway=service switch isunpaved 1.6 1.3
#
# tracks and track-like ways are rated mainly be tracktype/grade
# But note that if no tracktype is given (mainly for road/path/footway)
# it can be o.k. if there's any other hint for quality
#
switch or highway=track or highway=road or highway=path highway=footway
switch tracktype=grade1 switch probablyGood 1.0 1.3
switch tracktype=grade2 switch probablyGood 1.1 2.0
switch tracktype=grade3 switch probablyGood 1.5 3.0
switch tracktype=grade4 switch probablyGood 2.0 5.0
switch tracktype=grade5 switch probablyGood 3.0 5.0
switch probablyGood 1.0 5.0
#
# When avoiding unsafe ways, avoid highways without a bike hint
#
add switch and avoid_unsafe not isbike 2 0
#
# exclude motorways and proposed roads
#
switch or highway=motorway highway=motorway_link 100000
switch highway=proposed 100000
#
# actuals roads are o.k. if we have a bike hint
#
switch or highway=trunk highway=trunk_link switch isbike 1.5 10
switch or highway=primary highway=primary_link switch isbike 1.2 3
switch or highway=secondary highway=secondary_link switch isbike 1.1 1.6
switch or highway=tertiary highway=tertiary_link switch isbike 1.0 1.4
switch highway=unclassified switch isbike 1.0 1.3
#
# default for any other highway type not handled above
#
2.0
---context:node # following code refers to node tags
assign defaultaccess
switch access=
1 # add default barrier restrictions here!
switch or access=private access=no
0
1
assign bikeaccess
or or longdistancecycleway=yes lcn=yes
switch bicycle=
switch vehicle=
defaultaccess
switch or vehicle=private vehicle=no
0
1
switch or bicycle=private or bicycle=no bicycle=dismount
0
1
assign footaccess
or bicycle=dismount
switch foot=
defaultaccess
switch or foot=private foot=no
0
1
assign initialcost
switch bikeaccess
0
switch footaccess
100
1000000

View file

@ -0,0 +1,223 @@
# *** The trekking profile is for slow travel
# *** and avoiding car traffic, but still with
# *** a focus on approaching your destination
# *** efficiently.
---context:global # following code refers to global config
# Use the following switches to change behaviour
# (1=yes, 0=no):
assign consider_elevation 0 # set to 0 to ignore elevation in routing
assign allow_steps 1 # set to 0 to disallow steps
assign allow_ferries 1 # set to 0 to disallow ferries
assign ignore_cycleroutes 0 # set to 1 for better elevation results
assign stick_to_cycleroutes 0 # set to 1 to just follow cycleroutes
assign avoid_unsafe 0 # set to 1 to avoid standard highways
# the elevation parameters
assign downhillcost switch consider_elevation 60 0
assign downhillcutoff 1.5
assign uphillcost 0
assign uphillcutoff 1.5
---context:way # following code refers to way-tags
#
# pre-calculate some logical expressions
#
assign is_ldcr and longdistancecycleway=yes not ignore_cycleroutes
assign isbike or bicycle=yes or bicycle=designated lcn=yes
assign ispaved or surface=paved or surface=asphalt or surface=concrete surface=paving_stones
assign isunpaved not or surface= or ispaved or surface=fine_gravel surface=cobblestone
assign probablyGood or ispaved and isbike not isunpaved
#
# this is the cost (in Meter) for a 90-degree turn
# The actual cost is calculated as turncost*cos(angle)
# (Suppressing turncost while following longdistance-cycleways
# makes them a little bit more magnetic)
#
assign turncost switch is_ldcr 0 90
#
# calculate the initial cost
# this is added to the total cost each time the costfactor
# changed
#
assign initialcost switch highway=ferry 10000 0
#
# implicit access here just from the motorroad tag
# (implicit access rules from highway tag handled elsewhere)
#
assign defaultaccess
switch access=
not motorroad=yes
switch or access=private access=no
0
1
#
# calculate logical bike access
#
assign bikeaccess
or longdistancecycleway=yes
switch bicycle=
switch vehicle=
defaultaccess
switch or vehicle=private vehicle=no
0
1
not or bicycle=private or bicycle=no bicycle=dismount
#
# calculate logical foot access
#
assign footaccess
or bikeaccess
or bicycle=dismount
switch foot=
defaultaccess
not or foot=private foot=no
#
# if not bike-, but foot-acess, just a moderate penalty,
# otherwise access is forbidden
#
assign accesspenalty
switch bikeaccess
0
switch footaccess
4
100000
#
# handle one-ways. On primary roads, wrong-oneways should
# be close to forbidden, while on other ways we just add
# 4 to the costfactor (making it at least 5 - you are allowed
# to push your bike)
#
assign oneway
switch oneway=
junction=roundabout
or oneway=yes or oneway=true oneway=1
assign onewaypenalty
switch switch reversedirection=yes oneway oneway=-1
switch or cycleway=opposite or cycleway=opposite_lane cycleway=opposite_track 0
switch or highway=primary highway=primary_link 50
switch or highway=secondary highway=secondary_link 30
switch or highway=tertiary highway=tertiary_link 20
4.0
0.0
#
# calculate the cost-factor, which is the factor
# by which the distance of a way-segment is multiplied
# to calculate the cost of that segment. The costfactor
# must be >=1 and it's supposed to be close to 1 for
# the type of way the routing profile is searching for
#
assign costfactor
add max onewaypenalty accesspenalty
#
# steps and ferries are special. Note this is handled
# before the longdistancecycleway-switch, to be able
# to really exlude them be setting cost to infinity
#
switch highway=steps switch allow_steps 40 100000
switch highway=ferry switch allow_ferries 5.67 100000
#
# handle long-distance cycle-routes.
#
switch is_ldcr 1 # always treated as perfect (=1)
add switch stick_to_cycleroutes 0.5 0.05 # everything else somewhat up
#
# some other highway types
#
switch highway=pedestrian 3
switch highway=bridleway 5
switch highway=cycleway 1
switch or highway=residential highway=living_street switch isunpaved 1.5 1.1
switch highway=service switch isunpaved 1.6 1.3
#
# tracks and track-like ways are rated mainly be tracktype/grade
# But note that if no tracktype is given (mainly for road/path/footway)
# it can be o.k. if there's any other hint for quality
#
switch or highway=track or highway=road or highway=path highway=footway
switch tracktype=grade1 switch probablyGood 1.0 1.3
switch tracktype=grade2 switch probablyGood 1.1 2.0
switch tracktype=grade3 switch probablyGood 1.5 3.0
switch tracktype=grade4 switch probablyGood 2.0 5.0
switch tracktype=grade5 switch probablyGood 3.0 5.0
switch probablyGood 1.0 5.0
#
# When avoiding unsafe ways, avoid highways without a bike hint
#
add switch and avoid_unsafe not isbike 2 0
#
# exclude motorways and proposed roads
#
switch or highway=motorway highway=motorway_link 100000
switch highway=proposed 100000
#
# actuals roads are o.k. if we have a bike hint
#
switch or highway=trunk highway=trunk_link switch isbike 1.5 10
switch or highway=primary highway=primary_link switch isbike 1.2 3
switch or highway=secondary highway=secondary_link switch isbike 1.1 1.6
switch or highway=tertiary highway=tertiary_link switch isbike 1.0 1.4
switch highway=unclassified switch isbike 1.0 1.3
#
# default for any other highway type not handled above
#
2.0
---context:node # following code refers to node tags
assign defaultaccess
switch access=
1 # add default barrier restrictions here!
switch or access=private access=no
0
1
assign bikeaccess
or or longdistancecycleway=yes lcn=yes
switch bicycle=
switch vehicle=
defaultaccess
switch or vehicle=private vehicle=no
0
1
switch or bicycle=private or bicycle=no bicycle=dismount
0
1
assign footaccess
or bicycle=dismount
switch foot=
defaultaccess
switch or foot=private foot=no
0
1
assign initialcost
switch bikeaccess
0
switch footaccess
100
1000000

View file

@ -0,0 +1,223 @@
# *** The trekking profile is for slow travel
# *** and avoiding car traffic, but still with
# *** a focus on approaching your destination
# *** efficiently.
---context:global # following code refers to global config
# Use the following switches to change behaviour
# (1=yes, 0=no):
assign consider_elevation 1 # set to 0 to ignore elevation in routing
assign allow_steps 1 # set to 0 to disallow steps
assign allow_ferries 1 # set to 0 to disallow ferries
assign ignore_cycleroutes 0 # set to 1 for better elevation results
assign stick_to_cycleroutes 0 # set to 1 to just follow cycleroutes
assign avoid_unsafe 0 # set to 1 to avoid standard highways
# the elevation parameters
assign downhillcost switch consider_elevation 60 0
assign downhillcutoff 1.5
assign uphillcost 0
assign uphillcutoff 1.5
---context:way # following code refers to way-tags
#
# pre-calculate some logical expressions
#
assign is_ldcr and longdistancecycleway=yes not ignore_cycleroutes
assign isbike or bicycle=yes or bicycle=designated lcn=yes
assign ispaved or surface=paved or surface=asphalt or surface=concrete surface=paving_stones
assign isunpaved not or surface= or ispaved or surface=fine_gravel surface=cobblestone
assign probablyGood or ispaved and isbike not isunpaved
#
# this is the cost (in Meter) for a 90-degree turn
# The actual cost is calculated as turncost*cos(angle)
# (Suppressing turncost while following longdistance-cycleways
# makes them a little bit more magnetic)
#
assign turncost switch is_ldcr 0 90
#
# calculate the initial cost
# this is added to the total cost each time the costfactor
# changed
#
assign initialcost switch highway=ferry 10000 0
#
# implicit access here just from the motorroad tag
# (implicit access rules from highway tag handled elsewhere)
#
assign defaultaccess
switch access=
not motorroad=yes
switch or access=private access=no
0
1
#
# calculate logical bike access
#
assign bikeaccess
or longdistancecycleway=yes
switch bicycle=
switch vehicle=
defaultaccess
switch or vehicle=private vehicle=no
0
1
not or bicycle=private or bicycle=no bicycle=dismount
#
# calculate logical foot access
#
assign footaccess
or bikeaccess
or bicycle=dismount
switch foot=
defaultaccess
not or foot=private foot=no
#
# if not bike-, but foot-acess, just a moderate penalty,
# otherwise access is forbidden
#
assign accesspenalty
switch bikeaccess
0
switch footaccess
4
100000
#
# handle one-ways. On primary roads, wrong-oneways should
# be close to forbidden, while on other ways we just add
# 4 to the costfactor (making it at least 5 - you are allowed
# to push your bike)
#
assign oneway
switch oneway=
junction=roundabout
or oneway=yes or oneway=true oneway=1
assign onewaypenalty
switch switch reversedirection=yes oneway oneway=-1
switch or cycleway=opposite or cycleway=opposite_lane cycleway=opposite_track 0
switch or highway=primary highway=primary_link 50
switch or highway=secondary highway=secondary_link 30
switch or highway=tertiary highway=tertiary_link 20
4.0
0.0
#
# calculate the cost-factor, which is the factor
# by which the distance of a way-segment is multiplied
# to calculate the cost of that segment. The costfactor
# must be >=1 and it's supposed to be close to 1 for
# the type of way the routing profile is searching for
#
assign costfactor
add max onewaypenalty accesspenalty
#
# steps and ferries are special. Note this is handled
# before the longdistancecycleway-switch, to be able
# to really exlude them be setting cost to infinity
#
switch highway=steps switch allow_steps 40 100000
switch highway=ferry switch allow_ferries 5.67 100000
#
# handle long-distance cycle-routes.
#
switch is_ldcr 1 # always treated as perfect (=1)
add switch stick_to_cycleroutes 0.5 0.05 # everything else somewhat up
#
# some other highway types
#
switch highway=pedestrian 3
switch highway=bridleway 5
switch highway=cycleway 1
switch or highway=residential highway=living_street switch isunpaved 1.5 1.1
switch highway=service switch isunpaved 1.6 1.3
#
# tracks and track-like ways are rated mainly be tracktype/grade
# But note that if no tracktype is given (mainly for road/path/footway)
# it can be o.k. if there's any other hint for quality
#
switch or highway=track or highway=road or highway=path highway=footway
switch tracktype=grade1 switch probablyGood 1.0 1.3
switch tracktype=grade2 switch probablyGood 1.1 2.0
switch tracktype=grade3 switch probablyGood 1.5 3.0
switch tracktype=grade4 switch probablyGood 2.0 5.0
switch tracktype=grade5 switch probablyGood 3.0 5.0
switch probablyGood 1.0 5.0
#
# When avoiding unsafe ways, avoid highways without a bike hint
#
add switch and avoid_unsafe not isbike 2 0
#
# exclude motorways and proposed roads
#
switch or highway=motorway highway=motorway_link 100000
switch highway=proposed 100000
#
# actuals roads are o.k. if we have a bike hint
#
switch or highway=trunk highway=trunk_link switch isbike 1.5 10
switch or highway=primary highway=primary_link switch isbike 1.2 3
switch or highway=secondary highway=secondary_link switch isbike 1.1 1.6
switch or highway=tertiary highway=tertiary_link switch isbike 1.0 1.4
switch highway=unclassified switch isbike 1.0 1.3
#
# default for any other highway type not handled above
#
2.0
---context:node # following code refers to node tags
assign defaultaccess
switch access=
1 # add default barrier restrictions here!
switch or access=private access=no
0
1
assign bikeaccess
or or longdistancecycleway=yes lcn=yes
switch bicycle=
switch vehicle=
defaultaccess
switch or vehicle=private vehicle=no
0
1
switch or bicycle=private or bicycle=no bicycle=dismount
0
1
assign footaccess
or bicycle=dismount
switch foot=
defaultaccess
switch or foot=private foot=no
0
1
assign initialcost
switch bikeaccess
0
switch footaccess
100
1000000