logo separator

[mkgmap-dev] Corrections for mp reader

From Andrzej Popowski popej at poczta.onet.pl on Sun Dec 21 16:32:24 GMT 2014

Hi,

I have made 3 simple corrections for reader of Polish mp format. 
Proposed patch is included.

1. Line RouteParam= have most parameters optional, "oneway" and "toll" 
too. Mkgmap should use defaults, when parameters are missing. Probably 
there should be syntax check added, but I don't know how to invoke exit 
with error message.

2. CGPSmapper supports multiple labels, I have added support for lines 
"Label2=" and "Label3=".

3. Country name can have separator and short name. I have included 
function unescape() for "Country=".

-- 
Best regards,
Andrzej
-------------- next part --------------
--- src/uk/me/parabola/mkgmap/general/MapElement.java	2013-12-29 01:00:05.255294100 +0100
+++ src/uk/me/parabola/mkgmap/general/MapElement.java	2014-12-21 15:21:25.062799600 +0100
@@ -78,6 +78,15 @@
 		this.labels[0] = name;
 	}
 
+	public void add2Name(String name) {
+		for (int i = 1; i < 4; i++) {
+			if (this.labels[i] == null) {
+				this.labels[i] = name;
+				break;
+			}
+		}
+	}
+
 	public void setLabels(String[] labels) {
 		this.labels = Arrays.copyOf(labels, 4);
 	}
--- src/uk/me/parabola/mkgmap/reader/polish/PolishMapDataSource.java	2014-12-08 15:48:50.073510300 +0100
+++ src/uk/me/parabola/mkgmap/reader/polish/PolishMapDataSource.java	2014-12-21 15:07:19.816915200 +0100
@@ -484,6 +484,8 @@
 	private boolean isCommonValue(MapElement elem, String name, String value) {
 		if (name.equals("Label")) {
 			elem.setName(unescape(recode(value)));
+		}else if (name.equals("Label2") || name.equals("Label3")) {
+			elem.add2Name(unescape(recode(value)));
 		} else if (name.equals("Levels") || name.equals("EndLevel") || name.equals("LevelsNumber")) {
 			try {
 				endLevel = Integer.valueOf(value);
@@ -503,7 +505,7 @@
 		} else if (name.equals("Phone")) {
 		  elem.setPhone(recode(value));			
 		} else if (name.equals("CountryName")) {
-		  elem.setCountry(recode(value));
+		  elem.setCountry(unescape(recode(value)));
 		} else if (name.equals("RegionName")) {
 			//System.out.println("RegionName " + value);
 		  elem.setRegion(recode(value));				
--- src/uk/me/parabola/mkgmap/reader/polish/RoadHelper.java	2014-06-25 16:52:16.956860000 +0200
+++ src/uk/me/parabola/mkgmap/reader/polish/RoadHelper.java	2014-12-21 14:24:37.760538400 +0100
@@ -101,8 +101,8 @@
 			roadClass = 0;
 		if (roadClass > 4)
 			roadClass = 4;
-		oneway = Integer.parseInt(f[2]) > 0;
-		toll = Integer.parseInt(f[3]) > 0;
+		oneway = (f.length > 2) ? Integer.parseInt(f[2]) > 0: false;
+		toll = (f.length > 3) ? Integer.parseInt(f[3]) > 0: false;
 		byte noAccess = 0;
 		for (int j = 0; j < f.length - 4; j++){
 			if (Integer.parseInt(f[4+j]) == 0)


More information about the mkgmap-dev mailing list