Ignore:
Timestamp:
2015-11-21T00:52:19+01:00 (9 years ago)
Author:
Don-vip
Message:

fix #12118 - NPE

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/Geometry.java

    r8928 r9038  
    597597            }
    598598
    599             //test if the line is crossed and if so invert the inside flag.
    600             if ((newPoint.getEastNorth().getY() < point.getEastNorth().getY()) == (point.getEastNorth().getY() <= oldPoint.getEastNorth().getY())
    601                     && (point.getEastNorth().getX() - p1.getEastNorth().getX()) * (p2.getEastNorth().getY() - p1.getEastNorth().getY())
    602                     < (p2.getEastNorth().getX() - p1.getEastNorth().getX()) * (point.getEastNorth().getY() - p1.getEastNorth().getY())) {
    603                 inside = !inside;
     599            EastNorth pEN = point.getEastNorth();
     600            EastNorth opEN = oldPoint.getEastNorth();
     601            EastNorth npEN = newPoint.getEastNorth();
     602            EastNorth p1EN = p1.getEastNorth();
     603            EastNorth p2EN = p2.getEastNorth();
     604
     605            if (pEN != null && opEN != null && npEN != null && p1EN != null && p2EN != null) {
     606                //test if the line is crossed and if so invert the inside flag.
     607                if ((npEN.getY() < pEN.getY()) == (pEN.getY() <= opEN.getY())
     608                        && (pEN.getX() - p1EN.getX()) * (p2EN.getY() - p1EN.getY())
     609                        < (p2EN.getX() - p1EN.getX()) * (pEN.getY() - p1EN.getY())) {
     610                    inside = !inside;
     611                }
    604612            }
    605613
Note: See TracChangeset for help on using the changeset viewer.