Re: [mkgmap-dev] [PATCH v1] Multipolygon: Allow nested inner polygons

2010-03-05 Thread WanMil
 I have found that some multipolygons use nested inner polygons.
 Example:
 * A forest (outer) with a lake (inner) that has an island (inner) which
 is not a forest. (example:
 http://www.openstreetmap.org/browse/relation/331402)

 By definition of the multipolygon relation
 (http://wiki.openstreetmap.org/wiki/Relation:multipolygon) one has to
 create two mps. But I see that it is a nice simplification lots of
 mappers are using.

 Attached patch handles this situation.
 The inner and outer roles are now used as follows:
 * the outmost polygon must have role=outer (or role=empty)
 * all outmost polygons with role=inner are not used (a warning is issued)
 * all inside polygons with role=inner use their own tagging
 * all inside polygons with role=outer use the mp tagging if available or
 their own tagging if the mp is not tagged
 * all inside polygons with role=empty are categorized automatically as
 outer/inner depending on the nest level
 * all inside polygons with role=outer without a direct ambient inner
 polygon are dropped with a warning message (outer in outer polygon)

 Most of the renderers do not support inner in inner polygons but I think
 it is a very reasonable extension of the multipolygon handling.

 This patch also improves the error messages. I haven't seen any more
 are not processed due to an unknown reason messages and I look forward
 that the community will also not be able to generate any more ... ;-)

 WanMil


There have been different opinions about this patch.

There is one controversal point:
Should mkgmap allow nested inner polygons?

 From my point of view: YES. Because it does not harm in any way. The 
nested inner polygons I analysed were all reasonable. Ok, they are not 
100% compliant to the specification but this is common to lots of others 
things in (anarchic) OSM.

At the moment I see two possible changes:
1. Issue a warning for any nested inner polygon but process it anyhow.
2. Reject nested inner polygons (and issue a warning). What a pity but 
they are not 100% compliant.

Please let me know what's the opinion of mkgmap community and committers 
because I want the improvements of error messages to be committed.

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] Multipolygon: Allow nested inner polygons

2010-03-03 Thread Torsten Leistikow
Jeffrey Ollie schrieb am 02.03.2010 21:07:
 I've listened to that argument for a while and I'm tired of it.

And I have tried to fight this anarchy and I got tired of it. So I accepted it
as a fact and became much more relaxed and satisfied with OSM :-)

Gruss
Torsten
___
mkgmap-dev mailing list
mkgmap-dev@lists.mkgmap.org.uk
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev


Re: [mkgmap-dev] [PATCH v1] Multipolygon: Allow nested inner polygons

2010-03-02 Thread WanMil
 WanMil schrieb:
 I have found that some multipolygons use nested inner polygons.
 Example:
 * A forest (outer) with a lake (inner) that has an island (inner) which
 is not a forest. (example:
 http://www.openstreetmap.org/browse/relation/331402)

 But neither mapnik nor osmarender show the inner-inner island (wood),
 because this construct is not a valid advanced-multipolygon.

 Chris


The patch supports the complete multipolygon specification. And 
additionally it is tolerant towards incorrect (but reasonable) 
multipolygons.
So why should mkgmap be restrictive if it doesn't need to?

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] Multipolygon: Allow nested inner polygons

2010-03-02 Thread Torsten Leistikow
WanMil schrieb am 02.03.2010 18:48:
 The patch supports the complete multipolygon specification. And 
 additionally it is tolerant towards incorrect (but reasonable) 
 multipolygons.
 So why should mkgmap be restrictive if it doesn't need to?

Since there is not really a specification for the OSM tagging, mkgmap should not
check the data for correctness but try to support as much taggings as possible.
So for example in a style file you must also check for typical typing errors,
e.g. centre vs center.

Gruss
Torsten
___
mkgmap-dev mailing list
mkgmap-dev@lists.mkgmap.org.uk
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev


Re: [mkgmap-dev] [PATCH v1] Multipolygon: Allow nested inner polygons

2010-03-02 Thread Jeffrey Ollie
On Tue, Mar 2, 2010 at 1:12 PM, Torsten Leistikow de_m...@gmx.de wrote:
 WanMil schrieb am 02.03.2010 18:48:
 The patch supports the complete multipolygon specification. And
 additionally it is tolerant towards incorrect (but reasonable)
 multipolygons.
 So why should mkgmap be restrictive if it doesn't need to?

 Since there is not really a specification for the OSM tagging, mkgmap should 
 not
 check the data for correctness but try to support as much taggings as 
 possible.
 So for example in a style file you must also check for typical typing errors,
 e.g. centre vs center.

I've listened to that argument for a while and I'm tired of it.
Complete anarchy when tagging make writing software to use OSM data
incredibly difficult.  At some point people are going to have to grow
up and come to an agreement on tagging standards and then stick to it.

-- 
Jeff Ollie
___
mkgmap-dev mailing list
mkgmap-dev@lists.mkgmap.org.uk
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev


Re: [mkgmap-dev] [PATCH v1] Multipolygon: Allow nested inner polygons

2010-03-02 Thread WanMil
 On Tue, Mar 2, 2010 at 1:12 PM, Torsten Leistikowde_m...@gmx.de  wrote:
 WanMil schrieb am 02.03.2010 18:48:
 The patch supports the complete multipolygon specification. And
 additionally it is tolerant towards incorrect (but reasonable)
 multipolygons.
 So why should mkgmap be restrictive if it doesn't need to?

 Since there is not really a specification for the OSM tagging, mkgmap should 
 not
 check the data for correctness but try to support as much taggings as 
 possible.
 So for example in a style file you must also check for typical typing errors,
 e.g. centre vs center.

 I've listened to that argument for a while and I'm tired of it.
 Complete anarchy when tagging make writing software to use OSM data
 incredibly difficult.  At some point people are going to have to grow
 up and come to an agreement on tagging standards and then stick to it.


Ok, so revert the description of the patch:
* The patch detects polygons with role=outer that is inside another 
polygon with role=outer and issues a warning for that.

The inner in inner case is a well known error :-)

WanMil
___
mkgmap-dev mailing list
mkgmap-dev@lists.mkgmap.org.uk
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev


[mkgmap-dev] [PATCH v1] Multipolygon: Allow nested inner polygons

2010-03-01 Thread WanMil

I have found that some multipolygons use nested inner polygons.
Example:
* A forest (outer) with a lake (inner) that has an island (inner) which 
is not a forest. (example: 
http://www.openstreetmap.org/browse/relation/331402)


By definition of the multipolygon relation 
(http://wiki.openstreetmap.org/wiki/Relation:multipolygon) one has to 
create two mps. But I see that it is a nice simplification lots of 
mappers are using.


Attached patch handles this situation.
The inner and outer roles are now used as follows:
* the outmost polygon must have role=outer (or role=empty)
* all outmost polygons with role=inner are not used (a warning is issued)
* all inside polygons with role=inner use their own tagging
* all inside polygons with role=outer use the mp tagging if available or 
their own tagging if the mp is not tagged
* all inside polygons with role=empty are categorized automatically as 
outer/inner depending on the nest level
* all inside polygons with role=outer without a direct ambient inner 
polygon are dropped with a warning message (outer in outer polygon)


Most of the renderers do not support inner in inner polygons but I think 
it is a very reasonable extension of the multipolygon handling.


This patch also improves the error messages. I haven't seen any more 
are not processed due to an unknown reason messages and I look forward 
that the community will also not be able to generate any more ... ;-)


WanMil

Index: src/uk/me/parabola/mkgmap/reader/osm/MultiPolygonRelation.java
===
--- src/uk/me/parabola/mkgmap/reader/osm/MultiPolygonRelation.java  
(revision 1593)
+++ src/uk/me/parabola/mkgmap/reader/osm/MultiPolygonRelation.java  
(working copy)
@@ -1,6 +1,7 @@
 package uk.me.parabola.mkgmap.reader.osm;
 
-import java.awt.*;
+import java.awt.Polygon;
+import java.awt.Rectangle;
 import java.awt.geom.Area;
 import java.awt.geom.Line2D;
 import java.awt.geom.PathIterator;
@@ -479,14 +480,19 @@
}
 
private ArrayListPolygonStatus getPolygonStatus(BitSet 
outmostPolygons,
-   boolean outer) {
+   String defaultRole) {
ArrayListPolygonStatus polygonStatusList = new 
ArrayListPolygonStatus();
for (int polyIndex = outmostPolygons.nextSetBit(0); polyIndex 
= 0; polyIndex = outmostPolygons
.nextSetBit(polyIndex + 1)) {
// polyIndex is the polygon that is not contained by 
any other
// polygon
JoinedWay polygon = polygons.get(polyIndex);
-   polygonStatusList.add(new PolygonStatus(outer, 
polyIndex, polygon));
+   String role = getRole(polygon);
+   // if the role is not explicitly set use the default 
role
+   if (role == null || .equals(role)) {
+   role = defaultRole;
+   } 
+   polygonStatusList.add(new 
PolygonStatus(outer.equals(role), polyIndex, polygon));
}
return polygonStatusList;
}
@@ -511,16 +517,17 @@
}
}
 
+   // join all single ways to polygons, try to close ways and 
remove non closed ways 
polygons = joinWays(allWays);
closeWays(polygons);
removeUnclosedWays(polygons);
 
-   // now we have closed ways == polygons only
+   // now only closed ways are left = polygons only
 
// check if we have at least one polygon left
if (polygons.isEmpty()) {
// do nothing
-   log.warn(Multipolygon  + toBrowseURL()
+   log.info(Multipolygon  + toBrowseURL()
+  does not contain a closed 
polygon.);
cleanup();
return;
@@ -538,21 +545,29 @@
 
// the intersectingPolygons marks all intersecting/overlapping 
polygons
intersectingPolygons = new HashSetJoinedWay();
+   
+   // check which polygons lie inside which other polygon 
createContainsMatrix(polygons);
 
+   // unfinishedPolygons marks which polygons are not yet processed
BitSet unfinishedPolygons = new BitSet(polygons.size());
unfinishedPolygons.set(0, polygons.size());
 
// create bitsets which polygons belong to the outer and to the 
inner role
BitSet innerPolygons = new BitSet();
+   BitSet taggedInnerPolygons = new BitSet();
BitSet outerPolygons = new BitSet();
+   BitSet taggedOuterPolygons = new BitSet();
+   
int wi = 0;
for (Way w : polygons) {

Re: [mkgmap-dev] [PATCH v1] Multipolygon: Allow nested inner polygons

2010-03-01 Thread Chris-Hein Lunkhusen
WanMil schrieb:
 I have found that some multipolygons use nested inner polygons.
 Example:
 * A forest (outer) with a lake (inner) that has an island (inner) which
 is not a forest. (example:
 http://www.openstreetmap.org/browse/relation/331402)

But neither mapnik nor osmarender show the inner-inner island (wood),
because this construct is not a valid advanced-multipolygon.

Chris

___
mkgmap-dev mailing list
mkgmap-dev@lists.mkgmap.org.uk
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev