logo separator

[mkgmap-dev] Background in polish format reader

From Andrzej Popowski popej at poczta.onet.pl on Thu Mar 12 15:25:37 GMT 2020

Hi,

the following quote from cGPSmapper describes peculiarities of command 
"Background=Y":

If there is only one object set as the background, then the
EndLevel is automatically set to 9.
If there is no background object, or more than one, then the
EndLevel is not changed.

As I understand, background is a special object for cGPSmapper. If there 
is only single background in a source, then compiler can modify EndLevel 
value.

Mkgmap doesn't change EndLevel. I prepared a patch, that simply extends 
EndLevel for any background object, which contains only "Data0=" layer. 
I hope this should work for most cases.

Proper solution would be to count all background objects and 
conditionally modify single background after reading an entire source file.

-- 
Best regards,
Andrzej
-------------- next part --------------
Index: src/uk/me/parabola/mkgmap/reader/polish/PolishMapDataSource.java
===================================================================
--- src/uk/me/parabola/mkgmap/reader/polish/PolishMapDataSource.java	(revision 4465)
+++ src/uk/me/parabola/mkgmap/reader/polish/PolishMapDataSource.java	(working copy)
@@ -104,6 +104,8 @@
 	private int endLevel;
 	private char elevUnits;
 	private int currentLevel;
+	private boolean dataHighLevel;
+	private boolean background;
 	private int poiDispFlag;
 	private String defaultCountry;
 	private String defaultRegion;
@@ -306,6 +308,8 @@
 			if (!lineStringMap.isEmpty()) {
 				if (extraAttributes != null && shape.hasExtendedType())
 					shape.setExtTypeAttributes(makeExtTypeAttributes());
+				if (background && !dataHighLevel)
+					endLevel = levels.length -1;
 				for (Map.Entry<Integer , List<List<Coord>>> entry : lineStringMap.entrySet()) {
 					setResolution(shape, entry.getKey());
 					addShapesFromPattern(entry.getValue());
@@ -329,6 +333,8 @@
 		endLevel = 0;
 		lineStringMap.clear();
 		currentLevel = 0;
+		dataHighLevel = false;
+		background = false;
 	}
 
 	private void addShapesFromPattern(List<List<Coord>> pointsLists) {
@@ -595,6 +601,9 @@
 		} else if (name.startsWith("Data")) {
 			extractResolution(name);
 			addLineString(value, true);
+		} else if (name.equals("Background")) {
+			if ("Y".equals(value))
+				background = true;
 		}
 		else {
 			if(extraAttributes == null)
@@ -765,6 +774,8 @@
 	 */
 	private int extractResolution(String name) {
 		currentLevel = Integer.parseInt(name.substring(name.charAt(0) == 'O'? 6: 4));
+		if (currentLevel > 0)
+			dataHighLevel = true;
 		return extractResolution(currentLevel);
 	}
 


More information about the mkgmap-dev mailing list