Changes between Initial Version and Version 1 of Ticket #22404, comment 2


Ignore:
Timestamp:
2022-09-29T16:09:34+02:00 (2 years ago)
Author:
taylor.smock

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #22404, comment 2

    initial v1  
    44Anyway, it is a fairly simple fix. Unit testing it might be a bit harder.
    55
    6 {{{#!diff
    7 Index: src/org/openstreetmap/josm/data/vector/VectorDataStore.java
    8 ===================================================================
    9 diff --git a/src/org/openstreetmap/josm/data/vector/VectorDataStore.java b/src/org/openstreetmap/josm/data/vector/VectorDataStore.java
    10 --- a/src/org/openstreetmap/josm/data/vector/VectorDataStore.java       (revision 18564)
    11 +++ b/src/org/openstreetmap/josm/data/vector/VectorDataStore.java       (date 1664394677575)
    12 @@ -267,9 +267,18 @@
    13      private <T extends Tile & VectorTile> VectorRelation areaToRelation(T tile, Layer layer,
    14        Collection<VectorPrimitive> featureObjects, Area area) {
    15          VectorRelation vectorRelation = new VectorRelation(layer.getName());
    16 -        for (VectorPrimitive member : pathIteratorToObjects(tile, layer, featureObjects, area.getPathIterator(null))) {
    17 +        PathIterator pathIterator = area.getPathIterator(null);
    18 +        int windingRule = pathIterator.getWindingRule();
    19 +        for (VectorPrimitive member : pathIteratorToObjects(tile, layer, featureObjects, pathIterator)) {
    20              final String role;
    21              if (member instanceof VectorWay && ((VectorWay) member).isClosed()) {
    22 +                // Area messes up the winding. See #22404.
    23 +                if (windingRule == PathIterator.WIND_NON_ZERO) {
    24 +                    VectorWay vectorWay = (VectorWay) member;
    25 +                    List<VectorNode> nodes = new ArrayList<>(vectorWay.getNodes());
    26 +                    Collections.reverse(nodes);
    27 +                    vectorWay.setNodes(nodes);
    28 +                }
    29                  role = Geometry.isClockwise(((VectorWay) member).getNodes()) ? "outer" : "inner";
    30              } else {
    31                  role = "";
    32 @@ -374,8 +383,13 @@
    33          } else if (shape instanceof Path2D) {
    34              primitive = pathToWay(tile, layer, featureObjects, (Path2D) shape).stream().findFirst().orElse(null);
    35          } else if (shape instanceof Area) {
    36 -            primitive = areaToRelation(tile, layer, featureObjects, (Area) shape);
    37 -            primitive.put(RELATION_TYPE, MULTIPOLYGON_TYPE);
    38 +            VectorRelation vectorRelation = areaToRelation(tile, layer, featureObjects, (Area) shape);
    39 +            if (vectorRelation.getMembersCount() != 1) {
    40 +                primitive = vectorRelation;
    41 +                primitive.put(RELATION_TYPE, MULTIPOLYGON_TYPE);
    42 +            } else {
    43 +                primitive = vectorRelation.getMember(0).getMember();
    44 +            }
    45          } else {
    46              // We shouldn't hit this, but just in case
    47              throw new UnsupportedOperationException(Objects.toString(shape));
    48 }}}
     6~~I'm going to look into why the style sheet isn't being converted into a roughly equivalent mapcss style sheet.~~
    497
    50 I'm going to look into why the style sheet isn't being converted into a roughly equivalent mapcss style sheet.
     8EDIT: The style sheet was fine. The render code was expecting only `WAY` and I was giving it `CLOSEDWAY`.