MapPoint Forums

MapForums

Community of MapPoint and Bing Maps Users and Developers




Route Optimization

This is a discussion on Route Optimization within the Development forums, part of the MapPoint Desktop Discussion category; We are trying to better understand how to set up MapPoint (or another application) to optimize delivery routes for us. ...


Go Back   MapPoint Forums > Map Forums > MapPoint Desktop Discussion > Development

Today's Posts Twitter Feed Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
  2 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 07-04-2009
Junior Member
White Belt
 
Join Date: Jul 2009
Posts: 5
Route Optimization

We are trying to better understand how to set up MapPoint (or another application) to optimize delivery routes for us. We have the ability to push lists of addresses but need some simple options for the drivers to select a starting point address and to be able to reorder the addresses visually if necessary. Please advise if there is sample code available for this, if we can do it through a hosted version of MapPoint or if we need to host a copy of MapPoint on our server.
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 07-06-2009
Senior Member
Black Belt
 
Join Date: Nov 2004
Location: Belgium
Posts: 2,308
Re: Route Optimization

Hi,

this is a brief example that should get you started. You need for each start / stop / via point a Location object. You can create this Location object by latitude / longitude coordinates, but also with address.

Code:
// if there was a previous active route then we clear it
route.Clear();

// set start point
loc = map.GetLocation(Lat, Lon, Alt);
wp = route.Waypoints.Add(loc, "Start point");
wp.SegmentPreferences = GeoSegmentPreferences.geoSegmentPreferred;

// set waypoints
loc = map.GetLocation(Lat, Lon, Alt);
wp = route.Waypoints.Add(loc, "a waypoint");
wp.SegmentPreferences = GeoSegmentPreferences.geoSegmentPreferred;

// set end point
loc = map.GetLocation(Lat, Lon, Alt);
wp = route.Waypoints.Add(loc, "the eindpoint");
wp.SegmentPreferences = GeoSegmentPreferences.geoSegmentPreferred;

// eventually you can optimize the route
route.Waypoints.Optimize();

// set preferred roads
route.DriverProfile.set_PreferredRoads(GeoRoadType.geoRoadArterial, 0.1);
route.DriverProfile.set_PreferredRoads(GeoRoadType.geoRoadFerry, 0.1);
route.DriverProfile.set_PreferredRoads(GeoRoadType.geoRoadInterstate, 0.9);
route.DriverProfile.set_PreferredRoads(GeoRoadType.geoRoadOtherHighway, 0.6);
route.DriverProfile.set_PreferredRoads(GeoRoadType.geoRoadToll, 0.2);

// set preferred speed
route.DriverProfile.set_Speed(GeoRoadType.geoRoadArterial, 50);
route.DriverProfile.set_Speed(GeoRoadType.geoRoadInterstate, 120);
route.DriverProfile.set_Speed(GeoRoadType.geoRoadLimitedAccess, 120);
route.DriverProfile.set_Speed(GeoRoadType.geoRoadOtherHighway, 90);
route.DriverProfile.set_Speed(GeoRoadType.geoRoadStreet, 50);

// set time
route.DriverProfile.StartTime = System.DateTime.Now;

// finally calculate the route
route.Calculate();
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 07-06-2009
Junior Member
White Belt
 
Join Date: Jul 2009
Posts: 5
Re: Route Optimization

Hi Wilfried,
Thank you for the pointing. Can you tell me how the software would work? Do we need to host a copy of MapPoint on our web server or how does that part work?

This is for a new venture we are working on in an effort to help people eat healthier. Check our web site: www.freggies.com

We are currently sending our address lists (for delivery) to Google maps but then the driver has to sort them manually. We are hoping for an easier solution where we can have the software optimize the list.

Thank you for your additional input-
Regards,
Jerrod
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 07-08-2009
Senior Member
Black Belt
 
Join Date: Nov 2004
Location: Belgium
Posts: 2,308
Re: Route Optimization

Hi,

No Mappoint is a desktop program. However you can host an application on a webserver that uses MapPoint embedded, for example to calculate the route. But to view maps and route you need MapPoint on the client machines.
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 07-08-2009
Junior Member
White Belt
 
Join Date: Jul 2009
Posts: 5
Re: Route Optimization

Wilfried,
I know that mappoint allows for the map view and directions to be outputted fairly easily. If we hosted this on our server, couldn't we just do the work of developing the route there and then just feed the results via text or graphic image?

Do you know of another solution that would get us to where we need to be? We need to be able to send a starting point and a list of stops and have a result in a list of addresses in order after optimization. Even a graphic image is secondary to just getting the list optimized.

Thank you-
Jerrod
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 07-10-2009
Senior Member
Black Belt
 
Join Date: Nov 2004
Location: Belgium
Posts: 2,308
Re: Route Optimization

Hi,

Yes you can calculate all with mappoint on a server machine and send text or graphic output to client machines.
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 07-10-2009
Junior Member
White Belt
 
Join Date: Jul 2009
Posts: 5
Re: Route Optimization

Wilfried - is there some additional text code needed to accomplish this? if so, can you provide me with a quote to create that for us? i have a copy of MP 2009 that we could load on our server for this use.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8 (permalink)  
Old 07-13-2009
Senior Member
Black Belt
 
Join Date: Nov 2004
Location: Belgium
Posts: 2,308
Re: Route Optimization

Hi Jerrod,

Yes of course. Please contact me on my private email address.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #9 (permalink)  
Old 3 Weeks Ago
Junior Member
White Belt
 
Join Date: Jan 2010
Posts: 6
Question Re: Route Optimization

Quote:
Originally Posted by Wilfried View Post
Hi,

this is a brief example that should get you started. You need for each start / stop / via point a Location object. You can create this Location object by latitude / longitude coordinates, but also with address.

Code:
// if there was a previous active route then we clear it
route.Clear();

// set start point
loc = map.GetLocation(Lat, Lon, Alt);
wp = route.Waypoints.Add(loc, "Start point");
wp.SegmentPreferences = GeoSegmentPreferences.geoSegmentPreferred;

// set waypoints
loc = map.GetLocation(Lat, Lon, Alt);
wp = route.Waypoints.Add(loc, "a waypoint");
wp.SegmentPreferences = GeoSegmentPreferences.geoSegmentPreferred;

// set end point
loc = map.GetLocation(Lat, Lon, Alt);
wp = route.Waypoints.Add(loc, "the eindpoint");
wp.SegmentPreferences = GeoSegmentPreferences.geoSegmentPreferred;

// eventually you can optimize the route
route.Waypoints.Optimize();

// set preferred roads
route.DriverProfile.set_PreferredRoads(GeoRoadType.geoRoadArterial, 0.1);
route.DriverProfile.set_PreferredRoads(GeoRoadType.geoRoadFerry, 0.1);
route.DriverProfile.set_PreferredRoads(GeoRoadType.geoRoadInterstate, 0.9);
route.DriverProfile.set_PreferredRoads(GeoRoadType.geoRoadOtherHighway, 0.6);
route.DriverProfile.set_PreferredRoads(GeoRoadType.geoRoadToll, 0.2);

// set preferred speed
route.DriverProfile.set_Speed(GeoRoadType.geoRoadArterial, 50);
route.DriverProfile.set_Speed(GeoRoadType.geoRoadInterstate, 120);
route.DriverProfile.set_Speed(GeoRoadType.geoRoadLimitedAccess, 120);
route.DriverProfile.set_Speed(GeoRoadType.geoRoadOtherHighway, 90);
route.DriverProfile.set_Speed(GeoRoadType.geoRoadStreet, 50);

// set time
route.DriverProfile.StartTime = System.DateTime.Now;

// finally calculate the route
route.Calculate();
Hi. I build as below:
Private Sub OBLICZ()
Dim objApp As New MapPoint.Application
Dim objMap As MapPoint.Map
Dim objRoute As MapPoint.Route
Dim objLoc1 As MapPoint.Location
Dim objLoc2 As MapPoint.Location

Set objApp = CreateObject("MapPoint.Application.EU.16")
objApp.Visible = False

Set objMap = objApp.NewMap
Set objRoute = objMap.ActiveRoute
Worksheets("Arkusz1").Cells(1, 3).Value = "ODLEGŁOŚĆ (kms)"
Worksheets("Arkusz1").Cells(1, 4).Value = "Czas(mins)"
Worksheets("Arkusz1").Cells(1, 5).Value = "Koszt(PLN)"
NReadRow = 2

Do While Worksheets("Arkusz1").Cells(NReadRow, 2) <> ""

'Locate the 2 points
Set objLoc1 = objMap.FindResults(Worksheets("Arkusz1").Cells(NRe adRow, 1)).Item(1)
Set objLoc2 = objMap.FindResults(Worksheets("Arkusz1").Cells(NRe adRow, 2)).Item(1)

'Calculate the route
objRoute.Waypoints.Add objLoc1
objRoute.Waypoints.Add objLoc2
objRoute.Calculate

'Drive Distance in kms
Worksheets("Arkusz1").Cells(NReadRow, 3) = objRoute.Distance
'Drive Time in minutes
Worksheets("Arkusz1").Cells(NReadRow, 4) = objRoute.DrivingTime
'Straight Line Distance in kms (as a check)
Worksheets("Arkusz1").Cells(NReadRow, 5) = objRoute.Cost
objRoute.Clear

NReadRow = NReadRow + 1

Loop

End Sub

Can You add for me to my compilation:
use motorways - max
national roads - max - 2

fuel consumtion:
city - 20
other - 16
cost per liter - 2,20

stop for 30minutes after 3hrs driving

I aprecieate a help
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #10 (permalink)  
Old 3 Weeks Ago
Senior Member
Black Belt
 
Join Date: Nov 2004
Location: Belgium
Posts: 2,308
Re: Route Optimization

Hi,

Code:
objroute.DriverProfile.set_PreferredRoads(GeoRoadType.geoRoadInterstate, 0.9);
objroute.DriverProfile.set_PreferredRoads(GeoRoadType.geoRoadOtherHighway, 0.6);
And similar for the other parameters you need.
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
optimization, route


LinkBacks (?)
LinkBack to this Thread: http://www.mapforums.com/route-optimization-10729.html

Posted By For Type Date
A Simple Add-in for MapPoint API Beginners - MapPoint Articles - MP2K Magazine This thread Refback 07-06-2009 10:15 AM
"Excel Basics to Blackbelt": A Reference Text for MapPoint Integration - MapPoint Articles - MP2K Magazine This thread Refback 07-06-2009 10:00 AM

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
Route optimization Lanzo Bing Maps and MapPoint Web Service 5 09-22-2009 04:17 AM
Route Optimization in Bing Maps powered by OnTerra’s free Stop Optimization Service Johannes Kebeck's Blog Bing Maps Blogs & Tweets 0 07-01-2009 08:11 AM
In using Optimization for a route, is there any wa.... Anonymous MapPoint Desktop Discussion 3 11-18-2008 03:38 AM
Route Optimization and Stop Time DorothyJBT Bing Maps and MapPoint Web Service 3 06-12-2008 04:25 AM
Route Optimization Jeff Smith MapPoint Desktop Discussion 0 03-23-2005 03:06 PM


All times are GMT -5. The time now is 08:04 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.2
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 55 56 57 58 59 60 61 62 63 64 65 66 67