How do I use rectangular local tiles in android mapbox? - android

Brand new to Mapbox.
I'm using the Android SDK version and have local (not cached, nothing from a server) tiles. I would like it if the tiles were not required to be square, but could be rectangular. I'm seeking an example and documentation on how to load local tiles from my assets folder. Right now my tiles are simply stored as .png files in "./assets/map/tiles/zoom/x/y.png" naming convention, but I could change it easily if that helps.
I don't see any examples or documentation anywhere. The code looks like it isn't designed to handle non-square tiles and it isn't clear on what I would do to get my tiles from a local source. I could make my tiles square if that's a problem, but I can't load from a server since the app will be used where there is no data connection.
Thx.

Tiles are required to be square in the Android SDK. While it would be nice to support rectangular, elliptical, etc tile shapes, it would be unclear what geographical area they represented. And computers love squares, very literally - rectangles are performance bottlenecks in some cases. So, you'll need to use squares.

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.

how to autocrop business card images taken from camera using opencv in android

I am developing an app that captures a business card using custom android camera and then i need to autocrop the unwanted space in android and then store the image . I am using opencv for this. All examples i am seeing are in python . I need it in android native.
You can probably try something like this:
1) Get an edge map of the image (perform edge detection)
2) Find contours on the edge map. The outermost contour should correspond to the boundaries of your business card. (under assumption that the business card image is against a solid background) This will help you extract the business card from the image.
3) Once extracted you can store the image separately without the unwanted space.
OpenCV will help you with points 1,2 and 3. Use something like a cannyedge detection for point 1. The findContours function will come in handy for point 2. Point 3 is basic image manipulation which I guess you don't need help with.
This might not be the most precise answer out there - but neither is the question is very precise - so, i guess it is alright.

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.

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/");

Osmdroid: How I can create and load a map from my own bitmaps(tiles)?

I am starting to use Osmdroid and I would like to use this technology for showing a map about an F1 circuit. I have a big picture and I can cut it up to divide it into smaller tiles.
Can I modify the osmdroid library for the upload of these pictures?
I would like to save these bitmaps (tiles) in my assets folder.
I am pretty lost on how to do this.
I am using this way because android, normally, gives a memory error when I try show this complete full-size picture. If I only show some tiles of the image (depends of the zoom) maybe my app would work better?
Thanks in advance!
Osmdroid uses a system in which world map is divided into tiles. Tiles usually have the same pixel size which means that the bigger zoom level you use the more tiles are needed to "cover the world". Each tile has its coordinates (x,y) and a zoom level in which it is designed to be used.
It is possible to use various custom tile sources in osmdroid. Take a look at this class in osmdroid - it creates instances of some tile sources. You can create your own tile sources using the same mechanism. However, all this uses these x,y coordinates of the world I described above. Osmdroid will ask your tile source for example for tile 10,10 in zoom level 10. If you are able to create tiles of your map to work with this coordinates system then it will work. However, it may be hard to do this for custom maps such as F1 circuits.
I am also interested in this and probably will try to use tiling mechanism of osmdroid to display some big images in the near future. If you succeed in this please let me know:).
I think there's two questions here:
How to create osmdroid format map tiles from a bitmap file.
How to load them into osmdroid
For question 1 you can use a tool to create your tiles.
http://www.maptiler.org/
Can be used to create tiles from a bitmap giving in your bitmap and its boundaries coordinates.
http://mobac.sourceforge.net/
Creates Atlas from online maps, it can create osmdroid zip atlas. Not sure if you could use it to create your osmdroid zip format.
If Mobile Atlas creator doesn't help perhaps you can create the zip manually if your source bitmap is not too big.
For question 2:
I extended an osmdroid class to deploy maps in an apk using the asset folder. See here:
https://stackoverflow.com/a/14832770/891479

Categories

Resources