Index: Osm5XmlHandler.java =================================================================== --- Osm5XmlHandler.java (Revision 1485) +++ Osm5XmlHandler.java (Arbeitskopie) @@ -118,6 +118,7 @@ private final boolean generateSea; private boolean generateSeaUsingMP = true; private boolean allowSeaSectors = true; + private boolean extendSeaSectors = false; private String[] landTag = { "natural", "land" }; private final Double minimumArcLength; private final String frigRoundabouts; @@ -146,6 +147,10 @@ generateSeaUsingMP = true; else if("no-sea-sectors".equals(o)) allowSeaSectors = false; + else if("extend-sea-sectors".equals(o)) { + allowSeaSectors = false; + extendSeaSectors = true; + } else if(o.startsWith("land-tag=")) landTag = o.substring(9).split("="); else { @@ -1259,6 +1264,20 @@ seaRelation.addElement("outer", sea); generateSeaBackground = false; } + else if (extendSeaSectors) { + // create additional points at next border + if (null == hStart) { + hStart = getNextEdgeHit(seaBounds, pStart); + w.getPoints().add(0, hStart.getPoint(seaBounds)); + } + if (null == hEnd) { + hEnd = getNextEdgeHit(seaBounds, pEnd); + w.getPoints().add(hEnd.getPoint(seaBounds)); + } + log.debug("hits (second try): ", hStart, hEnd); + hitMap.put(hStart, w); + hitMap.put(hEnd, null); + } else { // show the coastline even though we can't produce // a polygon for the land @@ -1461,6 +1480,36 @@ return null; } + private EdgeHit getNextEdgeHit(Area a, Coord p) + { + int lat = p.getLatitude(); + int lon = p.getLongitude(); + int minLat = a.getMinLat(); + int maxLat = a.getMaxLat(); + int minLong = a.getMinLong(); + int maxLong = a.getMaxLong(); + + log.info(String.format("getNextEdgeHit: (%d %d) (%d %d %d %d)", lat, lon, minLat, minLong, maxLat, maxLong)); + int min = lat - minLat; + int i = 0; + double l = ((double)(lon - minLong))/(maxLong-minLong); + if (maxLong - lon < min) { + min = maxLong - lon; + i = 1; + l = ((double)(lat - minLat))/(maxLat-minLat); + } + if (maxLat - lat < min) { + min = maxLat - lat; + i = 2; + l = ((double)(maxLong - lon))/(maxLong-minLong); + } + if (lon - minLong < min) { + i = 3; + l = ((double)(maxLat - lat))/(maxLat-minLat); + } + return new EdgeHit(i, l); + } + private void concatenateWays(List ways) { Map beginMap = new HashMap();