The major difference between the two files is that the ellipsoid parameters
are included within the .PAS file and are placed in a VB .CLS file. I was
experimenting with VB at the time and wanted to see how the class file was
implemented.
All of the major routines are done as functions
with a standard calling method. They all return an error code indicating success
or failure. The error numbers are defined as integer constants and I have
attempted to use them consistently. The computed data is always returned as a
Var (Pascal) or ByRef (VB) structure.
Mapstuff contains the following routine for your use:
(I am discussing Mapstuff.PAS here but the discussion is applicable to
Mapstuff.bas as well)
Antipod:
This function computes the Antipod of a given latitude/longitude set.
For example the antipod of 43N/73W is 43S/107E. the function returns an
integer error flag if either lat or long is not in proper range. The
lat and long are assumed to be decimal degrees.
IsAntipodal:
This function determines if a two sets of lat/long are antipodal. The
function returns true if the sets are antipodal else it returns false.
The lat/longs are assumed to be decimal degrees.
ComputeZone:
This function compute the zone data for any UTM zone. It expects a Type
ZoneStruct and populates it with information concerning the UTM zone of
interest. As with all the main functions in Mapstuff, the function
returns an error code of type Integer that signals success or failure.
Given the latitude and longitude of a place, ComputeZone will return
the UTM central longitude of the place along with the zone number and
zone letter of the place.
Converge:
This function computes the convergence of meridians between two parallels
of Latitude. The function returns the convergence in meters in the
GeoStruct component Distance (i.e. gs.Distance). DO NOT confuse this
function with the computation of the Grid North (convergence) in LL2UTM
or UTM2ll.
DMSToD
DToDMS:
DtoDMS converts an angle in decimal degrees to it constituent parts;
degrees, minutes and seconds. These components are returned a a DMS
structure (byref). DMSToD converts an angle from degrees/minutes/seconds
to decimal degrees.
Sex2Deg:
Sex2Deg converts an angle expressed in sexigesimal format:
dd.mmsssss or
dd.mmmmmm
where dd is degrees, mm is minutes and sssss represents ss.ssss seconds
(or mmmmmm represents mm.mmmm) into decimal degrees:
dd.ddddd
FmtDMS:
this Function formats angular and time quantities. It is designed mainly for
display purposes.
Input: x decimal value - function restricts number
of decimals to 5
NDig: number of digits to right of decimal
FOut: format of output string
DD = decimal degrees
i.e. ddd.dddd (for n=4)
DM = degrees and decimal minutes
i.e. ddd mm.mmmm (for n=4)
DMS = degrees, minutes and decimal seconds
i.e. ddd mm ss.ssss (for n=4)
DorH: formating type
Deg = formatting to degrees
Hour = formatting to hours
LLT:controls the way that degrees are
formated:
Lat = degrees formatted DD
Long = degrees formatted DDD
None = no special formatting for degrees
The function returns a string with the angle/time value properly
formatted.
FmtDMS is intended for printing or display purposes.
NOTE: FmtDMS rounds at the last decimal place
GetAllSerialPorts:
This function reads the registery and returns the names of all the serial ports
installed on the computer. The serial port names are returned in a StringList.
This
function is NOT implemented in VB.
GetEllipseStuff:
This function extracts the ellipse data record for the requested datum
from the arrays in the initialization section. It returns the ellipse's
major and minor axes as well as the ellipsoid name in an EllipseStruct.
GetDatumStuff:
This function extracts the datum data for the requested datum from the
arrays in the initialization section. It returns the datum information in
a DatumStruct. The intent of the inclusion of the datum data is to allow
the user of an application to get to the ellipsoid information through
datum name which is commonly used in GPS receivers. The datumNumber is
geoid number for the ellipsoid associated with the named datum.
Suggested use:
Read the datumNames into a list box in your application and allow the
user to select one and use its ListIndex+1 as the index for GetDatumStuff.
Then use the datumNumber as the geoid number to get to the underlying
ellipse data eMajor, eMinor and eName using GetEllipseStuff
GetFlattening:
This function extracts the chosen ellipsoid flattening value (f) from the
array rflat in the initialization section and returns the reciprocal
flattening value (1/f).
LL2UTM
UTM2LL:
These functions are implementations of the algorithms presented in the
USGS Professional Paper 1395 "Map Projections - a Working Manual" by John
P. Snyder.
LL2UTM converts a position defined by a latitude/longitude pair to it's
correspond UTM coordinates using a datum of the user's choice. The
function returns the requested information in a UTMStructure and returns
the error code WICNOERROR if no errors encountered in the conversion.
UTM2LL converts a position described by a UTM Easting/Northing and zone
to it's corresponding latitude/longitude. The requested information is
returned in a UTMStructure and the function returns WICNOERROR if
successful.
ModAzimuth
ModLatitude
ModLongitude
Modulus:
These functions attempt to constrain their arguments to specific ranges.
ModAzimuth constrains an angle (in radians) to the range of 0 <= angle
<= 2*PI (0 to 360 deg). It is used for azimuths.
ModLatitude constrains an angle (in radians) to the range -PI/2 <= angle
>= +PI/2 (-90 deg to +90 deg). It is used for latitudes
ModLongitude constrains an angle (in radians) to the range -PI <= angle
>= PI (-180 deg to +180 deg). It is used for longitudes
Modulus is my implementation of the Mod function for floating point
numbers. It returns the remainder of the division of x/y as a double.
ParseLatLong:
This function parses a string containing an angle and extracts the degrees
minutes and seconds. The string must be in the format dd:mm:ss.ss or
dd:mm.mm or dd.ddd The string delimiters can be a colon (:) or a
semicolon (;) or a comma (,). The angle is returned as decimal degrees.
This function is useful for use with data entry into a text box. I use
the textbox KeyPress event to restrict input of degrees to digits,
delimiters and tab and backspace keys along with the valid delimiters
so that ParseLatLong() will return the value of an angle passed to it
from TextBox.Text.
Reciprocal:
This function returns the reciprocal of an azimuth. Azimuth is in decimal
degrees.
VDirect
VInverse:
These functions are the implementation of Vincenty's algorithms published in
his "Direct and Inverse Solutions on the Ellipsoid with Application of
Nested Equations"
Given the latitude and longitude of a point and the azimuth and distance
to a second point, VDirect returns the latitude and longitude of the
second point and the azimuth of the first point from the second. The
computed data is returned in a GeoStructure. The distance is returned
in meters and the azimuth is the angle measured from true north.The
function returns the standard WICNOERROR if successful.
Given the latitude and longitude of two points, VInverse returns the
distance between the two points in meters and the azimuth of each point
from the other. These azimuths are NOT reciprocals. The functions returns
the standard WICNOERROR if successful.
Ruler2LL:
This function computes a latitude/longitude of a point from a ruler measurement
of the x and y coordinates of the point from any corner of the map. The user
specifies the corner latitude and longitude, the map datum, the map scale and the
measurement units (millimeters, centimeters or inches) and the function returns the
latitude and longitude of the designated point.
LL2Ruler:
This function calculates x and y coordinates of a latitude/longitude. The user supplies
the latitude/longitude of the LOWER LEFT corner of the map and the x and y coordinates
of the point, the map scale and map datum and the function returns the latitude and
longitude of the designated point. This function is MOST accurate for small scale maps.
There are several other helper routines in Mapstuff and I urge you to
peruse the code in order to gain a better understanding of the code.
Top

This page was last updated on Wednesday, December 03, 2003