English 中文(简体)
Calculating distance from latitude, longitude and height using a geocentric co-ordinate system
原标题:

I ve implemented this method in Javascript and I m roughly 2.5% out and I d like to understand why.

My input data is an array of points represented as latitude, longitude and the height above the WGS84 ellipsoid. These points are taken from data collected from a wrist-mounted GPS device during a marathon race.

My algorithm was to convert each point to cartesian geocentric co-ordinates and then compute the Euclidean distance (c.f Pythagoras). Cartesian geocentric is also known as Earth Centred Earth Fixed. i.e. it s an X, Y, Z co-ordinate system which rotates with the earth.

My test data was the data from a marathon and so the distance should be very close to 42.26km. However, the distance comes to about 43.4km. I ve tried various approaches and nothing changes the result by more than a metre. e.g. I replaced the height data with data from the NASA SRTM mission, I ve set the height to zero, etc.

Using Google, I found two points in the literature where lat, lon, height had been transformed and my transformation algorithm is matching.

What could explain this? Am I expecting too much from Javascript s double representation? (The X, Y, Z numbers are very big but the differences between two points is very small).

My alternative is to move to computing the geodesic across the WGS84 ellipsoid using Vincenty s algorithm (or similar) and then calculating the Euclidean distance with the two heights but this seems inaccurate.

Thanks in advance for your help!

问题回答

I ve just worked out what seems to be the main cause of the problem. I had the latitude and longitude round the wrong way in my transformation function.

Trap for young players: Point data gives the longitude first, not the latitude.

I m now getting 42,476.75 from my algorithm and 42,476.69 from the spheroid. Close enough for my purposes.

Thanks everybody!

Javascript is easily accurate enough in its calculations, so I don t think your problem is coming from there. Certainly not a 2.5% error or so.

You throw around words I ve never even heard of, so I ll assume you re at least as knowledgeable on geodesic distance calculation as I am. I remember dabbling with this a long time ago and the way to do this required calculating hyperbolic sines and cosines to do the "weird" spherical geometry. If you just "do" Euclidian planar distance, your distances will be off once the Earth s curvature becomes significant.

So... are you doing hyp-sin s? Is your program doing exponentials and logarithms and stuff? If not, you may be applying the wrong formulae.

There... that s all I know about the topic. Good luck!

You could use the Google Maps Api for a calculation like this. I did this once.





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签