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

Speed up optimize for routes + geofencing

This is a discussion on Speed up optimize for routes + geofencing within the MapPoint Desktop 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 ...

  1. #1
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137

    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

  2. #2
    Winwaed's Avatar
    Winwaed is offline Mapping-Tools.com Black Belt
    Join Date
    Feb 2004
    Location
    Irving,Texas
    Posts
    1,859
    Blog Entries
    60
    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

  3. #3
    thejun is offline Junior Member White Belt
    Join Date
    May 2004
    Posts
    2

    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?

  4. #4
    Winwaed's Avatar
    Winwaed is offline Mapping-Tools.com Black Belt
    Join Date
    Feb 2004
    Location
    Irving,Texas
    Posts
    1,859
    Blog Entries
    60
    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

  5. #5
    thejun is offline Junior Member White Belt
    Join Date
    May 2004
    Posts
    2
    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.

  6. #6
    Winwaed's Avatar
    Winwaed is offline Mapping-Tools.com Black Belt
    Join Date
    Feb 2004
    Location
    Irving,Texas
    Posts
    1,859
    Blog Entries
    60
    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

  7. #7
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137
    Is it possible to get the lat/lon of a polygon that the users has drawn on the map?

  8. #8
    Eric Frost's Avatar
    Eric Frost is offline Administrator Black Belt
    Join Date
    Jul 1992
    Posts
    5,094
    Blog Entries
    4
    It is.. you can loop through the nodes. There is some code in this example: http://www.mp2kmag.com/importersub01.asp

    Eric
    ~ Order MapPoint MapPoint 2013 Here and Get Free Access to the MapForums Downloads ~
    ~~
    ~ Upgrade to Get Access to the MapForums Downloads ~

  9. #9
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137
    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#

  10. #10
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137
    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&#40;int i = 0; i < k.Length;i++&#41;
    					&#123;
    						r.MoveNext&#40;&#41;;
    						MapPoint.Location l = &#40;MapPoint.Location&#41;&#40;r.Current&#41;;   
    						ActiveMap.AddPushpin&#40;l,"test"&#41;;
    					&#125;
    				&#125;
    			&#125;

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Optimize Progress Bar
    By Metod in forum MapPoint Desktop Discussion
    Replies: 15
    Last Post: 11-16-2005, 02:13 PM
  2. Optimize multiple stops
    By petekk in forum MapPoint Desktop Discussion
    Replies: 7
    Last Post: 09-29-2005, 05:09 PM
  3. Optimize Events
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 12-03-2003, 12:45 PM
  4. Optimize and calculate a Route
    By rms62 in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 08-22-2003, 03:55 PM
  5. Route optimize: shortest vs quickest
    By David Kachuck in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 12-16-2002, 08:23 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