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, 10:20

bahung1221's gravatar image

bahung1221
264
accept rate: 0%

edited 04 Feb, 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, 12:31

Richard's gravatar image

Richard ♦
29.9k43266400
accept rate: 19%

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, 07:54) bahung1221

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

(04 Feb, 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, 13:52

mtmail's gravatar image

mtmail
4.3k1464
accept rate: 29%

Your answer
toggle preview

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:

×81
×55
×35
×16

question asked: 03 Feb, 10:20

question was seen: 196 times

last updated: 04 Feb, 08:43

powered by OSQA