I am using a GPS receiver and using its latitude and longitude in my application. I have saved some latitude and longitude in my database which are the latitude and longitudes of the locations through which GPS receiver will be travelled.
If GPS receiver is switched on in the middle of the two latitude and longitudes, then how will receiver know that it is in the way of these two points.(assuming receiver will not travel in a straight line).
please guide me in this…
Can you give an example with numbers, so it’s easier to understand? I can see that you have:
- a future goal where you want to go, represented by a lat/lon
- the current location from a GPS receiver, represented by a lat/lon.
But I’m not sure what you want to know.
Suppose I have a route defined in the database as A,B,C,D.
I have crossed station A and my receiver is not switched on yet. In the middle of the journey, receiver is switched on. Now my software has to configure itself such that it knows about the next coming station (in this case station B).
how can I do this…
Assuming that the software knows that you’re traveling by train you can lookup the closest railway from your current position, verify the vector of your movement with the vector of the railway and then know in which direction you’re moving on the railway. Finding the next station then shouldn’t be too difficult.
thanks…Lambertus for the reply…but can you more elaborate your answer…I am not able to understand how to look up the closest railway station…
Ok so you have the location from the receiver and want to know which is the closest station, this is the simple question. It’s harder to know which stations you have passed since routes can be very non linear, especially on rails where trains will often cover the same railway several times.
But ignoring all the problem here is a solution.
for station = (a,b,c,d)
With this you will have a list of distances to all stations, and the delta direction to them, just choose the best value…
Thanks for your reply…
In your code can you tell how you are calculating the azimuth angle:
for station = (a,b,c,d)
I am using C#.net and want to calculate azimuth angle of my location with respect to north direction. I have searched formula for it. The formula I found is using two latitudes and longitudes. But in my case I have only one latitude and longitude (of my current location).
In this case, how can I calculate azimuth angle.
Can you please go in detail in your code.
Well usually you can get the current heading from the GPS and you won’t have to calculate it yourself, You can also do as I do above. I’ve edited my code for some clarity, adding a sleep there, what I do is:
- I get my ccurrent location
- wait 10 seconds
- get a new location
- calculate azimuth between those.
If you search on google for “calculating azimuth” I’m sure you will find code for C sharp as well. Code guru has a generic example you should probably read it all.
PS. this method has some serious drawbacks, making it almost unusable DS.