How to get the name of the nearest street from my LatLong? (OFFLINE)

962 views
Skip to first unread message

Felipe Ferreira

unread,
Jun 17, 2014, 10:46:03 PM6/17/14
to mapsfo...@googlegroups.com
Hi,

I'm working on an Android app that shows the speed limit of the street where the user is. But first, I have to determine which street the LatLong of GPS is.

I think the "mapsforge-map-reader" library, has this feature, but I could not use it.

If anyone has any tips or know how to export this or any information from my "city.map", please help me!


Sorry my bad english!

Emux

unread,
Jun 18, 2014, 2:14:59 AM6/18/14
to mapsfo...@googlegroups.com
What you're talking about is reverse geocoding.
The map file is optimized for rendering maps on the screen and not for any kind of queries.
If you want to implement some sort of search, you'll need to use your own database or online RESTful services.

--
Emux
Cruiser - Atlas

Felipe Ferreira

unread,
Jun 18, 2014, 8:41:53 AM6/18/14
to mapsfo...@googlegroups.com
Emux, thanks for replying!

Okay then, I'll try to find another way to do it, find the street and then use a database of speed limits. 

The OSM data (.osm files), has information for each "way" and the list of "nodes" that define your "path".
I'll try to write a code to find the "way",where the GPS is, through these "nodes".

Thanks again...

Christian Pesch

unread,
Jun 20, 2014, 6:30:44 AM6/20/14
to mapsfo...@googlegroups.com
Hi Felipe,

I'm interested in finding an offline solution for reverse geocoding, too. Are you planning to use the .map files from mapsforge 
for your "finding the way through the nodes" or do you use the .osm.pbf files? Or?

Kind regards
Christian

womisa

unread,
Jun 20, 2014, 8:55:58 AM6/20/14
to mapsfo...@googlegroups.com
Hello Felipe,

were you viewed BRouter and Graphhoper as an offline router?

Both can also supply the road information.

Greetings
Achim

Felipe Ferreira

unread,
Jun 20, 2014, 11:13:46 AM6/20/14
to mapsfo...@googlegroups.com
Hi Christian,

Yes, it would be interesting to take this information from .map file, but for now, 
I would have to use a .osm database. I read somewhere that when converting "OSM data" for .map file, if changing some .xml file, I could put other tags in (.map file).



Hello Achim,

Thanks man, maybe I don't have to reinvent the wheel, I will research these offline routers.

Emux

unread,
Jun 20, 2014, 11:32:18 AM6/20/14
to mapsfo...@googlegroups.com
I read somewhere that when converting "OSM data" for .map file, if changing some .xml file, I could put other tags in (.map file).

That's tag-mapping.xml that can be as parameter to map writer.
If you don't provide one then the default is used.

robvr

unread,
Jun 20, 2014, 8:50:57 PM6/20/14
to mapsfo...@googlegroups.com
Parse the osm file and store every road with it's bounding box in a quadfile or R-tree.
Than expand your latlng to a rectangle the size you want to find roads, and query the quadtree with that rectangle.
You than have all roads nearby you, if none, increase you rectangel and query again,
Than calculate the shortest distance to these roads/vectors.
There is plenty info when you google quadfile and how to find the shortest distance to a vector.
Success
Rob

robvr

unread,
Jun 20, 2014, 9:10:35 PM6/20/14
to mapsfo...@googlegroups.com

womisa

unread,
Jun 21, 2014, 3:40:59 AM6/21/14
to mapsfo...@googlegroups.com
Hi Felipe,

look in the well-documented interface (API) of graph Hopper for your needs ...

==>  https://github.com/graphhopper/graphhopper
==>
http://graphhopper-read-only-archive.1087335.n5.nabble.com/Get-Street-name-and-Town-name-of-a-GPS-point-td580.html#a581

Greetings
Achim

Stephan75

unread,
Jun 21, 2014, 2:50:33 PM6/21/14
to mapsfo...@googlegroups.com

Felipe Ferreira

unread,
Jun 22, 2014, 12:52:09 AM6/22/14
to mapsfo...@googlegroups.com
Hi guys, thanks for the replies!

Achim, I took a look at the link you sent, and I did it using GraphHopper.

QueryResult rua = hopper.getLocationIndex().findClosest(latitude, longitude, EdgeFilter.ALL_EDGES);
logUser(rua.getClosestEdge().getName());

Now I will try to put the maxspeed tag in the .map file, using the tag-mapping.xml, as Emux said.

thanks again...

womisa

unread,
Jun 22, 2014, 4:06:06 AM6/22/14
to mapsfo...@googlegroups.com
Hi Felipe,

perhaps this will help you further
==> http://graphhopper-read-only-archive.1087335.n5.nabble.com/Re-Speed-Limits-td214.html#a216
==> http://graphhopper-read-only-archive.1087335.n5.nabble.com/speed-limit-td1016.html#a1027

Search
in the Forum from GraphHopper for this
..... maxspeed, speed....

Or ask in the GH forum. The author is very helpful.

Greetings
Achim


Reply all
Reply to author
Forward
0 new messages