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

Sebastiaan Couwenberg sebastic at moszumanska.debian.org
Mon Jun 1 07:09:46 UTC 2015


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

sebastic pushed a commit to branch master
in repository mkgmap.

commit 21243da3c43c4e47e865bc1dbd451b519622d57d
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Mon Jun 1 08:57:17 2015 +0200

    Imported Upstream version 0.0.0+svn3598
---
 doc/options.txt                                    | 45 ++++++++-------
 resources/help/en/options                          | 52 ++++++++---------
 resources/mkgmap-version.properties                |  4 +-
 resources/styles/default/lines                     |  2 +-
 resources/styles/default/points                    |  2 +-
 src/uk/me/parabola/mkgmap/build/LocatorConfig.java | 15 +++--
 src/uk/me/parabola/mkgmap/build/MapBuilder.java    | 57 ++++++++++++++-----
 src/uk/me/parabola/mkgmap/main/Main.java           |  4 +-
 .../parabola/mkgmap/osmstyle/StyledConverter.java  | 66 +++++++++++++++++++---
 .../mkgmap/reader/osm/LinkDestinationHook.java     | 56 ++++++++++--------
 .../mkgmap/reader/osm/POIGeneratorHook.java        | 48 +++++++++++++++-
 11 files changed, 241 insertions(+), 110 deletions(-)

diff --git a/doc/options.txt b/doc/options.txt
index 54d1300..667c328 100644
--- a/doc/options.txt
+++ b/doc/options.txt
@@ -34,7 +34,7 @@ long name instead.
 
 ;--output-dir=filename
 :     The directory in which all output files are written. It defaults
-to the current working directory, ie. the directory the command is
+to the current working directory, i.e. the directory the command is
 executed from.
 
 ;-n name
@@ -46,7 +46,7 @@ that it is unique and does not clash with others.
 
 ;--description=text
 : 	Sets the descriptive text for the map. This may be displayed in
-QLandkarte, MapSource on on a GPS etc, where it is normally shown
+QLandkarte, MapSource or on a GPS, where it is normally shown
 below the family name. Example: --description="Germany, Denmark"
 Please note: if you use splitter.jar to build a template.args file
 and use -c template.args, then that file may contain a
@@ -71,12 +71,15 @@ no abbreviated region name.
 ;--latin1
 : 	This is equivalent to --code-page=1252.
 
+;--unicode
+:	This is equivalent to --code-page=65001. Note that only newer devices support Unicode.
+
 ;--code-page=number
 :     This option enables the use of international characters. Only 8 bit
 character sets are supported and so you have to specify which code page
 you want to use.
 
-: It is entirely dependant on the device firmware which code pages are
+: It is entirely dependent on the device firmware which code pages are
 supported.
 
 ;--charset=name
@@ -120,12 +123,12 @@ tags using the style file:
   (mkgmap:is_in - used by location-autofill=is_in)
 
 : If the index is created from previously compiled .img files, then the
-same code page and sorting options (eg. --code-page, --latin1 etc) must
+same code page and sorting options (e.g. --code-page, --latin1) must
 be used as were used to compile the individual map tiles.
 
 ;--bounds=directory|zipfile
-:     A directory or a zipfile containing the preprocessed bounds files. 
-Bounds files in a zipfile must be located in the zipfiles root directory.
+:     A directory or a zip file containing the preprocessed bounds files. 
+Bounds files in a zip file must be located in the zip file's root directory.
 
 : The preprocessed boundaries are used to add special tags to all elements 
 (points, lines and polygons) containing the elements location information.
@@ -180,7 +183,7 @@ The mkgmap:street tag must be added to the street in the style file.
 :: Way 2 - name=Main Street, mkgmap:street=Main Street
 :: Way 3 - mkgmap:street=Mainstreet
 :: Way 4 - name=Main Street [A504]
-: The node matches to way 2. It has mkgmap:street set with a value equal to
+: The node matches to Way 2. It has mkgmap:street set with a value equal to
 the addr:street tag value of the house  number node.
 
 === Overview map options ===
@@ -228,15 +231,15 @@ style file.
 ;--style=name
 : 	Specify a style name. Must be used if --style-file points to a 
 directory or zip file containing multiple styles. If --style-file 
-is not used, it selects one of the builtin styles. 
+is not used, it selects one of the built-in styles. 
 
 ;--list-styles
-: 	List the available styles. If this option is preceeded by a style-file
+: 	List the available styles. If this option is preceded by a style-file
 option then it lists the styles available within that file.
 
 ;--check-styles
 : 	Perform some checks on the available styles. If this option is 
-preceeded by a style-file option then it checks the styles 
+preceded by a style-file option then it checks the styles 
 available within that file. If it is also preceded by the style
 option it will only check that style.
 
@@ -249,7 +252,7 @@ its own default. Up to 8 levels may be specified.
 ;--name-tag-list
 : 	Get the tag that will be used to supply the name.  Useful for
 language variations.  You can supply a list and the first one
-will be used.  eg. --name-tag-list=name:en,int_name,name
+will be used.  e.g. --name-tag-list=name:en,int_name,name
 
 ;--map-features=file
 : 	This option is ignored; use the --style-file option instead.
@@ -289,7 +292,7 @@ part of the mapname in the list of the individual maps.
 ;--copyright-file=file
 : 	Specify copyright messages from a file.
 Note that the first copyright message is not displayed on a device, but is 
-shown in BaseCamp.
+shown in BaseCamp. The copyright file must include at least two lines.
 
 ;--license-file=file
 : 	Specify a file which content will be added as license. 
@@ -306,7 +309,7 @@ Recommended setting is 4, this should lead to only small differences
 (Default is 2.6, which should lead to invisible changes)
 
 ;--reduce-point-density-polygon=NUM
-: 	Allows to set the maximal allowed error distance for the DP algorythm
+: 	Allows to set the maximal allowed error distance for the DP algorithm
 to be applied against polygons. Recommended setting is 8.
 
 ;--merge-lines
@@ -380,7 +383,7 @@ that the roundabouts do not fork or overlap other roundabouts.
 
 ;--check-roundabout-flares
 : 	Sanity check roundabout flare roads - warn if they don't point
-in the correct direction or if they are not oneway or if they
+in the correct direction or if they are not one-way or if they
 extend too far.
 
 ;--max-flare-length-ratio=NUM
@@ -447,8 +450,8 @@ time as using the cycleway creating options.
 defaults to 1 if this option is not specified) determines
 those roads to report: 
 :* 0 = none
-:* 1 = multiple oneway roads that join together but go nowhere
-:* 2 = individual oneway roads that go nowhere.
+:* 1 = multiple one-way roads that join together but go nowhere
+:* 2 = individual one-way roads that go nowhere.
 
 
 ;--road-name-pois[=GarminCode]
@@ -483,13 +486,13 @@ The POIs are created at the following positions
 :; polygons: 
 :: First rule that applies:
 ::* the first node tagged with a tag defined by the pois-to-areas-placement option
-::* the center point  
+::* the centre point  
 ::
 
 :;multipolygons:
 :: First rule that applies:
 ::* the node with role=label
-::* the center point of the biggest area
+::* the centre point of the biggest area
 :
 
 ;--pois-to-areas-placement[=taglist]
@@ -497,14 +500,14 @@ The POIs are created at the following positions
 node of the polygon tagged with the first tag/value pair. If none of the nodes are
 tagged with the first tag-value pair the first node tagged with the second tag-value
 pair is used and so on. If none of the tag-value pairs matches or the taglist is empty 
-the center of the polygon is used.
+the centre of the polygon is used.
 It is possible to define wildcards for tag values like entrance=*.
 
 : Default: entrance=main;entrance=yes;building=entrance
 
 ;--precomp-sea=directory|zipfile
 :     Defines the directory or a zip file that contains precompiled sea tiles. 
-Sea files in a zipfile must be located in the zipfiles root directory or in 
+Sea files in a zip file must be located in the zip files root directory or in 
 a sub directory sea. When this option is defined all natural=coastline tags 
 from the input OSM tiles are removed and the precompiled data is used instead. 
 This option can be combined with the generate-sea options multipolygon, polygons 
@@ -580,7 +583,7 @@ the flood blocker
     Turn on all of the options that make cycleways.
 
 ;--make-opposite-cycleways
-: 	Some oneway streets allow bicycle traffic in the reverse
+: 	Some one-way streets allow bicycle traffic in the reverse
 direction and this option makes a way with the same points as
 the original that allows bicycle traffic (in both directions).
 
diff --git a/resources/help/en/options b/resources/help/en/options
index b37dd71..61b19d0 100644
--- a/resources/help/en/options
+++ b/resources/help/en/options
@@ -33,7 +33,7 @@ filename
 
 --output-dir=filename
     The directory in which all output files are written. It defaults
-    to the current working directory, ie. the directory the command is
+    to the current working directory, i.e. the directory the command is
     executed from.
 
 -n name
@@ -45,7 +45,7 @@ filename
 
 --description=text
 	Sets the descriptive text for the map. This may be displayed in
-	QLandkarte, MapSource on on a GPS etc, where it is normally shown
+	QLandkarte, MapSource or on a GPS, where it is normally shown
 	below the family name. Example: --description="Germany, Denmark"
 	Please note: if you use splitter.jar to build a template.args file
 	and use -c template.args, then that file may contain a
@@ -71,14 +71,14 @@ Label options:
 	This is equivalent to --code-page=1252.
 
 --unicode
-	This is equivalent to --code-page=65001. Note that only newer devices support unicode.
+	This is equivalent to --code-page=65001. Note that only newer devices support Unicode.
 
 --code-page=number
     This option enables the use of international characters. Only 8 bit
     character sets are supported and so you have to specify which code page
     you want to use.
 
-	It is entirely dependant on the device firmware which code pages are
+	It is entirely dependent on the device firmware which code pages are
 	supported.
 	
 --charset=name
@@ -122,9 +122,9 @@ Address search options:
 	  (mkgmap:is_in - used by location-autofill=is_in)
 
   If the index is created from previously compiled .img files, then the
-  same code page and sorting options (eg. --code-page, --latin1 etc) must
+  same code page and sorting options (e.g. --code-page, --latin1) must
   be used as were used to compile the individual map tiles.
-
+  
 --x-split-name-index
     A temporary option to enable indexing each part of a street name separately.
     So for example if the street is "Aleksandra Gryglewskiego" then you will be able to
@@ -136,8 +136,8 @@ Address search options:
     any let us know!
 
 --bounds=directory|zipfile
-    A directory or a zipfile containing the preprocessed bounds files. 
-    Bounds files in a zipfile must be located in the zipfiles root directory.
+    A directory or a zip file containing the preprocessed bounds files. 
+    Bounds files in a zip file must be located in the zip file's root directory.
 
     The preprocessed boundaries are used to add special tags to all elements 
     (points, lines and polygons) containing the elements location information.
@@ -157,7 +157,7 @@ Address search options:
           <inputfile> <boundsdir>
     
     The input file must contain the boundaries that should be preprocessed. 
-    It can have OSM, PBF or O5M fileformat. It is recommended that it 
+    It can have OSM, PBF or O5M file format. It is recommended that it 
     contains the boundary data only to avoid very high memory usage.
     The boundsdir gives the directory where the processed files are stored.
     This directory can be used as --bounds parameter with mkgmap.               
@@ -188,7 +188,7 @@ Address search options:
      Way 2 - name=Main Street, mkgmap:street=Main Street
      Way 3 - mkgmap:street=Mainstreet
      Way 4 - name=Main Street [A504]
-    The node matches to way 2. It has mkgmap:street set with a value equal to
+    The node matches to Way 2. It has mkgmap:street set with a value equal to
     the addr:street tag value of the house number node.
   
 Overview map options:
@@ -236,15 +236,15 @@ Style options:
 --style=name
 	Specify a style name. Must be used if --style-file points to a 
   directory or zip file containing multiple styles. If --style-file 
-  is not used, it selects one of the builtin styles. 
+  is not used, it selects one of the built-in styles. 
 
 --list-styles
-	List the available styles. If this option is preceeded by a style-file
+	List the available styles. If this option is preceded by a style-file
 	option then it lists the styles available within that file.
 
 --check-styles
 	Perform some checks on the available styles. If this option is 
-  preceeded by a style-file option then it checks the styles 
+  preceded by a style-file option then it checks the styles 
   available within that file. If it is also preceded by the style
   option it will only check that style.
 
@@ -257,7 +257,7 @@ Style options:
 --name-tag-list
 	Get the tag that will be used to supply the name.  Useful for
 	language variations.  You can supply a list and the first one
-	will be used.  eg. --name-tag-list=name:en,int_name,name
+	will be used.  e.g. --name-tag-list=name:en,int_name,name
 
 --map-features=file
 	This option is ignored; use the --style-file option instead.
@@ -296,11 +296,11 @@ Product description options:
 --copyright-file=file
 	Specify copyright messages from a file.
 	Note that the first copyright message is not displayed on a device, but is 
-	shown in BaseCamp.
+	shown in BaseCamp. The copyright file must include at least two lines.
 
 --license-file=file
 	Specify a file which content will be added as license. 
-  All entrys of all maps will be merged in the overview map.
+  All entries of all maps will be merged in the overview map.
 
 Optimization options:
 
@@ -313,7 +313,7 @@ Optimization options:
 	(Default is 2.6, which should lead to invisible changes)
 
 --reduce-point-density-polygon=NUM
-	Allows to set the maximal allowed error distance for the DP algorythm
+	Allows to set the maximal allowed error distance for the DP algorithm
 	to be applied against polygons. Recommended setting is 8.
 
 --merge-lines
@@ -387,7 +387,7 @@ Miscellaneous options:
 
 --check-roundabout-flares
 	Sanity check roundabout flare roads - warn if they don't point
-	in the correct direction or if they are not oneway or if they
+	in the correct direction or if they are not one-way or if they
 	extend too far.
 
 --max-flare-length-ratio=NUM
@@ -451,8 +451,8 @@ Miscellaneous options:
 --report-dead-ends=LEVEL
 	Set the dead end road warning level. The value of LEVEL (which
 	defaults to 1 if this option is not specified) determines
-	those roads to report: 0 = none, 1 = multiple oneway roads
-	that join together but go nowhere, 2 = individual oneway roads
+	those roads to report: 0 = none, 1 = multiple one-way roads
+	that join together but go nowhere, 2 = individual one-way roads
 	that go nowhere.
 
 --road-name-pois[=GarminCode]
@@ -461,7 +461,7 @@ Miscellaneous options:
 	can be specified with this option.  This is a workaround for not
 	being able to search for roads.
 	0x2f15: a blue dot in the middle of the road, and if you select,
-		or 'hover' over it, the streetname appears.
+		or 'hover' over it, the street name appears.
 	
 --add-pois-to-lines
 	Generate POIs for lines. For each line (must not be closed) POIs are
@@ -485,23 +485,23 @@ Miscellaneous options:
 	   polygons: 
 	       * the first node tagged with a tag defined by the pois-to-areas-placement 
 	         option
-	       * the center point  
+	       * the centre point  
 	   multipolygons:
 	       * the node with role=label
-	       * the center point of the biggest area
+	       * the centre point of the biggest area
 
 --pois-to-areas-placement[=taglist]
     A semicolon separated list of tag=value definitions. A POI is placed at the first
     node of the polygon tagged with the first tag/value pair. If none of the nodes are
     tagged with the first tag-value pair the first node tagged with the second tag-value
     pair is used and so on. If none of the tag-value pairs matches or the taglist is empty 
-    the center of the polygon is used.
+    the centre of the polygon is used.
     It is possible to define wildcards for tag values like entrance=*.
     Default: entrance=main;entrance=yes;building=entrance
 
 --precomp-sea=directory|zipfile
     Defines the directory or a zip file that contains precompiled sea tiles. 
-    Sea files in a zipfile must be located in the zipfiles root directory or in 
+    Sea files in a zip file must be located in the zip file's root directory or in 
     a sub directory sea. When this option is defined all natural=coastline tags 
     from the input OSM tiles are removed and the precompiled data is used instead. 
     This option can be combined with the generate-sea options multipolygon, polygons 
@@ -580,7 +580,7 @@ Miscellaneous options:
 	Turn on all of the options that make cycleways.
 
 --make-opposite-cycleways
-	Some oneway streets allow bicycle traffic in the reverse
+	Some one-way streets allow bicycle traffic in the reverse
 	direction and this option makes a way with the same points as
 	the original that allows bicycle traffic (in both directions).
 
diff --git a/resources/mkgmap-version.properties b/resources/mkgmap-version.properties
index 3b51c84..de8be19 100644
--- a/resources/mkgmap-version.properties
+++ b/resources/mkgmap-version.properties
@@ -1,2 +1,2 @@
-svn.version: 3552
-build.timestamp: 2015-04-29T07:57:34+0100
+svn.version: 3598
+build.timestamp: 2015-05-18T07:21:27+0100
diff --git a/resources/styles/default/lines b/resources/styles/default/lines
index e2d79c0..391220a 100644
--- a/resources/styles/default/lines
+++ b/resources/styles/default/lines
@@ -81,7 +81,7 @@ highway=*
 # Convert generic path to most specific
 highway=footway & snowplowing!=no
 & (bicycle=yes|bicycle=designated|bicycle=permissive|bicycle=official)
-{set highway=cycleway; set bicycle=yes}
+{set highway=cycleway; set bicycle=yes; set foot=yes}
 highway=path & snowplowing!=no
 & (bicycle=designated|bicycle=permissive|bicycle=official)
 {set highway=cycleway; set bicycle=yes}
diff --git a/resources/styles/default/points b/resources/styles/default/points
index edfd825..2e030a4 100644
--- a/resources/styles/default/points
+++ b/resources/styles/default/points
@@ -213,7 +213,7 @@ leisure=stadium { name '${name} (${sport})' | '${name}' } [0x2c08 resolution 24]
 leisure=track { name '${name} (${sport})' | '${name}' } [0x2c08 resolution 24]
 leisure=water_park [0x2d09 resolution 24]
 
-man_made=tower|landmark=chimney [0x6411 resolution 24]
+man_made=tower|man_made=mast|landmark=chimney [0x6411 resolution 24]
 
 # Edge 705 displays 0x650a,0x6511,0x6512,0x6513,0x6603,0x6614 as hollow white circles, no menu
 natural=cave_entrance [0x6601 resolution 24]
diff --git a/src/uk/me/parabola/mkgmap/build/LocatorConfig.java b/src/uk/me/parabola/mkgmap/build/LocatorConfig.java
index c754f33..cbdd6ce 100644
--- a/src/uk/me/parabola/mkgmap/build/LocatorConfig.java
+++ b/src/uk/me/parabola/mkgmap/build/LocatorConfig.java
@@ -156,9 +156,7 @@ public class LocatorConfig {
 									setPoiDispTag(iso, poiDispTag);
 								}
 								Node driveOnLeft = attr.getNamedItem("driveOnLeft");
-								if (driveOnLeft != null && "true".equals(driveOnLeft.getNodeValue())){
-									driveOnLeftFlagMap.put(iso, true);
-								}
+								driveOnLeftFlagMap.put(iso, driveOnLeft != null && "true".equals(driveOnLeft.getNodeValue()));
 							}
 
 							if (iso != null) {
@@ -350,9 +348,14 @@ public class LocatorConfig {
 	{
 		if (iso == null)
 			return false;
-		if (driveOnLeftFlagMap.containsKey(iso))
-			return true;
-		return false;
+		Boolean driveOnLeft = driveOnLeftFlagMap.get(iso);
+		if (driveOnLeft == null){
+			log.warn("Did not find iso code",iso,"in LocatorConfig.xml, assuming drive-on-right for it");
+			driveOnLeftFlagMap.put(iso,false);
+			return false;
+		}
+		else 
+			return driveOnLeft;
 	}
 }
 
diff --git a/src/uk/me/parabola/mkgmap/build/MapBuilder.java b/src/uk/me/parabola/mkgmap/build/MapBuilder.java
index 94d4340..67f5d6d 100644
--- a/src/uk/me/parabola/mkgmap/build/MapBuilder.java
+++ b/src/uk/me/parabola/mkgmap/build/MapBuilder.java
@@ -627,8 +627,12 @@ public class MapBuilder implements Configurable {
 		// The top level has to cover the whole map without subdividing, so
 		// do a special check to make sure.
 		LevelInfo[] levels = null; 
-		if (src instanceof OverviewMapDataSource)
+		if (src instanceof OverviewMapDataSource){
+			mergeLines = true;
+			prepShapesForMerge(src.getShapes());
+			mergeShapes = true;
 			levels = src.mapLevels();
+		}
 		else {
 			if (OverviewBuilder.isOverviewImg(map.getFilename())) {
 				levels = src.overviewMapLevels();
@@ -697,6 +701,29 @@ public class MapBuilder implements Configurable {
 	}
 
 	/**
+	 * for the overview map: 
+	 * Make sure that all {@link Coord} instances are
+	 * identical when they are equal.
+	 * @param shapes the list of shapes
+	 */
+	private void prepShapesForMerge(List<MapShape> shapes) {
+		HashMap<Coord,Coord> coordMap = new HashMap<>();
+		for (MapShape s : shapes){
+			List<Coord> points = s.getPoints();
+			int n = points.size();
+			for (int i = 0; i< n; i++){
+				Coord co = points.get(i);
+				Coord repl = coordMap.get(co);
+				if (repl == null)
+					coordMap.put(co, co);
+				else 
+					points.set(i, repl);
+			}
+		}
+		return;
+	}
+
+	/**
 	 * Create the top level subdivision.
 	 *
 	 * There must be an empty zoom level at the least detailed level. As it
@@ -859,20 +886,20 @@ public class MapBuilder implements Configurable {
 			info += s.trim() + "\n";
 		}
 		if (!info.isEmpty())
-			map.addInfo(info);
-		if (copyrights.isEmpty()){
-			// There has to be (at least) two copyright messages or else the map
-			// does not show up.  The second and subsequent ones will be displayed
-			// at startup, although the conditions where that happens are not known.
-			// All copyright messages are displayed in BaseCamp.
-			String[] copyrightMessages = src.copyrightMessages();
-			if (copyrightMessages.length < 2)
-				map.addCopyright("program licenced under GPL v2");
-
-			for (String cm : copyrightMessages)
-				map.addCopyright(cm);
-		} else {
-			for (String cm : copyrights)
+			map.addInfo(info);
+		if (copyrights.isEmpty()){
+			// There has to be (at least) two copyright messages or else the map
+			// does not show up.  The second and subsequent ones will be displayed
+			// at startup, although the conditions where that happens are not known.
+			// All copyright messages are displayed in BaseCamp.
+			String[] copyrightMessages = src.copyrightMessages();
+			if (copyrightMessages.length < 2)
+				map.addCopyright("program licenced under GPL v2");
+
+			for (String cm : copyrightMessages)
+				map.addCopyright(cm);
+		} else {
+			for (String cm : copyrights)
 				map.addCopyright(cm);
 		}
 	}
diff --git a/src/uk/me/parabola/mkgmap/main/Main.java b/src/uk/me/parabola/mkgmap/main/Main.java
index 7f9a865..98157c0 100644
--- a/src/uk/me/parabola/mkgmap/main/Main.java
+++ b/src/uk/me/parabola/mkgmap/main/Main.java
@@ -133,7 +133,9 @@ public class Main implements ArgumentProcessor {
 			commandArgs.setValidOptions(getValidOptions(System.err));
 			commandArgs.readArgs(args);
 		} catch (MapFailedException e) {
-			System.err.println(e.getMessage()); // should not happen
+			// one of the combiners failed
+			e.printStackTrace();
+			++numExitExceptions;
 		} catch (ExitException e) {
 			++numExitExceptions;
 			System.err.println(e.getMessage());
diff --git a/src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java b/src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java
index f271115..95300a3 100644
--- a/src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java
+++ b/src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java
@@ -59,6 +59,7 @@ import uk.me.parabola.mkgmap.general.MapShape;
 import uk.me.parabola.mkgmap.osmstyle.housenumber.HousenumberGenerator;
 import uk.me.parabola.mkgmap.reader.osm.CoordPOI;
 import uk.me.parabola.mkgmap.reader.osm.Element;
+import uk.me.parabola.mkgmap.reader.osm.FakeIdGenerator;
 import uk.me.parabola.mkgmap.reader.osm.FeatureKind;
 import uk.me.parabola.mkgmap.reader.osm.GType;
 import uk.me.parabola.mkgmap.reader.osm.Node;
@@ -111,7 +112,8 @@ public class StyledConverter implements OsmConverter {
 	private IdentityHashMap<Coord, CoordNode> nodeIdMap = new IdentityHashMap<>();
 
 	public final static String WAY_POI_NODE_IDS = "mkgmap:way-poi-node-ids";
-	
+	private final HashMap<Integer, Map<String,MapPoint>> pointMap;
+
 	private List<ConvertedWay> roads = new ArrayList<>();
 	private List<ConvertedWay> lines = new ArrayList<>();
 	private HashMap<Long, ConvertedWay> modifiedRoads = new HashMap<>();
@@ -134,6 +136,8 @@ public class StyledConverter implements OsmConverter {
 	private int numDriveOnSideUnknown;
 	private int numRoads;
 	
+	private String countryAbbr;
+
 	private final boolean checkRoundabouts;
 	private int reportDeadEnds; 
 	private final boolean linkPOIsToWays;
@@ -161,6 +165,7 @@ public class StyledConverter implements OsmConverter {
 		} else 
 			nameTagList = null;
 		this.style = style;
+		pointMap = new HashMap<>();
 		wayRules = style.getWayRules();
 		nodeRules = style.getNodeRules();
 		lineRules = style.getLineRules();
@@ -185,6 +190,9 @@ public class StyledConverter implements OsmConverter {
 		default:
 			throw new ExitException("invalid parameters for option drive-on:"+driveOn);
 		}
+		countryAbbr = props.getProperty("country-abbr", null);
+		if (countryAbbr != null)
+			countryAbbr = countryAbbr.toUpperCase();
 			
 		checkRoundabouts = props.getProperty("check-roundabouts",false);
 		reportDeadEnds = props.getProperty("report-dead-ends", 1);  
@@ -351,14 +359,21 @@ public class StyledConverter implements OsmConverter {
 		if (cw.isRoad()){
 			roads.add(cw);
 			numRoads++;
-			String country = way.getTag(countryTagKey);
-			if (country != null) {
-				if (LocatorConfig.get().getDriveOnLeftFlag(country))
-					numDriveOnLeftRoads++;
-				else
-					numDriveOnRightRoads++;
-			} else
-				numDriveOnSideUnknown++;
+			if (cw.isFerry() == false){
+				String country = way.getTag(countryTagKey);
+				if (country != null) {
+					boolean drivingSideIsLeft =LocatorConfig.get().getDriveOnLeftFlag(country); 
+					if (drivingSideIsLeft)
+						numDriveOnLeftRoads++;
+					else
+						numDriveOnRightRoads++;
+					if (driveOnLeft != null && drivingSideIsLeft != driveOnLeft)
+						log.warn("wrong driving side",way.toBrowseURL());
+					if (log.isDebugEnabled())
+						log.debug("assumed driving side is",(drivingSideIsLeft ? "left" : "right"),way.toBrowseURL());
+				} else
+					numDriveOnSideUnknown++;
+			}
 			if (cw.isRoundabout()) {
 				if (wasReversed)
 					log.warn("Roundabout", way.getId(), "has reverse oneway tag (" + way.getPoints().get(0).toOSMURL() + ")");
@@ -540,6 +555,7 @@ public class StyledConverter implements OsmConverter {
 	}
 	
 	public void end() {
+		pointMap.clear();
 		style.reportStats();
 		driveOnLeft = calcDrivingSide();
 		
@@ -999,9 +1015,41 @@ public class StyledConverter implements OsmConverter {
 		elementSetup(mp, gt, node);
 		mp.setLocation(node.getLocation());
 
+		boolean dupPOI = checkDuplicatePOI(mp);
+		if (dupPOI){
+			if (log.isInfoEnabled()){
+				if (FakeIdGenerator.isFakeId(node.getId()))
+					log.info("ignmoring duplicate POI with type",GType.formatType(type),mp.getName(),"for generated element with id",node.getId(),"at",mp.getLocation().toDegreeString());
+				else 
+					log.info("ignmoring duplicate POI with type",GType.formatType(type),mp.getName(),"for element",node.toBrowseURL());
+			}
+			return;
+		}
+		
 		collector.addPoint(mp);
 	}
 
+	/**
+	 * Check if we already have added a point with the same type + name and equal location.
+	 * @param mp
+	 * @return
+	 */
+	private boolean checkDuplicatePOI(MapPoint mp) {
+		Map<String, MapPoint> typeMap = pointMap.get(mp.getType());
+		if (typeMap == null){
+			typeMap = new HashMap<>();
+			pointMap.put(mp.getType(), typeMap);
+		}
+		MapPoint old = typeMap.get(mp.getName());
+		if (old == null){
+			typeMap.put(mp.getName(), mp);
+		} else {
+			if (old.getLocation().equals(mp.getLocation()))
+				return true;
+		}
+		return false;
+	}
+
 	private static final short[] labelTagKeys = {
 		TagDict.getInstance().xlate("mkgmap:label:1"),
 		TagDict.getInstance().xlate("mkgmap:label:2"),
diff --git a/src/uk/me/parabola/mkgmap/reader/osm/LinkDestinationHook.java b/src/uk/me/parabola/mkgmap/reader/osm/LinkDestinationHook.java
index 78d3b51..ccb0646 100644
--- a/src/uk/me/parabola/mkgmap/reader/osm/LinkDestinationHook.java
+++ b/src/uk/me/parabola/mkgmap/reader/osm/LinkDestinationHook.java
@@ -92,12 +92,12 @@ public class LinkDestinationHook extends OsmReadingHooksAdaptor {
 					// 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("direction:forward");
+					directedDestination = w.getTag("destination: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("direction:backward");
+					directedDestination = w.getTag("destination:backward");
 				} else {
 					points = w.getPoints();
 				}
@@ -130,9 +130,10 @@ public class LinkDestinationHook extends OsmReadingHooksAdaptor {
 						}
 					}
 					
-					if (destinationTag == null) {
+					if (destinationTag == null && directedDestination != null) {
 						// use the destination:forward or :backward value
 						destinationTag = directedDestination;
+						w.addTag("destination", destinationTag);
 					}
 					
 					if (destinationTag != null)
@@ -443,15 +444,17 @@ public class LinkDestinationHook extends OsmReadingHooksAdaptor {
 		// belongs to a motorway/trunk or is a "subexit" within a motorway/trunk junction
 		Set<Coord> motorwayCoords = new HashSet<Coord>();
 		Set<Coord> trunkCoords = new HashSet<Coord>();
-		for (Way w : saver.getWays().values()) {
-			String motorwayTag = w.getTag("highway");
-			if (motorwayTag != null) {
-				if (motorwayTag.equals("motorway"))
-					motorwayCoords.addAll(w.getPoints());
-				else if (motorwayTag.equals("trunk"))
-					trunkCoords.addAll(w.getPoints());
-			}
-		}	
+		if (processExits){
+			for (Way w : saver.getWays().values()) {
+				String motorwayTag = w.getTag("highway");
+				if (motorwayTag != null) {
+					if (motorwayTag.equals("motorway"))
+						motorwayCoords.addAll(w.getPoints());
+					else if (motorwayTag.equals("trunk"))
+						trunkCoords.addAll(w.getPoints());
+				}
+			}	
+		}
 		
 		
 		// remove the adjacent links from the destinationLinkWays list
@@ -462,6 +465,7 @@ public class LinkDestinationHook extends OsmReadingHooksAdaptor {
 		while (linksWithDestination.isEmpty()== false) {
 			Way linkWay = linksWithDestination.poll();
 			String destination = linkWay.getTag("destination");
+			
 
 			if (log.isDebugEnabled())
 				log.debug("Check way",linkWay.getId(),linkWay.toTagString());
@@ -708,18 +712,22 @@ public class LinkDestinationHook extends OsmReadingHooksAdaptor {
 	}
 
 	public Set<String> getUsedTags() {
-		if (processDestinations) {
-			// When processing destinations also load the destination:lanes,forward and backward tag 
-			// to be able to copy the value to the destination tag
-			// Do not load destination because it makes sense only if the tag is
-			// referenced in the style file
-			Set<String> tags = new HashSet<String>();
-			tags.add("destination:lanes");
-			tags.add("destination:forward");
-			tags.add("destination:backward");
-			return tags;
-		} else 
+		if (!(processDestinations || processExits))
 			return Collections.emptySet();
+		// When processing destinations also load the destination:lanes,forward and backward tag 
+		// to be able to copy the value to the destination tag
+		// Do not load destination because it makes sense only if the tag is
+		// referenced in the style file
+		Set<String> tags = new HashSet<String>();
+		tags.add("highway");
+		tags.add("destination:lanes");
+		tags.add("destination:forward");
+		tags.add("destination:backward");
+		if (processExits){
+			tags.add("exit_to");
+			tags.add("ref");
+		}
+		return tags;
 	}	
 
 	public void end() {
@@ -727,8 +735,6 @@ public class LinkDestinationHook extends OsmReadingHooksAdaptor {
 
 		retrieveWays();
 		
-//		if (processDestinations)
-//			processDestinations();
 		if (processExits || processDestinations)
 			processWays();
 		
diff --git a/src/uk/me/parabola/mkgmap/reader/osm/POIGeneratorHook.java b/src/uk/me/parabola/mkgmap/reader/osm/POIGeneratorHook.java
index 8da68e7..706e826 100644
--- a/src/uk/me/parabola/mkgmap/reader/osm/POIGeneratorHook.java
+++ b/src/uk/me/parabola/mkgmap/reader/osm/POIGeneratorHook.java
@@ -25,6 +25,7 @@ import java.util.Set;
 
 import uk.me.parabola.imgfmt.app.Coord;
 import uk.me.parabola.log.Logger;
+import uk.me.parabola.mkgmap.build.LocatorUtil;
 import uk.me.parabola.util.EnhancedProperties;
 
 /**
@@ -67,6 +68,7 @@ public class POIGeneratorHook extends OsmReadingHooksAdaptor {
 	
 	private boolean poisToAreas = false;
 	private boolean poisToLines = false;
+	private List<String> nameTags;
 	
 	/** Name of the bool tag that is set to true if a POI is created from an area */
 	public static final short AREA2POI_TAG = TagDict.getInstance().xlate("mkgmap:area2poi");
@@ -81,7 +83,8 @@ public class POIGeneratorHook extends OsmReadingHooksAdaptor {
 			log.info("Disable Areas2POIHook because add-pois-to-areas and add-pois-to-lines option is not set.");
 			return false;
 		}
-		
+		nameTags = LocatorUtil.getNameTags(props);
+
 		this.poiPlacementTags = getPoiPlacementTags(props);
 		
 		this.saver = saver;
@@ -337,6 +340,24 @@ public class POIGeneratorHook extends OsmReadingHooksAdaptor {
 		
 	}
 
+	/**
+	 * Retrieves the name of the given element based on the name-tag-list option.
+	 * @param e an OSM element
+	 * @return the name or <code>null</code> if the element has no name
+	 */
+	private String getName(Element e) {
+//		if (e.getName()!= null) {
+//			return e.getName();
+//		}
+		for (String nameTag : nameTags) {
+			String nameTagVal = e.getTag(nameTag);
+			if (nameTagVal != null) {
+				return nameTagVal;
+			}
+		}
+		return null;
+	}
+
 	private void addPOIsToMPs() {
 		int mps2POI = 0;
 		for (Relation r : saver.getRelations().values()) {
@@ -345,8 +366,29 @@ public class POIGeneratorHook extends OsmReadingHooksAdaptor {
 			if (r instanceof MultiPolygonRelation == false) {
 				continue;
 			}
-			
-			Coord point = ((MultiPolygonRelation)r).getCofG();
+			// boundary relations may have a node with role admin_centre, if yes, use the 
+			// location of it
+			Node existingPOI = null;
+			if ("boundary".equals(r.getTag("type")) && "administrative".equals(r.getTag("boundary"))){
+				for (Entry<String, Element> pair : r.getElements()){
+					String role = pair.getKey();
+					Element el = pair.getValue(); 
+					if ("admin_centre".equals(role)){
+						if (el instanceof Node){
+							String bName = getName(r);
+							String pName = getName(el);
+							if (bName != null && bName.equals(pName))
+								existingPOI = (Node) el;
+						}
+						break;
+					}
+				}
+			}
+			Coord point;
+			if (existingPOI ==null)
+				point = ((MultiPolygonRelation)r).getCofG();
+			else 
+				point = existingPOI.getLocation();
 			if (point == null) {
 				continue;
 			}

-- 
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