The sample gave me SQL exceptions unless I changed the sql strings:
string querySql = $“SELECT * FROM {sourceDB.Map.TableName} WHERE " + ConvetToSqlString(tileRange) + $” LIMIT {offset},{offset + 1000}";
var entries = sourceDB.Map.Query(querySql);
targetDB.Map.Insert(entries);
querySql = $"SELECT images.tile_data as tile_data, images.tile_id as tile_id FROM {sourceDB.Images.TableName} WHERE images.tile_id IN ( SELECT {Map.TileIdColumnName} FROM {sourceDB.Map.TableName} WHERE " + ConvetToSqlString(tileRange) + ")";
The map we got from Thinkgeo is a world streets map of size 59GB. How do I modify the example to use it as source?
Thanks Liang for pointing out the issue! We’ve fixed the issue on GitHub.
You can change the sample code and launch the global mbtiles instead of the Frisco one in the sample, zoom to the area you interested and then draw a rectangle to start clipping. Drawing the mbtiles will not take much time, of course extracting will take a while depending the size you cut it.
Do I need to change other settings? I tried replace local DB with worldstreets.mbtiles but got exceptions.
//ThinkGeoMBTilesFeatureLayer thinkGeoMBTilesFeatureLayer = new ThinkGeoMBTilesFeatureLayer(“Data/tiles_Frisco.mbtiles”, new Uri(“Data/thinkgeo-world-streets-light.json”, UriKind.Relative));
ThinkGeoMBTilesFeatureLayer thinkGeoMBTilesFeatureLayer = new ThinkGeoMBTilesFeatureLayer(“Data/worldstreets.mbtiles”, new Uri(“Data/thinkgeo-world-streets-light.json”, UriKind.Relative));
It launches the map correctly for me. Can you check the size of the map file and make sure it’s not corrupted, it should be 60,474,036,224 bytes. Also, I see the same issue once I input the wrong mbtiles file name, please make sure the name is correct.
My map file size is correct at 56.3 GB (60,474,036,224 bytes).
I didn’t change MbtilesDatabase sourceDB = MbtilesDatabase.OpenDatabase(“Data/tiles_Frisco.mbtiles”);
to worldstreets.mbtiles.
After changing it the window shows up. But it takes forever to show a whole map of US for I want to generate a map of Illinois. When I checked Extract Vector Tiles, it hit an exception.
I can zoom out to the US without a problem. Once you draw a rectangle and start the clipping, the map will display a bit weird though. Can you start from clipping a small area for test, or you prefer us to generate IL for you?
Thank you for showing me how to extract map properly today.
I tried to extract Illionois map this afternoon. I think something went wrong. After 30 minutes it was still running, the file size grew to more than 1.5 GB. It seems there is an infinite loop somewhere.
I downloaded the new code and was able to generate Illinois maps quickly within 5 minutes. The map is around 280 to 332 MB.
But when I tried to use the map, i.e., set DB to the newly generated map, with CurrentExtent as (-10970065.1793334, 5536525.3190895, -8621919.68345808, 4292742.00174302), the map did not show as expected.
Sorry now we cannot access DropBox or GoogleDrive succeed, could you please describe what’s the problem you met? You mentioned the result is not shows as expected, I think some screen shots and description about it should be helpful.
And we can build that in our side, so if we know your setting we can did the same test like yours.
Now I changed the program to use Illinois3.mbtiles as source, changed current extent to (-10970065.1793334, 5536525.3190895, -8621919.68345808, 4292742.00174302).
It took very long o load. When I zoomed in, nothing appeared.
The reason of that is when the sample build the new mbtils, it forget build index.
You can add this code into the logic when create new mbtiles file, or you can just run it once to build index for your existing mbtiles and it should also works.
MbtilesDatabase sourceDB = MbtilesDatabase.OpenDatabase(@"D:\Illinois3.mbtiles");
string querySql = "CREATE INDEX tile_id_index ON images(tile_id)";
sourceDB.Images.Query(querySql);
Here is my test result, it’s fast after build index.
I added the 3 lines at the end of function
private void ExtractTiles(RectangleShape bbox, string targetFilePath)
{
…
sourceDB = MbtilesDatabase.OpenDatabase(targetFilePath);
string querySql1 = “CREATE INDEX tile_id_index ON images(tile_id)”;
sourceDB.Images.Query(querySql1);
}