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);
}
}
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);
}
}
Aggregations