MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




Lat/Long of my Postal Code

This is a discussion on Lat/Long of my Postal Code within the MapPoint 2006/2009 Discussion forums, part of the Map Forums category; Hello guys, it is possible to get Lat/Long of an Postal Code? I found this: http://www.mp2kmag.com/articles.asp?ArticleID=9 But why must show ...


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 11-23-2005
Junior Member
White Belt
 
Join Date: Nov 2005
Posts: 3
Lat/Long of my Postal Code

Hello guys,

it is possible to get Lat/Long of an Postal Code?

I found this:

http://www.mp2kmag.com/articles.asp?ArticleID=9

But why must show the Find Form from Mappoint?
Is it possible to make it with this code?

Set oPushA = oMap.FindAddressResults(Street, City, , , PLZ)
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 11-25-2005
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,112
Hi,

Yes, FindAddressResults give you a collection of Location objects. To get the lat / long you have to write some code yourself. Check also this article http://www.mp2kmag.com/articles.asp?...xtract.lat.lon to find out.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3 (permalink)  
Old 11-26-2005
Junior Member
White Belt
 
Join Date: Nov 2005
Posts: 3
But I have no lat/long.

What can I do?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4 (permalink)  
Old 11-26-2005
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,112
Hi,

No what you get in the results is a collection of Location objects. They do not contain the coordinates, but the article shows you an easy method of getting the coordinates from out of a Location object.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5 (permalink)  
Old 11-26-2005
Junior Member
White Belt
 
Join Date: Nov 2005
Posts: 3
But when I make an Function I must have an Parameter dblLat and dblLon.

Is this correct or what make i wrong?


' Compute latitude and longitude given a location object
' Author: Gilles Kohl
' (gilles@compuserve.com)
'
' This code is copyrighted freeware - use freely, but please leave this
' header intact. Suggestions and comments welcome.

Function Arccos(x As Double) As Double
If x = 1 Then
Arccos = 0
Exit Function
End If
Arccos = Atn(-x / Sqr(-x * x + 1)) + 2 * Atn(1)
End Function

Public Function 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
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
  #6 (permalink)  
Old 11-27-2005
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,112
Hi,


Quote:
Public Function CalcPos(objMap As MapPoint.map, locX As MapPoint.Location, dblLat As Double, dblLon As Double)
dblLat and dblLon are result pareameters, so as far as I can see quick from this example VB takes parameters by reference. so you have to define them and put on the stack before calling CalcPos.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7 (permalink)  
Old 11-29-2005
calv1ns's Avatar
Member
Green Belt
 
Join Date: Mar 2005
Posts: 91
Wil is right...

The way Gilles wrote the routine is for the values of dblLat and dblLong to be passed back out of the subroutine. In VB6 the routine works great. In .net in addition to all the syntax changes you have to pass the two lat long varaibles "ByRef" so the routine has access to change them. This is all explained by Gilles here:

http://www.mp2kmag.com/a66--location....mappoint.html

Good luck,
Ciao,
__________________
Calv1ns
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
code, lat or long, postal


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
Office Interface, Lat & Long, Canada & Mexico Postal The Lone Turtle Wish List 0 11-13-2005 08:12 AM
POSTAL CODE????? Anonymous Wish List 0 02-12-2005 06:01 AM
Postal Code Anonymous MapPoint 2006/2009 Discussion 1 10-14-2004 04:08 PM
How to get a postal code huelsi MapPoint 2006/2009 Discussion 0 07-27-2003 01:00 PM
need postal code! Anonymous Wish List 0 07-22-2003 05:47 AM


All times are GMT -5. The time now is 12:27 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