- double ssx = ModelledCRS.xToLongitude(sx);
- double ssy = ModelledCRS.yToLatitude(-sy); // Invert for Simantics diagram coordinate system
- double distSq = line.ptSegDistSq(ssx, ssy);
-// System.out.println("s: " + sx + ", " + sy);
-// System.out.println("ss: " + ssx + ", " + ssy);
-// System.out.println("p1: " + edge.getStartPoint());
-// System.out.println("p2: " + edge.getEndPoint());
-// System.out.println("line: " + "(" + line.getX1() + ", " + line.getY1() + ", " + line.getX2() + ", " + line.getY2() + ")");
-// System.out.println("distance from line is " + Math.sqrt(distSq) + " with tolerance " + tolerance);
- return distSq <= tolerance * tolerance;
+
+ double coords[] = new double[6];
+ Point2D prevPoint = new Point2D.Double(), curPoint = new Point2D.Double();
+ Line2D line = new Line2D.Double();
+ for (PathIterator it = path.getPathIterator(null); !it.isDone(); it.next()) {
+ int type = it.currentSegment(coords);
+ switch (type) {
+ case PathIterator.SEG_MOVETO:
+ curPoint.setLocation(coords[0], coords[1]);
+ break;
+ case PathIterator.SEG_LINETO:
+ prevPoint.setLocation(curPoint);
+ curPoint.setLocation(coords[0], coords[1]);
+ line.setLine(prevPoint, curPoint);
+ double distSq = line.ptSegDistSq(sx, sy);
+// System.out.println("s: " + sx + ", " + sy);
+// System.out.println("ss: " + ssx + ", " + ssy);
+// System.out.println("p1: " + edge.getStartPoint());
+// System.out.println("p2: " + edge.getEndPoint());
+// System.out.println("line: " + "(" + line.getX1() + ", " + line.getY1() + ", " + line.getX2() + ", " + line.getY2() + ")");
+// System.out.println("distance from line is " + Math.sqrt(distSq) + " with tolerance " + tolerance);
+ if (distSq <= tolerance * tolerance)
+ return true;
+ break;
+ default:
+ LOGGER.error("Invalid edge path", new IllegalStateException());
+ return false;
+ }
+ }
+
+ return false;