MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




CalcPos in python

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


Go Back   MapPoint Forums > Map Forums > MapPoint 2006/2009 Discussion

Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 08-31-2006
Junior Member
White Belt
 
Join Date: Aug 2006
Posts: 3
CalcPos in python

It's fairly trivial, but I do not believe that CalcPos in python is posted anywhere.


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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2 (permalink)  
Old 08-31-2006
Eric Frost's Avatar
Senior Member
Black Belt
 
Join Date: Jul 1992
Posts: 2,291
Blog Entries: 1
Cool! good work, thanks, Eric
__________________
~ Now taking orders for MapPoint 2009 ~
~
~ Upgrade to MapForums Plus membership ~
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

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


All times are GMT -5. The time now is 08:20 PM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5
MP2K Magazine
Visitor Map

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.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51