As the crows flies and rail

Well
05-24-2007, 03:05 PM
MapPoint is a very nice tool to find road distances between two cities.

Is there any way to do the same things with railway or as the crows flies distances?

Thanks for your help

A. Ouellet

Wilfried
05-25-2007, 03:02 AM
Hi,

You can use Distance or DistanceTo methods.

Well
05-25-2007, 07:12 AM
Hi Wilfred and everybody,

I succeed to find route and as the crow flies distances between two cities. However, I haven't any idea on how to find railway distance. I possibly also need to find maritime distance between two ports. Is there a way to do that?


Thanks a lot,

A. Ouellet

P.S: I am a french Canadian. I am sorry for all possible English mistakes

Well
05-25-2007, 07:19 AM
I just forgot. Here is the code I use. It work good.

A. Ouellet

Private Sub CommandButton1_Click()
Dim oApp As MapPoint.Application
Dim objMap As MapPoint.Map
Dim objLocOne As MapPoint.Location
Dim objLocTwo As MapPoint.Location
Dim objRoute As Route
Dim LocOne As String
Dim LocTwo As String
Dim sFileName As String
Dim Distance As Long
Dim i As Integer

Set oApp = CreateObject("MapPoint.Application.NA.11")
Set objMap = oApp.NewMap
Set objRoute = objMap.ActiveRoute

i = 3
Do Until Cells(i, 1) = 0
'As the crow flies
LocOne = Cells(i, 1)
LocTwo = Cells(i, 2)
Set objLocOne = objMap.FindResults(LocOne).Item(1)
Set objLocTwo = objMap.FindResults(LocTwo).Item(1)
objMap.AddPushpin objLocOne
objMap.AddPushpin objLocTwo
Distance = objMap.Distance(objLocOne, objLocTwo)
Cells(i, 3) = Distance
Cells(i, 4) = Distance * 1.609344 'km

'Route distances
objRoute.Waypoints.Add objMap.FindResults(LocOne).Item(1)
objRoute.Waypoints.Add objMap.FindResults(LocTwo).Item(1)
objRoute.Calculate

Distance = objRoute.Distance
Cells(i, 5) = Distance
Cells(i, 6) = Distance * 1.609344 'km

i = i + 1
Loop

'Insert map in Excel
objMap.DataSets.ZoomTo 'Zoom sur la map
sFileName = "\\Exchange-srv\Alexandre\Recherche\MapPoint\Map.ptm (file://\\Exchange-srv\Alexandre\Recherche\MapPoint\Map.ptm)"
objMap.SaveAs sFileName
ActiveSheet.OLEObjects.Add(Filename:=sFileName, Link:=False,_ DisplayAsIcon:=False).Select

End Sub

Wilfried
05-25-2007, 12:58 PM
Hi,

For railway distance I think the only possible way is to put Location objects and calculate distance in segments.

What exacly do you mean by 'maritime distance' ? Do you mean the distance in Nautical miles ?

Well
05-25-2007, 01:39 PM
Hi Wilfried,

For the railway distance, that’s what I though.

By 'maritime distance', I mean distance between two ports in km. As a crow flies distance is a good approximation, but imprecise. For example, look at the way to get the Montreal port when coming from Europe.

Thank you again,

A. Ouellet

P.S: Sorry again for english mistakes

Wilfried
05-26-2007, 05:42 AM
Hi,

I understeand, thanks for clarify. I think with maritime distance it will be the same problem as for rail distance.

 
Web mp2kmag.com
mapforums.com