NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

I know it seems this is an idiot idea, but I just want to find a way to support reverse geocoding on an offline map for mobile.

Currently, I successfully load pbf files of a specific area that were got from a large mbtiles file on server (using xyz url, e.g. https://myserver.com/data/14/13047/7696.pbf) and then able to render the offline map on a mobile device with these vector tiles.

Now, I want to find a way to allow user to save the POI of a specific coordinate which already showed on the map. But the POI was rendered by mapbox gl so I can't get data from it.

Is it possible to read information from mbtiles or pbf files? Because I think they have all needed information. Or may you advise some other way to achieve offline reverse geocoding?

I found that ArcGis have something similar (https://developers.arcgis.com/android/kotlin/sample-code/offline-geocode/) that they call locator files, but it seems I must use these tiles server instead of my own tiles server.

Thank you so much!

asked 03 Feb '21, 10:20

bahung1221's gravatar image

bahung1221
26224
accept rate: 0%

edited 04 Feb '21, 07:22


Is it possible to read information from mbtiles or pbf files?

Yes, it is. Your favourite programming language will probably have a protobuf decoder, which you can use to extract data from the pbf vector tile (https://github.com/mapbox/vector-tile-spec). You can then reconstitute the geometries and the tags from here.

I've done this successfully in the past (in Swift for iOS) and it's reasonably easy. But you do need to know your way around the vector tile format.

permanent link

answered 03 Feb '21, 12:31

Richard's gravatar image

Richard ♦
30.9k44279412
accept rate: 18%

Glad to hear it's possible, so I just need to determine the pbf file that contain specific POI from coordinate, and then I will able to get all the tags from it.

I will try it, thank you so much!

(04 Feb '21, 07:54) bahung1221

No problem. Do come back here if you encounter any issues.

(04 Feb '21, 08:43) Richard ♦

https://github.com/mapbox/carmen/ can index data from geojson or mbtiles and use mbtiles as storage. The backend has an abstraction and anything following the https://github.com/mapbox/tilelive#awesome-tilelive-modules API standard can be used, e.g. locally stored mbtile files.

permanent link

answered 03 Feb '21, 13:52

mtmail's gravatar image

mtmail
4.8k1574
accept rate: 27%

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×85
×60
×38
×18

question asked: 03 Feb '21, 10:20

question was seen: 2,747 times

last updated: 04 Feb '21, 08:43

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum