|
Download the Eye4Software GPS Toolkit fully functional 30 day trial version for free |
|
Browse through the Eye4Software GPS Toolkit manual |
The Eye4Software GPS toolkit allows software developers to add GPS functionality to their own programs without the need to have any knowledge on serial communications and GPS protocols like RS-232 and NMEA0183.
The product can be used in many programming environments, such as Visual Basic, Visual C++, Visual Studio.Net, Borland C++ Builder, Borland Delphi and VBA, but also web oriented applications such as ASP, ASP.NET and PHP, and all other programming environments that support ActiveX.
First you must have Borland Delphi and the Eye4Software GPS Component installed on your computer. We will use Borland Delphi 7.0 in this document, but other versions from 6.0 and up can be used also. You can download the Eye4Software GPS Component here.
For this demo, a console application is used. To create a simple console application project in Delphi, follow the next steps: Select the "Other..." option from the "File" => "New" Menu and select the "Console Application" option, and click "OK".
To use ActiveX controls in a Delphi Console Application project, you first have to specify some units to add ActiveX support. Modify the "uses" block at the top of the code like this:
uses SysUtils, OleServer, ComObj, ActiveX;
Declare the objects like this:
var objGpsProjection : Variant; objGpsDatumSrc : Variant; objGpsDatumDst : Variant; objGpsGridSrc : Variant; objGpsGridDst : Variant; objGpsConstants : Variant;
Before the program is able to load OLE objects, we have to initialize OLE/COM, otherwise an exception is thrown when we try to execute the program:
OleInitialize ( nill );
It is now time to create the objects:
objGpsProjection := CreateOleObject ( 'Eye4Software.GpsProjection' ); objGpsDatumSrc := CreateOleObject ( 'Eye4Software.GpsDatumParameters' ); objGpsDatumDst := CreateOleObject ( 'Eye4Software.GpsDatumParameters' ); objGpsGridSrc := CreateOleObject ( 'Eye4Software.GpsGridParameters' ); objGpsGridDst := CreateOleObject ( 'Eye4Software.GpsGridParameters' ); objGpsConstants := CreateOleObject ( 'Eye4Software.GpsConstants' );
The following code shows how to perform a map projection transformation using the GPS Toolkit. In this example GPS coordinates are transformed from WGS84 to British National Grid using the Transverse Mercator projection. For a list of other map grids, please refer to our map grid list.
program GridTrans;
{$APPTYPE CONSOLE}
uses
SysUtils, OleServer, ComObj, ActiveX;
{Declare the GPS Toolkit objects}
var
objGpsProjection : Variant;
objGpsDatumSrc : Variant;
objGpsDatumDst : Variant;
objGpsGridSrc : Variant;
objGpsGridDst : Variant;
objGpsConstants : Variant;
begin
{ Initialize OLE }
OleInitialize ( nil );
{ Create Objects }
objGpsProjection := CreateOleObject ( 'Eye4Software.GpsProjection' );
objGpsDatumSrc := CreateOleObject ( 'Eye4Software.GpsDatumParameters' );
objGpsDatumDst := CreateOleObject ( 'Eye4Software.GpsDatumParameters' );
objGpsGridSrc := CreateOleObject ( 'Eye4Software.GpsGridParameters' );
objGpsGridDst := CreateOleObject ( 'Eye4Software.GpsGridParameters' );
objGpsConstants := CreateOleObject ( 'Eye4Software.GpsConstants' );
{ Set Source Datum }
objGpsDatumSrc.Axis := 6378137.0;
objGpsDatumSrc.Flattening := 298.257223563;
{ Set Source Grid }
objGpsGridSrc.Projection := objGpsConstants.GPS_PROJECTION_NONE;
objGpsGridSrc.Datum := objGpsDatumSrc;
{ Set Destination Datum }
objGpsDatumDst.Axis := 6377563.396;
objGpsDatumDst.Flattening := 299.3249646;
objGpsDatumDst.TranslationX := 482.5;
objGpsDatumDst.TranslationY := -130.6;
objGpsDatumDst.TranslationZ := 564.6;
objGpsDatumDst.RotationX := -1.042;
objGpsDatumDst.RotationY := -0.214;
objGpsDatumDst.RotationZ := -0.631;
objGpsDatumDst.ScaleFactor := 8.150;
{ Set Destination Grid }
objGpsGridDst.Projection := objGpsConstants.GPS_PROJECTION_TM;
objGpsGridDst.Datum := objGpsDatumDst;
objGpsGridDst.FalseEasting := 200000;
objGpsGridDst.FalseNorthing := 250000;
objGpsGridDst.OriginLatitude := 53.5;
objGpsGridDst.OriginLongitude := -8.0;
objGpsGridDst.ScaleFactor := 1.0;
{ Set Source Latitude and Longitude }
objGpsProjection.Latitude := 54.66;
objGpsProjection.Longitude := -6.81;
{ Display the result }
WriteLn ( 'Latitude (WGS84) : ' + FloatToStr ( objGpsProjection.Latitude ) );
WriteLn ( 'Longitude (WGS84) : ' + FloatToStr ( objGpsProjection.Longitude ) );
{ Transform }
objGpsProjection.TransformGrid ( objGpsGridSrc, objGpsGridDst );
WriteLn ( 'Northing (British Grid) : ' + FloatToStr ( objGpsProjection.Northing ) );
WriteLn ( 'Easting (British Grid) : ' + FloatToStr ( objGpsProjection.Easting ) );
end.