### Eclipse Workspace Patch 1.0 #P mkgmap Index: src/uk/me/parabola/mkgmap/reader/osm/xml/Osm5XmlHandler.java =================================================================== --- src/uk/me/parabola/mkgmap/reader/osm/xml/Osm5XmlHandler.java (revision 1506) +++ src/uk/me/parabola/mkgmap/reader/osm/xml/Osm5XmlHandler.java (working copy) @@ -1507,6 +1507,8 @@ int maxLong = a.getMaxLong(); log.info(String.format("getNextEdgeHit: (%d %d) (%d %d %d %d)", lat, lon, minLat, minLong, maxLat, maxLong)); + // correction for latitude to real distance (1 at equator, 0 at north or south pole) + double corFactor = Math.cos(lat); // shortest distance to border (init with distance to southern border) int min = lat - minLat; // number of edge as used in getEdgeHit. @@ -1518,7 +1520,7 @@ // normalized position at border (0..1) double l = ((double)(lon - minLong))/(maxLong-minLong); // now compare distance to eastern border with already known distance - if (maxLong - lon < min) { + if (((maxLong - lon) * corFactor) < min) { // update data if distance is shorter min = maxLong - lon; i = 1; @@ -1531,7 +1533,7 @@ l = ((double)(maxLong - lon))/(maxLong-minLong); } // same for western border - if (lon - minLong < min) { + if (((lon - minLong) * corFactor) < min) { i = 3; l = ((double)(maxLat - lat))/(maxLat-minLat); }