Hi WanMil,
By the way, how could I fix this kind of messages:
2010/03/17 07:06:33 WARNING (MultiPolygonRelation): 63240003.osm.gz: Polygon 461
1686018427476479(16P : (4611686018427472578[16P]) carries role inner but lies in
side an inner polygon. Potentially its role should be outer.
Could the message include the way ID?
Marko
You don't see it but the message includes the way id:-) It is an
artificially generated way (4611686018427472578) from the generate-sea
algorithm so there is no "original" OSM way id.
I do understand that there is no OSM relation ID for generate-sea, but
I do not understand how there could be no way ID. The natural=coastline
are genuine OSM ways, aren't they?
Yes they are genuine OSM ways. But these ways are assembled by the
generate-sea algorithm to polygons which get a new artificial id (the
4611686018427472578). The multipolygon algorithm does not have any
knowledge about the source OSM ways and their ids so it is not possible
to create a more detailed log message at that point.
Why are these messages generated? Generate-sea is not complaining anything,
now that my script strips any incomplete islands from the extract and patches
the mainland coastline so that it will reach the tile borders. Also the map
is looking good. It is not really a big deal. I have been grepping away
the generated IDs from the output, in addition to selected IDs that I have
analyzed before (splitter or Geofabrik's osmosis problem).
The messages are generated because the generate-sea algorithm generated
two polygons with role=inner and one of these polygons lies inside the
other. I don't know if that's a bug of the generate-sea code or if the
OSM data has a problem.
I have tried a quick patch so that the mp code can output the original
way ids if there is a problem. This patch should NOT be committed. It is
not tested....
But hopefully it can help you to find the problem you've had.
You will get messages like:
Polygon 4611686018427482402(128P : (4603087[82P],4603088[46P]) carries
role inner but is not inside any other polygon. Potentially it does not
belong to this multipolygon.
The first id (4611686018427482402) is the artificial id. The ids in the
list (4603087, 4603088) are the original OSM ids.
WanMil
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<Coord> 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<EdgeHit> hits = (NavigableSet<EdgeHit>)
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<Coord> 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<Way> 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<Coord>(
originalWay.getPoints()));
+ this.autoAddTags = autoAddTags;
this.originalWays = new ArrayList<Way>();
addWay(originalWay);
@@ -1708,11 +1713,27 @@
updateBounds(originalWay.getPoints());
}
+ public JoinedWay(boolean autoAddTags) {
+ super(FakeIdGenerator.makeFakeId());
+ this.autoAddTags=autoAddTags;
+ this.originalWays = new ArrayList<Way>();
+ 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<Coord> 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());
+ }
}
}
}
_______________________________________________
mkgmap-dev mailing list
[email protected]
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev