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  


A More Compact Method for Obtaining Lat/Long

An alternate method for obtaining lat/lon was recently posted to the MapPoint newsgroup by Gilles Kohl that works with pushpins and also works in the European version.

In a previous article Chris Gebhardt provided a workaround allowing developers to determine the lat/long in MapPoint. The details are here. An alternate method for obtaining lat/lon was recently posted to the MapPoint newsgroup by Gilles Kohl that works with pushpins and also works in the European version.

The following code will return the lat/lon of a pushpin (actually, its location object) passed by reference. CalcPos is the actual working horse, Arccos is just a trigonometric helper function. Note that this approach does not require iterations nor does it require a specific units setting (miles vs. kilometers) on the users machine.

Usage: Paste the snippet below into your VB code, and call CalcPos with a Map object, your pushpin's location, and two doubles that will receive the lat and lon respectively.

The routine accepts a map object (MapPoint.Map) and a location (MapPoint.Location) as input parameters, and will return the corresponding lat/lon in two doubles passed by reference.

Here's how it works in principle:

  • In an initialization step performed only once, it first creates a location object at the north pole and one at (0, 90W). During this step, it also computes the half circumference of the earth (distance between north and south pole) and the quarter circumference - we need that later. All this is done assuming the earth is a perfect sphere - just as the MapPoint Distance function does.
  • The latitude (angle in degrees) of locX (the location of unknown latitude and longitude) is easily computed like so:

    ' Compute latitude from distance to north pole
    ' dblLat = 90 - 180 * objMap.Distance(locNorthPole, locX) / dblHalfEarth

  • The "absolute longitude" is computed in two steps - first, compute the great circle distance to the Greenwich meridian by creating a location with the same latitude but longitude zero, then convert this resulting distance to a longitude. (the distance on a circle parallel to the equator)
  • Finally, if the distance of our unknown location to (objMap.GetLocation(0, -90) is less than a quarter of the Earth circumference, we're in the western hemisphere, so the sign of the longitude value is negative, otherwise, leave it as it is.

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