MK Map

Here's a tool to find local area names within Milton Keynes. It's useful!

Using a T610, I can find area names within Milton Keynes, so when a resident calls to say "I can't get get Broadband in Wavenden Gate!" I can quickly find out where this remote place is. I select Wavenden Gate on the phone, and MapPoint springs into life showing where Wavendon Gate is.

Putting it all together

We have lots of components here - the sort of arena Bill Gates loves!

Where to start?

1, Buy the phone. "The Link" offered me one for 100, with a contract at 15 a month. (I might get around to using it as a phone one day.)

2, Download Phone Front.

3, Install Bluetooth. Today I'm using 3Com's offering. (As an aside, no I cannot transfer photos from the phone to the pc using Bluetooth!)

4, MapPoint has an Automation interface. You know OCX, COM. Well it's 2003 and they're called assemblies these days and we have to do things differently.

Here's how I created the MapPoint Automation interface:

C:\temp>TlbImp "C:\Program Files\Microsoft MapPoint Europe\mpeu81.tlb" /verbose

Microsoft (R) .NET Framework Type Library to Assembly Converter 1.1.4322.573
Copyright (C) Microsoft Corporation 1998-2002. All rights reserved.

Type GeoFieldType imported.
Type GeoCountry imported.
Type GeoRGBType imported.
...
Type Recordset80 imported.
Type Field80 imported.
Type library imported to MapPoint.dll

C:\temp>dir *.dll
Directory of C:\temp

22/08/2003 12:42 102,400 MapPoint.dll

I copied the generated file "MapPoint.dll" in to the Phone Front directory. Adding the a reference to the dll in the Phone Front script editor means we can "do things" with MapPoint. I've put a copy here.

5 Visual Basic .NET (VB.NET) We are running the Common Language Runtime, and VB is an easy way to get started. Make your life easier by compiling testing and running under Visual Studio. Final tweaks can be made with the Phone Front Editor.

6 Getting the local area names from within Milton Keynes in a programmatic form is devious, but not horrendous.

  1. Get a Milton Keynes City Atlas.
  2. OCR in the local names index to grid reference table.
  3. Convert the atlas 800metre grid references to Ordnance Survey Grid references
  4. Convert Ordnance Survey Grid references to Latitude and Longitude. I've done this before.
  5. Generate the local area name, latitude and longitude as a series of VB statements

Here's the Phone Front Script file.

Installing MK Map

Here are some notes on installing MK Map. Copy the MapPoint assembly DLL and VB script files to the phone front directory "C:\Program Files\Phone Front".

Click "Add..." and choose the MK Map, adding it to the phone menu.

The Code

There's a small piece of code for Phone Front "My.Phone.ShowMenu" that presents a menu on the phone.

Imports System
Imports PhoneFrontObject
Imports Microsoft.VisualBasic

Public Class AreaInfo

    ' manages area name and location

Public Sub New(ByVal n As String, ByVal lt As String, ByVal ln As String)

name = n
latitude = lt
longitude = ln

End Sub

Public Function GetName()

Return name

End Function

Public Sub GetLatLong(ByRef lt As String, ByRef ln As String)

lt = latitude
ln = longitude

End Sub

Private name As String
Private latitude As String
Private longitude As String

End Class

Public Class Chunkette

    ' manages a sub menu of areas

Public Sub New(ByVal chunkname As String)

name_ = chunkname
a1 = New AreaInfo() {}

End Sub

Public Sub AddAreaInfo(ByVal area As String, ByVal lat As String, ByVal lon As String)

ReDim Preserve a1(a1.GetUpperBound(0) + 1)
a1(a1.GetUpperBound(0)) = New AreaInfo(area, lat, lon)

End Sub

Public Function GetName()

Return name_

End Function

Public Sub GetLatLong(ByVal index As Int16, ByRef lt As String, ByRef ln As String)

a1(index).GetLatLong(lt, ln)

End Sub

Private name_ As String
Private a1 As AreaInfo()

Public Sub BuildArray(ByRef arr As String())

arr = New String() {}

Dim i As AreaInfo

For Each i In a1

ReDim Preserve arr(arr.GetUpperBound(0) + 1)
arr(arr.GetUpperBound(0)) = New String(i.GetName())

Next

End Sub

End Class

Public Class AreaMap

    ' manages the entire map

Public Sub New()

areas_ = New Chunkette() {}
AddChunkName("As..Bl")
AddAreaInfo("ASHLAND", "52.01738207897", "-0.730730095426344")
AddAreaInfo("ATTERBURY", "52.0530820672119", "-0.706384001530729")
AddAreaInfo("BANCROFT", "52.0539499345162", "-0.788032039186508")
AddAreaInfo("BANCROFT PARK", "52.054069298774", "-0.799696376884553")
AddAreaInfo("BEANHILL", "52.0175070534213", "-0.742384669782257")
AddAreaInfo("BLAKELANDS", "52.075033151798", "-0.740769000914645")
AddAreaInfo("BLEAK HALL", "52.0176308751963", "-0.754039328550041")
AddAreaInfo("BLETCHLEY", "51.9959346115866", "-0.74298915152133")
AddAreaInfo("BLUE BRIDGE", "52.0612602034784", "-0.799503651832278")
AddChunkName("Bo..Br")
AddAreaInfo("BOLBECK PARK", "52.0678424223646", "-0.740971255786758")
AddAreaInfo("BRADVILLE", "52.0611408085155", "-0.787837441965636")

...

AddAreaInfo("WILLEN LAKE", "52.0532095107107", "-0.718047752186325")
AddAreaInfo("WILLEN PARK", "52.0605265161132", "-0.729507631680813")
AddAreaInfo("WINTERHILL", "52.0321352520023", "-0.765298135083233")
AddChunkName("Wo..Wy")
AddAreaInfo("WOLVERTON", "52.0613784438916", "-0.811169942472653")
AddAreaInfo("WOLVERTON MILL", "52.0616114609964", "-0.834502762938018")
AddAreaInfo("WOLVERTON MILL EAST", "52.0616114609964", "-0.834502762938018")
AddAreaInfo("WOLVERTON MILL SOUTH", "52.0544204659574", "-0.834689871216744")
AddAreaInfo("WOODHILL", "52.0110417021648", "-0.812504235053032")
AddAreaInfo("WOOLSTONE", "52.0389543398436", "-0.730119247562297")
AddAreaInfo("WOUGHTON ON THE GREEN", "52.0317635956198", "-0.73032294878901")
AddAreaInfo("WOUGHTON PARK", "52.0244466824536", "-0.718870207588151")
AddAreaInfo("WYMBUSH", "52.0396874613461", "-0.800081584847822")

End Sub

Private Sub AddChunkName(ByVal x As String)

ReDim Preserve areas_(areas_.GetUpperBound(0) + 1)
areas_(areas_.GetUpperBound(0)) = New Chunkette(x)
'Console.WriteLine(areas_.GetUpperBound(0))

End Sub

Public Sub BuildRootArray(ByRef arr As String())

arr = New String() {}

Dim i As Chunkette
For Each i In areas_

ReDim Preserve arr(arr.GetUpperBound(0) + 1)
arr(arr.GetUpperBound(0)) = New String(i.GetName())

Next

End Sub

Public Sub BuildAlphaArray(ByVal i As Int16, ByRef arr As String())

areas_(i).BuildArray(arr)

End Sub

Public Sub GetLatLong(ByVal chunk As Int16, ByVal index As Int16, ByRef lt As String, ByRef ln As String)

areas_(chunk).GetLatLong(index, lt, ln)

End Sub

Private Sub AddAreaInfo(ByVal area As String, ByVal lat As String, ByVal lon As String)

areas_(areas_.GetUpperBound(0)).AddAreaInfo(area, lat, lon)

End Sub

Private areas_ As Chunkette()

End Class

Public Class PhoneFrontScript

Public Shared Sub Main()

Dim MKMap As AreaMap = New AreaMap
Dim lt As String
Dim ln As String

Dim oMpApp As MapPoint.Application
Dim objLoc As MapPoint.Location

Try

oMpApp = GetObject(, "MapPoint.Application")

Catch ex As System.Exception

oMpApp = New MapPoint.Application()
MKMap.GetLatLong(2, 3, lt, ln)
' CMK!
objLoc = oMpApp.ActiveMap.GetLocation(lt, ln)
objLoc.GoTo
oMpApp.ActiveMap.ZoomIn
oMpApp.ActiveMap.ZoomIn
oMpApp.ActiveMap.ZoomIn
oMpApp.ActiveMap.ZoomIn
oMpApp.ActiveMap.ZoomIn
oMpApp.ActiveMap.ZoomIn
oMpApp.ActiveMap.ZoomIn

End Try

oMpApp.WindowState = 0
' maximise!
oMpApp.Visible = True
oMpApp.UserControl = True

Dim menu As String()
MKMap.BuildRootArray(menu)

Dim chunk As Integer = My.Phone.ShowMenu("Area Key", 0, menu)
if (chunk < 0)

return

end if

MKMap.BuildAlphaArray(chunk , menu)
Dim oom1 As Integer = My.Phone.ShowMenu("Area Names", 0, menu)

if (oom1 < 0)

return

end if

MKMap.GetLatLong(chunk , oom1 , lt, ln)
objLoc = oMpApp.ActiveMap.GetLocation(lt, ln)

Dim objPushpin As MapPoint.Pushpin = oMpApp.ActiveMap.AddPushpin(objLoc, menu(oom1))
' Browse to the pushpin.
objPushpin.GoTo()
' Highlight the pushpin.
objPushpin.Highlight = True

End Sub

End Class

Broadband

Above I said "So when some resident calls to say 'I can't get get Broadband in Wavenden Gate!'"... Why?

That's because I live in Milton Keynes, a modern city in England that has dire Broadband coverage.

I'm doing something about it!

Comments

Comments? Email me