• Post Reply Bookmark Topic Watch Topic
  • New Topic

GPS in Java  RSS feed

 
Graham Weatherup
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi at the moment I am trying to change GPS(lat,lon,alt) data into local ENU data with respect to a reference point, I cannot work out what I am doing wrong. I plan to put this in a for loop to work through a lot of points. the output below i think shows the point im looking at is 385kilometers from the reference point but from gpsvisualizer.com i get the map attached showing the points are 4.4kilometers apart. The formulae have come from wikipedia but I have seen similar in papers so assume they are right. Also I am unsure for the altitude should I be using the 3.2 or 3.2+50

GGA string Altitude = 3.2
GGA string Height of geoid above WGS84 ellipsoid = 50


Thank You for any help you can give me.

CODE


OUTPUT
4796852.49597502
877587.1655287134
4097342.304744489
380570.53379599785
-60802.27603134864
-11639.114359959927
385572.7129186495

sample.PNG
[Thumbnail for sample.PNG]
gpsvisualizer.com output for points used
 
Paul Clapham
Sheriff
Posts: 22841
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's possible that your Z coordinates aren't in the same units as your X and Y coordinates when you get to the end of that code. I don't have any evidence for that, that would require somebody who understood the calculations, it's just a hypothesis to give us something to work on. So I suggest that you start with alt = 0 and get the two-dimensional calculation working first.

By the way you do realize that 50+3.2 evaluates to 53.2 in Java, just like in real arithmetic, right? Or was that supposed to represent something else?
 
Campbell Ritchie
Marshal
Posts: 56595
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
... and welcome to the Ranch
 
Graham Weatherup
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Campbell and Paul.

Paul, thanks for your suggestions. I represented the altitude in this way because when i do this for all my gps points i think i might need to take the altitude from the 2 parts of the gga string. 50=height of geoid above epsiloid and 3.2=height of sensor above geoid(mean sea level), though I am unsure of this so if anyone could clarify...

I can make alt=o then the output is

eX = 4796812.541688626
eY = 877579.8558670182
eZ = 4097307.9468655568
X = 380567.36392072774
Y = -60801.76789729365
Z = -11692.217407807311
Distance = 385393.7901173396

changing to System.out.println("Distance = "+sqrt(X*X+Y*Y));

so even if I ignore the Z component (which i think should be almost 0 anyway, but doesn't seem to be)
distance=sqrt(X^2 + Y^2) = 385393.7901173396

I think this should mean 385000m which is again still way too large (I need it in the region of 4500 according to the image), Unfortunately I can not eradicate alt from the equations as it is needed even for the X and Y components.
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Math class's trigonometric methods accept radians, not degrees.
 
Graham Weatherup
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Darryl, I just came back to say I had it, but you beat me to it, thanks for the help.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!