So here is the situation in my android app, I have ORIGIN and DESTINATION LATLNG and ArrayList of LATLNG which fall on a particular route, now I want filter all those BUS STOPS which fall between ORIGIN & DESTINATION LATLNG.
I have used Google Map & Directions api to find route also tried various methods POLYUTIL class from GOOGLE MAP UTIL SDK but nothing is giving accurate result. Can anybody let me know how to do it? Here is the logic I have used:
fun Route.getUmoStops2(busStops: List<BusStop>): List<BusStop> {
val filteredStops = mutableListOf<BusStop>()
getBusPolyline().forEach { list ->
busStops.forEach { stop ->
stop.toLatLng()?.let { stopLatLng ->
if (PolyUtil.containsLocation(stopLatLng, list, true)) {
Timber.d("STOP_FIND::: L2 found a stop")
filteredStops.add(stop)
else {
Timber.d("STOP_FIND::: L3 stop not found!")
}
}
}
}
filteredStops.reverse()
return filteredStops
}