-3

How do I get the lat/long of point X which is 1KM north to lat/long point Y (such as 39.777012,-105.068951)?

In Java CODE please! No external links (I don't read math). Thanks..

Poni
  • 11,061
  • 25
  • 80
  • 121

1 Answers1

1

Use the answer you posted in your code, UnitConstants.DegreesToRadians is defined as follow:

double DegreesToRadians = Math.PI / 180.0;

You could also use Math.toRadians to do the conversion (Thanks to @Hovercraft Full Of Eels for pointing this out)

Calculating such a distance is done using some mathematical formulas that use radians not degrees and that's why all angles need to be transformed to radian by applying the UnitConstants.DegreesToRadians factor, more info here

Call the method defined in the previous link I have provided like this:

LatLonAlt dest= CalculateDerivedPosition(source, 1000, 0);

source being the source point, 1000 is 1KM to the destination point and 0 degrees (or radians) as the destination point is on the north compared to the source point.

Not to repeat the information, have a look at this SO answer. Have a look at this article as well, it will definitely help you out.

Community
  • 1
  • 1
GETah
  • 20,922
  • 7
  • 61
  • 103
  • Why not simply use the Math utilitiy methods as per the comments in the original post? – Hovercraft Full Of Eels Jun 16 '12 at 21:14
  • @GETah: Talking about "Destination point given distance and bearing from start point" in your refered link? – Poni Jun 16 '12 at 21:18
  • @Poni Yes, I just wanted to clarify that answer – GETah Jun 16 '12 at 21:19
  • @GETah Just another quick question about it: What are the values of `Math.sin(d / R)`? I assume `d` for distance... and `R`? Really no clue! – Poni Jun 16 '12 at 21:21
  • Ahh nm, understood (angular distance (in radians)). – Poni Jun 16 '12 at 21:22
  • @GETah Please take a look at edit #2. It's a new code, according to the link you've sent me. For some reason I'm getting strange values. Tried to manipulate the return value with no luck. Any suggestion? And, the link you've sent - already saw it, doesn't help me get it. – Poni Jun 16 '12 at 21:32
  • No answer uh? All I need is ~5 lines of code, not links to whole articles, which I don't understand anyway (not a math guy). – Poni Jun 16 '12 at 22:10
  • @GETah did you try to run the code? Something is seriously missing here. I'm sorry, I just can't get it this way (snippet of code at a time).... it's too complicated and nothing seem to work properly. I get points such as (1.063692,-4.537986) which is definitely not the correct result. I don't know what to say, if you'd make a final effort to bring up a concise function I'd really appriciate it. If not, thanks for the try anyway. – Poni Jun 16 '12 at 22:40