Index: src/uk/me/parabola/mkgmap/reader/osm/xml/Osm5XmlHandler.java =================================================================== --- src/uk/me/parabola/mkgmap/reader/osm/xml/Osm5XmlHandler.java (revision 1607) +++ src/uk/me/parabola/mkgmap/reader/osm/xml/Osm5XmlHandler.java (working copy) @@ -1175,8 +1175,9 @@ log.info("clipping " + segment); toBeRemoved.add(segment); for (List pts : clipped) { - long id = FakeIdGenerator.makeFakeId(); - Way shore = new Way(id, pts); + MultiPolygonRelation.JoinedWay shore = new MultiPolygonRelation.JoinedWay(false); + shore.addWay(segment); + shore.addPoints(pts); toBeAdded.add(shore); } } @@ -1295,9 +1296,8 @@ if(generateSeaUsingMP) seaRelation.addElement("inner", w); else { - if(!FakeIdGenerator.isFakeId(w.getId())) { - Way w1 = new Way(FakeIdGenerator.makeFakeId()); - w1.getPoints().addAll(w.getPoints()); + if(w instanceof MultiPolygonRelation.JoinedWay==false) { + MultiPolygonRelation.JoinedWay w1 = new MultiPolygonRelation.JoinedWay(w,false); // only copy the name tags for(String tag : w) if(tag.equals("name") || tag.endsWith(":name")) @@ -1309,8 +1309,10 @@ } } else if(allowSeaSectors) { - seaId = FakeIdGenerator.makeFakeId(); - sea = new Way(seaId); + MultiPolygonRelation.JoinedWay mpSeaWay = new MultiPolygonRelation.JoinedWay(false); + mpSeaWay.addWay(w); + sea = mpSeaWay; + seaId = sea.getId(); sea.getPoints().addAll(points); sea.addPoint(new Coord(pEnd.getLatitude(), pStart.getLongitude())); sea.addPoint(pStart); @@ -1352,9 +1354,8 @@ // now construct inner ways from these segments NavigableSet hits = (NavigableSet) hitMap.keySet(); while (!hits.isEmpty()) { - long id = FakeIdGenerator.makeFakeId(); - Way w = new Way(id); - wayMap.put(id, w); + MultiPolygonRelation.JoinedWay w = new MultiPolygonRelation.JoinedWay(false); + wayMap.put(w.getId(), w); EdgeHit hit = hits.first(); EdgeHit hFirst = hit; @@ -1365,6 +1366,7 @@ if (segment != null) { // add the segment and get the "ending hit" log.info("adding: ", segment); + w.addWay(segment); for(Coord p : segment.getPoints()) w.addPointIfNotEqualToLastPoint(p); hNext = getEdgeHit(seaBounds, segment.getPoints().get(segment.getPoints().size()-1)); @@ -1423,9 +1425,8 @@ for (Way w : islands) { - if(!FakeIdGenerator.isFakeId(w.getId())) { - Way w1 = new Way(FakeIdGenerator.makeFakeId()); - w1.getPoints().addAll(w.getPoints()); + if(w instanceof MultiPolygonRelation.JoinedWay==false) { + MultiPolygonRelation.JoinedWay w1 = new MultiPolygonRelation.JoinedWay(w, false); // only copy the name tags for(String tag : w) if(tag.equals("name") || tag.endsWith(":name")) @@ -1708,12 +1709,11 @@ if (w2 != null) { log.info("merging: ", ways.size(), w1.getId(), w2.getId()); List points2 = w2.getPoints(); - Way wm; - if (!FakeIdGenerator.isFakeId(w1.getId())) { - wm = new Way(FakeIdGenerator.makeFakeId()); + MultiPolygonRelation.JoinedWay wm; + if (w1 instanceof MultiPolygonRelation.JoinedWay == false) { + wm = new MultiPolygonRelation.JoinedWay(w1, false); ways.remove(w1); ways.add(wm); - wm.getPoints().addAll(points1); beginMap.put(points1.get(0), wm); // only copy the name tags for(String tag : w1) @@ -1721,8 +1721,9 @@ wm.addTag(tag, w1.getTag(tag)); } else { - wm = w1; + wm = (MultiPolygonRelation.JoinedWay)w1; } + wm.addWay(w2); wm.getPoints().addAll(points2); ways.remove(w2); beginMap.remove(points2.get(0)); @@ -1763,17 +1764,17 @@ if(nearest != null && smallestGap < maxCoastlineGap) { Coord w2s = nearest.getPoints().get(0); log.warn("Bridging " + (int)smallestGap + "m gap in coastline from " + w1e.toOSMURL() + " to " + w2s.toOSMURL()); - Way wm; - if (!FakeIdGenerator.isFakeId(w1.getId())) { - wm = new Way(FakeIdGenerator.makeFakeId()); + MultiPolygonRelation.JoinedWay wm; + if (w1 instanceof MultiPolygonRelation.JoinedWay == false) { + wm = new MultiPolygonRelation.JoinedWay(w1, false); ways.remove(w1); ways.add(wm); - wm.getPoints().addAll(points1); wm.copyTags(w1); } else { - wm = w1; + wm = (MultiPolygonRelation.JoinedWay)w1; } + wm.addWay(nearest); wm.getPoints().addAll(nearest.getPoints()); ways.remove(nearest); // make a line that shows the filled gap Index: src/uk/me/parabola/mkgmap/reader/osm/MultiPolygonRelation.java =================================================================== --- src/uk/me/parabola/mkgmap/reader/osm/MultiPolygonRelation.java (revision 1607) +++ src/uk/me/parabola/mkgmap/reader/osm/MultiPolygonRelation.java (working copy) @@ -1684,7 +1684,7 @@ * This is a helper class that stores that gives access to the original * segments of a joined way. */ - private static class JoinedWay extends Way { + public static class JoinedWay extends Way { private final List originalWays; private boolean closedArtificially = false; @@ -1693,10 +1693,15 @@ public int minLon; public int maxLon; private Rectangle bounds = null; + private final boolean autoAddTags; public JoinedWay(Way originalWay) { + this(originalWay,true); + } + public JoinedWay(Way originalWay, boolean autoAddTags) { super(FakeIdGenerator.makeFakeId(), new ArrayList( originalWay.getPoints())); + this.autoAddTags = autoAddTags; this.originalWays = new ArrayList(); addWay(originalWay); @@ -1708,11 +1713,27 @@ updateBounds(originalWay.getPoints()); } + public JoinedWay(boolean autoAddTags) { + super(FakeIdGenerator.makeFakeId()); + this.autoAddTags=autoAddTags; + this.originalWays = new ArrayList(); + minLat = Integer.MAX_VALUE; + minLon = Integer.MAX_VALUE; + maxLat = Integer.MIN_VALUE; + maxLon = Integer.MIN_VALUE; + } + public void addPoint(int index, Coord point) { getPoints().add(index, point); updateBounds(point); } + public void addPoints(List points) { + for (Coord c : points) { + addPoint(c); + } + } + public void addPoint(Coord point) { super.addPoint(point); updateBounds(point); @@ -1770,9 +1791,11 @@ log.debug("Joined", this.getId(), "with", way.getId()); } this.originalWays.add(way); - addTagsOf(way); - if (getName() == null && way.getName() != null) { - setName(way.getName()); + if (autoAddTags) { + addTagsOf(way); + if (getName() == null && way.getName() != null) { + setName(way.getName()); + } } } }