Welcome to MapForums!

Register, sign in, or use Facebook Connect above to join in and participate in the forum.

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

Subscribe to receive our newsletter.
Subscribe Unsubscribe
Results 1 to 2 of 2

Reverse Geocoding, Pt. III

This is a discussion on Reverse Geocoding, Pt. III within the MP2K Magazine Articles forums, part of the Map Forums category; Walt Cygan, a frequent contributor of late, submits this solution for tackling reverse geocoding Read the full article: http://www.mp2kmag.com/articles.asp?ArticleID=50...

  1. #1
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137

    Reverse Geocoding, Pt. III

    Walt Cygan, a frequent contributor of late, submits this solution for tackling reverse geocoding

    Read the full article: http://www.mp2kmag.com/articles.asp?ArticleID=50

  2. #2
    Mossoft is offline Member Yellow Belt
    Join Date
    Feb 2003
    Posts
    48
    I have a similar/simpler/less accurate(but good enough for my purposes) method which I call when a point on the map is clicked, passing in the location's X and Y values:

    Code:
    Function FindNearestAddress(locX As Long, locY As Long) As String
    'Mossoft2003
        Dim dblTolerance    As Double
        Dim blnFound        As Boolean
        Dim lngCount        As Long
        Dim fr      As MapPoint.FindResults
        Dim sa      As MapPoint.StreetAddress
        Dim obj     As Object
        Dim lngAttempt  As Long
        Dim ToleranceStep   As Long
        Dim dX      As Long
        Dim dY      As Long
        Const ALTITUDE_LIMIT = 15
        
        On Error Resume Next
        
        If mapWhere.ActiveMap.Altitude < ALTITUDE_LIMIT Then
        
            blnFound = False
            lngAttempt = 0
            ToleranceStep = ALTITUDE_LIMIT - mapWhere.ActiveMap.Altitude
            dX = locX
            dY = locY
    
            Do
                Set fr = mapWhere.ActiveMap.ObjectsFromPoint&#40;dX, dY&#41;
                For Each obj In fr
                    Set sa = obj.StreetAddress
                    If Not sa Is Nothing Then
                        FindNearestAddress = sa.Value & " &#40;" & CStr&#40;mapWhere.ActiveMap.Distance&#40;mapWhere.ActiveMap.XYToLocation&#40;locX, locY&#41;, obj&#41;&#41; & " miles&#41;"
                        blnFound = True
                        Exit For
                    End If
                Next
                If blnFound Then Exit Do
                lngAttempt = lngAttempt + 1
                Select Case lngAttempt Mod 8
                    Case 1
                        dX = locX
                        dY = locY + ToleranceStep
                    Case 2
                        dX = locX + ToleranceStep
                        dY = locY + ToleranceStep
                    Case 3
                        dX = locX + ToleranceStep
                        dY = locY
                    Case 4
                        dX = locX + ToleranceStep
                        dY = locY - ToleranceStep
                    Case 5
                        dX = locX
                        dY = locY - ToleranceStep
                    Case 6
                        dX = locX - ToleranceStep
                        dY = locY - ToleranceStep
                    Case 7
                        dX = locX - ToleranceStep
                        dY = locY
                    Case 0
                        dX = locX - ToleranceStep
                        dY = locY + ToleranceStep
                        ToleranceStep = ToleranceStep + 1
                End Select
            Loop While Not blnFound And ToleranceStep < &#40;2 * ALTITUDE_LIMIT&#41;
        End If
        
    FNA_Exit&#58;
        Exit Function
    FNA_Error&#58;
        Debug.Print "ERROR&#58; " & Err.Description
        Resume FNA_Exit
    
    End Function
    The search pattern is an 8 pointed star eminating, and spiralling out, from the original point.
    The altitude check is to ensure the view point is low enough to display address level locations.

    M.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Reverse Geocoding
    By Anonymous in forum News and Announcements
    Replies: 30
    Last Post: 07-26-2006, 12:21 PM
  2. Reverse geocoding with c#
    By ayazaliuk in forum MapPoint Desktop Discussion
    Replies: 3
    Last Post: 06-16-2005, 07:52 AM
  3. Reverse GeoCoding
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 04-16-2004, 11:56 AM
  4. reverse geocoding
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 01-26-2004, 11:15 PM
  5. Reverse Geocoding
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 01-26-2004, 01:30 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96