MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




Lat Lon problem URGENT HELP

This is a discussion on Lat Lon problem URGENT HELP within the MapPoint 2006/2009 Discussion forums, part of the Map Forums category; Hi, I'm using in VB program the following function to get Lat and Lon, but if I execute it more ...


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

Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read



Click here to register

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-04-2005
Junior Member
White Belt
 
Join Date: Apr 2005
Posts: 6
Lat Lon problem URGENT HELP

Hi,

I'm using in VB program the following function to get Lat and Lon, but if I execute it more than once I retrieve the error
"Method Distance of object _Map failed.

I retrieve the error in this line
dblLat = 90 - 180 * objMap.Distance(locNorthPole, locX) / dblHalfEarth


Sub CalcPos(objMap As MapPoint.Map, locX As MapPoint.Location, dblLat As Double, dblLon As Double)
Static locNorthPole As MapPoint.Location
Static locSantaCruz As MapPoint.Location ' Center of western hemisphere
Static dblHalfEarth As Double ' Half circumference of the earth (as a sphere)
Static dblQuarterEarth As Double ' Quarter circumference of the earth (as a sphere)
Static Pi As Double

' Check if initialization already done
If locNorthPole Is Nothing Then
Set locNorthPole = objMap.GetLocation(90, 0)
Set locSantaCruz = objMap.GetLocation(0, -90)

' Compute distance between north and south poles == half earth circumference
dblHalfEarth = objMap.Distance(locNorthPole, objMap.GetLocation(-90, 0))

' Quarter of that is the max distance a point may be away from locSantaCruz and still be in western hemisphere
dblQuarterEarth = dblHalfEarth / 2
Pi = 3.14159265358979
End If

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

Dim l As Double
Dim d As Double

' 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) * Pi

' Compute Longitude from great circle distance
dblLon = 180 * Arccos((Cos((d * 2 * Pi) / (2 * dblHalfEarth)) - Sin(l) * Sin(l)) / (Cos(l) * Cos(l))) / Pi

' Correct longitude sign if located in western hemisphere
If objMap.Distance(locSantaCruz, locX) < dblQuarterEarth Then dblLon = -dblLon

Lat = dblLat
Lon = dblLon

End Sub
__________________
Thanks
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 05-04-2005
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,122
Hi,

This code is ok if you have nothing changed on it. It is widely used in VB and other languages. You should check what is wrong with objMap. When you start to debug first thing to try is other method calls on it. they probably will fail also. Then you have to check out what is changed between the 2 function calls. Also check in debugger if all varialbles are still valid.
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

Tags
lat, lon, problem, urgent


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
Link Data Wizard Problem (URGENT HELP!!!) craig_korn MapPoint 2006/2009 Discussion 1 05-19-2005 03:03 PM
Matching records problem - URGENT HELP Abilio Serafim MapPoint 2006/2009 Discussion 0 05-09-2005 12:23 PM
Need help URGENT amitsh MapPoint 2006/2009 Discussion 2 03-09-2004 05:38 PM
ZIP Codes Austria-URGENT Anonymous MapPoint 2006/2009 Discussion 2 01-04-2004 02:52 PM
layer problem [urgent] Joeba MapPoint 2006/2009 Discussion 3 10-16-2003 10:11 AM


All times are GMT -5. The time now is 10:54 AM.


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


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 52 53 54 55