In my styles, I want to render closed waterway polygons as areas by using the
continue statement in my lines:
waterway=canal & natural!=water [0x1f resolution 23 continue]
polygons file:
waterway=canal [0x3c resolution 23]
Those closed bodies are rendered ok now, filled with water. If this waterway
area consists of two or more separate ways, connected to each other,
this is not rendered as water polygon but only as linear elements, which is
excellent.
Problem arise at the tile borders, where I get unwanted side effects, linear
elements of waterways that cross the tiles are automatically closed by mkgmap
and therefore rendered as areas (filled up with water), which I do not want. I
like to distinguish those artifical polygons in my style file from the really
closed waterway polygons. Are those artifcially closed polygons tagged
internally by mkgmap somehow, so I can exclude them from my polygon style?
No. This situation cannot be detected by the style file. At the moment
all ways with both endpoints outside the bbox are closed automatically.
I have attached a patch that does exactly what you want.
All ways are now tagged with two additional tags:
mkgmap:wayclosed true/false - signals if a way is closed (first point ==
last point)
mkgmap:autoclosing true/false - true if both end points of the way are
outside the bbox and the way is automatically closed if a polygon rule
matches.
The patch is superfluous if splitter ensures that a closed way is closed
in all splitted tiles.
WanMil
Background:
In the Netherlands there are tons of areas of water tagged as waterway=*
(canal, drain, river).
According to the wiki this tagging is wrong (for polygons natural=water should
be used, or for bigger rivers, waterway=riverbank).
But since Potlatch, Josm and Mapnik automatically render closed waterways as
areas, many mappers are making this mistake.
(One could argue if maybe the wiki should be revised, why is only
waterway=riverbank a polygon and a closed body of waterway=river not?)
In Potlatch all natural=water polygons are called "Lake" so many mappers want
to 'improve' those areas by tagging them as waterways.
I have tried to contact the Potlatch developers about this issue but they dont
seem to care to adjust it.
_______________________________________________
mkgmap-dev mailing list
[email protected]
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
Index: src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java
===================================================================
--- src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java (revision 2340)
+++ src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java (working copy)
@@ -286,12 +286,29 @@
preConvertRules(way);
Rule rules;
+ way.addTag("mkgmap:closed",String.valueOf(way.isClosed()));
+ way.addTag("mkgmap:autoclosing", "false");
if ("polyline".equals(way.getTag("mkgmap:stylefilter")))
rules = lineRules;
else if ("polygon".equals(way.getTag("mkgmap:stylefilter")))
rules = polygonRules;
- else
+ else if (way.isClosed()==false) {
+ // check if start or end point lie within the bbox
+ if (bbox.insideBoundary(way.getPoints().get(0)) ||
+ bbox.insideBoundary(way.getPoints().get(way.getPoints().size()-1))) {
+ log.error("Use line rules only for " + way);
+ rules = lineRules;
+ } else {
+ // the way may be closed automatically because both endpoints are outside the bbox
+ // set a tag so that these ways can be ignored in the style rules
+ way.addTag("mkgmap:autoclosing", "true");
+ log.error("Use both rules for " + way);
+ rules = wayRules;
+ }
+ }
+ else {
rules = wayRules;
+ }
rules.resolveType(way, new TypeResult() {
public void add(Element el, GType type) {
@@ -532,8 +549,9 @@
// check if start or end point lie within the bbox
if (bbox.insideBoundary(way.getPoints().get(0)) ||
bbox.insideBoundary(way.getPoints().get(way.getPoints().size()-1))) {
- log.warn("Unclosed way",way.toBrowseURL(),way.toTagString(),
- "should be converted as shape but the start or end point lies inside the bbox. Skip it.");
+ // this should not happen because it is checked before the style processing
+ log.error("Unclosed way "+way.toBrowseURL()+" "+way.toTagString()+
+ " should be converted as shape but the start or end point lies inside the bbox. Skip it.");
return;
}
_______________________________________________
mkgmap-dev mailing list
[email protected]
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev