revelashon
06-03-2006, 02:14 PM
I am having a problem getting directions between two locations created with only Lat/Long. I don't care if the locations do not have addresses. The problem is that for certain starting points, the directions end up like this: "DAY1: Depart from Eastern GMT5 Head South on loacal roads Turn Left on local road....". It spends a few days traveling on local roads before it finds a street, and that street is nowhere near the starting point. In the MapPoint application, I tried creating the same route and it is alway able to find a street in one step: "Head South on local roads Turn right on Main St. ..." I've tried playing with the altitude parameter of getLocation(lat, long, alt) and there is no one altitude that works consistently for all coordinates.
Does every coordinate have a different ideal altitude?
How would I know that the route planner got lost on local roads?
revelashon
06-03-2006, 02:32 PM
I found this post:
http://www.mp2kmag.com/mappoint/discussion/viewtopic.asp?t=6357&highlight=directions
I wonder if my problem has something to do with my preferred roads settings. I'll try it next time I have a chance. Until then can someone please offer some input.
Wilfried
06-04-2006, 12:34 PM
Hi,
You have to set altitude to 1 as in the example. This is for most of the MP geo things to have some accuratie.
revelashon
06-05-2006, 09:08 AM
I've tried with the altitude set to 1 and I get the same results. Here is exaclty what some of the directions look like:
DAY 1
Depart Eastern (GMT - 5) on Local road(s) (West)
Turn RIGHT (North) onto Local road(s)
Bear LEFT (North) onto Local road(s)
Turn LEFT (West) onto Local road(s)
Turn LEFT (South) onto Local road(s)
Turn RIGHT (North) onto Local road(s)
Turn RIGHT (North-West) onto Local road(s)
Turn LEFT (South) onto Local road(s)
Bear LEFT (South) onto Local road(s)
Bear LEFT (South-West) onto Local road(s)
Turn RIGHT (West) onto Local road(s)
Trips that should only take a few minutes are being scheduled over the course of serveral days. Furthermore, as I had mentioned earlier, in the MapPoint 2004 application's route planner, identical data yeilds proper directions.
revelashon
06-05-2006, 10:12 AM
I made the application visible so I could see the routes for myself and found out that it is starting the routes from the center of "Eastern GMT 5" rather than the location that I specified. I will continue to investigate.
revelashon
06-05-2006, 10:34 AM
I found the problem:
The ObjectsFromPoint method is returning the center of Eastern GMT 5 as the closest object. This only happens when there aren't any addresses nearby.
What I did to fix the problem:
Since I do not require an address for my start point (vehicle GPS location), I simply used the getLocation method on the start point. In my original build this was how it was done, but then I required an address for the end point and that is how I lost track of the requirement for the start point. Everything is fine now.
Wilfried
06-05-2006, 02:30 PM
Hi,
Good that it is solved. But I do not understeand how (my English is not my native language). Can you elaborate more please ?
revelashon
06-05-2006, 04:17 PM
Following is the flawed code:
1: location = map.GetLocation(latitude, longitude, altitude);
2: location.goTo();
3: results = map.ObjectsFromPoint(map.locationToX(location), map.locationToY(location));
4: foreach(object sample in results)
5: {
6: if(sample is Location)
7: {
8: if(!findAddress || sample.StreetAddress != null)
9: return sample;
10: }
11: }
Followed by another method for finding the address if that one failed. The problem occured on line #3. Sometimes MapPoint will return the center of a timezone as the closest object. I think this may be what Gilles Kohl refered to as "'so close, but yet so far' syndrome" in "Reverse Geocoding, Another Method". I changed the code so something similar to the following:
1: location = map.GetLocation(latitude, longitude, altitude);
2: location.goTo();
3: results = map.ObjectsFromPoint(map.locationToX(location), map.locationToY(location));
4: if(findAddress)
5: {
6: foreach(object sample in results)
7: {
8: if(sample is Location)
9: {
10: if(sample.StreetAddress != null)
11: return sample;
12: }
13: }
14: }
15: return location;
Now the original location is returned if no address can be found. Keep this in mind. This code will not find an address for all points, rather in a "don't care" situation it will try to find an address. Should it fail, the name of the location will be the GPS coordinates that it was created from.
Wilfried
06-06-2006, 02:01 PM
Hi,
Thanks for feedback :)