Skip to content

Conversation

@sgelb
Copy link
Collaborator

@sgelb sgelb commented Sep 30, 2018

This is a basic prototype to show how offline maps can be integrated (see #296).

OsmDroid allows the use of offline vector maps in Mapsforge format. This format is used by various map apps, e.g. Oruxmaps and Locus. As vector maps are rendered on the device, different styles (sometimes called themes or designs) can be applied on the same data set.

To avoid the need to download the same data and to ease the use of offline maps, this prototype reuses offline maps already downloaded by Oruxmaps.

Make it work, step by step

Open questions

  1. How much does it cost to recursivly search for map data and style files on the primary shared storage directory? This would provide the general use of any found offline map data and styles, regardless of a specific app. (Note: maps come as .map-files, styles as .xml with xmlns="http://mapsforge.org/renderTheme"). Another idea is to search in hardcoded paths for specific map apps as well as some generic paths like Downloads or Documents.
  2. Can multiple offline maps be loaded at the same time?
  3. What's a nice UI/UX for the settings?

Additional remarks

This really is just a prototype to get a first impression how this could work. Loaded tiles are not cached, there are hardcoded strings, the logic to find offline maps is oruxmap specific and should be generalized and refactored into its own class, and so on and so on. The chances are very high that this PR will overwritten by force-pushing updated code!

@saemy
Copy link
Collaborator

saemy commented Oct 4, 2018

Thank you very much for this great extension, @sgelb!

One idea: What if, instead of selecting both the map and the theme files, we just select the base directory (oruxmaps/) in which we both expect the mapfiles/ and mapstyles/ sub-directories. This allows us to use more than one map file if available, without the user having to change the source.
Also, this might enable us to use a file picker where the user can select an arbitrary path, also one on the sdcard (my Environment.getExternalStorageDirectory() points to a directory on the internal disk).

Opening every .xml file to automatically look for the styles might be very costly. However, if we require the above directory structure we might get away with searching the whole filesystem for a mapfiles/ directory. Also, in contrast to the proposal in the previous section, we might also not enforce the storage directory structure at all and just use the user provided path as a hint for your proposed search.

@sgelb
Copy link
Collaborator Author

sgelb commented Oct 5, 2018

It's now possible to select multiple map sources at once. This is supported out of the box by MapsForge, the sources are merged into a single map source. Overlapping map sources do work.

@sgelb
Copy link
Collaborator Author

sgelb commented Oct 5, 2018

Environment.getExternalStorageDirectory() is not the best named method, see the description on developer.android.com for more. In short, this is the default shared directory for data not private to an app and does not have to be external at all. Default folders for downloads, pictures etc are placed here. In my tests, Oruxmap as well as Locus save their offline map data somewhere below this directory. Did you make a different experience?

@sgelb
Copy link
Collaborator Author

sgelb commented Nov 15, 2019

I basically started this PR from scratch. Have a look at #345

@sgelb sgelb closed this Nov 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants