|
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 and coordinate conversion functionality to their own programs or scripts, without the need to have any knowledge on serial communications and GPS protocols like RS-232 and NMEA0183. For more information about the GPS toolkit, please visit the GPS toolkit product page.
The product can be used in many programming environments, such as VBScript, Visual Basic, Visual C++, Visual Basic .NET, Visual C# .NET, Borland C++ Builder, Borland Delphi and VBA (Access, Excel), but also web oriented applications such as ASP, ASP.NET and PHP, and all other programming environments that support ActiveX controls.
You can use the GPS Toolkit with scripts like VBScript or JScript, to for instance, batch convert coordinates or convert GIS datafiles from one map projection or map datum to another.
First you must have a VBScript editor and the Eye4Software GPS Toolkit installed on your computer. If you do not have a dedicated VBScript editor, notepad will do. You can download the Eye4Software GPS Toolkit here.
To create your VBScript, you can just use notepad or any other text editor. Create a file with a ".vbs" extension. In case the VBScript code will be embedded into an ASP webpage, use the ".asp" extension.
On top of your script, please add the following code to declare the objects:
Dim objProjection Dim objDatumSrc Dim objDatumDst Dim objGridSrc Dim objGridDst
And the following code to create instances of the objects needed:
Set objProjection = CreateObject ( "Eye4Software.GpsProjection" ) Set objDatumSrc = CreateObject ( "Eye4Software.GpsDatumParameters" ) Set objDatumDst = CreateObject ( "Eye4Software.GpsDatumParameters" ) Set objGridSrc = CreateObject ( "Eye4Software.GpsGridParameters" ) Set objGridDst = CreateObject ( "Eye4Software.GpsGridParameters" )
The following scripts demonstrate how to convert coordinates using a predefined grid (easiest way to perform a conversion) and the Transverse Mercator, Lambert Conformal Conic or Stereographic projection, making use of the Eye4Software GPS Toolkit and VBScript:
Option Explicit
Dim objProjection
Dim objGridSrc
Dim objGridDst
Set objProjection = CreateObject ( "Eye4Software.GpsProjection" )
Set objGridSrc = CreateObject ( "Eye4Software.GpsGridParameters" )
Set objGridDst = CreateObject ( "Eye4Software.GpsGridParameters" )
WScript.Echo "Eye4Software GPS Toolkit " & objProjection.Version & " - Grid Conversion Demo"
WScript.Echo
' Set Source Grid ( WGS84, Geographic Latitude and Longitude )
' 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 or grid, just change the code below (EPSG code)
objGridSrc.LoadFromId ( 4326 )
' Set Destination Grid ( Dutch Grid )
' The ID for the Dutch Grid is 28992, see 'http://www.eye4software.com/resources/grids' for a full list of supported grids
' To convert to another datum or grid, just change the code below (EPSG code)
objGridDst.LoadFromId ( 28992 )
' Set Source coordinates ( WGS84)
objProjection.Latitude = 52.110000
objProjection.Longitude = 5.290000
WScript.Echo "Convert from Latitude / Longitude to Dutch Grid (RDNAP)"
WScript.Echo
WScript.Echo "Latitude = " & objProjection.Latitude
WScript.Echo "Longitude = " & objProjection.Longitude
WScript.Echo
' Perform the transformation
objProjection.TransformGrid objGridSrc, objGridDst
' Return the result
WScript.Echo "Result: " & objProjection.LastError & " (" & objProjection.LastErrorDescription & ")"
WScript.Echo
If ( objProjection.LastError = 0 ) Then
WScript.Echo "Northing = " & objProjection.Northing
WScript.Echo "Easting = " & objProjection.Easting
End If
WScript.Echo "Ready."
Option Explicit
Dim objDatumSrc, objDatumDst, objGridSrc, objGridDst, objProjection, objConstants
Set objDatumSrc = CreateObject ( "Eye4Software.GpsDatumParameters" )
Set objDatumDst = CreateObject ( "Eye4Software.GpsDatumParameters" )
Set objGridSrc = CreateObject ( "Eye4Software.GpsGridParameters" )
Set objGridDst = CreateObject ( "Eye4Software.GpsGridParameters" )
Set objProjection = CreateObject ( "Eye4Software.GpsProjection" )
Set objConstants = CreateObject ( "Eye4Software.GpsConstants" )
' Set Source Datum: WGS84
objDatumSrc.Axis = 6378137.000
objDatumSrc.Flattening = 298.257223563
' Set Source GridL: Latitude/Longitude
objGridSrc.Projection = objConstants.GPS_PROJECTION_NONE
objGridSrc.Datum = objDatumSrc
' Set Destination Datum: Belgium 1972
objDatumDst.Axis = 6378388.000
objDatumDst.Flattening = 297.000
objDatumDst.TranslationX = -99.059
objDatumDst.TranslationY = 53.322
objDatumDst.TranslationZ = -112.486
objDatumDst.RotationX = 0.419
objDatumDst.RotationY = -0.830
objDatumDst.RotationZ = 1.885
objDatumDst.ScaleFactor = -1.000
' Set destination grid: Belgium Lambert 72
objGridDst.Projection = objConstants.GPS_PROJECTION_LAMBERT2SP
objGridDst.Datum = objDatumDst
objGridDst.FalseNorthing = 5400088.438000
objGridDst.FalseEasting = 150000.012560
objGridDst.OriginLatitude = 90.0
objGridDst.OriginLongitude = 4.367487
objGridDst.ParallelNorth = 49.833334
objGridDst.ParallelSouth = 51.166667
objGridDst.ScaleFactor = 0.0000
' Set Source coordinates
objProjection.Latitude = 51.900000
objProjection.Longitude = 4.400000
' Perform the transformation
objProjection.TransformGrid objGridSrc, objGridDst
' Return the result
WScript.Echo "Convert from Latitude / Longitude to Lambert-72 using Lambert projection"
WScript.Echo
WScript.Echo "Result: " & objProjection.LastError & " (" & objProjection.LastErrorDescription & ")"
WScript.Echo
If ( objProjection.LastError = 0 ) Then
WScript.Echo "Latitude = " & objProjection.Latitude
WScript.Echo "Longitude = " & objProjection.Longitude
WScript.Echo
WScript.Echo "Northing = " & objProjection.Northing
WScript.Echo "Easting = " & objProjection.Easting
End If
WScript.Echo "Ready."
Option Explicit
Dim objDatumSrc, objDatumDst, objGridSrc, objGridDst, objProjection, objConstants
Set objDatumSrc = CreateObject ( "Eye4Software.GpsDatumParameters" )
Set objDatumDst = CreateObject ( "Eye4Software.GpsDatumParameters" )
Set objGridSrc = CreateObject ( "Eye4Software.GpsGridParameters" )
Set objGridDst = CreateObject ( "Eye4Software.GpsGridParameters" )
Set objProjection = CreateObject ( "Eye4Software.GpsProjection" )
Set objConstants = CreateObject ( "Eye4Software.GpsConstants" )
' Set Source Datum: WGS84
objDatumSrc.Axis = 6378137.000
objDatumSrc.Flattening = 298.257223563
' Set Source GridL: Latitude/Longitude
objGridSrc.Projection = objConstants.GPS_PROJECTION_NONE
objGridSrc.Datum = objDatumSrc
' Set Destination Datum: WGS84
objDatumDst.Axis = 6378137.000
objDatumDst.Flattening = 298.257223563
' Set destination grid: RDNAP
objGridDst.Projection = objConstants.GPS_PROJECTION_TRANSVERSEMERCATOR
objGridDst.Datum = objDatumDst
objGridDst.FalseNorthing = 0
objGridDst.FalseEasting = 500000
objGridDst.OriginLatitude = 0
objGridDst.OriginLongitude = 3
objGridDst.ScaleFactor = 0.9996
' Set Source coordinates
objProjection.Latitude = 51.900000
objProjection.Longitude = 4.400000
' Perform the transformation
objProjection.TransformGrid objGridSrc, objGridDst
' Return the result
WScript.Echo "Convert from Latitude / Longitude to UTM Zone 31 using transverse mercator projection"
WScript.Echo
WScript.Echo "Result: " & objProjection.LastError & " (" & objProjection.LastErrorDescription & ")"
WScript.Echo
If ( objProjection.LastError = 0 ) Then
WScript.Echo "Latitude = " & objProjection.Latitude
WScript.Echo "Longitude = " & objProjection.Longitude
WScript.Echo
WScript.Echo "Northing = " & objProjection.Northing
WScript.Echo "Easting = " & objProjection.Easting
End If
WScript.Echo "Ready."
Option Explicit
Dim objDatumSrc, objDatumDst, objGridSrc, objGridDst, objProjection, objConstants
Set objDatumSrc = CreateObject ( "Eye4Software.GpsDatumParameters" )
Set objDatumDst = CreateObject ( "Eye4Software.GpsDatumParameters" )
Set objGridSrc = CreateObject ( "Eye4Software.GpsGridParameters" )
Set objGridDst = CreateObject ( "Eye4Software.GpsGridParameters" )
Set objProjection = CreateObject ( "Eye4Software.GpsProjection" )
Set objConstants = CreateObject ( "Eye4Software.GpsConstants" )
' Set Source Datum: WGS84
objDatumSrc.Axis = 6378137.000
objDatumSrc.Flattening = 298.257223563
' Set Source GridL: Latitude/Longitude
objGridSrc.Projection = objConstants.GPS_PROJECTION_NONE
objGridSrc.Datum = objDatumSrc
' Set destination datum: Amersfoort
objDatumDst.Axis = 6377397.155
objDatumDst.Flattening = 299.1528183
objDatumDst.TranslationX = 539.16
objDatumDst.TranslationY = 26.15
objDatumDst.TranslationZ = 465.89
objDatumDst.RotationX = -1.304
objDatumDst.RotationY = -0.103
objDatumDst.RotationZ = -1.145
objDatumDst.ScaleFactor = 4.0772
' Set destination grid: RDNAP
objGridDst.Projection = objConstants.GPS_PROJECTION_STEREOGRAPHIC
objGridDst.Datum = objDatumDst
objGridDst.FalseNorthing = 463000.00
objGridDst.FalseEasting = 155000.00
objGridDst.OriginLatitude = 52.156161
objGridDst.OriginLongitude = 5.387639
objGridDst.ScaleFactor = 0.999908
' Set Source coordinates
objProjection.Latitude = 51.900000
objProjection.Longitude = 4.400000
' Perform the transformation
objProjection.TransformGrid objGridSrc, objGridDst
' Return the result
WScript.Echo "Convert from Latitude / Longitude to RDNAP using stereographic projection"
WScript.Echo
WScript.Echo "Result: " & objProjection.LastError & " (" & objProjection.LastErrorDescription & ")"
WScript.Echo
If ( objProjection.LastError = 0 ) Then
WScript.Echo "Latitude = " & objProjection.Latitude
WScript.Echo "Longitude = " & objProjection.Longitude
WScript.Echo
WScript.Echo "Northing = " & objProjection.Northing
WScript.Echo "Easting = " & objProjection.Easting
End If
WScript.Echo "Ready."