Index: src/org/openstreetmap/josm/data/osm/WaySegment.java
===================================================================
--- src/org/openstreetmap/josm/data/osm/WaySegment.java	(revision 14421)
+++ src/org/openstreetmap/josm/data/osm/WaySegment.java	(working copy)
@@ -4,6 +4,9 @@
 import java.awt.geom.Line2D;
 import java.util.Objects;
 
+import org.openstreetmap.josm.data.coor.EastNorth;
+import org.openstreetmap.josm.tools.Geometry;
+
 /**
  * A segment consisting of 2 consecutive nodes out of a way.
  */
@@ -111,11 +114,27 @@
                 getFirstNode().equals(s2.getSecondNode()) || getSecondNode().equals(s2.getFirstNode()))
             return false;
 
-        return Line2D.linesIntersect(
-                getFirstNode().getEastNorth().east(), getFirstNode().getEastNorth().north(),
-                getSecondNode().getEastNorth().east(), getSecondNode().getEastNorth().north(),
-                s2.getFirstNode().getEastNorth().east(), s2.getFirstNode().getEastNorth().north(),
-                s2.getSecondNode().getEastNorth().east(), s2.getSecondNode().getEastNorth().north());
+        EastNorth p1 = getFirstNode().getEastNorth();
+        EastNorth p2 = getSecondNode().getEastNorth();
+        EastNorth p3 = s2.getFirstNode().getEastNorth();
+        EastNorth p4 = s2.getSecondNode().getEastNorth();
+        boolean res1 = Line2D.linesIntersect(p1.east(), p1.north(), p2.east(), p2.north(), p3.east(), p3.north(),
+                p4.east(), p4.north());
+        if (res1) {
+            // calculate the position of the intersection point of the lines (not segments)
+            EastNorth is = Geometry.getLineLineIntersection(p1, p2, p3, p4);
+            if (is == null)
+                return false;
+            double d1 = is.distanceSq(p1);
+            double d2 = is.distanceSq(p2);
+            double d3 = is.distanceSq(p3);
+            double d4 = is.distanceSq(p4);
+            double eps = 0.00000001;
+            // return false if the intersection is extremely close to one of the given points
+            if (Math.abs(d1) < eps || Math.abs(d2) < eps || Math.abs(d3) < eps || Math.abs(d4) < eps)
+                return false;
+        }
+        return res1;
     }
 
     /**
