允许车辆通过私人道路OSM GraphHopper

时间:2015-09-23 13:20:06

标签: java openstreetmap graphhopper

我正在尝试修改CarFlagEncoder.java,以便GraphHopper将使用默认情况下没有的两条道路:

http://www.openstreetmap.org/way/181263007
http://www.openstreetmap.org/way/37720333

我是否正确地说允许访问此道路就像从restrictedValues.add("private")方法中删除public CarFlagEncoder( int speedBits, double speedFactor, int maxTurnCosts )一样简单?

public CarFlagEncoder( int speedBits, double speedFactor, int maxTurnCosts )
{
    super(speedBits, speedFactor, maxTurnCosts);
    restrictions.addAll(Arrays.asList("motorcar", "motor_vehicle", "vehicle", "access"));
    restrictedValues.add("private");
    restrictedValues.add("agricultural");
    restrictedValues.add("forestry");
    restrictedValues.add("no");
    restrictedValues.add("restricted");
    restrictedValues.add("delivery");
    restrictedValues.add("military");

它要么在acceptWay方法中,要么需要修改:

@Override
public long acceptWay( OSMWay way )
{
    String highwayValue = way.getTag("highway");
    if (highwayValue == null)
    {
        if (way.hasTag("route", ferries))
        {
            String motorcarTag = way.getTag("motorcar");
            if (motorcarTag == null)
                motorcarTag = way.getTag("motor_vehicle");

            if (motorcarTag == null && !way.hasTag("foot") && !way.hasTag("bicycle") || "yes".equals(motorcarTag))
                return acceptBit | ferryBit;
        }
        return 0;
    }

    if ("track".equals(highwayValue))
    {
        String tt = way.getTag("tracktype");
        if (tt != null && !tt.equals("grade1") && !tt.equals("grade2") && !tt.equals("grade3"))
            return 0;
    }

    if (!defaultSpeedMap.containsKey(highwayValue))
        return 0;

    if (way.hasTag("impassable", "yes") || way.hasTag("status", "impassable"))
        return 0;

    // multiple restrictions needs special handling compared to foot and bike, see also motorcycle
    String firstValue = way.getFirstPriorityTag(restrictions);
    if (!firstValue.isEmpty())
    {
        if (restrictedValues.contains(firstValue))
            return 0;
        if (intendedValues.contains(firstValue))
            return acceptBit;
    }

    // do not drive street cars into fords
    if (isBlockFords() && ("ford".equals(highwayValue) || way.hasTag("ford")))
        return 0;

    // do not drive cars over railways (sometimes incorrectly mapped!)
    if (way.hasTag("railway") && !way.hasTag("railway", acceptedRailways))
        return 0;

    return acceptBit;
}

如果有人能够解释最好的方法,我会非常感激。

0 个答案:

没有答案