Changeset 18675 in josm for trunk/src/org


Ignore:
Timestamp:
2023-02-22T19:14:00+01:00 (17 months ago)
Author:
taylor.smock
Message:

Fix #22684: IAE: Parameter 'en1' must not be null in PowerLines.addWaterWaySegments (patch by gaben, modified)

PowerLines.addWaterWaySegments now only adds segments where all nodes have
position data.

This additionally fixes a similar issue caused by inspecting an incomplete
way in InspectPrimitiveDataText. In this case, the centroid is still
calculated, but does not account for how nodes without positional data
will affect the centroid.

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/validation/tests/PowerLines.java

    r18553 r18675  
    131131        for (int i = 0; i < w.getNodesCount() - 1; i++) {
    132132            final WaySegment es1 = new WaySegment(w, i);
    133             CrossingWays.getSegments(this.cellSegmentsWater, es1.getFirstNode(), es1.getSecondNode()).forEach(list -> list.add(es1));
     133            final Node first = es1.getFirstNode();
     134            final Node second = es1.getSecondNode();
     135
     136            if (first.isLatLonKnown() && second.isLatLonKnown()) {
     137                CrossingWays.getSegments(this.cellSegmentsWater, first, second).forEach(list -> list.add(es1));
     138            }
    134139        }
    135140    }
  • trunk/src/org/openstreetmap/josm/tools/Geometry.java

    r18590 r18675  
    939939     */
    940940    public static EastNorth getCentroid(List<? extends INode> nodes) {
    941         return getCentroidEN(nodes.stream().map(INode::getEastNorth).collect(Collectors.toList()));
     941        return getCentroidEN(nodes.stream().filter(INode::isLatLonKnown).map(INode::getEastNorth).collect(Collectors.toList()));
    942942    }
    943943
     
    955955        } else if (size == 2) {
    956956            return nodes.get(0).getCenter(nodes.get(1));
     957        } else if (size == 0) {
     958            return null;
    957959        }
    958960
Note: See TracChangeset for help on using the changeset viewer.