I'm implementing alghorithm to search POI near the route (array of Lat, Long points). My problem is that I don't know how to calculate distance beetween line segment and POI. Look at picture that I attached. Can somebody give me some formula for fast calculation this distance?
Notes: Using PHP and MySQL with Spatial Extension.
Assumptions: - I have database of POI with lat, long - - I have array of points (lat, long) in correct (drive) order - route - The calculations will be made on max 20 km area so flat surface assumption is ok. - The POI must be returned in order that the driver will be passing the route.