[mkgmap] 01/05: Imported Upstream version 0.0.0+svn3668

Sebastiaan Couwenberg sebastic at moszumanska.debian.org
Tue Mar 1 05:52:46 UTC 2016


This is an automated email from the git hooks/post-receive script.

sebastic pushed a commit to branch master
in repository mkgmap.

commit 35c6dd4f656a792e5bc80b08c9c8ab646202c3d8
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Tue Mar 1 06:36:11 2016 +0100

    Imported Upstream version 0.0.0+svn3668
---
 doc/options.txt                                    | 19 ++++--
 resources/help/en/options                          | 22 +++---
 resources/mkgmap-version.properties                |  4 +-
 resources/styles/default/inc/access                | 22 +++---
 resources/styles/default/lines                     | 38 +++++------
 .../me/parabola/imgfmt/app/net/NumberPreparer.java | 79 +++++++++++-----------
 src/uk/me/parabola/imgfmt/app/net/RouteNode.java   |  1 -
 .../parabola/mkgmap/osmstyle/RuleFileReader.java   |  2 +
 .../parabola/mkgmap/osmstyle/StyledConverter.java  |  4 ++
 .../mkgmap/reader/osm/LinkDestinationHook.java     | 59 +++++++++++-----
 .../parabola/mkgmap/reader/osm/SeaGenerator.java   | 15 ++--
 .../mkgmap/reader/osm/boundary/BoundaryMerger.java | 12 ++--
 .../mkgmap/reader/osm/boundary/BoundaryUtil.java   |  7 +-
 .../mkgmap/osmstyle/RuleFileReaderTest.java        | 45 ++++++++++++
 14 files changed, 207 insertions(+), 122 deletions(-)

diff --git a/doc/options.txt b/doc/options.txt
index 8d9c511..2a5eea9 100644
--- a/doc/options.txt
+++ b/doc/options.txt
@@ -1,6 +1,5 @@
-= List of options =
-Note that option order is significant:  An option only applies to
-subsequent input files.  (So if you are using splitter, you probably
+= List of options = Note that option order is significant: An option only 
+applies to subsequent input files. (So if you are using splitter, you probably 
 want to put most of your options before '-c template.args'.)
 
 === General options ===
@@ -632,9 +631,14 @@ to the next junction or a length of ~25 m. The tags
 are ignored for pedestrian-only ways.      
 <p>
 ;--process-destination
-: 	Splits all motorway_link, trunk_link, and primary_link 
-ways tagged with destination into two or three parts where 
-the second part is additionally tagged with mkgmap:dest_hint=true. 
+: 	Splits all motorway_link, trunk_link, primary_link, secondary_link,
+and tertiary_link ways tagged with destination into two or three parts where 
+the second part is additionally tagged with mkgmap:dest_hint=true.
+The code checks for the tags destination, destination:lanes, 
+destination:street and some variants with :forward/:backward like
+destination:forward or destination:lanes:backward. If a value for
+destination is found, the tag destination is set to it and the way is split.
+This happens before the style rules are processed.
 This allows to use any routable Garmin type (except 0x08 and 0x09)
 for that part so that the Garmin device tells the name of
 this part as hint which destination to follow.
@@ -643,7 +647,8 @@ See also --process-exits.
 ;--process-exits
 :     Usual Garmin devices do not tell the name of the exit on motorways 
 while routing with mkgmap created maps. This option splits each
-motorway_link, trunk_link and primary_link way into three parts. 
+motorway_link, trunk_link, primary_link, secondary_link, and 
+tertiary_link way into three parts. 
 All parts are tagged with the original tags of the link. 
 Additionally the middle part is tagged with the following tags:
 <pre>
diff --git a/resources/help/en/options b/resources/help/en/options
index b4f6932..f3ad0cc 100644
--- a/resources/help/en/options
+++ b/resources/help/en/options
@@ -628,20 +628,26 @@ Miscellaneous options:
     are ignored for pedestrian-only ways.      
 
 --process-destination
-	Splits all motorway_link, trunk_link, and primary_link 
-	ways tagged with destination into two or three parts where 
-	the second part is additionally tagged with mkgmap:dest_hint=true. 
+	Splits all motorway_link, trunk_link, primary_link, secondary_link,
+	and tertiary_link ways tagged with destination into two or three parts where 
+	the second part is additionally tagged with mkgmap:dest_hint=true.
+	The code checks for the tags destination, destination:lanes, 
+	destination:street and some variants with :forward/:backward like
+	destination:forward or destination:lanes:backward. If a value for
+	destination is found, the tag destination is set to it and the way is split.
+	This happens before the style rules are processed.
 	This allows to use any routable Garmin type (except 0x08 and 0x09)
 	for that part so that the Garmin device tells the name of
-	this part as hint which destination to follow.
+	this part as hint which destination to follow.     
 	See also --process-exits.
 	
 --process-exits
     Usual Garmin devices do not tell the name of the exit on motorways 
     while routing with mkgmap created maps. This option splits each
-    motorway_link, trunk_link and primary_link way into three parts. 
-	All parts are tagged with the original tags of the link. 
-	Additionally the middle part is tagged with the following tags:
+    motorway_link, trunk_link, primary_link, secondary_link, and tertiary_link 
+		way into three parts. 
+		All parts are tagged with the original tags of the link. 
+		Additionally the middle part is tagged with the following tags:
       mkgmap:exit_hint=true
       mkgmap:exit_hint_ref=<ref tag value of the exit>
       mkgmap:exit_hint_name=<name tag value of the exit>
@@ -649,7 +655,7 @@ Miscellaneous options:
     Adding a rule checking the mkgmap:exit_hint=true makes it possible
     to use any routable Garmin type (except 0x08 and 0x09) for the middle 
     part so that the Garmin device tells the name of this middle part as 
-    hint where to leave the motorway/trunk.
+    hint where to leave the major road.
 	The first part must have type 0x08 or 0x09 so that Garmin uses the hint. 
 	
 --delete-tags-file=FILENAME
diff --git a/resources/mkgmap-version.properties b/resources/mkgmap-version.properties
index a2aba20..ec20f2c 100644
--- a/resources/mkgmap-version.properties
+++ b/resources/mkgmap-version.properties
@@ -1,2 +1,2 @@
-svn.version: 3660
-build.timestamp: 2016-01-24T08:14:44+0000
+svn.version: 3668
+build.timestamp: 2016-02-19T07:22:00+0000
diff --git a/resources/styles/default/inc/access b/resources/styles/default/inc/access
index d0fd1fa..d6edbad 100644
--- a/resources/styles/default/inc/access
+++ b/resources/styles/default/inc/access
@@ -19,7 +19,7 @@
 highway=* & motorroad=yes                  { add bicycle=no; add foot=no; }
 highway=motorway | highway=motorway_link   { add bicycle=no; add foot=no; }
 
-access=agricultural  { set access=no; add foot=yes }
+(access=agricultural | access=forestry) { set access=no; add foot=yes }
 
 # Now fill the access tree (http://wiki.openstreetmap.org/wiki/Key:access) 
 # This is required so that subsequent rules do not add a tag (bicycle) which is already defined by a higher tag (vehicle) 
@@ -43,18 +43,18 @@ railway=platform                           { add foot=yes; add access=no }
 
 # throughroute cannot be handled differently for different vehicle types
 # Therefore we have to choose one vehicle type - and the winner is: motorcar
-motorcar=destination   { set mkgmap:throughroute=no; set motorcar=yes } 
-access=destination     { set mkgmap:throughroute=no; set access=yes }
+motorcar=destination  | motorcar=delivery { set mkgmap:throughroute=no; set motorcar=yes } 
+access=destination    | access=delivery   { set mkgmap:throughroute=no; set access=yes }
 
 # Normalize all values that indicate a restriction to 'no'
-foot=private          | foot=agricultural          { set foot=no }
-bicycle=private       | bicycle=agricultural       { set bicycle=no }
-motorcar=private      | motorcar=agricultural      { set motorcar=no }
-goods=private         | goods=agricultural         { set goods=no }
-hgv=private           | hgv=agricultural           { set hgv=no }
-bus=private           | bus=agricultural           { set bus=no }
-taxi=private          | taxi=agricultural          { set taxi=no }
-emergency=private     | emergency=agricultural     { set emergency=no }
+foot=private          | foot=agricultural       | foot=forestry       { set foot=no }
+bicycle=private       | bicycle=agricultural    | bicycle=forestry    { set bicycle=no }
+motorcar=private      | motorcar=agricultural   | motorcar=forestry   { set motorcar=no }
+goods=private         | goods=agricultural      | goods=forestry      { set goods=no }
+hgv=private           | hgv=agricultural        | hgv=forestry        { set hgv=no }
+bus=private           | bus=agricultural        | bus=forestry        { set bus=no }
+taxi=private          | taxi=agricultural       | taxi=forestry       { set taxi=no }
+emergency=private     | emergency=agricultural  | emergency=forestry  { set emergency=no }
 
 # Copy the OSM access tags to the mkgmap internal tags
 foot=*       { set mkgmap:foot='${foot}' }
diff --git a/resources/styles/default/lines b/resources/styles/default/lines
index 9223f9f..c1bf020 100644
--- a/resources/styles/default/lines
+++ b/resources/styles/default/lines
@@ -46,31 +46,31 @@ highway=motorway|highway=motorway_link { add oneway=yes; add mkgmap:numbers=fals
 # Set highway names to include the reference if there is one
 highway=motorway { name '${ref|highway-symbol:hbox} ${name}' | '${ref|highway-symbol:hbox}' | '${name}' }
 
-(highway=motorway_link | highway=trunk_link | highway=primary_link) & mkgmap:exit_hint=true & mkgmap:dest_hint=true
-  { name '${destination:ref|subst: =>} ${destination|subst:;=> |subst:/=> }' | 
+# start of rules for process-exits and process-destination options
+# which may add info to a part of these highway=*_link roads:
+# motorway_link, trunk_link, primary_link, secondary_link, tertiary_link
+# build destination hint 
+dest_hint=* { delete dest_hint }
+mkgmap:dest_hint=true
+  { set dest_hint = '${destination:ref|subst: =>} ${destination|subst:;=> |subst:/=> }' |
          '${ref|subst: =>} ${destination|subst:;=> |subst:/=> }' | 
-         '${destination|subst:;=> |subst:/=> }' |
-         'Exit ${mkgmap:exit_hint_ref} ${mkgmap:exit_hint_name}' | 
-         'Exit ${mkgmap:exit_hint_ref} ${mkgmap:exit_hint_exit_to}' | 
-         'Exit ${mkgmap:exit_hint_exit_to}' |
-         'Exit ${mkgmap:exit_hint_name}' |
-         'Exit ${mkgmap:exit_hint_ref}'
+         '${destination|subst:;=> |subst:/=> }';
        }
-
-(highway=motorway_link | highway=trunk_link | highway=primary_link) & mkgmap:exit_hint!=* & mkgmap:dest_hint=true
-  { name '${destination:ref|subst: =>} ${destination|subst:;=> |subst:/=> }' |
-         '${ref|subst: =>} ${destination|subst:;=> |subst:/=> }' | 
-         '${destination|subst:;=> |subst:/=> }'
-       }
-
-(highway=motorway_link | highway=trunk_link | highway=primary_link) & mkgmap:exit_hint=true & mkgmap:dest_hint!=*
-  { name 'Exit ${mkgmap:exit_hint_ref} ${mkgmap:exit_hint_name}' | 
+# build exit hint 
+exit_hint=* { delete exit_hint }
+mkgmap:exit_hint=true 
+  { set exit_hint = 'Exit ${mkgmap:exit_hint_ref} ${mkgmap:exit_hint_name}' | 
          'Exit ${mkgmap:exit_hint_ref} ${mkgmap:exit_hint_exit_to}' | 
          'Exit ${mkgmap:exit_hint_exit_to}' |
          'Exit ${mkgmap:exit_hint_name}' |
-         'Exit ${mkgmap:exit_hint_ref}'
+         'Exit ${mkgmap:exit_hint_ref}';
        }
-              
+  
+# use destination hint and/or exit hint to build name              
+(mkgmap:exit_hint=true | mkgmap:dest_hint=true)
+  {	name '${exit_hint} ${dest_hint}' | 	'${dest_hint}' | 		'${exit_hint}' }
+# end of rules for process-exits and process-destination options	
+  
 highway=trunk {name '${ref|highway-symbol:hbox} ${name}' | '${ref|highway-symbol:hbox}' | '${name}'; addlabel '${name} (${ref})' }
 highway=primary {name '${ref|highway-symbol:box} ${name}' | '${ref|highway-symbol:box}' | '${name}'; addlabel '${name} (${ref})' }
 highway=secondary | highway=tertiary {name '${ref|highway-symbol:oval} ${name}' | '${ref|highway-symbol:oval}' | '${name}'; addlabel '${name} (${ref})' }
diff --git a/src/uk/me/parabola/imgfmt/app/net/NumberPreparer.java b/src/uk/me/parabola/imgfmt/app/net/NumberPreparer.java
index a23fc77..4b48d47 100644
--- a/src/uk/me/parabola/imgfmt/app/net/NumberPreparer.java
+++ b/src/uk/me/parabola/imgfmt/app/net/NumberPreparer.java
@@ -886,7 +886,7 @@ class CityZipWriter {
 	private final String type;
 	private final int numItems;
 	private final int defaultIndex;
-	
+	int []lastEncodedIndexes = {-1, -1};
 	
 	public CityZipWriter(String type, int defIndex, int numItems) {
 		this.type = type;
@@ -898,67 +898,69 @@ class CityZipWriter {
 	public ByteArrayOutputStream getBuffer(){
 		return buf;
 	}
+
 	public boolean compile(List<Numbers> numbers){
 		try {
-			int lastNodeIndex = -1;
 			// left and right entry in zip or city table
-			int []prevIndexes = new int[2]; 
-			prevIndexes[0] = prevIndexes[1] = -1;
-			int []indexes = new int[2]; 
+			int []indexes = {defaultIndex, defaultIndex}; // current num 
+			int []refIndexes = {defaultIndex, defaultIndex}; // previous num 
+			int lastEncodedNodeIndex = -1;
+			boolean needsWrite = false;
 			for (Numbers num : numbers){
-				for (int i = 0; i < 2; i++){
-					indexes[i] = -1;
-					boolean left = (i == 0);
+				for (int side = 0; side < 2; side++){
+					indexes[side] = defaultIndex;
+					boolean left = (side == 0);
 					switch (type) {
 					case "zip":
 						ZipCodeInfo zipInfo = num.getZipCodeInfo(left);
 						if (zipInfo != null){
-							if (zipInfo.getImgZip() != null)
-								indexes[i] = zipInfo.getImgZip().getIndex();
-							else 
-								indexes[i] = 0; // or default?
+							if (zipInfo.getImgZip() != null){
+								indexes[side] = zipInfo.getImgZip().getIndex();
+							}
 						}
 						break;
 					case "city": 
 						CityInfo cityInfo = num.getCityInfo(left);
 						if (cityInfo != null){
-							if (cityInfo.getImgCity() != null)
-								indexes[i] = cityInfo.getImgCity().getIndex();
-							else 
-								indexes[i] = 0; // or default?
+							if (cityInfo.getImgCity() != null){
+								indexes[side] = cityInfo.getImgCity().getIndex();
+							}
 						}
 						break;
 					default:
 						break;
 					}
 				}
-				if (indexes[0] < 0 && indexes[1] < 0)
+				if (indexes[0] == refIndexes[0] && indexes[1] == refIndexes[1])
 					continue;
-				if (lastNodeIndex < 0){
-					if (num.getIndex() > 0 ){ 
-						int [] defindexes = {defaultIndex,defaultIndex};
-						write(0, defindexes, prevIndexes);
-					}
+				needsWrite = true;
+				if (num.getIndex() > 0){
+					int range = num.getIndex() - 1;
+					if (lastEncodedNodeIndex > 0)
+						range -= lastEncodedNodeIndex;
+					encode(range, refIndexes);
 				}
-				int skip = num.getIndex() - lastNodeIndex - 1;
-				assert defaultIndex > 0 : "bad default index";
-				lastNodeIndex = num.getIndex();
-				if (indexes[0] < 0)
-					indexes[0] = defaultIndex;
-				if (indexes[1] < 0)
-					indexes[1] = defaultIndex;
-				write(skip, indexes, prevIndexes);
+				refIndexes[0] = indexes[0];
+				refIndexes[1] = indexes[1];
+				lastEncodedNodeIndex = num.getIndex(); 
+			}
+			if (needsWrite){
+				int lastIndexWithNumbers = numbers.get(numbers.size()-1).getIndex();
+				int range = lastIndexWithNumbers - lastEncodedNodeIndex;
+				encode(range, indexes);
+			}
+			else {
+				buf.reset(); // probably not needed
 			}
 		} catch (Abandon e) {
 			return false;
 		}
 		return true;
 	}
-
-	private void write(int skip, int[] indexes, int[] prevIndexes) {
-		if (Arrays.equals(indexes, prevIndexes))
-			return;
+	
+	private void encode(int skip, int[] indexes) {
 		// we can signal new values for left and / or right side 
+		
 		int sidesFlag = 0;  
 		if (indexes[0] <= 0 && indexes[1] <= 0){
 			sidesFlag |= 4; // signal end of a zip code/city interval
@@ -968,14 +970,14 @@ class CityZipWriter {
 				sidesFlag |= 2;
 		} else {
 			if (indexes[1] != indexes[0]){
-				if (indexes[0] > 0 && indexes[0] != prevIndexes[0])
+				if (indexes[0] > 0 && indexes[0] != lastEncodedIndexes[0])
 					sidesFlag |= 1;
-				if (indexes[1] > 0 && indexes[1] != prevIndexes[1])
+				if (indexes[1] > 0 && indexes[1] != lastEncodedIndexes[1])
 					sidesFlag |= 2;
 			}
 		}
 
-		int initFlag = Math.max(skip-1,0);
+		int initFlag = skip;
 		if (initFlag > 31){
 			// we have to write two bytes
 			buf.write((byte) (initFlag & 0x1f | 0x7<<5));
@@ -989,7 +991,8 @@ class CityZipWriter {
 			if (indexes[1] > 0 && (sidesFlag & 2) != 0)
 				writeIndex(indexes[1]);
 		}
-		System.arraycopy(indexes, 0, prevIndexes, 0, indexes.length);
+		lastEncodedIndexes[0] = indexes[0];
+		lastEncodedIndexes[1] = indexes[1];
 	}
 	
 	void writeIndex(int val){
diff --git a/src/uk/me/parabola/imgfmt/app/net/RouteNode.java b/src/uk/me/parabola/imgfmt/app/net/RouteNode.java
index ae8b7f9..b4bbb43 100644
--- a/src/uk/me/parabola/imgfmt/app/net/RouteNode.java
+++ b/src/uk/me/parabola/imgfmt/app/net/RouteNode.java
@@ -559,7 +559,6 @@ public class RouteNode implements Comparable<RouteNode> {
 				if(arci.getDest() == arcj.getDest() &&
 				   arci.getLength() == arcj.getLength() &&
 				   arci.getPointsHash() == arcj.getPointsHash()) {
-					log.error(arci.isForward(),arcj.isForward());
 					log.warn("Similar arcs (" + arci.getRoadDef() + " and " + arcj.getRoadDef() + ") from " + coord.toOSMURL());
 				}
 			}
diff --git a/src/uk/me/parabola/mkgmap/osmstyle/RuleFileReader.java b/src/uk/me/parabola/mkgmap/osmstyle/RuleFileReader.java
index ff6b4f9..b55e5fa 100644
--- a/src/uk/me/parabola/mkgmap/osmstyle/RuleFileReader.java
+++ b/src/uk/me/parabola/mkgmap/osmstyle/RuleFileReader.java
@@ -397,6 +397,8 @@ public class RuleFileReader {
 	 * is indexable or it is indexable itself.
 	 */
 	private static boolean isSolved(Op op) {
+		if (op.isType(NOT))
+			return false;
 		return isIndexable(op) || isIndexable(op.getFirst());
 	}
 
diff --git a/src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java b/src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java
index 2a827ca..5dc6287 100644
--- a/src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java
+++ b/src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java
@@ -1475,6 +1475,10 @@ public class StyledConverter implements OsmConverter {
 		GType gt = cw.getGType();
 		List<Integer> nodeIndices = new ArrayList<>();
 		List<Coord> points = way.getPoints();
+		if (points.size() < 2){
+			log.warn("road has < 2 points",way.getId(),"(discarding)");
+			return;
+		}
 		Way trailingWay = null;
 		String debugWayName = way.getDebugName();
 
diff --git a/src/uk/me/parabola/mkgmap/reader/osm/LinkDestinationHook.java b/src/uk/me/parabola/mkgmap/reader/osm/LinkDestinationHook.java
index 4c714fa..9903ccd 100644
--- a/src/uk/me/parabola/mkgmap/reader/osm/LinkDestinationHook.java
+++ b/src/uk/me/parabola/mkgmap/reader/osm/LinkDestinationHook.java
@@ -53,9 +53,10 @@ public class LinkDestinationHook extends OsmReadingHooksAdaptor {
 	private Map<Long, Way> destinationLinkWays = new HashMap<Long, Way>();
 	
 	private final static Set<String> highwayTypes = new LinkedHashSet<String>(Arrays.asList(
-			"motorway", "trunk", "primary", "motorway_link", "trunk_link", "primary_link"));
+			"motorway", "trunk", "primary", "secondary", "tertiary", 
+			"motorway_link", "trunk_link", "primary_link", "secondary_link", "tertiary_link"));
 	private HashSet<String> linkTypes = new HashSet<String>(Arrays.asList(
-			"motorway_link", "trunk_link", "primary_link"));
+			"motorway_link", "trunk_link", "primary_link", "secondary_link", "tertiary_link"));
 	
 
 	/** Map way ids to its restriction relations so that the relations can easily be updated when the way is split. */
@@ -92,17 +93,24 @@ public class LinkDestinationHook extends OsmReadingHooksAdaptor {
 				// the points of the way are kept so that it is easy to get
 				// the adjacent ways for a given _link way
 				String directedDestination = null;
+				String directedDestinationLanes = null;
+				String directionSuffix = null;
 				List<Coord> points;
+				
 				if (isOnewayInDirection(w)) {
 					// oneway => don't need the last point because the
 					// way cannot be driven standing at the last point
 					points = w.getPoints().subList(0, w.getPoints().size() - 1);
 					directedDestination = w.getTag("destination:forward");
+					directedDestinationLanes = w.getTag("destination:lanes:forward");
+					directionSuffix = "forward";
 				} else if (isOnewayOppositeDirection(w)) {
 					// reverse oneway => don't need the first point because the
 					// way cannot be driven standing at the first point
 					points = w.getPoints().subList(1, w.getPoints().size());
 					directedDestination = w.getTag("destination:backward");
+					directedDestinationLanes = w.getTag("destination:lanes:backward");
+					directionSuffix = "backward";
 				} else {
 					points = w.getPoints();
 				}
@@ -119,30 +127,46 @@ public class LinkDestinationHook extends OsmReadingHooksAdaptor {
 				// if the way is a link way and has a destination tag
 				// put it the list of ways that have to be processed
 				if (linkTypes.contains(highwayTag)) {
+					String destSourceTagKey = "destination"; 
 					String destinationTag = w.getTag("destination");
-					
 					if (destinationTag == null) {
 						// destination is not set 
-						// => check if destination:lanes is without any lane specific information (no |) 
-						String destLanesTag = w.getTag("destination:lanes");
+						// => check if destination:lanes is without any lane specific information (no |)
+						destSourceTagKey = "destination:lanes";
+						String destLanesTag = w.getTag(destSourceTagKey);
+						if (destLanesTag == null && directedDestinationLanes != null){
+							destLanesTag = directedDestinationLanes;
+							destSourceTagKey += ":" + directionSuffix;
+						}
 						if (destLanesTag != null && destLanesTag.contains("|") == false) {
 							// the destination:lanes tag contains no | => no lane specific information
 							// use this tag as destination tag 
-							w.addTag("destination", destLanesTag);
 							destinationTag = destLanesTag;
-							if (log.isDebugEnabled())
-								log.debug("Use destination:lanes tag as destination tag because there is one lane information only. Way ",w.getId(),w.toTagString());
 						}
+						if (destinationTag == null){
+							// try to use the destination:street value
+							destSourceTagKey = "destination:street";
+							destinationTag = w.getTag(destSourceTagKey);
+						}
+						if (destinationTag == null && directedDestination != null) {
+							// use the destination:forward or :backward value
+							destinationTag = directedDestination;
+							destSourceTagKey = "destination:" + directionSuffix; 
+						}
+						if (destinationTag != null && "destination".equals(destSourceTagKey) == false){
+							w.addTag("destination", destinationTag);
+							if (log.isDebugEnabled()){
+								if (destSourceTagKey.startsWith("destination:lanes"))
+									log.debug("Use",destSourceTagKey,"as destination tag because there is one lane information only. Way ",w.getId(),w.toTagString());
+								else 
+									log.debug("Use",destSourceTagKey,"as destination tag. Way ",w.getId(),w.toTagString());
+							}
+						}
+						
 					}
-					
-					if (destinationTag == null && directedDestination != null) {
-						// use the destination:forward or :backward value
-						destinationTag = directedDestination;
-						w.addTag("destination", destinationTag);
-					}
-					
-					if (destinationTag != null)
+					if (destinationTag != null){
 						destinationLinkWays.put(w.getId(), w);
+					}
 				}
 			}
 		}
@@ -735,8 +759,11 @@ public class LinkDestinationHook extends OsmReadingHooksAdaptor {
 		Set<String> tags = new HashSet<String>();
 		tags.add("highway");
 		tags.add("destination:lanes");
+		tags.add("destination:lanes:forward");
+		tags.add("destination:lanes:backward");
 		tags.add("destination:forward");
 		tags.add("destination:backward");
+		tags.add("destination:street");
 		if (processExits){
 			tags.add("exit_to");
 			tags.add("ref");
diff --git a/src/uk/me/parabola/mkgmap/reader/osm/SeaGenerator.java b/src/uk/me/parabola/mkgmap/reader/osm/SeaGenerator.java
index c411d8c..fcbf952 100644
--- a/src/uk/me/parabola/mkgmap/reader/osm/SeaGenerator.java
+++ b/src/uk/me/parabola/mkgmap/reader/osm/SeaGenerator.java
@@ -38,6 +38,7 @@ import java.util.zip.GZIPInputStream;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipFile;
 
+import uk.me.parabola.imgfmt.ExitException;
 import uk.me.parabola.imgfmt.FormatException;
 import uk.me.parabola.imgfmt.MapFailedException;
 import uk.me.parabola.imgfmt.Utils;
@@ -181,13 +182,7 @@ public class SeaGenerator extends OsmReadingHooksAdaptor {
 							if (indexFileName.endsWith(".gz")) {
 								indexStream = new GZIPInputStream(indexStream);
 							}
-							try{
-								precompData = loadIndex(indexStream);
-							} catch (IOException exp) {
-								log.error("Cannot read index file " + indexFileName,
-										exp);
-							}
-							
+							precompData = loadIndex(indexStream);
 							if (precompData != null){
 								if (zipFile != null){
 									precompData.precompZipFileInternalPath = internalPath;
@@ -198,9 +193,9 @@ public class SeaGenerator extends OsmReadingHooksAdaptor {
 							indexStream.close();
 						}
 					} catch (IOException exp) {
-						log.error("Cannot read index file " + indexFileName,
-								exp);
-
+						log.error("Cannot read index file", indexFileName, "in", precompSea, exp);
+//						exp.printStackTrace();
+						throw new ExitException("Failed to read required index file in " + precompSeaDir); 
 					}
 					precompIndex.set(precompData);
 				}
diff --git a/src/uk/me/parabola/mkgmap/reader/osm/boundary/BoundaryMerger.java b/src/uk/me/parabola/mkgmap/reader/osm/boundary/BoundaryMerger.java
index 371e4f5..75616f6 100644
--- a/src/uk/me/parabola/mkgmap/reader/osm/boundary/BoundaryMerger.java
+++ b/src/uk/me/parabola/mkgmap/reader/osm/boundary/BoundaryMerger.java
@@ -40,13 +40,11 @@ public class BoundaryMerger {
 	
 	private void copy(File file, File to) {
 		String filename = file.getName();
-		
-		try {
-	      FileChannel in = (new FileInputStream(file)).getChannel();
-	      FileChannel out = (new FileOutputStream(new File(to,filename))).getChannel();
-	      in.transferTo(0, file.length(), out);
-	      in.close();
-	      out.close();
+		try (FileChannel in = (new FileInputStream(file)).getChannel();
+				FileChannel out = (new FileOutputStream(new File(to, filename))).getChannel()) {
+			in.transferTo(0, file.length(), out);
+			in.close();
+			out.close();
 		} catch (IOException exp) {
 			System.err.println(exp);
 		}
diff --git a/src/uk/me/parabola/mkgmap/reader/osm/boundary/BoundaryUtil.java b/src/uk/me/parabola/mkgmap/reader/osm/boundary/BoundaryUtil.java
index 43da6ed..9cd4c10 100644
--- a/src/uk/me/parabola/mkgmap/reader/osm/boundary/BoundaryUtil.java
+++ b/src/uk/me/parabola/mkgmap/reader/osm/boundary/BoundaryUtil.java
@@ -40,6 +40,7 @@ import java.util.regex.Pattern;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipFile;
 
+import uk.me.parabola.imgfmt.ExitException;
 import uk.me.parabola.imgfmt.FormatException;
 import uk.me.parabola.imgfmt.app.Coord;
 import uk.me.parabola.log.Logger;
@@ -381,9 +382,9 @@ public class BoundaryUtil {
 						log.error("boundary zip file contains directories. Files in directories will be ignored." + dirName);			
 					}
 				} catch (IOException ioe) {
-					System.err.println("Unhandled exception:");
-					ioe.printStackTrace();
-				}
+					log.error("Cannot read",dirName,ioe);
+//					ioe.printStackTrace();
+					throw new ExitException("Failed to read required file " + dirName);				}
 			}
 		}
 		return names;
diff --git a/test/uk/me/parabola/mkgmap/osmstyle/RuleFileReaderTest.java b/test/uk/me/parabola/mkgmap/osmstyle/RuleFileReaderTest.java
index 99ef40c..183115e 100644
--- a/test/uk/me/parabola/mkgmap/osmstyle/RuleFileReaderTest.java
+++ b/test/uk/me/parabola/mkgmap/osmstyle/RuleFileReaderTest.java
@@ -56,10 +56,12 @@ public class RuleFileReaderTest {
 		el.addTag("highway", "footway");
 
 		GType type = getFirstType(rs, el);
+		assertNotNull(type);
 		assertEquals("plain footway", "[0x3 level 0]", type.toString());
 
 		el.addTag("type", "rough");
 		type = getFirstType(rs, el);
+		assertNotNull(type);
 		assertEquals("rough footway", "[0x2 level 2]", type.toString());
 	}
 
@@ -77,6 +79,7 @@ public class RuleFileReaderTest {
 		el.addTag("highway", "primary");
 
 		GType type = getFirstType(rs, el);
+		assertNotNull(type);
 		assertEquals("min level", 1, type.getMinLevel());
 		assertEquals("max level", 3, type.getMaxLevel());
 	}
@@ -95,6 +98,7 @@ public class RuleFileReaderTest {
 		el.addTag("x", "11");
 
 		GType type = getFirstType(rs, el);
+		assertNotNull(type);
 		assertEquals("expression ok", 1, type.getType());
 
 		// fails with x less than 10
@@ -111,6 +115,7 @@ public class RuleFileReaderTest {
 		el.addTag("x", "100");
 		el.addTag("e", "f");
 		type = getFirstType(rs, el);
+		assertNotNull(type);
 		assertEquals("c and e set", 1, type.getType());
 
 		el.addTag("c", "");
@@ -120,6 +125,7 @@ public class RuleFileReaderTest {
 
 		el.addTag("e", "f");
 		type = getFirstType(rs, el);
+		assertNotNull(type);
 		assertEquals("e is set to f", 1, type.getType());
 	}
 
@@ -146,25 +152,31 @@ public class RuleFileReaderTest {
 		el.addTag("layer", "-1");
 
 		GType type = getFirstType(rs, el);
+		assertNotNull(type);
 		assertEquals("9902 layer = -1", 0x1, type.getType());
 
 		// 9912
 		el.addTag("layer", "0");
 		type = getFirstType(rs, el);
+		assertNotNull(type);
 		assertEquals("9912 layer = 0", 0x2, type.getType());
 
 		// 9922
 		el.deleteTag("layer");
 		type = getFirstType(rs, el);
+		assertNotNull(type);
 		assertEquals("9922 no layer tag", 0x8, type.getType());
 
 		// 9932
 		el.addTag("layer", "1");
 		type = getFirstType(rs, el);
+		assertNotNull(type);
 		assertEquals("9932 layer is 1", 0x3, type.getType());
 
 		// 9952
 		el.addTag("layer", "+1");
+		type = getFirstType(rs, el);
+		assertNotNull(type);
 		assertEquals("9952 layer is +1", 0x3, type.getType());
 	}
 
@@ -263,6 +275,7 @@ public class RuleFileReaderTest {
 		Element el = new Way(1);
 		el.addTag("highway", "motorway");
 		GType type = getFirstType(rs, el);
+		assertNotNull(type);
 
 		// Check that the correct class and speed are returned.
 		assertEquals("class", 4, type.getRoadClass());
@@ -710,6 +723,7 @@ public class RuleFileReaderTest {
 
 		for (int i = 0; i < 3; i++) {
 			GType type = getFirstType(rs, el);
+			assertNotNull(type);
 			assertEquals("first type", 1, type.getType());
 			assertEquals("continue search", true, type.isContinueSearch());
 		}
@@ -787,6 +801,7 @@ public class RuleFileReaderTest {
 		way.addTag("include", "yes");
 
 		GType type = getFirstType(rs, way);
+		assertNotNull(type);
 		assertEquals(2, type.getType());
 	}
 
@@ -798,6 +813,7 @@ public class RuleFileReaderTest {
 		way.addTag("include", "yes");
 
 		GType type = getFirstType(rs, way);
+		assertNotNull(type);
 		assertEquals(2, type.getType());
 	}
 
@@ -856,11 +872,13 @@ public class RuleFileReaderTest {
 		el = new Way(2);
 		el.addTag("c", "1");
 		type = getFirstType(rs, el);
+		assertNotNull(type);
 		assertEquals(1, type.getType());
 
 		el = new Way(2);
 		el.addTag("c", "2");
 		type = getFirstType(rs, el);
+		assertNotNull(type);
 		assertEquals(2, type.getType());
 	}
 
@@ -889,11 +907,13 @@ public class RuleFileReaderTest {
 		el = new Way(2);
 		el.addTag("c", "1");
 		type = getFirstType(rs, el);
+		assertNotNull(type);
 		assertEquals(1, type.getType());
 
 		el = new Way(2);
 		el.addTag("c", "2");
 		type = getFirstType(rs, el);
+		assertNotNull(type);
 		assertEquals(2, type.getType());
 	}
 
@@ -1065,6 +1085,7 @@ public class RuleFileReaderTest {
 
 		w.addTag("c", "x");
 		type = getFirstType(rs, w);
+		assertNotNull(type);
 		assertEquals(6, type.getType());
 	}
 
@@ -1075,6 +1096,7 @@ public class RuleFileReaderTest {
 		w.addTag("a", "b");
 		w.addTag("b", "50");
 		GType type = getFirstType(rs, w);
+		assertNotNull(type);
 		assertEquals(6, type.getType());
 	}
 
@@ -1085,9 +1107,32 @@ public class RuleFileReaderTest {
 		w.addTag("a", "1");
 		w.addTag("b", "2");
 		GType type = getFirstType(rs, w);
+		assertNotNull(type);
 		assertEquals(5, type.getType());
 	}
 
+	@Test
+	public void test_X3NOT_Error() {
+		// Bug caused an Error: X3:NOT syntax exception to be thrown.
+		RuleSet rs = makeRuleSet("(a=1 | b=2) & !(c=1) & d!=3 [0x8]");
+		Way w = new Way(1);
+		w.addTag("b", "1");
+		GType type = getFirstType(rs, w);
+		assertNull(type);
+
+		w.addTag("b", "2");
+		type = getFirstType(rs, w);
+		assertNotNull(type);
+
+		w.addTag("d", "3");
+		type = getFirstType(rs, w);
+		assertNull(type);
+
+		w.addTag("d", "2");
+		type = getFirstType(rs, w);
+		assertNotNull(type);
+	}
+
 	/**
 	 * Get a way with a few points for testing length.
 	 *

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/mkgmap.git



More information about the Pkg-grass-devel mailing list