MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




Finding the nearest road given a lat long.

This is a discussion on Finding the nearest road given a lat long. within the MapPoint 2006/2009 Discussion forums, part of the Map Forums category; Hi, I want to find the nearest road from a lat/long the reason I want this is because of the ...


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 09-11-2002
Senior Member
Black Belt
 
Join Date: Jul 2002
Posts: 5,138
Finding the nearest road given a lat long.

Hi,
I want to find the nearest road from a lat/long the reason I want this is because of the inherant inaccuracy in GPS's sometimes my car appears off road (only slightly) but when I try to calculate a route based on these waypoints it goes mad and totaly gets it wrong.

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 09-11-2002
John Meyer's Avatar
Senior Member
Blue Belt
 
Join Date: Jul 2002
Posts: 479
Check out this article: Reverse Geocoding, Pt. III by Walt Cygan

http://www.mp2kmag.com/articles.asp?ArticleID=50
__________________
John
http://www.support-pc.com

Order MapPoint 2006 Here
https://secure.mp2kmag.com/?refer=support-PC
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 10-10-2002
Member
Yellow Belt
 
Join Date: Aug 2002
Posts: 45
Hi Scarr,

I encontered the same problem. Could you give me an update once you have a fix?

Thanks in advance!
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 12-22-2002
Member
Yellow Belt
 
Join Date: Dec 2002
Posts: 35
I have seen this issue pop up a lot, and I have an idea that I am going to try (though i am not quite there yet).. if you are tracking GPS then you know your compass heading. if you are moving along a road, and your gps is returning an invalid point, it must be either to the left or right of you. so if you take a line perpendicular to your compass heading, you can start looking along that line in both directions until you can get a valid location. if you check like 100 feet to either side of you, you should hit the road you want (and not the wrong one). just a thought, but it cuts down on the number of iterations required in the method where you spiral outward 360 degrees around your gps point.

hope this makes sense. post here if you get this working and i will do the same!

ps is there any way to get the car icon up on the map screen (like in streets and trips application during gps tracking)
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 04-04-2005
Junior Member
White Belt
 
Join Date: Apr 2005
Posts: 1
how to measure distance and direction

I’m new to MapPoint, and I want to drag a line from a point that shows distance and direction. I thought pointing a line in a give direction—say 286 degrees—would be an obvious feature similar to “Measure Distance.” Have I missed something or isn’t this doable?
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 04-05-2005
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,122
Hi,

I just encountered a similar problem (with other purpose, but my solution may be working for you). What I do is running in a circle around the point where the car 'pretends' to be. I start with a radius of 5 meter and check the circumfence of the circle every 5 meter. If not found I increment the radius by 5 meter till a street is found. In your case I only should do a small maximum of 10..15 meter because you can end up with a wrong street if car is on a non digitized street.

This is the code (in Delphi). DistanceRes is the resollution (I set it to 5 meter), and MaxDistance is the radius where the routine should give up. FindAddr is the routine that ask Mappoint for streetresults (not listed here).

Code:
function TMapPoint.CalcInCircle(CenterLat, CenterLon: double; Streets: TStrings; out Distance, Angle: integer): boolean;
var
   Lat, Lon: double;
   Radius: double;         // radius of the circle in degree
   Circum: integer;        // circumfence of the circle in Distance
   Count:  integer;        // the amount of points to calculate on the circumfence
   AngleInc: integer;      // angle increments in degree per calculation
begin
   Distance := DistanceRes;
   while Distance <= MaxDistance do begin
      Radius   := 1 / 60 / 1852 * Distance;
      Circum   := Trunc(Distance * 2 * PI);
      Count    := Circum div DistanceRes;
      AngleInc := 360 div Count;
      if AngleInc <= 0 then begin
         Result := False;
         Exit;
      end;
      Angle := 0;
      while Angle < 360 do begin
         CalcXY(CenterLat, CenterLon, Angle, Radius, Lat, Lon);
         Result := FindAddr(Lat, Lon, Streets);
         if Result then
            Exit;
         Inc(Angle, AngleInc);
      end;
      Inc(Distance, DistanceRes);
   end;
   Result := False;
end;
And this is the actulally working horse:

Code:
procedure TMapPoint.CalcXY(centerLat, centerLon, Angle, Radius: double; out Lat, lon: double);
var
   a, b, c, r: double;
begin
   {                       B
                         / |
                       /   |
                     /     |
                   /       |
               c /         | a
               /           |
             /             |
           /               |
         /_________________|
       A         b          C

       given A en c
       a = c * sin(A)
       b = c * cos(A)

       A == 0 is direction East in this drawing
       a = Latitude offset
       b = Longitude offset
       c = Radius of circle   }

   r := DegToRad(Angle);
   c := Radius;
   a := c * Sin(r);
   b := c * Cos(r) / Cos(DegToRad(centerLat));  // correct longitude for circle
   Lat := CenterLat + a;
   Lon := CenterLon + b;
end;
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 17 Hours Ago
Junior Member
Yellow Belt
 
Join Date: Jan 2007
Posts: 14
Re: Finding the nearest road given a lat long.

Hi Wilfried

I have a similar need. Actually, I need to show the nearest POI to the actual position of the vehicle. This info should be updated every 2 minutes or so. My POI table has some 1000s records.

What I'm doing so far is, in a separate thread, to load the POI data in an in-memory dataset (delphi kbmMemTable) and calculate the distance between every POI and the given position (for loop). I store the results (actual position - POI infos - distance) in an array, and finally select the closest POI (min distance).

I know what I'm doing is REALLY awful but since I didn't have much time when I did it, I didn't really have the choice (optimizing and taking time to search for the better solution when my boss is crying about not meeting an impossible deadline isn't the easiest thing to do

Anyway, I would like to optimize this now, so Could you give me a hand in adapting your code to my need?

Best Regards,
Michel
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
finding, lat, long, nearest, road


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
Nearest pushpins Anonymous MapPoint 2006/2009 Discussion 2 01-07-2004 07:57 AM
Finding nearest pushpins in dataset Dazzer MapPoint 2006/2009 Discussion 3 10-17-2003 09:38 AM
Finding Nearest Gas Station based on brand names- shell Anonymous MapPoint 2006/2009 Discussion 0 04-09-2003 02:09 PM
How can I find nearest point on a road from a point off-road Anonymous MapPoint 2006/2009 Discussion 1 11-12-2002 07:14 AM
How to find nearest city? Petr Brant MapPoint 2006/2009 Discussion 3 08-23-2002 02:49 PM


All times are GMT -5. The time now is 12:43 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