[mkgmap-dev] [PATCH v1] Merge from the mp branch
The attached patch contains a merge from the mp branch and fixes lots of multipolygon issues. I have also added some more javadoc and code comments, renamed methods and variables and removed not very useful logging statements. The mp branch is no longer needed. WanMil Index: src/uk/me/parabola/mkgmap/reader/osm/xml/Osm5XmlHandler.java === --- src/uk/me/parabola/mkgmap/reader/osm/xml/Osm5XmlHandler.java (revision 1484) +++ src/uk/me/parabola/mkgmap/reader/osm/xml/Osm5XmlHandler.java (working copy) @@ -20,9 +20,8 @@ import java.io.DataInputStream; import java.io.FileInputStream; import java.io.FileNotFoundException; -import java.io.InputStreamReader; import java.io.IOException; - +import java.io.InputStreamReader; import java.util.AbstractMap; import java.util.ArrayList; import java.util.HashMap; @@ -37,6 +36,12 @@ import java.util.SortedMap; import java.util.TreeMap; +import org.xml.sax.Attributes; +import org.xml.sax.ContentHandler; +import org.xml.sax.SAXException; +import org.xml.sax.SAXParseException; +import org.xml.sax.helpers.DefaultHandler; + import uk.me.parabola.imgfmt.app.Area; import uk.me.parabola.imgfmt.app.Coord; import uk.me.parabola.imgfmt.app.Exit; @@ -46,6 +51,7 @@ import uk.me.parabola.mkgmap.general.RoadNetwork; import uk.me.parabola.mkgmap.reader.osm.CoordPOI; import uk.me.parabola.mkgmap.reader.osm.Element; +import uk.me.parabola.mkgmap.reader.osm.FakeIdGenerator; import uk.me.parabola.mkgmap.reader.osm.GeneralRelation; import uk.me.parabola.mkgmap.reader.osm.MultiPolygonRelation; import uk.me.parabola.mkgmap.reader.osm.Node; @@ -55,12 +61,6 @@ import uk.me.parabola.mkgmap.reader.osm.Way; import uk.me.parabola.util.EnhancedProperties; -import org.xml.sax.Attributes; -import org.xml.sax.ContentHandler; -import org.xml.sax.SAXException; -import org.xml.sax.SAXParseException; -import org.xml.sax.helpers.DefaultHandler; - /** * Reads and parses the OSM XML format. * @@ -92,8 +92,6 @@ private static final long CYCLEWAY_ID_OFFSET = 0x1000; - private static final long FAKE_ID_BASE = 1L 62; - private Node currentNode; private Way currentWay; private Node currentNodeInWay; @@ -106,8 +104,6 @@ private Area bbox; private Runnable endTask; - private long nextFakeId = 1; - private final boolean reportUndefinedNodes; private final boolean makeOppositeCycleways; private final boolean makeCycleways; @@ -1054,14 +1050,6 @@ super.fatalError(e); } - public long makeFakeId() { - return FAKE_ID_BASE + nextFakeId++; - } - - public boolean isFakeId(long id) { - return id = FAKE_ID_BASE; - } - private long idVal(String id) { try { // attempt to parse id as a number @@ -1071,7 +1059,7 @@ // if that fails, fake a (hopefully) unique value Long fakeIdVal = fakeIdMap.get(id); if(fakeIdVal == null) { - fakeIdVal = makeFakeId(); + fakeIdVal = FakeIdGenerator.makeFakeId(); fakeIdMap.put(id, fakeIdVal); } //System.out.printf(%s = 0x%016x\n, id, fakeIdVal); @@ -1096,7 +1084,7 @@ log.info(clipping + segment); toBeRemoved.add(segment); for (ListCoord pts : clipped) { - long id = makeFakeId(); + long id = FakeIdGenerator.makeFakeId(); Way shore = new Way(id, pts); toBeAdded.add(shore); } @@ -1123,7 +,7 @@ // polygon so that the tile's background colour will // match the land colour on the tiles that do contain // some sea - long landId = makeFakeId(); + long landId = FakeIdGenerator.makeFakeId(); Way land = new Way(landId); land.addPoint(nw); land.addPoint(sw); @@ -1137,7 +1125,7 @@ return; } - long multiId = makeFakeId(); + long multiId = FakeIdGenerator.makeFakeId(); Relation seaRelation = null; if(generateSeaUsingMP) { seaRelation = new GeneralRelation(multiId); @@ -1173,8 +1161,8 @@ if(generateSeaUsingMP) seaRelation.addElement(inner, w); else {
Re: [mkgmap-dev] [PATCH v1] Merge from the mp branch
Hi WanMil, The attached patch contains a merge from the mp branch and fixes lots of multipolygon issues. I have also added some more javadoc and code comments, renamed methods and variables and removed not very useful logging statements. The mp branch is no longer needed. I tried making the Baltic map using this version of the MP code and --generate-sea=multipolygon,no-sea-sectors I received a lot of messages like this: 2010/01/16 21:06:59 WARNING (MultiPolygonRelation): Unclosed polygons in multipolygon relation 27016: 2010/01/16 21:06:59 WARNING (MultiPolygonRelation): - way: 29411823 role: outer osm: http://www.openstreetmap.org/browse/way/29411823 2010/01/16 21:06:59 WARNING (MultiPolygonRelation): - way: 30108097 role: outer osm: http://www.openstreetmap.org/browse/way/30108097 2010/01/16 21:06:59 WARNING (MultiPolygonRelation): - way: 29413658 role: outer osm: http://www.openstreetmap.org/browse/way/29413658 and: 2010/01/16 21:07:00 SEVERE (MultiPolygonRelation): Multipolygon http://www.openstreetmap.org/browse/relation/51154 contains intersected ways 2010/01/16 21:07:00 SEVERE (MultiPolygonRelation): - http://www.openstreetmap.org/browse/way/4611686018427387987 I guess that last way (with the fake id) is some joined up coastline segments. (incidentally, there's no point in creating an OSM URL for elements with fake ids, perhaps we should spot the fake ids and output something more appropriate). Anyway, the resulting map has a few nice islands but all of the land mass that touches the edges of a tile is flooded. I tried a couple of the tiles with the old MP code and the flooding went away so I think it's the new code rather than the generate-sea code that's causing the flooding. Mark ___ mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
Re: [mkgmap-dev] [PATCH v1] Merge from the mp branch
Am 16.01.2010 22:31, schrieb Mark Burton: Hi WanMil, The attached patch contains a merge from the mp branch and fixes lots of multipolygon issues. I have also added some more javadoc and code comments, renamed methods and variables and removed not very useful logging statements. The mp branch is no longer needed. I tried making the Baltic map using this version of the MP code and --generate-sea=multipolygon,no-sea-sectors I received a lot of messages like this: 2010/01/16 21:06:59 WARNING (MultiPolygonRelation): Unclosed polygons in multipolygon relation 27016: 2010/01/16 21:06:59 WARNING (MultiPolygonRelation): - way: 29411823 role: outer osm: http://www.openstreetmap.org/browse/way/29411823 2010/01/16 21:06:59 WARNING (MultiPolygonRelation): - way: 30108097 role: outer osm: http://www.openstreetmap.org/browse/way/30108097 2010/01/16 21:06:59 WARNING (MultiPolygonRelation): - way: 29413658 role: outer osm: http://www.openstreetmap.org/browse/way/29413658 and: 2010/01/16 21:07:00 SEVERE (MultiPolygonRelation): Multipolygon http://www.openstreetmap.org/browse/relation/51154 contains intersected ways 2010/01/16 21:07:00 SEVERE (MultiPolygonRelation): - http://www.openstreetmap.org/browse/way/4611686018427387987 I guess that last way (with the fake id) is some joined up coastline segments. (incidentally, there's no point in creating an OSM URL for elements with fake ids, perhaps we should spot the fake ids and output something more appropriate). Anyway, the resulting map has a few nice islands but all of the land mass that touches the edges of a tile is flooded. I tried a couple of the tiles with the old MP code and the flooding went away so I think it's the new code rather than the generate-sea code that's causing the flooding. Mark Mark, I will try to reproduce your errors and to improve the error messages. Which dump do you use for your Baltic map? WanMil ___ mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
Re: [mkgmap-dev] [PATCH v1] Merge from the mp branch
Yeah, the islands are not bad but the main land masses are all flooded. There's a lot of spurious crap when you zoom out but that (almost completely) goes away if you use the patch I posted earlier this evening. Mark ___ mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
Re: [mkgmap-dev] [PATCH v1] Merge from the mp branch
WanMil, I will try to reproduce your errors and to improve the error messages. I wasn't complaining about the quality of the messages, merely telling you that they were happening. Which dump do you use for your Baltic map? I grabbed it with XAPI (a mistake as it was about 2GB uncompressed) and have merged some other stuff into it. So to make life easy, I have uploaded a tile that you can try to: http://www.smartavionics.com/OSM/63240006.osm.gz That tile has land in the bottom half and a few islands. Mark ___ mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
Re: [mkgmap-dev] [PATCH v1] Merge from the mp branch
WanMil, I will try to reproduce your errors and to improve the error messages. I wasn't complaining about the quality of the messages, merely telling you that they were happening. You should complain :-) Logging fake ids does not help anyone to have a look on the OSM data. The warnings you see indicate wrong OSM data (an inner way intersects an outer way) OR it indicates problems with the tiles. In any case one must have the chance to check that. Which dump do you use for your Baltic map? I grabbed it with XAPI (a mistake as it was about 2GB uncompressed) and have merged some other stuff into it. So to make life easy, I have uploaded a tile that you can try to: http://www.smartavionics.com/OSM/63240006.osm.gz That tile has land in the bottom half and a few islands. Mark That's great. I will grab it now and check it tomorrow. I suppose that the problem is the autoclosing mechanism. The new multipolygon code tries to close ways by just readding the first point. I think I must add a bounding box check (if first and last point of an unclosed polygon touches the bounding box then the polygon is complemented by the bounding box - otherwise the simple algorithm is taken) WanMil ___ mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev