So I'm using coordinates to create a Polygon using path2d. I need to find out if a point is exactly on the line of the polygon I created.
Here's my code right now, which allows me to find out whether specific coordinates are within the polygon, but it returns false if the point is exactly on the line.
import java.awt.geom.Path2D;
public class Path2dMain {
public static void main(String[] args) {
Path2D.Double d = new Path2D.Double();
d.moveTo(40.6522526, -105.1398466);
d.lineTo(40.627764, -105.16559600000001);
d.lineTo(40.6232377, -105.13491200000001);
d.lineTo(40.6489967, -105.1317787);
d.lineTo(40.6522526, -105.1398466);
d.closePath();
System.out.println(d.contains(40.63, -105.1417787));
}
}
If anyone can see a solution to this that would be great, also it would be ok if it just retruned true if the point was on the line. Thanks in advance.