http://www.developer.com/java/other/article.php/3393581/Manipulate-GIS-Coordinates-with-Java.htm
This article presents GISCoordinate.java: a class that allows you to represent a GIS coordinate in your JAVA code in decimal degrees (38.4443, e.g. 122.33433), minute degrees (33 44 22E, 122 33 44N), or radian degrees. Also, you can use this class to manipulate the coordinate, moving it around the globe by giving it distances in feet and direction of travel. You then can extract the new coordinate that is calculated after the travel. In one of my applications, I had to be able to export data that was drawn on a bitmap map to GIS software. I realized I needed some class to represent a GIS coordinate and allow me to manipulate (move) it. The complication here lies in the fact that to generate a new coordinate using an existing coordinate, direction of travel and distance of travel, one needs to take into account the fact that the earth is round, not flat, and its roundness is not defined by any standard geometrical shape. Therefore, there are various formulas that you may use for this calculation, depending on what you believe the earth's shape to be. The common methods are: The class presented here allows you to: I based my code on the JavaScript code presented by Ed Williams, at: http://williams.best.vwh.net/gccalc.htm which, of course, had to be completely re-written in Java and wrapped in a nice object-oriented wrapper. GISCoordinate.java does have a main method that exemplifies the usage of the class. Basically, here are a few pointers: You typically instantiate the class as follows: This provides you with an object that represents the GIS coordinate: To see the representation of this in Decimal Degrees: You then can move the coordinate to any direction and any distance: Note that movedist is the distance in feet to move (in this, case half a mile) and movedeg is the degree of movement (from 0-360, so this would be south east'ish). Also, note that NAD83 method was picked, which assumes the earth to be of a certain shape. Of course, another method could have been used from the aforementioned nine. Look at the constants declared in the beginning of the class implementation to see the variable names of the different ones you can choose from. The new location can be printed again: The demo is self contained in the actual class. To compile and run the demo: To use this class in your code, you can modify the package name to suit your package scheme and call on it as per the examples in the main() method
Manipulate GIS Coordinates with Java
August 11, 2004
Introduction
Background
Credits
Using the Code
GISCoordinate g = new GISCoordinate("37:55:15","N","122:20:59","W");
Longitude:37 degrees 55 minutes 15 seconds North
Latitude: 122 degrees 20 minutes 59 seconds Westg.printDEGDEC(System.out);
double movedist=2640; //5280.0;
double movedeg=167;
System.out.println("Moving "+movedist+" Feet, in a direction of
"+movedeg+" degrees...");
g.move(movedist, movedeg, NAD83);
g.printDEGDEC(System.out);
javac com\ha\common\gis\*.java
java -classpath c:\temp\ com.ha.common.gis.GISCoordinate