MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




Speed up optimize for routes + geofencing

This is a discussion on Speed up optimize for routes + geofencing within the MapPoint 2006/2009 Discussion forums, part of the Map Forums category; Hi, I'm currently developping an application using MapPoint 2004 and I want to optimize the stopplaces for a route. Unfortunaltely ...


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

Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read



Click here to register

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-30-2004
Senior Member
Black Belt
 
Join Date: Jul 2002
Posts: 5,138
Speed up optimize for routes + geofencing

Hi,

I'm currently developping an application using MapPoint 2004 and I want to optimize the stopplaces for a route. Unfortunaltely it takes already 5 minutes to optimize 5 stops!? Is there anyway to speed up this process? Maybe a parameter to only take highways?

Further i'm trying to implement some geofencing. I want to check if a given location is within a random drawn shape (polyline or circle for example) Is there any way of doing this? A cirkel is not so diffucult but a free hand drawn image seems almost impossible.

I'm programming in C# so if you have some example's I would be very grateful.

Thanks
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 04-30-2004
Winwaed's Avatar
Mapping-Tools.com
Red Belt
 
Join Date: Feb 2004
Posts: 901
Blog Entries: 10
Optimising is slow because of all the different routes it tries to find. I suspect (but haven't done any explicit tests) that it takes longer if the waypoints are spread over a wide area.
One idea I had for speeding this up, was to sort them by "as the crow flies" distances between locations or zipcodes.
The problem with this is that a distance might appear close but the driving distance is much longer due to a lack of decent roads (eg. across a narrow lake or mountain range).
The classic UK example would be Ayr to the tip of the Mull of Kintyre. Takes quite a few hours because you have to go well north of Glasgow and then back down again! Alaska probably has similarly extreme examples (eg. Haines to Skagway).


For finding if a point is in a polygon: I've coded this before. I think I took my basic algorithm from Sedgwick's "Algorithms" but it is probably covered elsewhere (eg. Graphics Gems).
Basically, you create a 'ray' from your point to infinity in one direction (typically in the +X direction, constant Y). You then count the number of times this ray crosses the polygon boundary. If it is even, then you're outside the polygon. If it is odd, then you're inside it.

There are some gotchas to watch out for like a polygon corner having the same Y value as the point, or a polygon edge lying exactly on the ray. Also you're working on a sphere which complicates things a little.



Richard
PS: I could be contracted to code this up for you
__________________
Winwaed Software Technology LLC
http://www.winwaed.com
See http://www.mapping-tools.com for MapPoint Tools
Pre-Order MapPoint 2009 today: http://www.mapping-tools.com/mappoint2009
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 05-13-2004
Junior Member
White Belt
 
Join Date: May 2004
Posts: 2
Send a message via AIM to thejun Send a message via MSN to thejun
point in a geofence

so you can create a geofence by drawing it...
does it auto create latitude and longitude?

couldnt you do a search for a point by finding out if its outside that latitude and longitude, or would that not work for a polygon?

I do not quite understand the even and odd result.

If you had multiple geofences that overlap eachother, how would you find out all the geofences that point resides in?
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 05-13-2004
Winwaed's Avatar
Mapping-Tools.com
Red Belt
 
Join Date: Feb 2004
Posts: 901
Blog Entries: 10
If the polygons overlapped, you could check the point against each polygon in turn. Yes this could be slow, depending on the complexity and number of polygons. It can be greatly speeded up by comparing against the polygon's rectangular extents, and/or by sorting polygons.


re. the odd/even bit: Try it on a piece of paper. Draw a polygon. Start with a simple one like a square.
Point outside square:
- If ray misses square => 0 intersections
- If ray passes through square => 2 intersections
Point inside square:
- Ray always has one intersection

Try more complicated polygons with concave faces/etc, and you'll find an odd number of intersections occur when the point is inside the polygon.


Richard
__________________
Winwaed Software Technology LLC
http://www.winwaed.com
See http://www.mapping-tools.com for MapPoint Tools
Pre-Order MapPoint 2009 today: http://www.mapping-tools.com/mappoint2009
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 05-13-2004
Junior Member
White Belt
 
Join Date: May 2004
Posts: 2
Send a message via AIM to thejun Send a message via MSN to thejun
so i really only need to do 1 ray check then. if it comes back with odd, then its inside, if 0 or even, its outside. That should speed up the check.
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 05-14-2004
Winwaed's Avatar
Mapping-Tools.com
Red Belt
 
Join Date: Feb 2004
Posts: 901
Blog Entries: 10
You need one ray check for each point that you test in each polygon.


Richard
__________________
Winwaed Software Technology LLC
http://www.winwaed.com
See http://www.mapping-tools.com for MapPoint Tools
Pre-Order MapPoint 2009 today: http://www.mapping-tools.com/mappoint2009
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 05-17-2004
Senior Member
Black Belt
 
Join Date: Jul 2002
Posts: 5,138
Is it possible to get the lat/lon of a polygon that the users has drawn on the map?
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 05-17-2004
Eric Frost's Avatar
Senior Member
Black Belt
 
Join Date: Jul 1992
Posts: 2,487
Blog Entries: 1
It is.. you can loop through the nodes. There is some code in this example: http://www.mp2kmag.com/importersub01.asp

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
  #9 (permalink)  
Old 05-17-2004
Senior Member
Black Belt
 
Join Date: Jul 2002
Posts: 5,138
Hu, that last artical is not what I'm searching. It's about MapInfoFiles??? Through which nodes can I loop?

BTW I'm using C#
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 05-17-2004
Senior Member
Black Belt
 
Join Date: Jul 2002
Posts: 5,138
Found it, kinda shitty way to get the locations in C# from a polyline.

Code:
foreach(MapPoint.Shape s in ActiveMap.Shapes)
			{
				if(s.Name == "")
				{
					System.Array k = (System.Array)(s.Vertices);  
					System.Collections.IEnumerator r =  k.GetEnumerator();
					for(int i = 0; i < k.Length;i++)
					{
						r.MoveNext();
						MapPoint.Location l = (MapPoint.Location)(r.Current);   
						ActiveMap.AddPushpin(l,"test");
					}
				}
			}
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
geofencing, optimize, routes, speed


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 Progress Bar Metod MapPoint 2006/2009 Discussion 15 11-16-2005 02:13 PM
Optimize multiple stops petekk MapPoint 2006/2009 Discussion 7 09-29-2005 05:09 PM
Optimize Events Anonymous MapPoint 2006/2009 Discussion 0 12-03-2003 12:45 PM
Optimize and calculate a Route rms62 MapPoint 2006/2009 Discussion 2 08-22-2003 03:55 PM
Route optimize: shortest vs quickest David Kachuck MapPoint 2006/2009 Discussion 1 12-16-2002 08:23 PM


All times are GMT -5. The time now is 06:54 PM.


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


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