spacer1
spacer2 1_1 1_2
2_1
 Subscribe
 The MP2K Update!
 
 
 
 Magazine
Front Cover
What's New
Articles
News
Sample Data
Gallery
Advertise
About
 Features
MapPoint 2013
Press Releases
MapPoint Forums
Companies
Link to MP2Kmag
Wish List
MapPoint Trial
Authors
 Earlier Content
Past News Items
Past What's New Announcements
 Sponsors
 Order

MapPoint 2013

Programming MapPoint in .NET

MapPoint Book

  Spatial Community
SVG Tutorials
MapPoint

Map Visitors

  ARTICLES  


Geodesy: MapStuff Release version 0.9

Windsway Company is releasing some Geodesy oriented software as open souce code. This is not a complete application but rather a set of routines that you can use to build your own applications.

[Ed. Note: see the forum for the latest version.]

At least two functions in MapStuff.bas are of particular interest to MapPoint users. The first is Vinverse which is a highly accurate way to find the distance between two points when you know the latitude and longitude of the two points. The second is Vdirect that will give you the latitude and longitude of a second point when you know the distance and azimuth from a given point. Both of these functions consider the earth as an ellipsoid and you get to pick your map datum (WGS84 for MapPoint). Many other useful routines are in here as well.

The release consists of two open source files:

 Geodesy.cls
 Mapstuff.bas

Both files must be included in your Visual Basic® project. Download the entire package here.

Geodesy Class file:

The class file (.cls) contains the physical definitions of the supported datums and methods for retrieving the desired datum. Normally you need not use these methods at all as the functions that need the datum dimentions contain the necessary code to do this. However there is a function you can call to get the data.

Mapstuff:

Mapstuff is the file that contains all the action. There are routines for converting Latitude/Longitude to UTM coordinates and UTM Coordinates to Latitude/Longitude. There are implementations of T. Vincenty's Direct and Inverse Solution of Geodesics on the Ellipsoid. There are standard VB data structures called Types that are used throughout Mapstuff.These Types add order to the calling sequences of most of the routines. All Types and Routines are public. All the main functions return an error code of type Integer to flag success or failure. The error codes are constants in the definition section of the code. The code names all begin with WIC (for Windsway Instrument Company) and are ALWAYS Capitalized. A fuction returning WICNOERROR has completed successfully (this does not necessarily mean that the information returned is meaningful). Any other error code means something went wrong during the function call. The return codes for each function are documented in a comment block at the beginning of the function.

Mapstuff.bas contains the following routine for your use:

 ArcCos
 ArcSin
 ArcTan
 ATan2

These four routine simply implement the trigonometric function in a way that is standard to my way of doing software.

 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.bas, 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.

 DegToRad
 RadToDeg

DegToRad converts an angle in decimal degrees to radians and RadToDeg converts an angle in radians to decimal degrees.

 DMSToD
 DToDMS

DtoDMS converts an angle in decimal degrees to it constituant 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 where dd is degrees, mm is minutes and sssss represents ss.ssss seconds into decimal degrees: dd.ddddd

The function assumes that minutes are expressed as two digits and the first two digits of ss are the whole seconds and the balance of ssssss are the decimal portion. The decimal portion of ssssss can be expressed to any reasonable number of places. Therefore dd.mmssssss expresses an angle of dd degrees mm minutes and ss.ssss seconds

 FmtDMS

FmtDMS converts decimal degrees dd.ddddd into a string dd mm ss.ssss or time expressed as hh.hhhhh into a string hh mm ss.ssss with the appropriate symbols i.e. 23° 34' 45.5678" or 23h 34m 45.5678s. User specifies degrees or time and the number of decimal places for seconds. Decimal range from 0 to 5. If more than 5 places is specified, places is set to 5. FmtDMS is intended for printing or display purposes.

 GetEllipseStuff

This function extracts the ellipse data for the requested datum from the arrays in the class file Geodesy.cls. 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 class file Geodesy.cls. 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

 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. It returns the remainde of the division of x/y.

 Reciprocal

This function returns the reciprocal of an azimuth. Azimuth is in decimal degrees.

 Square

This function returns the square of a value, i.e. Square(x) = x * x

 Vdirect
 Vinverse

These funcitions are the implementation of Vincenty's algorithms.

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 returne 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.

Unzip the contents of Geodesy.Zip into a folder where you wish to run the sample stuff. I have the VB project in a folder Geodesy on the VB path. This will create a sample project for you to use to test the code.

I have included some simple code to illustrate how these routines might be used in a VB program. Cut and paste the Command1.Click and Command2.click code (files Testxxx.txt) into the Geodesy project's (Geodesy.vbp) GeoTest.frm module in place of the ones that is currently there and run the program from the IDE.

If you have questions I will try to field them, but I can't guarantee an instant response nor will I write complete projects for you. I would like to hear about any additions you make to my code. Send the source code please.

Remember this is an open source project and you are obligated by the license to share the code and any improvements with anyone who would like a copy. Please read the licensing agreement at the site documented in the code.

To stay informed of future updates to the library, send me and an e-mail with Geodesy in the subject line and I'll add you to the distribution list.

Discuss this story in the forum.

Author: Vic Fraenckel
Email: vfraenc1(AT)nycap.rr.com?subject=Geodesy
URL: http://www.windsway.com
Vic is the Owner/President of Windsway Instrument Company which manufactures the WindReader, an instrument for measuring wind speed and direction at various levels in the atmosphere. He has been interested in the mathematics of mapping as a hobby for many years.

His current quest is for a suitable sailboat for live-aboard cruising and he also acts as a technical advisor for a long distance gas balloon racing team. He is a ham radio operator - callsign KC2GUI.



Google
 
MP2Kmag Internet


 Recent Discussion
 Resources
Browse GIS books and periodicals
Find a MapPoint Partner or Consultant
Real Estate Columbia, MO


Want Your Site To Appear Here?

   © 1999-2012 MP2K. Questions and comments to: website@mp2kmag.com
  Microsoft and MapPoint 2002/2004/2006/2009/2010/2011/2013 are either trademarks or registered trademarks of Microsoft.