Commit 6db7af95 authored by Peter's avatar Peter
Browse files

merged master, moving to 0.5.0

parents cc19543d d3fdc549
......@@ -35,7 +35,7 @@ configurations.all {
**/
dependencies {
compile(group: 'com.graphhopper', name: 'graphhopper', version: '0.5.0-RC1') {
compile(group: 'com.graphhopper', name: 'graphhopper', version: '0.5.0') {
exclude group: 'com.google.protobuf', module: 'protobuf-java'
exclude group: 'org.openstreetmap.osmosis', module: 'osmosis-osm-binary'
exclude group: 'org.apache.xmlgraphics', module: 'xmlgraphics-commons'
......
......@@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.graphhopper</groupId>
<artifactId>graphhopper-android</artifactId>
<version>0.5.0-RC1</version>
<version>0.5.0</version>
<name>GraphHopper Android</name>
<packaging>apk</packaging>
<organization>
......@@ -16,7 +16,7 @@
<relativePath>../..</relativePath>
<groupId>com.graphhopper</groupId>
<artifactId>graphhopper-parent</artifactId>
<version>0.5.0-RC1</version>
<version>0.5.0</version>
</parent>
<properties>
<mapsforge.version>0.5.1</mapsforge.version>
......
......@@ -3,7 +3,7 @@ cd $HOME/..
destination=src/main/resources/com/graphhopper/util/
translations="en_US SKIP ar bg ca cs_CZ de_DE el es fa fil fi fr gl he hsb hu_HU it ja lt_LT ne nl pl_PL pt_BR pt_PT ro ru si sk sv_SE tr uk vi_VI zh_CN"
translations="en_US SKIP ar ast bg ca cs_CZ da_DK de_DE el es fa fil fi fr gl he hsb hu_HU it ja lt_LT ne nl pl_PL pt_BR pt_PT ro ru si sk sv_SE tr uk vi_VI zh_CN"
file=$1
# You can execute the following
......
......@@ -6,7 +6,7 @@
<groupId>com.graphhopper</groupId>
<artifactId>graphhopper</artifactId>
<name>GraphHopper</name>
<version>0.5.0-RC1</version>
<version>0.5.0</version>
<packaging>jar</packaging>
<description>
GraphHopper is a fast and memory efficient Java road routing engine
......@@ -15,7 +15,7 @@
<parent>
<groupId>com.graphhopper</groupId>
<artifactId>graphhopper-parent</artifactId>
<version>0.5.0-RC1</version>
<version>0.5.0</version>
</parent>
<properties>
......@@ -70,7 +70,7 @@
<dependency>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>xmlgraphics-commons</artifactId>
<version>1.5</version>
<version>2.0.1</version>
</dependency>
<dependency>
......@@ -81,7 +81,7 @@
<dependency>
<groupId>org.openstreetmap.osmosis</groupId>
<artifactId>osmosis-osm-binary</artifactId>
<version>0.43.1</version>
<version>0.44.1</version>
</dependency>
<dependency>
......
......@@ -60,8 +60,8 @@ public class GHRequest
/**
* Set routing request from specified startPlace (fromLat, fromLon) to endPlace (toLat, toLon)
* with a preferred start and end heading.
* Headings are north based azimuth (clockwise) in (0, 360) or NaN for equal preference.
* with a preferred start and end heading. Headings are north based azimuth (clockwise) in (0,
* 360) or NaN for equal preference.
*/
public GHRequest( double fromLat, double fromLon, double toLat, double toLon,
double startHeading, double endHeading )
......@@ -77,10 +77,9 @@ public class GHRequest
this(new GHPoint(fromLat, fromLon), new GHPoint(toLat, toLon));
}
/**
* Set routing request from specified startPlace to endPlace with a preferred start and end heading.
* Headings are north based azimuth (clockwise) in (0, 360) or NaN for equal preference
* Set routing request from specified startPlace to endPlace with a preferred start and end
* heading. Headings are north based azimuth (clockwise) in (0, 360) or NaN for equal preference
*/
public GHRequest( GHPoint startPlace, GHPoint endPlace, double startHeading, double endHeading )
{
......@@ -106,19 +105,19 @@ public class GHRequest
this(startPlace, endPlace, Double.NaN, Double.NaN);
}
/**
* Set routing request
*
* @param points List of stopover points in order: start, 1st stop, 2nd stop, ..., end
* @param favoredHeadings List of favored headings for starting (start point) and arrival (via and end points)
* Headings are north based azimuth (clockwise) in (0, 360) or NaN for equal preference
* <p>
* @param points List of stopover points in order: start, 1st stop, 2nd stop, ..., end
* @param favoredHeadings List of favored headings for starting (start point) and arrival (via
* and end points) Headings are north based azimuth (clockwise) in (0, 360) or NaN for equal
* preference
*/
public GHRequest( List<GHPoint> points, List<Double> favoredHeadings )
{
if (points.size() != favoredHeadings.size())
throw new IllegalArgumentException("Size of headings (" + favoredHeadings.size() +
") must match size of points (" + points.size() + ")");
throw new IllegalArgumentException("Size of headings (" + favoredHeadings.size()
+ ") must match size of points (" + points.size() + ")");
for (Double heading : favoredHeadings)
{
......@@ -130,7 +129,7 @@ public class GHRequest
/**
* Set routing request
*
* <p>
* @param points List of stopover points in order: start, 1st stop, 2nd stop, ..., end
*/
public GHRequest( List<GHPoint> points )
......@@ -140,19 +139,18 @@ public class GHRequest
/**
* Add stopover point to routing request.
*
* @param point geographical position (see GHPoint)
* <p>
* @param point geographical position (see GHPoint)
* @param favoredHeading north based azimuth (clockwise) in (0, 360) or NaN for equal preference
*/
public GHRequest addPoint( GHPoint point, Double favoredHeading )
public GHRequest addPoint( GHPoint point, double favoredHeading )
{
if (point == null)
throw new IllegalArgumentException("point cannot be null");
if (!possibleToAdd)
throw new IllegalStateException("Please call empty constructor if you intent to use "
+ "more than two places via addPlace method.");
+ "more than two places via addPoint method.");
points.add(point);
validateAzimuthValue(favoredHeading);
......@@ -162,7 +160,7 @@ public class GHRequest
/**
* Add stopover point to routing request.
*
* <p>
* @param point geographical position (see GHPoint)
*/
public GHRequest addPoint( GHPoint point )
......@@ -185,19 +183,16 @@ public class GHRequest
public boolean hasFavoredHeading( int i )
{
if (i >= favoredHeadings.size())
throw new IndexOutOfBoundsException("Index: " + i + " too large for list of size " + favoredHeadings.size());
return false;
return !Double.isNaN(favoredHeadings.get(i));
}
// validate Azimuth entry
private void validateAzimuthValue( Double heading )
private void validateAzimuthValue( double heading )
{
// heading must be in (0, 360) oder Nan
// heading must be in (0, 360) oder NaN
if (!Double.isNaN(heading) && ((Double.compare(heading, 360) > 0) || (Double.compare(heading, 0) < 0)))
{
throw new IllegalArgumentException("Heading " + heading + " must be in range (0,360) or NaN");
}
}
public List<GHPoint> getPoints()
......
......@@ -748,7 +748,7 @@ public class GraphHopper implements GraphHopperAPI
if (chEnabled)
{
initCHAlgoFactories();
ghStorage = new GraphHopperStorage(algoFactories.keySet(), dir, encodingManager, hasElevation(), ext);
ghStorage = new GraphHopperStorage(new ArrayList<Weighting>(algoFactories.keySet()), dir, encodingManager, hasElevation(), ext);
} else
ghStorage = new GraphHopperStorage(dir, encodingManager, hasElevation(), ext);
......@@ -851,9 +851,7 @@ public class GraphHopper implements GraphHopperAPI
initLocationIndex();
if (chEnabled)
{
createCHPreparations();
}
if (!isPrepared())
prepare();
......
......@@ -407,11 +407,11 @@ public class QueryGraph implements Graph
if (Math.abs(delta) > 1.74) // penalize if a turn of more than 100°
{
edge.setVirtualEdgePreference(true, false);
edge.setVirtualEdgePreference(true);
modifiedEdges.add(edge);
//also apply to opposite edge for reverse routing
VirtualEdgeIteratorState reverseEdge = virtualEdges.get(virtNodeIDintern * 4 + getPosOfReverseEdge(edgePos));
reverseEdge.setVirtualEdgePreference(true, true);
reverseEdge.setVirtualEdgePreference(true);
modifiedEdges.add(reverseEdge);
enforcementOccured = true;
}
......@@ -435,9 +435,9 @@ public class QueryGraph implements Graph
VirtualEdgeIteratorState incomingEdge = (VirtualEdgeIteratorState) getEdgeIteratorState(edgeId, nodeId);
VirtualEdgeIteratorState reverseEdge = (VirtualEdgeIteratorState) getEdgeIteratorState(edgeId, incomingEdge.getBaseNode());
incomingEdge.setVirtualEdgePreference(true, !incoming);
incomingEdge.setVirtualEdgePreference(true);
modifiedEdges.add(incomingEdge);
reverseEdge.setVirtualEdgePreference(true, incoming);
reverseEdge.setVirtualEdgePreference(true);
modifiedEdges.add(reverseEdge);
return true;
}
......@@ -449,10 +449,8 @@ public class QueryGraph implements Graph
{
for (VirtualEdgeIteratorState edge : modifiedEdges)
{
edge.setVirtualEdgePreference(false, false);
edge.setVirtualEdgePreference(false, true);
edge.setVirtualEdgePreference(false);
}
}
@Override
......
......@@ -35,7 +35,6 @@ public class VirtualEdgeIteratorState implements EdgeIteratorState, CHEdgeIterat
private final int adjNode;
private final int originalTraversalKey;
// indication if edges are dispreferred as start/stop edge
private boolean unfavoredReverseEdge;
private boolean unfavored;
public VirtualEdgeIteratorState( int originalTraversalKey, int edgeId, int baseNode, int adjNode, double distance, long flags, String name, PointList pointList )
......@@ -149,27 +148,18 @@ public class VirtualEdgeIteratorState implements EdgeIteratorState, CHEdgeIterat
public boolean getBoolean( int key, boolean reverse, boolean _default )
{
if (key == EdgeIteratorState.K_UNFAVORED_EDGE)
{
if (reverse)
return unfavoredReverseEdge;
else
return unfavored;
}
return unfavored;
// for non-existent keys return default
return _default;
}
/**
* This method sets edge to unfavored status for routing from or to the start/stop points.
* <p>
* @param reverse indicates if forward or backward direction is affected
*/
public void setVirtualEdgePreference( boolean unfavored, boolean reverse )
public void setVirtualEdgePreference( boolean unfavored )
{
if (reverse)
unfavoredReverseEdge = unfavored;
else
this.unfavored = unfavored;
this.unfavored = unfavored;
}
@Override
......
......@@ -115,6 +115,7 @@ public abstract class AbstractFlagEncoder implements FlagEncoder, TurnCostEncode
acceptedRailways.add("tram");
acceptedRailways.add("abandoned");
acceptedRailways.add("abandoned_tram");
acceptedRailways.add("disused");
// http://wiki.openstreetmap.org/wiki/Demolished_Railway
......
......@@ -57,7 +57,7 @@ public class BikeCommonFlagEncoder extends AbstractFlagEncoder
private final Map<String, Integer> bikeNetworkToCode = new HashMap<String, Integer>();
protected EncodedValue relationCodeEncoder;
private EncodedValue wayTypeEncoder;
private EncodedValue preferWayEncoder;
EncodedValue priorityWayEncoder;
// Car speed limit which switches the preference from UNCHANGED to AVOID_IF_POSSIBLE
private int avoidSpeedLimit;
......@@ -220,8 +220,8 @@ public class BikeCommonFlagEncoder extends AbstractFlagEncoder
wayTypeEncoder = new EncodedValue("WayType", shift, 2, 1, 0, 3, true);
shift += wayTypeEncoder.getBits();
preferWayEncoder = new EncodedValue("PreferWay", shift, 3, 1, 0, 7);
shift += preferWayEncoder.getBits();
priorityWayEncoder = new EncodedValue("PreferWay", shift, 3, 1, 0, 7);
shift += priorityWayEncoder.getBits();
return shift;
}
......@@ -328,11 +328,6 @@ public class BikeCommonFlagEncoder extends AbstractFlagEncoder
if (!isFerry(allowed))
{
double speed = getSpeed(way);
int priorityFromRelation = 0;
if (relationFlags != 0)
priorityFromRelation = (int) relationCodeEncoder.getValue(relationFlags);
encoded = setLong(encoded, PriorityWeighting.KEY, handlePriority(way, priorityFromRelation));
// bike maxspeed handling is different from car as we don't increase speed
speed = applyMaxSpeed(way, speed, false);
......@@ -353,6 +348,11 @@ public class BikeCommonFlagEncoder extends AbstractFlagEncoder
highwaySpeeds.get("primary"));
encoded |= directionBitMask;
}
int priorityFromRelation = 0;
if (relationFlags != 0)
priorityFromRelation = (int) relationCodeEncoder.getValue(relationFlags);
encoded = priorityWayEncoder.setValue(encoded, handlePriority(way, priorityFromRelation));
return encoded;
}
......@@ -539,7 +539,8 @@ public class BikeCommonFlagEncoder extends AbstractFlagEncoder
}
} else
{
if (avoidHighwayTags.contains(highway) || ((maxSpeed >= avoidSpeedLimit) && (highway != "track")))
if (avoidHighwayTags.contains(highway)
|| maxSpeed >= avoidSpeedLimit && !"track".equals(highway))
{
weightToPrioMap.put(50d, REACH_DEST.getValue());
if (way.hasTag("tunnel", intendedValues))
......@@ -569,11 +570,8 @@ public class BikeCommonFlagEncoder extends AbstractFlagEncoder
{
String classBicycle = way.getTag("class:bicycle");
if (classBicycle != null)
{
weightToPrioMap.put(100d, convertCallValueToPriority(classBicycle).getValue());
}
}
}
/**
......@@ -642,40 +640,12 @@ public class BikeCommonFlagEncoder extends AbstractFlagEncoder
switch (key)
{
case PriorityWeighting.KEY:
double prio = preferWayEncoder.getValue(flags);
if (prio == 0)
return (double) UNCHANGED.getValue() / BEST.getValue();
return prio / BEST.getValue();
return (double) priorityWayEncoder.getValue(flags) / BEST.getValue();
default:
return super.getDouble(flags, key);
}
}
@Override
public long getLong( long flags, int key )
{
switch (key)
{
case PriorityWeighting.KEY:
return preferWayEncoder.getValue(flags);
default:
return super.getLong(flags, key);
}
}
@Override
public long setLong( long flags, int key, long value )
{
switch (key)
{
case PriorityWeighting.KEY:
return preferWayEncoder.setValue(flags, value);
default:
return super.setLong(flags, key, value);
}
}
boolean isPushingSection( OSMWay way )
{
return way.hasTag("highway", pushingSections) || way.hasTag("railway", "platform");
......@@ -781,5 +751,4 @@ public class BikeCommonFlagEncoder extends AbstractFlagEncoder
{
specificBicycleClass = "class:bicycle:" + subkey.toString();
}
}
......@@ -40,7 +40,7 @@ public class FootFlagEncoder extends AbstractFlagEncoder
static final int SLOW_SPEED = 2;
static final int MEAN_SPEED = 5;
static final int FERRY_SPEED = 10;
private EncodedValue preferWayEncoder;
private EncodedValue priorityWayEncoder;
private EncodedValue relationCodeEncoder;
protected HashSet<String> sidewalks = new HashSet<String>();
private final Set<String> safeHighwayTags = new HashSet<String>();
......@@ -109,16 +109,16 @@ public class FootFlagEncoder extends AbstractFlagEncoder
avoidHighwayTags.add("trunk_link");
avoidHighwayTags.add("primary");
avoidHighwayTags.add("primary_link");
avoidHighwayTags.add("secondary");
avoidHighwayTags.add("secondary_link");
avoidHighwayTags.add("tertiary");
avoidHighwayTags.add("tertiary_link");
// for now no explicit avoiding #257
//avoidHighwayTags.add("cycleway");
allowedHighwayTags.addAll(safeHighwayTags);
allowedHighwayTags.addAll(avoidHighwayTags);
allowedHighwayTags.add("cycleway");
allowedHighwayTags.add("secondary");
allowedHighwayTags.add("secondary_link");
allowedHighwayTags.add("unclassified");
allowedHighwayTags.add("road");
// disallowed in some countries
......@@ -147,8 +147,8 @@ public class FootFlagEncoder extends AbstractFlagEncoder
speedEncoder = new EncodedDoubleValue("Speed", shift, speedBits, speedFactor, MEAN_SPEED, maxPossibleSpeed);
shift += speedEncoder.getBits();
preferWayEncoder = new EncodedValue("PreferWay", shift, 3, 1, 0, 7);
shift += preferWayEncoder.getBits();
priorityWayEncoder = new EncodedValue("PreferWay", shift, 3, 1, 0, 7);
shift += priorityWayEncoder.getBits();
return shift;
}
......@@ -283,40 +283,37 @@ public class FootFlagEncoder extends AbstractFlagEncoder
if (!isAccept(allowed))
return 0;
long encoded;
long encoded = 0;
if (!isFerry(allowed))
{
String sacScale = way.getTag("sac_scale");
if (sacScale != null)
{
if ("hiking".equals(sacScale))
encoded = speedEncoder.setDoubleValue(0, MEAN_SPEED);
encoded = speedEncoder.setDoubleValue(encoded, MEAN_SPEED);
else
encoded = speedEncoder.setDoubleValue(0, SLOW_SPEED);
encoded = speedEncoder.setDoubleValue(encoded, SLOW_SPEED);
} else
{
encoded = speedEncoder.setDoubleValue(0, MEAN_SPEED);
encoded = speedEncoder.setDoubleValue(encoded, MEAN_SPEED);
}
encoded |= directionBitMask;
int priorityFromRelation = 0;
if (relationFlags != 0)
priorityFromRelation = (int) relationCodeEncoder.getValue(relationFlags);
encoded = setLong(encoded, PriorityWeighting.KEY, handlePriority(way, priorityFromRelation));
boolean isRoundabout = way.hasTag("junction", "roundabout");
if (isRoundabout)
{
encoded = setBool(encoded, K_ROUNDABOUT, true);
}
} else
{
encoded = handleFerryTags(way, SLOW_SPEED, MEAN_SPEED, FERRY_SPEED);
encoded = encoded | handleFerryTags(way, SLOW_SPEED, MEAN_SPEED, FERRY_SPEED);
encoded |= directionBitMask;
}
int priorityFromRelation = 0;
if (relationFlags != 0)
priorityFromRelation = (int) relationCodeEncoder.getValue(relationFlags);
encoded = priorityWayEncoder.setValue(encoded, handlePriority(way, priorityFromRelation));
return encoded;
}
......@@ -326,40 +323,12 @@ public class FootFlagEncoder extends AbstractFlagEncoder
switch (key)
{
case PriorityWeighting.KEY:
double prio = preferWayEncoder.getValue(flags);
if (prio == 0)
return (double) UNCHANGED.getValue() / BEST.getValue();
return prio / BEST.getValue();
return (double) priorityWayEncoder.getValue(flags) / BEST.getValue();
default:
return super.getDouble(flags, key);
}
}
@Override
public long getLong( long flags, int key )
{
switch (key)
{
case PriorityWeighting.KEY:
return preferWayEncoder.getValue(flags);
default:
return super.getLong(flags, key);
}
}
@Override
public long setLong( long flags, int key, long value )
{
switch (key)
{
case PriorityWeighting.KEY:
return preferWayEncoder.setValue(flags, value);
default:
return super.setLong(flags, key, value);
}
}
protected int handlePriority( OSMWay way, int priorityFromRelation )
{
TreeMap<Double, Integer> weightToPrioMap = new TreeMap<Double, Integer>();
......@@ -389,32 +358,22 @@ public class FootFlagEncoder extends AbstractFlagEncoder
{
weightToPrioMap.put(40d, PREFER.getValue());
if (way.hasTag("tunnel", intendedValues))
weightToPrioMap.put(40d, UNCHANGED.getValue());
}
if (way.hasTag("bicycle", "official") || way.hasTag("bicycle", "designated"))
{
weightToPrioMap.put(44d, AVOID_IF_POSSIBLE.getValue());
}
if (avoidHighwayTags.contains(highway) || maxSpeed > 50)
{
if (way.hasTag("sidewalk", sidewalks))
{
weightToPrioMap.put(45d, REACH_DEST.getValue());
}
else
{
weightToPrioMap.put(45d, AVOID_AT_ALL_COSTS.getValue());
if (way.hasTag("sidewalk", "no"))
weightToPrioMap.put(40d, REACH_DEST.getValue());
else
weightToPrioMap.put(40d, UNCHANGED.getValue());
}
}
else
} else if (maxSpeed > 50 || avoidHighwayTags.contains(highway))
{
if (way.hasTag("sidewalk", sidewalks))
{
weightToPrioMap.put(45d, PREFER.getValue());
}
if (way.hasTag("sidewalk", "no"))
weightToPrioMap.put(45d, WORST.getValue());
else
weightToPrioMap.put(45d, REACH_DEST.getValue());
}
if (way.hasTag("bicycle", "official") || way.hasTag("bicycle", "designated"))
weightToPrioMap.put(44d, AVOID_IF_POSSIBLE.getValue());
}
@Override
......
......@@ -33,7 +33,7 @@ import java.util.HashSet;
public class MotorcycleFlagEncoder extends CarFlagEncoder
{
private EncodedDoubleValue reverseSpeedEncoder;
private EncodedValue preferWayEncoder;