Use of Planet.osm with osmDroid for offline maps - android

does anyone know if it is possible to build an Android application using osmDroid that makes use of Planet.osm stored on an SD card?
for example, you would store Planet.osm on a large SD card that has been put in a phone. The application loaded on the phone would then look in the SD card for the relevent maptiles and allow the user to have a full map offline.

No, not as you would expect it.
The Planet contains raw vector data whereas osmdroid needs pre-rendered raster tiles. You would need a renderer on your mobile device but rendering is a very ressource-intensive task and not really suited for mobile devices. Unless you are using pre-processed data (and ideally a vector renderer) as done by multiple mobile apps like OsmAnd. Storing pre-rendered tiles could be an option, but only for limited areas as their storage requirements increase very fast.
You can take a look at mapsforge if you intend to add vector rendering to your application.

Related

How to add style into .mbtiles file

I downloaded a payed .mbtiles file from Open Street Map and managed to create nice maps using openmaptiles-server over Kitematic.
However, I would like to use this .mbtiles file as offline repository of tiles in an Android based application I'm writing.
My plans are to have the mbtiles file stored on an SD card, and let osmdroid MapView read it from there.
However, the file doesn't contain (apparently..) the styling information on its own.
My question is how do I add a styling info such as "OSM Bright" or "Klokantech Basic" to my project so the map on my application looks like a proper map
Many thanks
It's not possible to render bitmap tiles on a device just from information contained in mbtiles data file.
What actually is a mbtiles file?
A mbtiles file is just an SQLite database which contains a very little amount of metadata and rendered bitmap images - tiles Those are the same bitmap files you would be serving online from your openmaptiles-server.
Size of mbtiles file versus size of tiles
MBtiles file size should be almost the same as the overall size of all generated files on your mbtiles server (it's the same number of tiles in each zoom level and the same number of pixels in each tile). If you see a significant difference, it may mean that your mbtiles file doesn't contain the same zoom range (e.g. it doesn't actually contain those most detailed zoom levels) or it contains a smaller area. Some difference may be also caused by a compression algorithm of contained bitmaps and here the actual styling of tiles may play some role (some bitmaps may be easier to compress a resulting PNG may be smaller.
It may be also possible, that the mbtiles file actually contains another image format (jpeg).
If you want to explore what is actually contained in the downloaded mbtiles file, try this tool.
Solution
I don't' think there is a solution when you need to use bitmap tiles. You need to either generate them on a server and download them via network, or you need to prerender them and pack into a mbtile file and download that to a device somehow.
One possible solution would be to use vector maps. It's actually possible to generate vector tiles from Openstreetmap data. Such tiles are than rendered on a device and can actually be styled on the device too.
Unfortunately, Osmdroid library does not support vector tiles at the time of writing (AFAIK). You would have to choose a different map rendering library.

Android OpenStreetMap tracker available offline

I'm new at osmdroid and I'm trying to build simple GPS tracking application that must work offline. So first of all I know that osmdroid works with .osm But how to download osm file directly to my android device and more importantly how later I need to use it. I dont understand .osm file is simply just xml with lots of coordinates and other data. So how that .osm file can be transform to a graphical map? I know that is necessary to parse .osm file to get data, but where to download actual graphical map?
osmdroid does not currently present .osm data, mainly due to performance reasons. osmdroid does render raster images that someone can capture into a zip or database and then transfer to device. The problem really is space. It's a big planet and getting raster images can be huge! You'd have to prepare geographic regions into a database then host them somewhere and have your app download them on demand.
osmdroid as a wiki on offline maps here:
https://github.com/osmdroid/osmdroid/wiki/Offline-Map-Tiles
An alternative approach is something like Mapsforge, which can preconvert .osm data into their own binary format, also chunked up by geographic region. Same rules apply, however the file/download sizes are much smaller. Support for osmdroid using Mapsforge is in beta at the moment, however mapsforge can run on it's own and has it's own demo apps and whatnot.
To transform the .osm file into a graphical map, you need something like renderd and a slew of other tools, all on open street maps wiki. Again, you need a boat ton of storage for the planet to convert it into raster images. Then you'd still have to package them somehow and get them on device.
Or you can just use online maps.

Create maps for maptiler

I´m actually doing a CustomTileProvider for Android, but I dont have idea how can I create tiles from MapTiler. It ask´s me for a Raster map Files, but Is there any tool to generate this map files.
MapTiler (http://www.maptiler.com/) can process normal images - such as a scanned paper map saved as JPEG or TIFF. You can also create a map in Adobe Photoshop or similar software. See: Visually aligning a jpeg image to Google Maps in preparation for Photoshop tile cutter
MapTiler opens the standard GIS data formats too (GeoTIFF, ECW, MrSID, ...).
Free geodata (opendata) are avaialable on the web nowadays. For example:
topographic maps for hiking (USGS DRGs) at http://www.archive.org/details/maps_usgs
nautical charts for sailing (NOAA) at http://www.nauticalcharts.noaa.gov/mcd/Raster/
etc.
Some typical maps rendered with MapTiler are visible at http://tileserver.maptiler.com/:
The free geodata are available in USA and some countries in Europe from the government websites.
High-quality geodata can be also purchased from various commercial data providers.
UPDATE: MapTiler Desktop application and command-line MapTiler Engine can now also generate raster tiles from vector data input (typically in PDF or GeoPDF format).
MapTiler tools can produce also Vector Tiles (MVT) from ShapeFiles or other vector GIS data - which can be displayed with Android/iOS native GL accelerated components or with client-side styles in a web browser. Maps made with vector tiles can be freely zoomed and rotated - with placenames displayed always in a readable non-rotated form. Look at https://www.maptiler.com/maps/ to see such maps - and create an account to make similar maps like this on your own. ;-)

Showing my raster map on mobile app (iOS/Android)

I'd like to show a map on my app and handling some events within it. I'm also need to load a background raster map to it (dwg format, which is the AutoCAD format for raster, but it doesn't really matter, since it can be converted to any other known format), doesn't matter if the file is local or remote.
I know very well how to id on desktop, but which options I have on mobile?
Thanks!
You have TileOverlays on Android and Tile Layers on iOS, which can both use remote and local data source.

Best way to deal with big (shape-)data for map in Android Application

I am building the prototype for an Android app that should result in a versatile map that can deal with a large but static amount of environmental data combined with (user-generated) data that will be hosted on a separate platform.
My current approach is to fetch the large static data via Google Fusion Tables (in original a shape file - .shp, .dbf, .shx that I have exported as a .kml with QGisMaps - the "smaller" .kml I am using is already 66.4MB, the one intended for final use over 140 MB...) I know it is possible to slice down .kml but will this have an effect on loading times?
You can see a current example of the shape data on Google Maps here https://www.google.com/fusiontables/DataSource?snapid=S717313eWaJ
But now I am wondering if I am on the right path at all since this one layer of data is loading very slowly on my machine and I am not aware of the hassle to put this map into an Android app - and more importantly also fetching more data from a separate server and putting it as another (filterable) layer on top of it. This layer will be collected data from users, thus not "static" but regularly updated - integer values displayed in color per geodata.
Several people hinted me to use Open Street Maps but some advised that Android is very eloquent with Google Maps - in the middle of development I thought maybe someone can tell me whether I chose the right direction to go for or are most likely facing less problems with an alternative solution.
I would be really glad if someone could advise me on the issue with combining map data from two different sources layerd onto one map in Android whereas one bunch of data is huge but static and the other user-generated values.
Thanks so much for your time and looking over this
best
Birgit
EDIT #1: I am now switching to Open Street Maps, hoping to be able to set up a GeoServer myself hosting the data and querying the WMS with the App. It seems like the size of the data still has to be compressed in some way, I will keep you updated.
I'll not be able to address all of your concernes, but I can share some of my experience with maps and ovelays.
The most important concept you must be aware is the memory heap. Each android application has a maximum memory amount that can be used to allocate data objects, called memory heap. This limit is different from device to device and can go from 16MB in small older devices to 64MB in new tablets.
Having said that, you will never be able to load all your data at one shot if the data structure required to hold it exceeds the maximum heap available for the application.
Also, usaging large amounts of memory makes your application better candidate to be terminated by users or by the SO when additional memory is required by critical activities (like a phone call).
Now, going to the maps part...
I've used Google maps as well as mapsforge api for OpenStreet maps. Google maps requires internet connection, while mapsforge enables you to use a local map file or online connection. OpenStree maps don't provide the sattelite view.
Regarding performance, online connection tends to be faster, as they download already rendered map images, while offline map requires the images to be rendered as needed. Mapforges can use a local cache to improve this a little.
Displaying Overlays:
I've used both API's to display paths with arround 10.000 points over a map, together with additional overlays (compass, scale bar, pop-ups, etc.) and the code runs smoothly in a mid-rande device. However, my code have some optimizations to reduce recreation of paths (when user zoom or move map) by transforming the already existing path.
good luck.
So this is how I eventually converted a .shp file into a format that could be displayed by OSMdroid's XYTilesource.
I exported the layers separately as .kml projected WGS84 and imported them as layers to TileMill. After having defied the colors for each layer in CSS, I exported my map as a set of MBTiles. I uploaded them to Mapbox.com. From there I can fetch the tiles which are in the format a.tiles.mapbox.com/v3/myUsername.myTiles/{z}/{x}/{y}.png in my OSMdroid Mapview.
final myTileSource tileSource = new XYTileSource("myTiles", null, 10, 16, 256, ".png", "http://a.tiles.mapbox.com/v3/myUserName.myTiles/");

Categories

Resources