0

I am very new to this side of the world. I am a classical embedded software developer. We want to incorporate GPS in our project. If I have the current Latitude, Longitude, Height,Heading (I hope this is what I think it is, the direction of the vehicle) and speed of the vehicle. Can I calculate the coordinates 20 meter before (I can also convert this to time scale). I am not sure how to proceed with this or what other information. I am not sure if this is totally possible at all.

  • 1
    In short, yes. If you know a location and a direction it is possible to calculate a different location 20 meters in front. How difficult that calculation is depends on what kind of libraries you have access to. This would be fairly trivial if you have some kind of GIS software available. If not, you'd have to dust off your trigonometry textbook I guess ;-) (because latitude and longitude are measured in degrees) – Berend Feb 28 '19 at 12:32
  • I assume your vehicle is moving in a straight line at a constant speed. If not, we don't have enough information. If so then have a look at this post. your question is not quite the same but it should give you some pointers. – MappaGnosis Feb 28 '19 at 14:57
  • @MappaGnosis, Yes considering the vehicle is moving in a straight line and at a constant speed. The thing is I do not have access for any libraries for doing this, everything has to be manually done. – user5603723 Mar 01 '19 at 06:02
  • @MappaGnosis, Thank you for that link. I went through most of them (haversine, Equirectangular approximation). The problem is I have 2 unknown variable (Lat2, Long2). That becomes impossible to find out with reverse engineering. In all of the methods given in that link, they are assuming they know 2 set of points and finding the distance between them. While I have to assume I know 1 set of point and distance between another and find the 2nd set. – user5603723 Mar 01 '19 at 06:12

1 Answers1

1
  • 20 meters is a fairly short distance and probably the indeterminacy in the definition of GPS coordinates covers a considerable part of that distance.

So let's assume that GPS coordinates are precisely defined and that you are handling enough decimal places to represent a difference of 20 meters in geographic coordinates.

  • For the calculation absolutely manual, and sufficiently fast, the reduction of the ellipsoid to a sphere is advisable and can not introduce big errors in those distances.

In any case, you can improve the accuracy, calculating the radius of curvature of the sphere for that particular position. Use the geocentric radius for the current latitude and add the ellipsoidal height to it. In addition, it would be interesting to compare the results with the calculations made on the mean radius. It is likely that the decimal places you use to express the coordinates, do not show the difference between the calculations with one or the other radius.

  • Calculations based on spherical trigonometry can be a good approach for this problem (not for the inverse), but still not necessary.

Still, if you are interested in do it, here is a development of the necessary formulas: Get lat/long given current point, distance and bearing . Note that your initial azimuth to know the preceding coordinates must be the vehicle's forward bearing plus PI.

  • On the other hand, the simplest solution, and probably sufficiently precise for this use case, is to transform the geographic coordinates to a Cartesian system (project the sphere to a plane tangent to the point of known coordinates) and perform the calculation in planimetric form:
lambda_2 = lambda_1 + SIN(alpha) * d / (COS(phi_1) * R)  
phi_2 = phi_1 + COS(alpha) * d / R 

Where:

  • lambda_1 is the longitude of the initial point, in radians.

  • phi_1 is the latitude of the initial point, in radians (and can't be a pole).

  • alpha is the azimuth to the preceding point (your bearing plus PI), in radians.

  • d is the distance, in meters or any distance unit.

  • R is the radius of your choice, in the same units as the distance (and must be greater than zero).

And:

  • lambda_2 is the longitude of the precedent point, in radians.

  • phi_2 is the latitude of the precedent point, in radians.

Gabriel De Luca
  • 14,289
  • 3
  • 20
  • 51
  • This is a good answer by @Gabriel De Luca, the suggestion to transform to a Cartesian system is a simple, and efficient solution if you are able to do so. – jbgramm Mar 02 '19 at 05:39
  • Hi, Thanks for your amazing answer. I was doing research over the weekend. I found an alternative, Geo Fencing. Is this a good alternative, as I don't have to worry about the heading and other stuff. As soon I have the point, I make a boundary about it – user5603723 Mar 04 '19 at 12:07