5

我正在尝试修改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;
}

如果有人可以请解释这样做的最佳方法,我将不胜感激。

4

0 回答 0