Index: RoadHelper.java =================================================================== --- RoadHelper.java (revision 723) +++ RoadHelper.java (working copy) @@ -21,6 +21,7 @@ import java.util.Map; import java.util.HashMap; +import uk.me.parabola.log.Logger; import uk.me.parabola.imgfmt.app.Coord; import uk.me.parabola.imgfmt.app.CoordNode; import uk.me.parabola.mkgmap.general.MapLine; @@ -32,10 +33,11 @@ * can occur in any order. */ class RoadHelper { + private static final Logger log = Logger.getLogger(RoadHelper.class); + private boolean hasRoads; private int roadId; - private int lastNodeIndex; - private List nodes = new ArrayList(); + private Map nodes = new HashMap(); private Map nodeCoords = new HashMap(); private RoadNetwork roadNetwork; @@ -49,7 +51,6 @@ public void clear() { roadId = 0; - lastNodeIndex = 0; nodes.clear(); road = null; } @@ -60,19 +61,17 @@ } public void addNode(int nodeIndex, String value) { - if (nodeIndex < lastNodeIndex) - return; - lastNodeIndex = nodeIndex; + if (nodes.containsKey(nodeIndex)) + log.warn("duplicate nodeidx %d, overwriting", nodeIndex); String[] f = value.split(","); // f[0] is the index into the line // f[1] is the node id - nodes.add(new NodeIndex(f[0], f[1])); + nodes.put(nodeIndex, new NodeIndex(f[0], f[1])); } public void addLine(MapLine l) { - if (roadId == 0) - return; - + if (road != null) + log.warn("multiple lines, overwriting"); road = new MapRoad(roadId, l); } @@ -87,15 +86,16 @@ if (roadId == 0) return; - System.out.printf("Road id %d\n", roadId); + log.debug("finishing road id " + roadId); // Set class and speed road.setRoadClass(roadClass); road.setSpeed(speed); - for (NodeIndex ni : nodes) { + for (NodeIndex ni : nodes.values()) { int n = ni.index; List points = road.getPoints(); + log.debug("road has " + points.size() +" points"); Coord coord = points.get(n); long id = coord.getId(); if (id == 0) { Index: PolishMapDataSource.java =================================================================== --- PolishMapDataSource.java (revision 723) +++ PolishMapDataSource.java (working copy) @@ -262,7 +262,6 @@ polyline.setType(Integer.decode(value)); } else if (name.startsWith("Data")) { List points = coordsFromString(value); - // If it is a contour line, then fix the elevation if required. if ((polyline.getType() == 0x20) || (polyline.getType() == 0x21) || @@ -285,7 +284,7 @@ } private List coordsFromString(String value) { - String[] ords = value.split("\\),\\("); + String[] ords = value.split("\\) *, *\\("); List points = new ArrayList(); for (String s : ords) { @@ -295,6 +294,7 @@ mapper.addToBounds(co); points.add(co); } + log.debug(points.size() + " points from " + value); return points; }