Search in sources :

Example 11 with CoordNode

use of uk.me.parabola.imgfmt.app.CoordNode in project mkgmap by openstreetmap.

the class RestrictionHelper method processAndAddRestrictions.

public void processAndAddRestrictions(RoadHelper roadHelper, MapDetails mapper) {
    Map<Long, CoordNode> allNodes = roadHelper.getNodeCoords();
    for (PolishTurnRestriction tr : allRestrictions) {
        GeneralRouteRestriction grr = new GeneralRouteRestriction("not", tr.getExceptMask(), Long.toString(tr.getNodId()));
        grr.setFromNode(allNodes.get(tr.getFromNodId()));
        grr.setFromWayId(tr.getRoadIdA());
        grr.setToNode(allNodes.get(tr.getToNodId()));
        if (tr.getViaNodId() != 0) {
            grr.setViaNodes(Arrays.asList(allNodes.get(tr.getNodId()), allNodes.get(tr.getViaNodId())));
            grr.setViaWayIds(Arrays.asList(tr.getRoadIdB()));
            grr.setToWayId(tr.getRoadIdC());
        } else {
            grr.setViaNodes(Arrays.asList(allNodes.get(tr.getNodId())));
            grr.setToWayId(tr.getRoadIdB());
        }
        // restriction should be part of the map
        mapper.addRestriction(grr);
    }
}
Also used : GeneralRouteRestriction(uk.me.parabola.imgfmt.app.net.GeneralRouteRestriction) CoordNode(uk.me.parabola.imgfmt.app.CoordNode)

Example 12 with CoordNode

use of uk.me.parabola.imgfmt.app.CoordNode in project mkgmap by openstreetmap.

the class RestrictionRelation method addRestriction.

public void addRestriction(MapCollector collector, IdentityHashMap<Coord, CoordNode> nodeIdMap) {
    if (!valid)
        return;
    List<CoordNode> viaNodes = new ArrayList<>();
    for (Coord v : viaPoints) {
        CoordNode vn = nodeIdMap.get(v);
        if (vn == null) {
            log.error(messagePrefix, "via node is not a routing node");
            return;
        }
        viaNodes.add(vn);
    }
    if (viaNodes.size() > 6) {
        log.warn(messagePrefix, "has more than 6 via nodes, this is not supported");
        return;
    }
    if (restriction == null) {
        log.error("internal error: can't add valid restriction relation", this.getId(), "type", restriction);
        return;
    }
    int addedRestrictions = 0;
    GeneralRouteRestriction grr;
    if (restriction.startsWith("no_")) {
        for (long fromWayId : fromWayIds) {
            for (long toWayId : toWayIds) {
                grr = new GeneralRouteRestriction("not", exceptMask, messagePrefix);
                grr.setFromWayId(fromWayId);
                grr.setToWayId(toWayId);
                grr.setViaNodes(viaNodes);
                grr.setViaWayIds(viaWayIds);
                grr.setDirIndicator(dirIndicator);
                addedRestrictions += collector.addRestriction(grr);
            }
        }
        if (log.isInfoEnabled())
            log.info(messagePrefix, restriction, "translated to", addedRestrictions, "img file restrictions");
    } else if (restriction.startsWith("only_")) {
        grr = new GeneralRouteRestriction("only", exceptMask, messagePrefix);
        grr.setFromWayId(fromWayIds.get(0));
        grr.setToWayId(toWayIds.get(0));
        grr.setViaNodes(viaNodes);
        grr.setViaWayIds(viaWayIds);
        grr.setDirIndicator(dirIndicator);
        int numAdded = collector.addRestriction(grr);
        if (numAdded > 0)
            log.info(messagePrefix, restriction, "added - allows routing to way", toWayIds.get(0));
    } else {
        log.error("mkgmap internal error: unknown restriction", restriction);
    }
}
Also used : Coord(uk.me.parabola.imgfmt.app.Coord) ArrayList(java.util.ArrayList) GeneralRouteRestriction(uk.me.parabola.imgfmt.app.net.GeneralRouteRestriction) CoordNode(uk.me.parabola.imgfmt.app.CoordNode)

Aggregations

CoordNode (uk.me.parabola.imgfmt.app.CoordNode)12 Coord (uk.me.parabola.imgfmt.app.Coord)10 ArrayList (java.util.ArrayList)6 GeneralRouteRestriction (uk.me.parabola.imgfmt.app.net.GeneralRouteRestriction)3 Way (uk.me.parabola.mkgmap.reader.osm.Way)3 HashMap (java.util.HashMap)2 IdentityHashMap (java.util.IdentityHashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 Map (java.util.Map)2 Entry (java.util.Map.Entry)2 MapExitPoint (uk.me.parabola.mkgmap.general.MapExitPoint)2 MapLine (uk.me.parabola.mkgmap.general.MapLine)2 MapPoint (uk.me.parabola.mkgmap.general.MapPoint)2 MapRoad (uk.me.parabola.mkgmap.general.MapRoad)2 Node (uk.me.parabola.mkgmap.reader.osm.Node)2 RestrictionRelation (uk.me.parabola.mkgmap.reader.osm.RestrictionRelation)2 MultiHashMap (uk.me.parabola.util.MultiHashMap)2 BitSet (java.util.BitSet)1 TreeMap (java.util.TreeMap)1