MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




Handling Route that Calculates but does not Optimize

This is a discussion on Handling Route that Calculates but does not Optimize within the MapPoint 2006/2009 Discussion forums, part of the Map Forums category; MapPoint Programming Challenge Come up with the best solution and get recognition in the next newsletter as well as receive ...


Go Back   MapPoint Forums > Map Forums > MapPoint 2006/2009 Discussion

Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 09-19-2004
Eric Frost's Avatar
Senior Member
Black Belt
 
Join Date: Jul 1992
Posts: 2,322
Blog Entries: 1
Handling Route that Calculates but does not Optimize

MapPoint Programming Challenge

Come up with the best solution and get recognition in the next newsletter as well as receive your choice of a Large MapPoint Mug or a AutoRoute 2004.



Some collections of stops cannot be Optimized. If this is being done programmatically, execution hangs.

A minimal example of a route that will not Optimize can be downloaded here:
http://www.mp2kmag.com/downloads/florida_ptm.zip

The route will calculate fine, but when you try to optimize, it returns an error "Unable to get directions from ... move one or both of the stops, and try again".

Specifically, it is the route up on Hilton street that is preventing it from Optimizing, if you shift it even slightly it seems to be fine.

So working Interactively, this is not really a problem. But programmatically from Excel, I am having trouble finding a way to trap for this condition.

Stops can be tested and those that that are totally unroutable (stuck behind a one-way road or on a mini-road network not connected to the main road network) can be caught as an error is generated from this condition. You can then shift the individual stop's position until it works.

Optimize does not generate a trappable error in the same way, it just hangs.

Here's the same minimal route in Excel, the code is included below.
http://www.mp2kmag.com/downloads/florida_xls.zip

When you run it, you see MapPoint uses cpu for several minutes, then just gives up.. there is no error generated, it just hangs. (hit ctrl-alt-del and kill mappoint to get back to excel).

How is it possible to detect this hanging or have it trigger and error and continue program execution without user intervention?

Good luck!
Eric

Code:
Private Sub CommandButton1_Click()
  'This will prevent the waiting for ole application warning from popping up
  Application.DisplayAlerts = False

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

  For i = 2 To 5
    objRoute.WayPoints.Add objMap.GetLocation(Worksheets("Sheet1").Cells(i, 2), _
      Worksheets("Sheet1").Cells(i, 3)), Worksheets("Sheet1").Cells(i, 1)
  Next
  
  Stop
  'The route can be calculated i.e. all the stops are routable
  objRoute.Calculate
  
  Stop
  'It is this Optimize that hangs and unfortunately doesn't generate an error trappable
  'by Excel. The error only appears when working interactively with MapPoint.
  objRoute.WayPoints.Optimize

  'Set back to true
  Application.DisplayAlerts = False
End Sub
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 01-28-2005
Senior Member
Black Belt
 
Join Date: Jul 2002
Posts: 5,138
MapPoint Programming Challenge - any solutions?

Hey All,

Did anybody come up with thoughts on the programming challenge? ("Some collections of stops cannot be Optimized. If this is being done programmatically, execution hangs.") I see no posts here... we'd much like some help with this one as it has us banging our heads.

-Tom
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 01-29-2005
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,055
Re: MapPoint Programming Challenge - any solutions?

Hi Tom,

A workaround could be to create the mappoint component in a thread and execute it invisible. Or maybe the object model. After a certain timeout then kill the thread.

However: I really dont know if the component or the object model or both are thread safe.
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 01-29-2005
Eric Frost's Avatar
Senior Member
Black Belt
 
Join Date: Jul 1992
Posts: 2,322
Blog Entries: 1
Oh, that's good I am not the only one. The best we have come up with is to have a separate (asynch) thread running to check for a failed (0 cpu usage) and hanging instance of MapPoint.

Eric
__________________
~ Now taking orders for MapPoint 2009 ~
~
~ Upgrade to MapForums Plus membership ~
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 03-07-2005
Junior Member
White Belt
 
Join Date: Feb 2005
Posts: 7
trapping the error

I use Visual foxpro to program rather than VB, but I am sure that you have the similar error trapping code to mine. In Visual Foxpro I had a similar problem where one location in the route created the error message that Mappoint was unable to find driving directions to that point. I simply put in an "ON ERROR" snippet that allowed me to perform other logic when this happened. In my case, I was looking for distances between 2 points so my on error section changed the calculation of distances from the calculate command to the distance as the crow flies which is less accurate but still close enough for my purposes.

In your case, once you trap the problem with "ON ERROR" you can perhaps put in code to look for a nearby location that is calculable.

At the very least, you are not stuck in limbo.

Ralph Skrzydlo
www.technologix.ca
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


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
Optimize and calculate a Route rms62 MapPoint 2006/2009 Discussion 2 08-22-2003 02:55 PM
Optimize a Route with Scheduled Time windows Anonymous MapPoint 2006/2009 Discussion 0 07-09-2003 06:20 AM
Calculate route with Segment preferences vs optimize David Kachuck MapPoint 2006/2009 Discussion 1 01-03-2003 03:29 PM
Route optimize: shortest vs quickest David Kachuck MapPoint 2006/2009 Discussion 1 12-16-2002 07:23 PM
I am developing a VB application which calculates .... Anonymous MapPoint 2006/2009 Discussion 2 04-04-2002 01:26 AM


All times are GMT -5. The time now is 05:26 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
MP2K Magazine
Visitor Map

Family Skiing
Whether you are looking for family skiing or just a ski holiday for a couple, visit Holiday Hypermarket. Check out the latest deals online.

City Break Holidays
Book city break holidays through Travel Counsellors. A personal travel advisor will help with your city break holiday plans.

Jamaica Holidays
Jamaica Holidays can include world class business hotels, upscale shopping and top entertainment and dining. Alternatively, hit the beach or hike in the hills. Book online with us.

Nile Cruises
Nile cruises are one of the best ways to discover the riches of Egypt. See ancient ruins and lush verdure from the River Nile. Book today!

Cheap Turkey Holidays
The best time of year to sneak in cheap Turkey holidays is during the off-peak season. Check out the great deals available during April, May or October. For other tips on how to bag a great value holiday simply check online at ulookubook.com

Package Holidays
With the help of Travel.co.uk you can find the package holidays of your dreams.

Cheap Holidays in Gran Canaria
Would you like to visit the Canary Islands, but you're on a budget? Get information on cheap holidays in Gran Canaria at On The Beach.


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