Reimers.dk

.NET, AJAX and Google APIs brought together
Welcome to Reimers.dk Sign in | Join | Help
in Search

Snap to street ?

Last post 02-13-2010, 15:30 by henkemota. 6 replies.
Sort Posts: Previous Next
  •  02-07-2010, 16:52 2991

    Snap to street ?

    Anyone that have an idea how to solve this supercool functionality ?  Example here http://econym.org.uk/gmap/example_snappath.htm ( look at the page source, DIRN )

    We have lat/long coordinates in a database but they are not always on the streets( polyline takes shortcut over streetcorners for example, we would like to avoid that )

    It would be supernice if the code in the example on the above link could be used with reimers map.

     Anyone who are skilled enough to solve this ? 

     

    Best regards

    Henkemota 

  •  02-09-2010, 8:40 2993 in reply to 2991

    Re: Snap to street ?

    You can say that this is already supported. What he does in the example is simply geocode the route between two points. You can use the static method GetRoute on the GoogleGeocoder class to do the same thing and plot it on the map.
  •  02-10-2010, 11:46 2996 in reply to 2993

    Re: Snap to street ?

    Thanks,

     Moreover, in the example you can click BESIDE a street and the route will start ON the street, it is this behaviour I am interested in achieving.

     Cheers! 

  •  02-10-2010, 23:41 2997 in reply to 2996

    Re: Snap to street ?

    The geocoder should give you a route on the street, even if you click a bit beside it. But be careful about clicking too far beside it, since the geocoder might decide to start you off on a different street.
  •  02-11-2010, 17:29 2998 in reply to 2997

    Re: Snap to street ?

    jjrdk:
    The geocoder should give you a route on the street, even if you click a bit beside it. But be careful about clicking too far beside it, since the geocoder might decide to start you off on a different street.

     What I think “HenkeMota” wants help with is that he has collected BAD or to FEW lat/long data with a GPS receiver.  The positions is NEAR the street rather than ON the street. So what he is asking for is a CODE example  

    that can start of with a collection of not so precise lat/long positions stored in a database table. Then he wants to use geocoder to get help to correct the bad lat/long coordinates to neareast street.  Then draw a polyline between points that follows the street and then take the next record and continue to build on the corrected polyline (following the streets) until all records as been processed and HenkeMota has a polyline that follows the streets rather than cutting corner or lie beside the streets.

    Think of the problem like cleaning up bad lat/longpoint with the help of the geocoder to follow the road. I have the same problem, here is a image on what to avoid ( http://www.freebords.se/baddata.jpg )  to few sample

    points means that polyline is cutting corners instead of following the streets as a car would do  Is this difficult ?  I am curios too, please help with code example how to achieve this super functionality !

     

     

     

     

  •  02-13-2010, 11:39 3005 in reply to 2998

    Re: Snap to street ?

    I think this is going beyond the original question. The original question, as I understand it, was how to get a line that follows the road between two points. The answer to that is ask the geocoding service for the route between the two.

    What you are asking is slightly more complicated. You want the geocoder to return the road data between two points that you have collected from a GPS. For this to work the geocoder would have to understand which road you are on and understand which way around the street block you took. This could be several options depending on how far your points are apart, so you may not get the correct result.

    The actual geocode requests are trivial if you use the Reimers.Map.Geocoding.GoogleGeocoder. But writing up the code to decide which is the actual route taken is a different matter and is very much application dependent. This is exactly why I refrain from writing up specific code samples, because it is never what matches people's applications, but they still think they have a right to demand that I write their application for them. 

  •  02-13-2010, 15:30 3006 in reply to 3005

    Re: Snap to street ?

    jjrdk, thanks

    You are right, the GetDirection follows the road nice, example code below (vb)

    Dim ADDR01 As Reimers.Map.Geocoding.Address = New Reimers.Map.Geocoding.Address("Torget 9", "19630", "Kungsängen", "", "", "SE", 6)

    Dim ADDR02 As Reimers.Map.Geocoding.Address = New Reimers.Map.Geocoding.Address("Långgatan 4", "544 30", "HJO", "", "", "SE", 6)

    Dim RESULT As Reimers.Map.Geocoding.GoogleResult = Reimers.Map.Geocoding.GoogleGeocoder.GetDirections(ADDR01, ADDR02, GOOGLEKEY) 

     

    Best Regards 

View as RSS news feed in XML