Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 22
buildToolsVersion "23.0.1"
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
applicationId "com.graphhopper.android"
Expand Down Expand Up @@ -41,10 +41,10 @@ dependencies {
exclude group: 'org.apache.xmlgraphics', module: 'xmlgraphics-commons'
}

compile group: 'org.mapsforge', name: 'mapsforge-core', version: '0.5.2'
compile group: 'org.mapsforge', name: 'mapsforge-map', version: '0.5.2'
compile group: 'org.mapsforge', name: 'mapsforge-map-android', version: '0.5.2'
compile group: 'org.mapsforge', name: 'mapsforge-map-reader', version: '0.5.2'
compile group: 'org.mapsforge', name: 'mapsforge-core', version: '0.6.0'
compile group: 'org.mapsforge', name: 'mapsforge-map', version: '0.6.0'
compile group: 'org.mapsforge', name: 'mapsforge-map-android', version: '0.6.0'
compile group: 'org.mapsforge', name: 'mapsforge-map-reader', version: '0.6.0'

compile group: 'org.slf4j', name: 'slf4j-android', version: '1.7.12'
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.12'
Expand Down
2 changes: 1 addition & 1 deletion android/app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<version>0.6-SNAPSHOT</version>
</parent>
<properties>
<mapsforge.version>0.5.2</mapsforge.version>
<mapsforge.version>0.6.0</mapsforge.version>
<!-- do not put the properties here as it differs from dev to dev <android.sdk.path>/home/peterk/Programme/android-sdk-linux_x86</android.sdk.path>
instead use your IDE to set it up or specify android sdk via command line
using -Dandroid.sdk.path=... or by setting environment variable ANDROID_HOME
Expand Down
2 changes: 1 addition & 1 deletion android/app/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

# Project target.
target=android-22
target=android-23
50 changes: 25 additions & 25 deletions android/app/src/main/java/com/graphhopper/android/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,30 +1,5 @@
package com.graphhopper.android;

import java.io.File;
import java.io.FilenameFilter;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

import org.mapsforge.core.graphics.Bitmap;
import org.mapsforge.core.graphics.Paint;
import org.mapsforge.core.graphics.Style;
import org.mapsforge.core.model.LatLong;
import org.mapsforge.core.model.MapPosition;
import org.mapsforge.core.model.Point;
import org.mapsforge.map.android.graphics.AndroidGraphicFactory;
import org.mapsforge.map.android.util.AndroidUtil;
import org.mapsforge.map.android.view.MapView;
import org.mapsforge.map.layer.Layers;
import org.mapsforge.map.layer.cache.TileCache;
import org.mapsforge.map.layer.overlay.Marker;
import org.mapsforge.map.layer.overlay.Polyline;
import org.mapsforge.map.layer.renderer.TileRendererLayer;
import org.mapsforge.map.reader.MapDataStore;
import org.mapsforge.map.reader.MapFile;
import org.mapsforge.map.rendertheme.InternalRenderTheme;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
Expand Down Expand Up @@ -59,6 +34,31 @@
import com.graphhopper.util.ProgressListener;
import com.graphhopper.util.StopWatch;

import org.mapsforge.core.graphics.Bitmap;
import org.mapsforge.core.graphics.Paint;
import org.mapsforge.core.graphics.Style;
import org.mapsforge.core.model.LatLong;
import org.mapsforge.core.model.MapPosition;
import org.mapsforge.core.model.Point;
import org.mapsforge.map.android.graphics.AndroidGraphicFactory;
import org.mapsforge.map.android.util.AndroidUtil;
import org.mapsforge.map.android.view.MapView;
import org.mapsforge.map.datastore.MapDataStore;
import org.mapsforge.map.layer.Layers;
import org.mapsforge.map.layer.cache.TileCache;
import org.mapsforge.map.layer.overlay.Marker;
import org.mapsforge.map.layer.overlay.Polyline;
import org.mapsforge.map.layer.renderer.TileRendererLayer;
import org.mapsforge.map.reader.MapFile;
import org.mapsforge.map.rendertheme.InternalRenderTheme;

import java.io.File;
import java.io.FilenameFilter;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

public class MainActivity extends Activity
{
private MapView mapView;
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.1'
classpath 'com.android.tools.build:gradle:1.5.0'
}
}

Expand Down
Binary file modified android/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Apr 10 15:27:10 PDT 2013
#Wed Oct 21 11:34:03 PDT 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip
10 changes: 3 additions & 7 deletions android/gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion config-example.properties
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ graph.flagEncoders=car
# MMAP_STORE_SYNC could be used otherwise but will be a lot slower
graph.dataaccess=RAM_STORE

# if you want to reduce storage size and you don't need instructions for the resulting path use:
# if you don't need turn instruction, you can reduce storage size by not storing way names:
# osmreader.instructions=false

# will write way names in the preferred language (language code as defined in ISO 639-1 or ISO 639-2):
Expand Down
17 changes: 17 additions & 0 deletions core/src/main/java/com/graphhopper/GraphHopper.java
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,19 @@ public Weighting createTurnWeighting( Weighting weighting, Graph graph, FlagEnco
return weighting;
}

/**
* Analyze the request for adjusted weightings and wrap them around the current weighting.
* @return Potentially an AdjustedWeighting
*/
public Weighting createAdjustedWeighting( Weighting weighting, GHRequest request )
{
//TODO How to pass multiple additional weightings?
String additionalWeighting = request.getHints().get("additional_weighting", "");
if (additionalWeighting.equals("unique_paths"))
weighting = new UniquePathWeighting(weighting);
return weighting;
}

@Override
public GHResponse route( GHRequest request )
{
Expand Down Expand Up @@ -1077,6 +1090,7 @@ protected List<Path> getPaths( GHRequest request, GHResponse rsp )
RoutingAlgorithmFactory tmpAlgoFactory = getAlgorithmFactory(weighting);
QueryGraph queryGraph = new QueryGraph(routingGraph);
queryGraph.lookup(qResults);
weighting = createAdjustedWeighting(weighting, request);
weighting = createTurnWeighting(weighting, queryGraph, encoder);

List<Path> paths = new ArrayList<Path>(points.size() - 1);
Expand Down Expand Up @@ -1118,6 +1132,9 @@ protected List<Path> getPaths( GHRequest request, GHResponse rsp )
if (path.getTime() < 0)
throw new RuntimeException("Time was negative. Please report as bug and include:" + request);

if (weighting instanceof UniquePathWeighting)
((UniquePathWeighting) weighting).addPath(path);

paths.add(path);
debug += ", " + algo.getName() + "-routing:" + sw.stop().getSeconds() + "s, " + path.getDebugInfo();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright 2015 peterk.
*
* 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.
*/
package com.graphhopper.routing.util;

/**
* The AdjustedWeighting wraps another Weighting.
*
* @author Robin Boldt
*/
public abstract class AbstractAdjustedWeighting implements Weighting
{

protected final Weighting superWeighting;

public AbstractAdjustedWeighting( Weighting superWeighting )
{
if (superWeighting == null)
throw new IllegalArgumentException("No super weighting set");
this.superWeighting = superWeighting;
}

/**
* Returns the flagEncoder of the superWeighting. Usually we do not have a Flagencoder here.
*/
@Override
public FlagEncoder getFlagEncoder()
{
return superWeighting.getFlagEncoder();
}

@Override
public boolean matches( String weightingAsStr, FlagEncoder encoder )
{
return getName().equals(weightingAsStr) && encoder == superWeighting.getFlagEncoder();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,13 @@ void collect( OSMWay way, TreeMap<Double, Integer> weightToPrioMap )
if (classBicycle != null)
weightToPrioMap.put(100d, convertClassValueToPriority(classBicycle).getValue());
}

if (way.hasTag("scenic", "yes"))
{
if (weightToPrioMap.lastEntry().getValue() < BEST.getValue())
// Increase the prio by one step
weightToPrioMap.put(110d, weightToPrioMap.lastEntry().getValue() + 1);
}
}

/**
Expand All @@ -597,18 +604,17 @@ long handleBikeRelated( OSMWay way, long encoded, boolean partOfCycleRelation )
wayType = WayType.ROAD;
else
wayType = WayType.OTHER_SMALL_WAY;

boolean isPushingSection = isPushingSection(way);
if (isPushingSection && !partOfCycleRelation || "steps".equals(highway))
wayType = WayType.PUSHING_SECTION;

if (way.hasTag("bicycle", intendedValues))
{
if (isPushingSection && !way.hasTag("bicycle", "designated"))
wayType = WayType.OTHER_SMALL_WAY;
else
if ( (wayType == WayType.OTHER_SMALL_WAY ) || (wayType == WayType.PUSHING_SECTION) )
wayType = WayType.CYCLEWAY;
else if (wayType == WayType.OTHER_SMALL_WAY || wayType == WayType.PUSHING_SECTION)
wayType = WayType.CYCLEWAY;
} else if ("cycleway".equals(highway))
wayType = WayType.CYCLEWAY;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,22 @@
* @author Karl Hübner
* @author Peter Karich
*/
public class TurnWeighting implements Weighting
public class TurnWeighting extends AbstractAdjustedWeighting
{
/**
* Encoder, which decodes the turn flags
*/
private final TurnCostEncoder turnCostEncoder;
private final TurnCostExtension turnCostExt;
private final Weighting superWeighting;
private double defaultUTurnCost = 40;

/**
* @param turnCostExt the turn cost storage to be used
*/
public TurnWeighting( Weighting superWeighting, TurnCostEncoder encoder, TurnCostExtension turnCostExt )
{
super(superWeighting);
this.turnCostEncoder = encoder;
this.superWeighting = superWeighting;
this.turnCostExt = turnCostExt;
if (encoder == null)
throw new IllegalArgumentException("No encoder set to calculate turn weight");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package com.graphhopper.routing.util;

import com.graphhopper.routing.Path;
import com.graphhopper.util.EdgeIteratorState;
import gnu.trove.set.TIntSet;
import gnu.trove.set.hash.TIntHashSet;

/**
* Rates already used Paths worse.
*
* @author RobinBoldt
*/
public class UniquePathWeighting extends AbstractAdjustedWeighting
{
// Contains the EdgeIds of the already visisted Edges
protected final TIntSet visitedEdges = new TIntHashSet();

public static int ALREADY_VISISTED_EDGES_PENALTY = 3;

public UniquePathWeighting( Weighting superWeighting )
{
super(superWeighting);
}

public void addPath( Path path )
{
for (EdgeIteratorState edge : path.calcEdges())
{
visitedEdges.add(edge.getEdge());
}
}

@Override
public double getMinWeight( double distance )
{
return superWeighting.getMinWeight(distance);
}

@Override
public double calcWeight( EdgeIteratorState edgeState, boolean reverse, int prevOrNextEdgeId )
{
double weight = superWeighting.calcWeight(edgeState, reverse, prevOrNextEdgeId);

if (visitedEdges.contains(edgeState.getEdge()))
{
weight = weight * ALREADY_VISISTED_EDGES_PENALTY;
}

return weight;
}

@Override
public String getName()
{
return "unique_path";
}
}
Loading