I am using osmdroid in android along with osmdroid bonus pack. I have drawn the a polygon. Now i want to check if the GeoPoint(Latitude, longitude) lies within the drawn polygon. How do i do it?
Here I am using contains method, which only accepts MotionEvent object and its not working. Is there any other method to do it?
My code is as bellow.
GeoPoint gPt0 = new GeoPoint(23.215210, 72.648600);
GeoPoint gPt1 = new GeoPoint(23.216030, 72.648340);
GeoPoint gPt2 = new GeoPoint(23.217400, 72.649070);
GeoPoint gPt3 = new GeoPoint(23.216570, 72.650290);
GeoPoint gPt4 = new GeoPoint(23.214750, 72.649130);
List<GeoPoint> list = new ArrayList<>();
list.add(gPt0);
list.add(gPt1);
list.add(gPt2);
list.add(gPt3);
list.add(gPt4);
Polygon polygon = new Polygon(getApplication());
polygon.setPoints(list);
GeoPoint center = new GeoPoint(23.21612, 72.64933);
map.getOverlays().add(polygon);
MotionEvent event = MotionEvent.obtain(1, 1, MotionEvent.ACTION_HOVER_ENTER, (float)23.21602, (float) 72.64926, 1);
Log.e("CONTAINS", polygon.contains(event)+"");