The Eye4Software GPS toolkit allows software developers to add GPS functionality to their own programs without the need to have any knowledge on geodesy and map projection formulas.
The product can be used to develop software for many operating systems, including: Linux, Windows, Solaris and Android. But also web oriented platforms by using Applets.
In order to develop GPS software using the GPS Toolkit and Java, you have to download and install the Java Developer Kit (JDK) from Oracle. The next step is to install a code editor. It is very well possible to develop Java applications from the command line interface (CLI), however, we strongly suggest to download a (free) Java IDE such as Eclipse or Netbeans. Finally, you have to download and install the Eye4Software GPS toolkit for Java.
Add the following import statement on top of the code that will be using the GPS Toolkit classes and interfaces:
import GpsToolkit.*;
In your class, add the following code to declare the GPS Toolkit interfaces:
IGpsDatumParameters objDatumSrc; IGpsDatumParameters objDatumDst; IGpsGridParameters objGridSrc; IGpsGridParameters objGridDst; IGpsGridParameters objProjection;
And the following code to create an instance of the objects (for instance in the constructor of your class):
IGpsDatumParameters objSrcDatum = new GpsDatumParameters (); IGpsDatumParameters objDstDatum = new GpsDatumParameters (); IGpsGridParameters objSrcGrid = new GpsGridParameters (); IGpsGridParameters objDstGrid = new GpsGridParameters (); IGpsProjection objProjection = new GpsProjection ();
The following script demonstrates how to perform a geodetic datum transformation using the Eye4Software GPS Toolkit and Java. To specify another map datum as source or destination, lookup the datum's ID in the map datum list.
package Samples;
import GpsToolkit.*;
public class ConvDatum
{
public static void main(String[] args)
{
IGpsProjection objProjection = new GpsProjection ();
IGpsDatumParameters objSrcDatum = new GpsDatumParameters ();
IGpsDatumParameters objDstDatum = new GpsDatumParameters ();
// Set Source Datum ( WGS84 )
// The ID for WGS84 is 4326, see 'http://www.eye4software.com/resources/datums' for a full list of supported datums
// To convert from another datum, just change the code below (EPSG code)
// To define your own datum, please have a look at the 'ConvUserGrid' Visual C# .NET demo.
objSrcDatum.LoadFromId(4326);
// Set Destination Datum ( NAD27 )
// The ID for NAD27 is 4267, see 'http://www.eye4software.com/resources/datums' for a full list of supported datums
// To convert to another datum, just change the code below (EPSG code)
// To define your own datum, please have a look at the 'ConvUserGrid' Visual C# .NET demo.
objDstDatum.LoadFromId(4267);
// Set source latitude and longitude coordinates
objProjection.set_Latitude ( 33.59 );
objProjection.set_Longitude ( -112.15 );
System.out.println( "Converting coordinates from WGS84 to NAD27 datum");
try
{
objProjection.TransformDatum ( objSrcDatum, objDstDatum );
System.out.format ("(WGS84) 33.590 N, 112.15 W => (NAD27) %3.6f N, %3.6f W\n",
objProjection.get_Latitude(), objProjection.get_Longitude () );
}
catch (GpsException e)
{
System.out.println( "An error occured during conversion: " + e.get_ErrorDescription() );
}
System.out.println ( "Ready." );
}
}