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

MapPoint 2006

Programming MapPoint in .NET

MapPoint Book

  Spatial Community
ViaVirtualEarth
SVG Tutorials
MapPoint

Map Visitors

 Direct Media

Small Business IT
Solving your problems quickly and efficiently is what makes Connect stand out. Find out more.

ink
Buy ink for printers directly from the factory! Fantastic value as well as superb special offers. Top brands!

Jersey Flights
Holiday Hypermarket should be your first choice for cheap flights. Book flights to exotic destinations or even just to Jersey.

Cheap Holidays in Turkey
For cheap holidays in Turkey visit On The Beach. Say when, say where, search our holiday database and booking is a breeze.

bulgarian property
Bulgarian beach and ski property available. High quality, luxury apartments available. See online today!

Holidays in Fuerteventura
Holidays in Fuerteventura are perfect for people who love vast beaches of white sand. Its coasts annually attract thousands to one of the best places in the world for windsurfing.

Cheap Greece Holidays
For cheap Greece holidays make sure you know when to book and who to book with. Visit ulookubook.com to get help with doing both of those things. Why not time your visit with a Greek festival?

  ARTICLES  


Converting Strings Into Decimal Degree Format

Below is a small utility routine and the corresponding documentation that will help convert a user-supplied string in degree, minute, second format (e.g. N 49° 12' 12.3") and will return a double in the decimal degree format MapPoint expects.

Microsoft MapPoint can accept geographical coordinates on input (e.g. in the "Find" dialog: select Edit/Find and switch to the "Lat/Lon" tab) as well as display them in the location sensor window (Tools/Location sensor).

While the "Find" dialog is smart and can handle values entered as degrees, minutes and seconds (simply separate them with a blank) or as decimal degrees, the GetLocation function available to the programmer requires doubles in decimal format.

Sometimes, coordinates are available in degree, minute, second format though, or users would like to enter values in this more familiar format (e.g. because that is the format their GPS is set to).

This article presents a handy VB subroutine for the MapPoint programmer that accepts a string in DMS (degree, minute, second) format and will convert it to decimal format. The routine is called DMSVal (in analogy to the Visual Basic "Val" conversion function).

The signature of the function is as follows:

  Function DmsVal(ByVal strDms As String, bValid as Boolean) As Double

DMSVal tries to be tolerant about the format of the strDMS string it accepts on input. There may be leading and trailing blanks, an optional compass point (N, E, S, W), and values for degrees, minutes and seconds separated by arbitrary delimiters except comma and period.

The decimal separator may be both the decimal point (.) common in North America as well as the comma (,) used in Europe (no thousands separator allowed nor needed though)

If compass points South (S or s) or West (W or w) are encountered, the return value is negative according to the convention used in MapPoint.

The following are examples of valid DMS strings:

  N 49° 1' 5.1"
  49/1/5.1
  E49d1m5.1s
  E49 1 5.1

DMSVal will set the "bValid" parameter to "False" if it could not convert the input string. A successful conversion is indicate by a bValid value of "True".

If you already have the values available in separate fields, the following function can be used:

   Function DmsValCalc(strCompassPoint As String, dblDeg As Double, _
                       dblMin as Double, dblSec as Double) As Double

DMSValCalc can be called directly with a compass point (N, E, S, W), and the degree, minutes and seconds values. It is used internally by DMSVal.

Here's the code:

There is also an online converter at: http://www.mp2kmag.com/latlong.asp

Discuss this story in the forum.

Author: Gilles Kohl
Email: gilles(AT)_deletethisincludingunderlines_compuserve.com
URL: http://www.procad.de
Gilles Kohl, a native of Luxembourg living in Germany, is a software development lead with PROCAD GmbH of Karlsruhe, Germany.

Mapping and especially GPS-related topics are a hobby - Gilles enjoys developing solutions for Microsoft MapPoint and his favorite outdoor occupation is confluence hunting.

As always, please direct questions to the newsgroup.



Google
 
MP2Kmag Internet


 Recent Discussion
-Virtual Earth on CSI: New York
-Helping out after the China quakes
-Coastal Boundaries
-Mapping Earthquakes in China
-An invalid argument was encountered.
-Navman Wireless Oem Solutions Enhances Leading Line Of Gps Receiver Modules
-T-mobile UK
-Virtual Earth and OpenLayers
-Reminder: Microsoft Virtual Earth Partner Webinar and Offer for Free Training
-Virtual Earth Quarterly Technical Briefing
-Customize User Page
-Information about area
-Territory information
-Gps task pane in ActiveX
-Worldwide Telescope Now Available!
-c++ - setting the color of a line
-Initial Costa Rica MapServer map is up & running!
-Satellite Images of Myanmar Cyclone Damage
-Virtual Earth Loyalist: Aerial View
-Leaving messages on the Virtual Earth for Government blog site
-Virtual Earth Webcast: Adding Mapping Capabilities to your Applications with Virtual Earth
-Get new Lat & Lon from speed
-Integrating Virtual Earth Maps and Excel 2007
-Zillow.com
-ADODB Recordset to MapPoint.DataSet
 Resources
Browse GIS books and periodicals
Best Car Contract Hire Lease Save
Find a MapPoint Partner or Consultant
Real Estate Columbia Custom Home


Want Your Site To Appear Here?

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

• Replacement Cordless Phone Batteries from DSMiller
Improve your career with a computer degree LocalEDU.com
• Tim Cohn's Marketing Strategy Consultancy
• Buy Toner, Ink Cartridges & Drums at Marquee Office Solutions
• Looking for Dry Erase Boards? See Dry Erase Boards
• 5339 - We Know Bikes: Road Bikes / Triathlon Bikes / Mountain Bikes / BMX Bikes
• Buy Your Car Used Cars, Car Lease and Contract Hire