logo separator

[mkgmap-dev] Commit r3743: Reduce rounding error when saving initial heading in compacted format

From Andrzej Popowski popej at poczta.onet.pl on Thu Jan 12 01:21:45 GMT 2017

Hi Gerd,

please check this patch, I think problem appears because of similar 
rounding error in AngleChecker.

-- 
Best Regards,
Andrzej
-------------- next part --------------
Index: src/uk/me/parabola/imgfmt/app/net/AngleChecker.java
===================================================================
--- src/uk/me/parabola/imgfmt/app/net/AngleChecker.java	(revision 3747)
+++ src/uk/me/parabola/imgfmt/app/net/AngleChecker.java	(working copy)
@@ -54,6 +54,7 @@
 	private final int MIN_LOW_SPEED_ANGLE = 0x20;
 
 	private int mask;
+	private int mrnd;
 
 	// helper class to collect multiple arcs with (nearly) the same initial headings
 	private class ArcGroup {
@@ -95,7 +96,7 @@
 			while (modIH < -180)
 				modIH += 360; 
 			initialHeading = modIH;
-			imgHeading = (byte) (RouteArc.directionFromDegrees(initialHeading) & mask); 
+			imgHeading = (byte) ((RouteArc.directionFromDegrees(initialHeading) + mrnd) & mask); 
 			
 			for (RouteArc arc : arcs){
 				arc.setInitialHeading(modIH);
@@ -129,6 +130,7 @@
 
 			for (RouteNode node : nodes.values()){
 				mask = 0xf0; // we assume compacted format
+				mrnd = 0x08; // rounding
 				fixSharpAngles(node, sharpAnglesCheckMask);				
 			}
 		}
@@ -393,7 +395,7 @@
 			}
 		}
 		for (ArcGroup ag : arcGroups){
-			ag.imgHeading = (byte) (RouteArc.directionFromDegrees(ag.initialHeading) & mask);
+			ag.imgHeading = (byte) ((RouteArc.directionFromDegrees(ag.initialHeading) + mrnd) & mask);
 		}
 		return arcGroups;
 	}


More information about the mkgmap-dev mailing list