Ticket #7635: 7635.patch

File 7635.patch, 3.6 KB (added by simon04, 11 years ago)
  • src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java

    diff --git a/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java b/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java
    index ee9bbf6..796a33c 100644
    a b public class StyledMapRenderer extends AbstractMapRenderer {  
    539539
    540540    public void drawArea(Relation r, Color color, MapImage fillImage, boolean disabled, TextElement text) {
    541541        Multipolygon multipolygon = MultipolygonCache.getInstance().get(nc, r);
    542         if (!r.isDisabled() && !multipolygon.getOuterWays().isEmpty()) {
     542        if (!r.isDisabled() && !multipolygon.getOuterWays().isEmpty() && multipolygon.isDrawEncouraged()) {
    543543            for (PolyData pd : multipolygon.getCombinedPolygons()) {
    544544                Path2D.Double p = pd.get();
    545545                if (!isAreaVisible(p)) {
  • src/org/openstreetmap/josm/data/osm/visitor/paint/relations/Multipolygon.java

    diff --git a/src/org/openstreetmap/josm/data/osm/visitor/paint/relations/Multipolygon.java b/src/org/openstreetmap/josm/data/osm/visitor/paint/relations/Multipolygon.java
    index d338709..7a726e5 100644
    a b import org.openstreetmap.josm.data.osm.Way;  
    2626import org.openstreetmap.josm.data.osm.event.NodeMovedEvent;
    2727import org.openstreetmap.josm.data.osm.event.WayNodesChangedEvent;
    2828import org.openstreetmap.josm.data.osm.visitor.paint.relations.Multipolygon.PolyData.Intersection;
     29import org.openstreetmap.josm.tools.Geometry;
    2930
    3031/**
    3132 * Multipolygon data used to represent complex areas, see <a href="https://wiki.openstreetmap.org/wiki/Relation:multipolygon">wiki</a>.
    public class Multipolygon {  
    592593    public List<PolyData> getCombinedPolygons() {
    593594        return combinedPolygons;
    594595    }
     596
     597    public boolean isDrawEncouraged() {
     598        if (!isIncomplete()) {
     599            return true;
     600        } else if (Main.pref.getBoolean("mappaint.multipolygon.incomplete", false)) {
     601            return true;
     602        }
     603
     604        // Determines if inner nodes lie on both sides of the line through the first and last node.
     605        // If this is the case, then drawing and incomplete multipolygon is problematic.
     606        int seenValues = 0;
     607        for (PolyData pd : getCombinedPolygons()) {
     608            final Node first = pd.nodes.get(0);
     609            final Node last = pd.nodes.get(pd.nodes.size() - 1);
     610            for (Node n : pd.nodes.subList(1, pd.nodes.size() - 2)) {
     611                final boolean isClockwise = Geometry.angleIsClockwise(first, last, n);
     612                seenValues |= isClockwise ? 0b10 : 0b01;
     613                if (seenValues == 0b11) {
     614                    return false;
     615                }
     616            }
     617        }
     618
     619        return true;
     620    }
    595621}
  • src/org/openstreetmap/josm/gui/mappaint/ElemStyles.java

    diff --git a/src/org/openstreetmap/josm/gui/mappaint/ElemStyles.java b/src/org/openstreetmap/josm/gui/mappaint/ElemStyles.java
    index af28bf4..0cf7330 100644
    a b public class ElemStyles {  
    246246                }
    247247                final Multipolygon multipolygon = MultipolygonCache.getInstance().get(nc, ref);
    248248
     249                if (!multipolygon.isDrawEncouraged()) {
     250                    continue;
     251                }
     252
    249253                if (multipolygon.getInnerWays().contains(osm)) {
    250254                    p = generateStyles(osm, scale, false);
    251255                    boolean hasIndependentElemStyle = false;