How to use sqlite database with Osmdroid? - osmdroid

While it is said that sqlite database is recommended format for offline map tiles (https://github.com/osmdroid/osmdroid/wiki/Offline-Map-Tiles) there is no really example how to use it. I have my sqlite file generated with mobac app but how to load it?
Any example would be helpful!
My environment is Xamarin, VS, Android.

Well I can't speak for Xamarin, but to use sqlite databases with osmdroid, simply get the file on device at /sdcard/osmdroid/yourfile.sqlite
then start osmdroid or whatever app it's running in
Then you need to tell osmdroid to display whatever tile source is in the sqlite's 'provider' column. This is documented at the following links
https://github.com/osmdroid/osmdroid/wiki/Map-Sources#using-a-different-tile-source
I agree, the wiki could use some clarification on this. In short, osmdroid runs a routine to discover all tile sources available offline when it starts up (with the default tile provider). Then when you switch tile sources, it will attempt to fulfill the tile request with all available sources until trying online source.
To summarize,
prepare your sqlite file
transfer to device /sdcard/osmdroid/
tell osmdroid to use a tile source that matches the 'provider' column in the database (and optionally set offline mode mapview.setUseDataConnection(false))
start it up

Related

Convert an unknown database file from a windows software into a MySqli Database

I have installed a software in my system and I have a lot of data from client in it. All the files which are inside DB folder of this software are with extensions for each individual party.
I want to to use these files to get converted to a MySqli Database.
Sample file from DB folder can be download from here
I have tried understanding for firebird service which this software uses to connect with these database files to get the things.
I want to extract database and import it inside MySqli (PhpMyAdmin)
The linked file seems to be a renamed Firebird database with structure version ODS 11.2 which corresponds to Firebird 2.5.x line.
For making a quick peep into the database you can use
IBSurgeon First Aid -- http://ib-aid.com
IB Expert (the Database Explorer feature) -- http://ibexpert.net
Free mode of FirstAID would let you peep into the data, but not extract it out, probably not even scroll ALL the tables. It also would most probably ignore all database structures that are not tables (UDF functions, procedures, VIEWs, auto-computed columns in tables) - afterall it is just low-level format parser, not an SQL engine.
IB Expert has as a non-commercial Personal edition, but it probably does not include DB Exp, however you may try a trial period of full version. However IBE's DBExp would probably also only show basic structures of the database, maybe it would be enough.
Alternatively you can install Firebird 2.5.8 - either a standalone version or maybe embedded (a set of DLLs used instead of FB server process) if your application can use it, then use any DB IDE suit to explore it. Most often mentioned for Firebird would be IBExpert, FlameRobin, Firebird Maestro or any other. Then you would be able to try different SQL queries, including SPs, VIEWs and UDF-functions if there were any registered for the database and actually used.
BTW IBExpert comes bundled with FB 2.5 Embedded, which one can use to open the database file.
After you figure out the format, you can either export required data into some intermediate format like CSV (for example: http://fbutils.sourceforge.net/ ) or use your C++ application (though why would anyone develop web-application in C++) using libraries like IB++ or OLE DB, etc. Maybe it would be better to just use the Firebird server and original DB files from PHP or what would you write the application in.

Use map data offline with osmdroid

My ultimate goal is to have map data (offline, because I will customize it myself) and display it in an app (Android). I could make osmdroid work to load maps online and I was trying to figure out how to download and display offline maps. I downloaded MOBAC (Mobile Atlas Creator) and export the data to SQLite format and when I had a look at it I realized that tiles are saved in image format (PNG).
What I would like to do is to import data to the phone to later use it in algorithms such as a search engine or a routing algorithm, so I need the "nodes" and "ways" (as I get them from the original OSM XML), import them to the phone and visualize it to later have this data available for the algorithms I want to develop. Basically, what MAPS.ME does. I think it wouldn't be difficult to convert the XML into the SQLite since a simple script could make it, but then, how can I generate the tiles from this custom SQLite database? Or, is there a way I can download the data in a more appropriate way to do what I'm planning to do?
Thanks.
Rendering the tiles in an app from raw Openstreetmap data would be computation heavy and inefficient. I would suggest to use image tiles you exported for visual representation.
In addition to tiles you should export a data set you will need in the application for desired functionality. You will not need all data from Openstreetmap so you should identify what you need and build your custom export (there are tools and libraries for processing and filtering of Openstreetmap data. I have used pyosmium for some filtering and processing but there are others.) For example, you can build your custom database with POIs you want to search for.
Routing is another chapter. You can implement it yourself but it is a very complex task. There is java library called Graphopper which can do the data extraction (from Openstreetmap) and offline routing for you. They have an online API too but it is possible to make it working completely offline (I did it for one application). Try to look at the source code because than you can see how complex topic routing is. Final note: data exported from Graphopper contains information about some POIs along routes. It may be possible to search for some things via its java API but I haven't investigated this yet.

Saving offline map atlas inside osmdroid

Is there a solution to save the map tiles inside the app like the Mobile Atlas Creator works on the desktop?
I only found a way by using PC application.
There sure is. It probably needs some more testing, but the example is located here:
https://github.com/osmdroid/osmdroid/blob/master/OpenStreetMapViewer/src/main/java/org/osmdroid/samplefragments/cache/SampleCacheDownloaderArchive.java
Essentially, when you fire up an instance of CacheManager, it gets the map view's IFileSystemCache instance, which is normally the Sqlite tile cache (the kind that expires). This example feeds in an alternate implementation that produces a permanent sql tile archive (no expiration dates in it).
Use it with caution has many tile sources do not allow you to do this in their terms of service and you can get banned for doing so
Edit: there's more info the wiki
https://github.com/osmdroid/osmdroid/wiki/Offline-Map-Tiles#use-osmdroids-cache-manager-on-device---version-52

Video Archive Manager

I am developing an application in which I need to capture and display as well as record live video feed coming from an input camera or any other source.
I am working on Windows 7 64 bit machine and building my application in C++ using Visual Studio. Now since I will be archiving all the videos, so along with my application I need to provide a video archive manager which can easily save them and attach tag to the videos based on their name and timestamp and fetch them based on some query. I dont want to write the whole archive manager by my self because of time constraints. So can anyone suggest some open source or even some proprietary tool which can do this for me.
If you don't want something elaborate, you can use the OS IpropertyStore to update metadata for the file and use Windows Search to retrieve them.
IPropertyStore to update tags
ISearchQueryHelper for searching them.
Developing Property Handlers for Windows Search shows more.

Qt / C++ - how to store configuration data

What is the best way to store application configuration in a Qt application?
If You store only list of name-value pairs QSettings class will suffice. It is cross platform and works well.
Check this page for more info:
http://doc.qt.io/archives/qt-4.7/qsettings.html
On the other hand if You have to store data in multiple tables (many params, many rows) I suggest You use Sqlite and QtSQL. Sqlite is ralational database that can be embeded in your application without the need of starting any servers or installing additional software. Sqlite sotres all tables in one *.db file. You can place each user's configuration in his home directory.
This link demonstrates how QtSQL library works:
http://doc.qt.io/archives/qt-4.7/sql-sqlstatements.html
Well, as you're using Qt anyway, why not using QSettings? You can use its default settings to save your configuration in platform specific default locations (e.g. Registry under Windows) or use it to write to classic INI files.