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 10 of 10

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. ...

  1. #1
    sessler is offline 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.

  2. #2
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433

    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();

  3. #3
    sessler is offline 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

  4. #4
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433

    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.

  5. #5
    sessler is offline 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

  6. #6
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433

    Re: Route Optimization

    Hi,

    Yes you can calculate all with mappoint on a server machine and send text or graphic output to client machines.

  7. #7
    sessler is offline 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.

  8. #8
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433

    Re: Route Optimization

    Hi Jerrod,

    Yes of course. Please contact me on my private email address.

  9. #9
    jakevo is offline Junior Member Yellow Belt
    Join Date
    Jan 2010
    Posts
    18

    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

  10. #10
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433

    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.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Route optimization
    By Lanzo in forum Bing Maps and MapPoint Web Service
    Replies: 5
    Last Post: 09-22-2009, 03:17 AM
  2. Route Optimization in Bing Maps powered by OnTerra’s free Stop Optimization Service
    By Johannes Kebeck's Blog in forum Bing Maps Blogs & Tweets
    Replies: 0
    Last Post: 07-01-2009, 07:11 AM
  3. In using Optimization for a route, is there any wa....
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 3
    Last Post: 11-18-2008, 02:38 AM
  4. Route Optimization and Stop Time
    By DorothyJBT in forum Bing Maps and MapPoint Web Service
    Replies: 3
    Last Post: 06-12-2008, 03:25 AM
  5. Route Optimization
    By Jeff Smith in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 03-23-2005, 02:06 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 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132