3

I need help I have the following 2 points on the map point A lat1/long1 and point B lat2/long2 in google map I have distance, arrived_time, bearingradians and speed.

With these data how can I get a estimated latitude longitude (google map format) to the next point on 10 minutes,20,30 and 40 minutes ?, having start and end point.

Point A lat1=37.78472 lon1=-122.39913

Point B lat2=37.78240 lon2=-121.23208

bearingradians=270

distance=102 KM

arrive_time=50 minutes

speed =122 KM/H

example: http://hmarina.sytes.net/mapagoogle.jpg

What I need you to calculate the nexts points, I going to use PHP, or where should I start

Thank you

user4131013
  • 425
  • 1
  • 7
  • 14

2 Answers2

4

There are multiple ways to calculate this. Some of them are quite complex.

You could use Vincenty's formula, which is often used for bearing and distance calculations. The formula needs Long/Lat of the starting point, the bearing and a distance. I doubt, that you want to reimplement this algo, so here you go: Implementing Vincenty's Formula in PHP

Another solution could be to use vectors to calculate the destination points along a great-circle given distance and bearing from start point. This approach might be a bit easier, then to work with spherical trigonometry. http://www.movable-type.co.uk/scripts/latlong-vectors.html and https://stackoverflow.com/a/1739066/1163786

Another one is to calculate the intermediate points on a great-circle. http://williams.best.vwh.net/avform.htm#Intermediate


Let's use Vincenty here and re-calc your end-point, given a starting-point, bearing and distance:

  • a starting point: Point A lat1=37.78472; lon1=-122.39913;
  • the bearing: approx. 89
  • the distance: 102 km

Result: Latitude: 37°47′42″N 37.79506902, Longitude: 121°14′28″W -121.24119021

That is pretty close your Point B.


Now, you want to determine the future position (lang/lat) by calculating the distance you will travel based on your current speed and your known time interval. In other words, your next point is 10 minutes from the starting point given speed 122 km/h and 89 bearing.

Calculate new distance: 122 km/h = 2033.33 m/min, so in 10 minutes: 20333.33 m = 20,333 km approx.

You new data for the formula:

  • a starting point, here: Point A lat1=37.78472; lon1=-122.39913;
  • the bearing: approx. 89
  • the distance: 20,333 km

And re-run vincenty with these values to get Lat/Long...


This might be of help:

Community
  • 1
  • 1
Jens A. Koch
  • 39,862
  • 13
  • 113
  • 141
  • Thank for you response for use Vincenty's formula first I need you convert Degress (google maps format) to GPS coordinates (how do it in PHP?) or I can use degress format (google map) directly. Thank you so much – user4131013 Oct 12 '14 at 15:18
  • 1
    This might be of help: http://stackoverflow.com/a/2548996/1163786 and format converters are also included in the PHP library. – Jens A. Koch Oct 12 '14 at 16:29
  • Thank you so much apreciate your help. – user4131013 Oct 14 '14 at 13:49
1

You have: speed = 122Km/h => You can calculate 10 minute walked (n _km)

You can calculate distance with 2 point distance

sqrt((lat1 - lat2)^2 + (lng1-lng2)^2);

you have distance and lat1, how to calculate lat2:

Read more in picture :)

Gottlieb Notschnabel
  • 9,408
  • 18
  • 74
  • 116
HoangHieu
  • 2,802
  • 3
  • 28
  • 44