Inside of my .mbtiles SQLite db, there's a column called tile_data holding the information relating to the specific tile that is being queried.
My application is taking a user long/lat as an input and then converting to a tile_row and tile_column equivalent values, then pulling the single blob with the data inside via the SQL query below.
The query (fully functional, just to show the code) is:
string query =
String.Format("SELECT tile_data from tiles WHERE zoom_level = {0} AND tile_row = {1} AND tile_column = {2}", ZoomLevel, _merc.TileLat, _merc.TileLong);
SQLiteCommand command = new SQLiteCommand(query, DbConn);
SQLiteDataReader reader = command.ExecuteReader();
while (reader.Read())
{
// ...
}
With the result being a single blob file, querying SELECT * will pull back the single tile with all data.
The blob inside of tile_data is a compressed (gzip) vector file that I need to access and work with, but I can't figure out how to decompress it within my application. Most gzip links that I've read through have been regarding file compression and outputting it to a .txt (or similar), whereas I'm looking to use this data in memory without needing an external file.
How can I decompress the blob and access he data in memory, rather than an external file?
MemoryStream, then pass that to aGZipStreamwithCompressionMode.Decompressthen pass that to aStreamReader.SqlDataReader.GetStreamto allow you to pull in the data in chunks instead of loading the entire file into aMemoryStream.