Community of VE/MapPoint Users and Developers
This is a discussion on CalcPos in python within the MapPoint 2006/2009 Discussion forums, part of the Map Forums category; It's fairly trivial, but I do not believe that CalcPos in python is posted anywhere. Code: import math # Calculates ...
| |||||||
| Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| CalcPos in python Code: import math
# Calculates lat/long of a mappoint location object
# This function was originally written in VB by
# Gilles Kohl (gilles@compuserve.com)
# original: http://www.mp2kmag.com/articles.asp?ArticleID=13
def CalcPos(objMap, locX):
locNorthPole = objMap.GetLocation(90, 0)
locSantaCruz = objMap.GetLocation(0, -90)
dblHalfEarth = objMap.Distance(locNorthPole, objMap.GetLocation(-90, 0))
dblQuarterEarth = dblHalfEarth / 2
# Compute latitude from distance to north pole
dblLat = 90 - 180 * objMap.Distance(locNorthPole, locX) / dblHalfEarth
# Compute great circle distance to locX from point
# on Greenwich meridian and computed Latitude
d = objMap.Distance(objMap.GetLocation(dblLat, 0), locX)
# convert latitude to radian
l = (dblLat / 180) * math.pi
# Compute Longitude from great circle distance
dblLon = 180 * math.acos((math.cos((d * 2 * math.pi)/(2 * dblHalfEarth)) -
math.sin(l) * math.sin(l))/(math.cos(l) * math.cos(l))) / math.pi
# Correct longitude sign if located in western hemisphere
if objMap.Distance(locSantaCruz, locX) < dblQuarterEarth:
dblLon = -1 * dblLon
return (dblLat, dblLon)
# END function |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Please help me with calcpos | chris701 | MapPoint 2006/2009 Discussion | 1 | 08-11-2006 11:55 AM |
| Using Python to Control MapPoint, Part 2 | Eric Frost | MP2K Magazine Articles | 0 | 07-11-2006 07:41 PM |
| Problems using CalcPos | Pete_ADL | MapPoint 2006/2009 Discussion | 4 | 06-21-2006 03:12 PM |
| Using Python to control MapPoint, Part 1 | Eric Frost | MP2K Magazine Articles | 0 | 03-26-2006 10:29 PM |
| Confused with calcpos :s | Matrices | MapPoint 2006/2009 Discussion | 4 | 09-25-2003 09:30 AM |
Cheap Flights to Brussels
Book cheap flights to Brussels online today. Brussels is a city with diverse culture with over 100 museums to visit and an array of different architectural designs to view.
Spain Weather
Check Spain Weather before you travel. We provide information on Spain including weather, flights and accommodation.
Cheap Holiday Turkey
Booking a cheap holiday to Turkey doesn't have to be at the expense of enjoyment. Dealchecker.co.uk searches holidays from the leading UK Tour Operators.
Egypt Holidays
Visit one of the most spectacular sightseeing destinations in the world with The Holiday Place. Egypt holidays provide a fantastic break!
Cheap Turkey Holidays
The best time of year to sneak in cheap Turkey holidays is during the off-peak season. Check out the great deals available during April, May or October. For other tips on how to bag a great value holiday simply check online at ulookubook.com
Cheap Travel
Travel.co.uk has some excellent offers on cheap travel. Click here.
Cheap Holidays to Goa
Dine on delightful seafood in west India. Find information on cheap holidays in Goa at On The Beach.