Hi Gerd

I've rearranged the direction flag setting logic a bit, taking bits
from ignore-oneway-for-line.patch

It ignores oneway except for roads and allows direction to be set false
even for routable oneways. I've tested routing when oneway=true,
hasDirection=false on eTrex HCx and gpsMapEdit and it respected the
oneway.

I couldn't find any references to the {style}/overlays file in any
documentation, but my reading of the code is that first substitution
element will get the full MapRoad info, including the hasDirection flag
and the MapLine copies will get also get the hasDirection flag.

Ticker

On Mon, 2021-05-17 at 11:29 +0100, Ticker Berkin wrote:
> Hi Gerd and others
> 
> I'm starting a dedicated thread as previous posts are split between
> various svn commits.
> 
> Looking at the current trunk code and ignore-oneway-for-lines.patch,
> there are bits I don't understand or didn't expect.
> 
> This is what I hope for:
> 
> --line-types-with-direction lists the lineTypes for which the initial
> state of the hasDirection flag is considered true. It should be
> independent of --allow-reverse-merge (see later). The purpose of this
> is to reduce the need to edit styles and clarity as to which
> lineTypes
> are displayed with direction. 
> 
> In the following, road means line with [road_class, road_speed], so
> includes ferries.
> 
> Style processing, having produced a line/road, sets hasDirection, in
> order of precedence:
> 1/ value of mkgmap:has-direction if tag exists
> 2/ true if oneway road
> 3/ true if in line-types-with-direction list
> 
> RoadMerger merges roads with same lineType, names, class, speed,
> oneway
> and hasDirection. It must not reverse oneway or hasDirection=true
> roads
> when doing this.
> 
> I don't think we need --allow-reverse-merge.
> 
> LineMergeFilter operates for level > 0. It merges any line/road with
> the same lineType, names, hasDirection. It must not reverse
> hasDirection=true.
> 
> Ticker
> 
> _______________________________________________
> mkgmap-dev mailing list
> mkgmap-dev@lists.mkgmap.org.uk
> https://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
Index: src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java
===================================================================
--- src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java	(revision 4720)
+++ src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java	(working copy)
@@ -234,16 +234,14 @@
 		// undocumented option - usually used for debugging only
 		mergeRoads = !props.getProperty("no-mergeroads", false);
 		allowReverseMerge = props.getProperty("allow-reverse-merge", false);
-		if (allowReverseMerge) {
-			final String typesOption = "line-types-with-direction";
-			String typeList = props.getProperty(typesOption, "");
-			if (typeList.isEmpty())
-				typeList = style.getOption(typesOption);
-			List<String> types = CommandArgs.stringToList(typeList, typesOption);
-			for (String type :types) {
-				if (!type.isEmpty()) {
-					lineTypesWithDirection.add(Integer.decode(type));
-				}
+		final String typesOption = "line-types-with-direction";
+		String typeList = props.getProperty(typesOption, "");
+		if (typeList.isEmpty())
+			typeList = style.getOption(typesOption);
+		List<String> types = CommandArgs.stringToList(typeList, typesOption);
+		for (String type :types) {
+			if (!type.isEmpty()) {
+				lineTypesWithDirection.add(Integer.decode(type));
 			}
 		}
 		routable = props.containsKey("route");
@@ -342,6 +340,7 @@
 			}
 			
 			boolean wasReversed = false;
+			boolean hasDirection = false;
 			String oneWay = way.getTag(TK_ONEWAY);
 			if (oneWay != null){
 				if("-1".equals(oneWay)) {
@@ -351,11 +350,13 @@
 					way.reverse();
 					wasReversed = true;
 					way.addTag(TK_ONEWAY, "yes");
+					hasDirection = true; // will get ignored if not road
 				}
 				if (way.tagIsLikeYes(TK_ONEWAY)) {
 					way.addTag(TK_ONEWAY, "yes");
 					if (foundType.isRoad() && hasSkipDeadEndCheckNode(way))
 						way.addTag("mkgmap:dead-end-check", "false");
+					hasDirection = true; // will get ignored if not road
 				} else { 
 					way.deleteTag(TK_ONEWAY);
 				}
@@ -363,13 +364,17 @@
 			ConvertedWay cw = new ConvertedWay(way, foundType);
 			cw.setReversed(wasReversed);
 
-			if (cw.isOneway() || way.tagIsLikeYes(TKM_HAS_DIRECTION)
-					|| lineTypesWithDirection.contains(foundType.getType()))
-				cw.setHasDirection(true);
-			if (way.tagIsLikeNo(TKM_HAS_DIRECTION)) 
-				cw.setHasDirection(false);
-			
-			if (cw.isRoad()){
+			if (way.tagIsLikeYes(TKM_HAS_DIRECTION))
+				hasDirection = true;
+			else if (way.tagIsLikeNo(TKM_HAS_DIRECTION))
+				hasDirection = false;
+			else if (lineTypesWithDirection.contains(foundType.getType()))
+				hasDirection = true;
+			else if (!cw.isRoad()) // ignore oneway setting
+				hasDirection = false;
+			cw.setHasDirection(hasDirection);
+
+			if (cw.isRoad()) {
 				if (way.getId() == lastRoadId) {
 					for (int i = roads.size() - 1; i >= 0; i--) {
 						ConvertedWay prevRoad = roads.get(i);
@@ -1275,8 +1280,7 @@
 			line.setType(replType);
 		line.setPoints(points);
 
-		if (cw.isOneway() || cw.hasDirection())
-			line.setDirection(true);
+		line.setDirection(cw.hasDirection());
 
 		clipper.clipLine(line, lineAdder);
 	}
@@ -1883,7 +1887,7 @@
 		if (cw.isOneway()) {
 			road.setOneway();
 		}
-		road.setDirection(cw.isOneway() || cw.hasDirection());
+		road.setDirection(cw.hasDirection());
 
 		road.setAccess(cw.getAccess());
 		
_______________________________________________
mkgmap-dev mailing list
mkgmap-dev@lists.mkgmap.org.uk
https://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Reply via email to