Community of VE/MapPoint Users and Developers
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 ...
| |||||||
| Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| Speed up optimize for routes + geofencing 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 |
| ||||
|
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 |
| |||
| 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? |
| ||||
|
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 |
| ||||
|
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 |
| ||||
|
It is.. you can loop through the nodes. There is some code in this example: http://www.mp2kmag.com/importersub01.asp Eric
__________________ |
| |||
|
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");
}
}
}
|
![]() |
| Tags |
| geofencing, optimize, routes, speed |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| 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 |