Google Earth Community
> Earth - Moderator Selected
Re: Java Code Snippets
Jun 1, 2010 6:34 PM
Posted in group:
Thanks for the Java code. It looks really useful, not only for your project, but for other projects involving geographic calculations as well.
A few questions on how to use the code follow:
Should the parameters be passed to the GreatCircleDistance method in radians? That seems to be the case because Java's Math methods are written to operate directly on angles given in radians.
It appears that convrd, convdr, and earthRadius are variables that are declared and assigned their values outside the methods that use them. Is the following what needs to be included in code in order to give them their necessary values?
double convrd = 180.0 / Math.PI;
double convdr = Math.PI / 180.0;
double earthRadius = 6371.0; // in kilometers, or 3959.0 miles
It appears that those variables could be declared, either as constants inside the methods that use them in order to make those methods self-contained - or alternatively the methods can all be placed together in a class, along with those variables, in which case the methods could each access the variables globally.
It also appears that the parameters to the GEpathFromBearing and bearingArrowKML methods should be passed in radians. Is this correct?
This is a really interesting project, and it is great that you are sharing some of the useful code with us.