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 2009
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 2009

Programming MapPoint in .NET

MapPoint Book

  Spatial Community
SVG Tutorials
MapPoint

Map Visitors

 Direct Media

Travel Insurance Compare over 450 travel insurance policies (inc. annual multi-trip, single trip & winter sports)

  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
-BingMapsDev: Reading @Chrispendleton article 'The world according to Bing' http://bit.ly/9mmoWy
-Easy game maker to make games like day of the tentacle or platform games?
-bingmaps: "The Thing About Bing" CP interview published in @gim_intl mag: http://bit.ly/b4l6eJ. Avail free online. ^CP
-bingmaps: Add Bing (Maps) to Your Safari Browser Extensions: http://bit.ly/aFeDsd. ^CP
-bingmaps: Here's a fun video: 10 Places not on Google Earth: http://bit.ly/bTcx1Y. ^CP
-MapPoint or alternative for Haiti?
-bingmaps: RT @gim_intl: ^JB We have published an interview with #Microsoft #Bing #Maps's @chrispendleton - now available online! http://ht.ly/2ik9f
-Problem with FindAddressResults
-Map multiple layers on one map
-bingmaps: Nice to see @MSFTResearch project Street Slide outside the firewall: http://j.mp/bUUYTu. ^CP
-SpatialImportDll_Feature colour Display
-bingmaps: See the updated Bing Twitter Map App? Photo pins, sharing, tabbed searches walk thru embedded maps: http://bit.ly/9rnCaL ^CP
-bingmaps: @redwanhuq Whatchu talkin' bout Willis? Details of your setup please...
-bingmaps: @zafeuer Pretty sure that's comScore rankings. ^CP
-Copying thematic maps from MapPoint 2010 to Excel/Word 2007
-Export territory data
-bingmaps: @mackenziepricee @TravisPearl MSR built Destination Maps as a Bing Map App. ^CP
-bingmaps: My IEEE article, "The World According to Bing" has gone syndicate. You can read it online now: http://bit.ly/apUnNL. ^CP
-bingmaps: @natelawrence You would think so...updates are coming, tho. The pump is certainly primed. ^CP
-bingmaps: RT @IncaX: IncaX, ONR, Pelican Racing and @BingMaps feature in GIS Professional magazine. http://tinyurl.com/34kjch7 ^CP
-bingmaps: @zafeuer Surprisingly, MQ is still number two in Map Search...for now. Do people still use AOL to connect to the intertube? ^CP
-bingmaps: @blakey15 Always a chance. Do you WANT a Silverlight experience or something within the SL experience?
-How up-to-date are the zip codes in MapPoint?
-MapPoint Business-Suite - freeware
-How do you chat in the trade or general discussion chats in World of Warcraft?
 Resources
Browse GIS books and periodicals
Find a MapPoint Partner or Consultant
Real Estate Columbia MO Homes for Sale


Want Your Site To Appear Here?

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

Improve your career with a computer degree LocalEDU.com
• Buy Toner Cartridges at Marquee Office Solutions
• Looking for Dry Erase Boards? See Dry Erase Boards • The Search Starts Here Used Cars
• 5339 - We Know Bikes: Road Bikes / Triathlon Bikes / Mountain Bikes / BMX Bikes
• Buy Your Car Used Cars UK, Car Lease and Contract Hire