[mkgmap] 01/04: Imported Upstream version 0.0.0+svn3674

Sebastiaan Couwenberg sebastic at moszumanska.debian.org
Fri Apr 1 23:06:00 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 f67a403067c7caebc62fcffb67198907a2ebad69
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Sat Apr 2 00:37:56 2016 +0200

    Imported Upstream version 0.0.0+svn3674
---
 .idea/ant.xml                                      |  3 +-
 .idea/modules.xml                                  |  3 +-
 build.xml                                          |  2 +-
 resources/mkgmap-version.properties                |  4 +-
 resources/styles/default/inc/water_lines           |  3 +
 src/uk/me/parabola/imgfmt/app/mdr/MDRFile.java     |  3 -
 src/uk/me/parabola/imgfmt/app/mdr/Mdr1.java        | 31 ---------
 src/uk/me/parabola/imgfmt/app/mdr/Mdr10.java       |  9 ---
 src/uk/me/parabola/imgfmt/app/mdr/Mdr11.java       |  4 --
 src/uk/me/parabola/imgfmt/app/mdr/Mdr2x.java       |  4 --
 src/uk/me/parabola/imgfmt/app/mdr/Mdr5.java        |  4 --
 src/uk/me/parabola/imgfmt/app/mdr/Mdr6.java        |  4 --
 src/uk/me/parabola/imgfmt/app/mdr/Mdr7.java        |  4 --
 .../me/parabola/imgfmt/app/mdr/MdrMapSection.java  | 23 ------
 .../me/parabola/mkgmap/combiners/MdrBuilder.java   |  7 +-
 src/uk/me/parabola/mkgmap/main/Main.java           | 81 +++++++++++++++-------
 .../parabola/mkgmap/osmstyle/RuleFileReader.java   |  9 ++-
 .../mkgmap/reader/osm/LinkDestinationHook.java     | 12 ++--
 .../mkgmap/sea/optional/PrecompSeaGenerator.java   | 35 ++++------
 .../mkgmap/osmstyle/RuleFileReaderTest.java        | 21 ++++++
 20 files changed, 115 insertions(+), 151 deletions(-)

diff --git a/.idea/ant.xml b/.idea/ant.xml
index 313b0c0..a2a4769 100644
--- a/.idea/ant.xml
+++ b/.idea/ant.xml
@@ -3,5 +3,4 @@
   <component name="AntConfiguration">
     <buildFile url="file://$PROJECT_DIR$/build.xml" />
   </component>
-</project>
-
+</project>
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
index 59bf28b..5728431 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -5,5 +5,4 @@
       <module fileurl="file://$PROJECT_DIR$/mkgmap.iml" filepath="$PROJECT_DIR$/mkgmap.iml" />
     </modules>
   </component>
-</project>
-
+</project>
\ No newline at end of file
diff --git a/build.xml b/build.xml
index eca68f0..2b09b34 100644
--- a/build.xml
+++ b/build.xml
@@ -272,7 +272,7 @@
 
 	<target name="test" depends="build-test, obtain-test-input-files" description="Run the junit tests">
 		<mkdir dir="tmp/report"/>
-		<junit printsummary="yes" failureproperty="junit.failure">
+		<junit printsummary="yes" failureproperty="junit.failure" forkmode="once">
 
 			<classpath refid="test"/>
 			<formatter type="xml"/>
diff --git a/resources/mkgmap-version.properties b/resources/mkgmap-version.properties
index ec20f2c..dae105d 100644
--- a/resources/mkgmap-version.properties
+++ b/resources/mkgmap-version.properties
@@ -1,2 +1,2 @@
-svn.version: 3668
-build.timestamp: 2016-02-19T07:22:00+0000
+svn.version: 3674
+build.timestamp: 2016-03-25T23:18:19+0000
diff --git a/resources/styles/default/inc/water_lines b/resources/styles/default/inc/water_lines
index 898e28e..e93ab4e 100644
--- a/resources/styles/default/inc/water_lines
+++ b/resources/styles/default/inc/water_lines
@@ -4,6 +4,9 @@ route=ferry {set mkgmap:numbers = false }
 route=ferry & (motorcar=no | motor_vehicle=no) {add mkgmap:ferry=1} [0x1b road_class=0 road_speed=0 resolution 23]
 route=ferry {add mkgmap:ferry=1} [0x1b road_class=3 road_speed=0 resolution 19]
 
+(waterway=river | waterway=canal) & intermittent=yes [0x26 resolution 20]
+(waterway=stream | waterway=drain) & intermittent=yes [0x10A02 resolution 22]
+
 waterway=canal [0x1f resolution 21]
 waterway=drain [0x1f resolution 22]
 waterway=river [0x1f resolution 18]
diff --git a/src/uk/me/parabola/imgfmt/app/mdr/MDRFile.java b/src/uk/me/parabola/imgfmt/app/mdr/MDRFile.java
index 3640b05..b77475e 100644
--- a/src/uk/me/parabola/imgfmt/app/mdr/MDRFile.java
+++ b/src/uk/me/parabola/imgfmt/app/mdr/MDRFile.java
@@ -266,8 +266,6 @@ public class MDRFile extends ImgFile {
 	private void writeSections(ImgFileWriter writer) {
 		sizes = new MdrMapSection.PointerSizes(sections);
 
-		mdr1.finish();
-
 		// Deal with the dependencies between the sections. The order of the following
 		// statements is sometimes important.
 		mdr28.buildFromRegions(mdr13.getRegions());
@@ -383,7 +381,6 @@ public class MDRFile extends ImgFile {
 			MdrMapSection mapSection = (MdrMapSection) section;
 			mapSection.setMapIndex(mdr1);
 			mapSection.initIndex(sectionNumber);
-			mapSection.relabelMaps(mdr1);
 		}
 
 		if (section instanceof HasHeaderFlags)
diff --git a/src/uk/me/parabola/imgfmt/app/mdr/Mdr1.java b/src/uk/me/parabola/imgfmt/app/mdr/Mdr1.java
index e2090b4..36c9d0a 100644
--- a/src/uk/me/parabola/imgfmt/app/mdr/Mdr1.java
+++ b/src/uk/me/parabola/imgfmt/app/mdr/Mdr1.java
@@ -13,8 +13,6 @@
 package uk.me.parabola.imgfmt.app.mdr;
 
 import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
 import java.util.List;
 
 import uk.me.parabola.imgfmt.app.ImgFileWriter;
@@ -46,7 +44,6 @@ import uk.me.parabola.imgfmt.app.ImgFileWriter;
  */
 public class Mdr1 extends MdrSection implements HasHeaderFlags {
 	private final List<Mdr1Record> maps = new ArrayList<>();
-	private int[] mapping;
 
 	public Mdr1(MdrConfig config) {
 		setConfig(config);
@@ -70,30 +67,6 @@ public class Mdr1 extends MdrSection implements HasHeaderFlags {
 		}
 	}
 
-	/**
-	 * The maps must be sorted in numerical order.
-	 */
-	public void finish() {
-		Collections.sort(maps, new Comparator<Mdr1Record>() {
-			public int compare(Mdr1Record o1, Mdr1Record o2) {
-				if (o1.getMapNumber() == o2.getMapNumber())
-					return 0;
-				else if (o1.getMapNumber() < o2.getMapNumber())
-					return -1;
-				else
-					return 1;
-			}
-		});
-
-		// Used to renumber all the existing (pre-sorted) map index numbers.
-		mapping = new int[maps.size()];
-		int count = 1;
-		for (Mdr1Record r : maps) {
-			mapping[r.getMapIndex()-1] = count;
-			count++;
-		}
-	}
-
 	public void writeSubSections(ImgFileWriter writer) {
 		if (isForDevice())
 			return;
@@ -166,8 +139,4 @@ public class Mdr1 extends MdrSection implements HasHeaderFlags {
 			magic |= 1;
 		return magic;
 	}
-
-	public int sortedMapIndex(int n) {
-		return mapping[n-1];
-	}
 }
diff --git a/src/uk/me/parabola/imgfmt/app/mdr/Mdr10.java b/src/uk/me/parabola/imgfmt/app/mdr/Mdr10.java
index 2dbf684..8e3c339 100644
--- a/src/uk/me/parabola/imgfmt/app/mdr/Mdr10.java
+++ b/src/uk/me/parabola/imgfmt/app/mdr/Mdr10.java
@@ -132,13 +132,4 @@ public class Mdr10 extends MdrMapSection {
 		// Nothing to do here
 		return 0;
 	}
-
-	/**
-	 * Nothing to do for this section.
-	 *
-	 * Although this section has a subsection by map index in mdr1, its record does not contain the
-	 * map index and so nothing needs to be re-written here.  The map index is contained in its mdr11ref.
-	 */
-	public void relabelMaps(Mdr1 maps) {
-	}
 }
diff --git a/src/uk/me/parabola/imgfmt/app/mdr/Mdr11.java b/src/uk/me/parabola/imgfmt/app/mdr/Mdr11.java
index ab505a9..c427798 100644
--- a/src/uk/me/parabola/imgfmt/app/mdr/Mdr11.java
+++ b/src/uk/me/parabola/imgfmt/app/mdr/Mdr11.java
@@ -173,8 +173,4 @@ public class Mdr11 extends MdrMapSection {
 	public List<Mdr11Record> getPois() {
 		return new ArrayList<>(pois);
 	}
-
-	public void relabelMaps(Mdr1 maps) {
-		relabel(maps, pois);
-	}
 }
diff --git a/src/uk/me/parabola/imgfmt/app/mdr/Mdr2x.java b/src/uk/me/parabola/imgfmt/app/mdr/Mdr2x.java
index d0c1fdf..7944ebe 100644
--- a/src/uk/me/parabola/imgfmt/app/mdr/Mdr2x.java
+++ b/src/uk/me/parabola/imgfmt/app/mdr/Mdr2x.java
@@ -124,8 +124,4 @@ public abstract class Mdr2x extends MdrMapSection implements HasHeaderFlags {
 	 * @return True if the streets are in the same group (city, region etc).
 	 */
 	protected abstract boolean sameGroup(Mdr7Record street1, Mdr7Record street2);
-
-	public void relabelMaps(Mdr1 maps) {
-		// Nothing to do, since all streets are re-labeled in their own section.
-	}
 }
diff --git a/src/uk/me/parabola/imgfmt/app/mdr/Mdr5.java b/src/uk/me/parabola/imgfmt/app/mdr/Mdr5.java
index 2186d96..652d9ba 100644
--- a/src/uk/me/parabola/imgfmt/app/mdr/Mdr5.java
+++ b/src/uk/me/parabola/imgfmt/app/mdr/Mdr5.java
@@ -202,8 +202,4 @@ public class Mdr5 extends MdrMapSection {
 	public List<Mdr5Record> getSortedCities() {
 		return Collections.unmodifiableList(cities);
 	}
-
-	public void relabelMaps(Mdr1 maps) {
-		relabel(maps, cities);
-	}
 }
diff --git a/src/uk/me/parabola/imgfmt/app/mdr/Mdr6.java b/src/uk/me/parabola/imgfmt/app/mdr/Mdr6.java
index d9398ec..249a0d7 100644
--- a/src/uk/me/parabola/imgfmt/app/mdr/Mdr6.java
+++ b/src/uk/me/parabola/imgfmt/app/mdr/Mdr6.java
@@ -88,8 +88,4 @@ public class Mdr6 extends MdrMapSection {
 	public int getExtraValue() {
 		return  ((getSizes().getZipSize()-1)&0x03) | (isForDevice() ? 0 : 0x04);
 	}
-
-	public void relabelMaps(Mdr1 maps) {
-		relabel(maps, zips);
-	}
 }
diff --git a/src/uk/me/parabola/imgfmt/app/mdr/Mdr7.java b/src/uk/me/parabola/imgfmt/app/mdr/Mdr7.java
index f5034a8..efa68b0 100644
--- a/src/uk/me/parabola/imgfmt/app/mdr/Mdr7.java
+++ b/src/uk/me/parabola/imgfmt/app/mdr/Mdr7.java
@@ -331,8 +331,4 @@ public class Mdr7 extends MdrMapSection {
 	public List<Mdr7Record> getSortedStreets() {
 		return Collections.unmodifiableList(streets);
 	}
-
-	public void relabelMaps(Mdr1 maps) {
-		relabel(maps, allStreets);
-	}
 }
diff --git a/src/uk/me/parabola/imgfmt/app/mdr/MdrMapSection.java b/src/uk/me/parabola/imgfmt/app/mdr/MdrMapSection.java
index cc5a330..14ab889 100644
--- a/src/uk/me/parabola/imgfmt/app/mdr/MdrMapSection.java
+++ b/src/uk/me/parabola/imgfmt/app/mdr/MdrMapSection.java
@@ -12,8 +12,6 @@
  */
 package uk.me.parabola.imgfmt.app.mdr;
 
-import java.util.List;
-
 import uk.me.parabola.imgfmt.app.ImgFileWriter;
 
 /**
@@ -71,25 +69,4 @@ public abstract class MdrMapSection extends MdrSection implements HasHeaderFlags
 	protected boolean hasFlag(int val) {
 		return (getExtraValue() & val) != 0;
 	}
-
-	public abstract void relabelMaps(Mdr1 maps);
-
-	/**
-	 * Relabel every map-index in the given set of records.
-	 *
-	 * The maps must be in sorted order, but because of the incremental way that we build the
-	 * index, this isn't known until the end.  So we get rewrite the mapIndex from the
-	 * initial to the final ordering.
-	 *
-	 * @param maps The final ordering of the maps.
-	 * @param records The set of records to be relabeled.
-	 * @param <T> The type of the record. Must be a subclass of RecordBase.
-	 */
-	protected <T extends RecordBase> void relabel(Mdr1 maps, List<T> records) {
-		for (T r : records) {
-			int n = r.getMapIndex();
-			int newIndex = maps.sortedMapIndex(n);
-			r.setMapIndex(newIndex);
-		}
-	}
 }
diff --git a/src/uk/me/parabola/mkgmap/combiners/MdrBuilder.java b/src/uk/me/parabola/mkgmap/combiners/MdrBuilder.java
index 29e06c6..6c5c985 100644
--- a/src/uk/me/parabola/mkgmap/combiners/MdrBuilder.java
+++ b/src/uk/me/parabola/mkgmap/combiners/MdrBuilder.java
@@ -310,13 +310,12 @@ public class MdrBuilder implements Combiner {
 			String name = road.getName();
 			if (name == null || name.isEmpty())
 				continue;
-			Mdr5Record mdrCity = null;
 			List<City> cities = road.getCities();
 			if (cities.isEmpty())
-				mdrFile.addStreet(road, mdrCity);
+				mdrFile.addStreet(road, null);
 			else {
 				for (City city : cities){
-					mdrCity = cityList.get(city.getIndex() - 1);
+					Mdr5Record mdrCity = cityList.get(city.getIndex() - 1);
 					if (mdrCity.getMapIndex() == 0)
 						mdrCity = null;
 
@@ -378,7 +377,7 @@ public class MdrBuilder implements Combiner {
 	 * These are only held for a single map at a time, which is
 	 * sufficient to link them all up.
 	 */
-	class AreaMaps {
+	private class AreaMaps {
 		private final Map<Integer, Mdr5Record> cities = new HashMap<>();
 		private Map<Integer, Mdr13Record> regions;
 		private Map<Integer, Mdr14Record> countries;
diff --git a/src/uk/me/parabola/mkgmap/main/Main.java b/src/uk/me/parabola/mkgmap/main/Main.java
index 98157c0..234459f 100644
--- a/src/uk/me/parabola/mkgmap/main/Main.java
+++ b/src/uk/me/parabola/mkgmap/main/Main.java
@@ -21,6 +21,8 @@ import java.io.InputStreamReader;
 import java.io.PrintStream;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -74,14 +76,14 @@ public class Main implements ArgumentProcessor {
 	private static final Logger log = Logger.getLogger(Main.class);
 
 	// Final .img file combiners.
-	private final List<Combiner> combiners = new ArrayList<Combiner>();
+	private final List<Combiner> combiners = new ArrayList<>();
 
-	private final Map<String, MapProcessor> processMap = new HashMap<String, MapProcessor>();
+	private final Map<String, MapProcessor> processMap = new HashMap<>();
 	private String styleFile = "classpath:styles";
 	private String styleOption;
 	private boolean verbose;
 
-	private final List<FilenameTask> futures = new LinkedList<FilenameTask>();
+	private final List<FilenameTask> futures = new LinkedList<>();
 	private ExecutorService threadPool;
 	// default number of threads
 	private int maxJobs = 1;
@@ -95,7 +97,6 @@ public class Main implements ArgumentProcessor {
 
 	/**
 	 * Used for unit tests
-	 * @param args
 	 */
 	public static void mainNoSystemExit(String[] args) {
 		Main.mainStart(args);
@@ -194,7 +195,7 @@ public class Main implements ArgumentProcessor {
 		if (stream == null)
 			return null;
 
-		Set<String> result = new HashSet<String>();
+		Set<String> result = new HashSet<>();
 		try {
 			BufferedReader r = new BufferedReader(new InputStreamReader(stream, "utf-8"));
 
@@ -276,7 +277,8 @@ public class Main implements ArgumentProcessor {
 	public void processOption(String opt, String val) {
 		log.debug("option:", opt, val);
 
-		if (opt.equals("number-of-files")) {
+		switch (opt) {
+		case "number-of-files":
 
 			// This option always appears first.  We use it to turn on/off
 			// generation of the overview files if there is only one file
@@ -285,28 +287,37 @@ public class Main implements ArgumentProcessor {
 			if (n > 0) // TODO temporary, this option will become properly default of on.
 				createTdbFiles = true;
 
-		} else if (opt.equals("help")) {
+			break;
+		case "help":
 			printHelp(System.out, getLang(), (!val.isEmpty()) ? val : "help");
-		} else if (opt.equals("style-file") || opt.equals("map-features")) {
+			break;
+		case "style-file":
+		case "map-features":
 			styleFile = val;
-		} else if (opt.equals("style")) {
+			break;
+		case "style":
 			styleOption = val;
-		} else if (opt.equals("verbose")) {
+			break;
+		case "verbose":
 			verbose = true;
-		} else if (opt.equals("list-styles")) {
+			break;
+		case "list-styles":
 			listStyles();
-		} else if (opt.equals("check-styles")) {
+			break;
+		case "check-styles":
 			checkStyles();
-		} else if (opt.equals("max-jobs")) {
+			break;
+		case "max-jobs":
 			if (val.isEmpty())
 				maxJobs = Runtime.getRuntime().availableProcessors();
 			else
 				maxJobs = Integer.parseInt(val);
-			if(maxJobs < 1) {
+			if (maxJobs < 1) {
 				log.warn("max-jobs has to be at least 1");
 				maxJobs = 1;
 			}
-		} else if (opt.equals("version")) {
+			break;
+		case "version":
 			System.err.println(Version.VERSION);
 			System.exit(0);
 		}
@@ -365,7 +376,6 @@ public class Main implements ArgumentProcessor {
 	 */
 	private void checkStyles() {
 		String[] names;
-		int checked = 0;
 		try {
 			StyleFileLoader loader = StyleFileLoader.createStyleLoader(styleFile, null);
 			names = loader.list();
@@ -383,15 +393,16 @@ public class Main implements ArgumentProcessor {
 			else 
 				System.out.println("Found one style in " + styleFile);
 		}
+		int checked = 0;
 		for (String name : names) {
-			if (styleOption != null && name.equals(styleOption) == false)
+			if (styleOption != null && !name.equals(styleOption))
 				continue;
 			if (names.length > 1){
 				System.out.println("checking style: " + name);
 			}
 			++checked;
 			boolean performChecks = true;
-			if ("classpath:styles".equals(styleFile) && "default".equals(name) == false){ 
+			if ("classpath:styles".equals(styleFile) && !"default".equals(name)){
 					performChecks = false;
 			}
 			Style style = readOneStyle(name, performChecks);
@@ -411,8 +422,8 @@ public class Main implements ArgumentProcessor {
 	 * @return the style or null in case of errors
 	 */
 	private Style readOneStyle(String name, boolean performChecks){
-		Style style = null;
 		searchedStyleName = name;
+		Style style = null;
 		try {
 			style = new StyleImpl(styleFile, name, new EnhancedProperties(), performChecks);
 		} catch (SyntaxException e) {
@@ -454,7 +465,7 @@ public class Main implements ArgumentProcessor {
 		}
 
 
-		List<FilenameTask> filenames = new ArrayList<FilenameTask>();
+		List<FilenameTask> filenames = new ArrayList<>();
 		
 		int numMapFailedExceptions = 0;
 		
@@ -525,8 +536,30 @@ public class Main implements ArgumentProcessor {
 		for (Combiner c : combiners)
 			c.init(args);
 
-		// will contain img files for which an additional ovm file was found  
-		HashSet<String> foundOvmFiles = new HashSet<String>();
+		Collections.sort(filenames, new Comparator<FilenameTask>() {
+			public int compare(FilenameTask o1, FilenameTask o2) {
+				if (!o1.getFilename().endsWith(".img") || !o2.getFilename().endsWith(".img"))
+					return o1.getFilename().compareTo(o2.getFilename());
+
+				// Both end in .img
+				try {
+					int id1 = FileInfo.getFileInfo(o1.getFilename()).getHexname();
+					int id2 = FileInfo.getFileInfo(o2.getFilename()).getHexname();
+					if (id1 == id2)
+						return 0;
+					else if (id1 < id2)
+						return -1;
+					else
+						return 1;
+				} catch (FileNotFoundException ignored) {
+				}
+				return 0;
+			}
+
+		});
+
+		// will contain img files for which an additional ovm file was found
+		HashSet<String> foundOvmFiles = new HashSet<>();
 		// try OverviewBuilder with special files  
 		if (tdbBuilderAdded){
 			for (FilenameTask file : filenames) {
@@ -535,7 +568,7 @@ public class Main implements ArgumentProcessor {
 
 				try {
 					String fileName = file.getFilename();
-					if (fileName.endsWith(".img") == false)
+					if (!fileName.endsWith(".img"))
 						continue;
 					fileName = OverviewBuilder.getOverviewImgName(fileName);
 					log.info("  " + fileName);
@@ -547,7 +580,7 @@ public class Main implements ArgumentProcessor {
 						if (c instanceof OverviewBuilder)
 							c.onMapEnd(fileInfo);
 					}
-				} catch (FileNotFoundException e) {
+				} catch (FileNotFoundException ignored) {
 				}
 			} 
 		}
diff --git a/src/uk/me/parabola/mkgmap/osmstyle/RuleFileReader.java b/src/uk/me/parabola/mkgmap/osmstyle/RuleFileReader.java
index b55e5fa..94f4bc4 100644
--- a/src/uk/me/parabola/mkgmap/osmstyle/RuleFileReader.java
+++ b/src/uk/me/parabola/mkgmap/osmstyle/RuleFileReader.java
@@ -272,6 +272,9 @@ public class RuleFileReader {
 		if (isFinished(op))
 			return op;
 
+		if (op.getFirst().isType(OR))
+			op = distribute(op.getFirst(), op.getSecond());
+
 		if (op.isType(AND)) {
 			// Recursively re-arrange the child nodes
 			rearrangeExpression(op.getFirst());
@@ -352,7 +355,7 @@ public class RuleFileReader {
 			// Transform ((first | second) & topSecond)
 			// into (first & topSecond) | (second & topSecond)
 
-			return distrubute(op1, top.getSecond());
+			return distribute(op1, top.getSecond());
 		} else {
 			// This shouldn't happen
 			throw new SyntaxException("X3:" + op1.getType());
@@ -360,7 +363,7 @@ public class RuleFileReader {
 		return top;
 	}
 
-	private static OrOp distrubute(Op op1, Op topSecond) {
+	private static OrOp distribute(Op op1, Op topSecond) {
 		Op first = op1.getFirst();
 		OrOp orOp = new OrOp();
 
@@ -371,7 +374,7 @@ public class RuleFileReader {
 		BinaryOp and2 = new AndOp();
 		Op second = rearrangeExpression(op1.getSecond());
 		if (second.isType(OR)) {
-			and2 = distrubute(second, topSecond);
+			and2 = distribute(second, topSecond);
 		} else {
 			and2.setFirst(second);
 			and2.setSecond(topSecond);
diff --git a/src/uk/me/parabola/mkgmap/reader/osm/LinkDestinationHook.java b/src/uk/me/parabola/mkgmap/reader/osm/LinkDestinationHook.java
index 9903ccd..db2bff1 100644
--- a/src/uk/me/parabola/mkgmap/reader/osm/LinkDestinationHook.java
+++ b/src/uk/me/parabola/mkgmap/reader/osm/LinkDestinationHook.java
@@ -50,7 +50,7 @@ public class LinkDestinationHook extends OsmReadingHooksAdaptor {
 	/** Maps which ways can be driven from a given Coord */
 	private IdentityHashMap<Coord, Set<Way>> adjacentWays = new IdentityHashMap<Coord, Set<Way>>();
 	/** Contains all _link ways that have to be processed */
-	private Map<Long, Way> destinationLinkWays = new HashMap<Long, Way>();
+	private Map<Long, Way> destinationLinkWays = new LinkedHashMap<Long, Way>();
 	
 	private final static Set<String> highwayTypes = new LinkedHashSet<String>(Arrays.asList(
 			"motorway", "trunk", "primary", "secondary", "tertiary", 
@@ -143,16 +143,16 @@ public class LinkDestinationHook extends OsmReadingHooksAdaptor {
 							// use this tag as destination tag 
 							destinationTag = destLanesTag;
 						}
-						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){
+							// try to use the destination:street value
+							destSourceTagKey = "destination:street";
+							destinationTag = w.getTag(destSourceTagKey);
+						}
 						if (destinationTag != null && "destination".equals(destSourceTagKey) == false){
 							w.addTag("destination", destinationTag);
 							if (log.isDebugEnabled()){
diff --git a/src/uk/me/parabola/mkgmap/sea/optional/PrecompSeaGenerator.java b/src/uk/me/parabola/mkgmap/sea/optional/PrecompSeaGenerator.java
index 2d52945..b4e63f5 100644
--- a/src/uk/me/parabola/mkgmap/sea/optional/PrecompSeaGenerator.java
+++ b/src/uk/me/parabola/mkgmap/sea/optional/PrecompSeaGenerator.java
@@ -256,26 +256,6 @@ public class PrecompSeaGenerator {
 		shapeIterator = null;
 	}
 
-	/**
-	 * Reads the next polygon from the shape file.
-	 * @return the next polygon (WGS84 projection)
-	 */
-	private Geometry readNextPolygon() {
-		if (shapeIterator.hasNext()) {
-			Feature feature = shapeIterator.next();
-			GeometryAttribute geom = feature.getDefaultGeometryProperty();
-			Geometry poly = (Geometry) geom.getValue();
-			try {
-				return transformToWGS84(poly);
-			} catch (Exception exp) {
-				System.err.println(exp);
-				return null;
-			}
-		} else {
-			return null;
-		}
-	}
-
 	public void runSeaGeneration() throws MismatchedDimensionException,
 			TransformException, IOException, InterruptedException {
 		createShapefileAccess();
@@ -328,7 +308,20 @@ public class PrecompSeaGenerator {
 			// read all polygons from the shape file and add them to the queues of the
 			// merger threads
 			Geometry wgs84Poly = null;
-			while ((wgs84Poly = readNextPolygon()) != null) {
+			while (shapeIterator.hasNext()) {
+				Feature feature = shapeIterator.next();
+				GeometryAttribute geom = feature.getDefaultGeometryProperty();
+				Geometry poly = (Geometry) geom.getValue();
+				if (poly == null){
+					continue;
+				}
+
+				try {
+					wgs84Poly = transformToWGS84(poly);
+				} catch (Exception exp) {
+					System.err.println(exp);
+					continue;
+				}
 
 				if (wgs84Poly.getNumGeometries() != 1) {
 					// only simple polygons are supported by now
diff --git a/test/uk/me/parabola/mkgmap/osmstyle/RuleFileReaderTest.java b/test/uk/me/parabola/mkgmap/osmstyle/RuleFileReaderTest.java
index 183115e..c6f16e7 100644
--- a/test/uk/me/parabola/mkgmap/osmstyle/RuleFileReaderTest.java
+++ b/test/uk/me/parabola/mkgmap/osmstyle/RuleFileReaderTest.java
@@ -1133,6 +1133,27 @@ public class RuleFileReaderTest {
 		assertNotNull(type);
 	}
 
+	@Test
+	public void testBugOrWithAndOnLeft() {
+		RuleSet rs = makeRuleSet("((a=1&b=2) | a=2) & c!=4 [0x2]");
+		Way w = new Way(1);
+		w.addTag("a", "2");
+
+		GType type = getFirstType(rs, w);
+		assertNotNull(type);
+	}
+
+	@Test
+	public void testBugOrWithAndOnLeft2() {
+		RuleSet rs = makeRuleSet("(((a=1 | a=5)&b=2) | a=2) & c!=4 [0x2]");
+		Way w = new Way(1);
+		w.addTag("a", "2");
+
+		GType type = getFirstType(rs, w);
+		assertNotNull(type);
+		assertEquals(type.getType(), 2);
+	}
+
 	/**
 	 * 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