spacer1
spacer2 1_1 1_2
2_1
 Subscribe
 The MP2K Update!
 
 
 
 Magazine
Front Cover
What's New
Articles
News
Sample Data
Gallery
Advertise
About
 Features
MapPoint 2013
Press Releases
MapPoint Forums
Companies
Link to MP2Kmag
Wish List
MapPoint Trial
Authors
 Earlier Content
Past News Items
Past What's New Announcements
 Sponsors
 Order

MapPoint 2013

Programming MapPoint in .NET

MapPoint Book

  Spatial Community
SVG Tutorials
MapPoint

Map Visitors

  MAPPOINT Q & A  

Top | Post New Question | Read All | MP2K Asks Microsoft

627 Walter - March 15, 2002

I am a first time database developer working on an Access database. I have a list of 200,000 customer records that have Latitude and Longitude coordinates (formatted in decimals, like: 40.72323 = Latitude and -73.99569 = longitude). I know the coordinates of 700 points of sale and I know the closest point of sale and the "crow flies distance" to that closest point of sale. I would like to add to my table of customers the drive distance to the closest point of sale. Thus I have a table: [cust_ID], [CLOSEST_POS_ID], [customer_latitude], [customer_longitude], [closest_POS_latitude] and [closest_POS_longitude], [drive_distance]. I would like to be able to do an update query that would populate the [drive_distance] field with the actual drive distance. Thus far, in my fledgling developer career, I have not "connected" with another program (please be specific). Thanks for your help.

Answer:

In a VB form, add the MapPoint ActiveX control, and call it "MapPointCtl".

Then do something like:

Dim objLocS As MapPointCtl.Location
Dim objLocF As MapPointCtl.Location
Dim objMap As MapPointCtl.Map
Dim objRoute as MapPointCtl.Route

Set objMap = ctlMapPoint.ActiveMap
Set objRoute = objMap.ActiveRoute

'...get dblLatS and dblLatF for the starting and ending points
'from your database
Set objLocS = objMap.GetLocation(dblLatS, dblLonS)
Set objLocF = objMap.GetLocation(dblLatF, dblLonF)

'Add Waypoints
objRoute.Waypoints.Add objLocS
objRoute.Waypoints.Add objLocF
objRoute.Calculate

'Get the distance
dblDriveDistance = objRoute.Distance

I haven't tested this so it may need some tweaking, but this should generally work. Be advised it will take a little bit of time to calculate 200,000 routes.

- Walt Cygan

Post New Answer / Follow-up


Google
 
MP2Kmag Internet


 Recent Discussion
 Resources


Want Your Site To Appear Here?

   © 1999-2012 MP2K. Questions and comments to: website@mp2kmag.com
  Microsoft and MapPoint 2002/2004/2006/2009/2010/2011/2013 are either trademarks or registered trademarks of Microsoft.