Currently I am making use of the Graphics.Path class to draw lines on a map. The path is constructed based on LatLong coordinates that are converted to X and Y points so they can be drawn on the screen.
Now I am trying to make it possible to let the user click on the path that is drawn on the screen.When the user clicks on the screen the application loops through the paths that are drawn on the screen to check for an intersection.
Is there any (easy) way to check for an intersection with a rectangle and a path?
Currently I am trying to do this by creating a Region from the current path:
Region pathBounderies = new Region((int)currentClickablePathBounds.left,(int)currentClickablePathBounds.top, (int)currentClickablePathBounds.right,(int)currentClickablePathBounds.bottom);
pathRegion = new Region();
pathRegionCreated = pathRegion.setPath(clickablePath, pathBounderies);
I check if the path intersects as follows:
RegionIterator ri = new RegionIterator(pathRegion);
Rect pixel = new Rect();
int centerX = pixel.centerX();
int centerY = pixel.centerY();
However, this seems to only work sometimes...
I am trying to solve this thing for a week now but I still havent figured out how to fix this.
Could anyone confirm that this is indeed the right/only way to do this? Or is my approach to this problem very wrong?