diff --git a/CONFIGURATION.md b/CONFIGURATION.md index 497dc43b..a844f91f 100644 --- a/CONFIGURATION.md +++ b/CONFIGURATION.md @@ -30,6 +30,7 @@ It also includes these global settings: * `compress` - whether to compress vector tiles (Any of "gzip","deflate" or "none"(default)) * `name`, `version` and `description` - about your project (these are written into the MBTiles file) * `bounding_box` (optional) - the bounding box to output, in [minlon, minlat, maxlon, maxlat] order +* `default_view` (optional) - the default location for the client to view, in [lon, lat, zoom] order (MBTiles only) * `mvt_version` (optional) - the version of the [Mapbox Vector Tile](https://github.com/mapbox/vector-tile-spec) spec to use; defaults to 2 A typical config file would look like this: @@ -81,6 +82,8 @@ This would combine the `roads` (z12-14) and `low_roads` (z9-11) layers into a si ### Additional metadata +Tilemaker writes a `json` metadata field containing a `vector_layers` key, whose value is an array of JSON objects describing each layer and its attributes. This is part of the MBTiles 1.3 spec and required by certain clients. + If you need to add additional metadata fields to your .mbtiles output, include the keys/values as an (optional) "metadata" entry under "settings". These will usually be string key/value pairs. (The value can also be another JSON entity - hash, array etc. - in which case it'll be encoded as JSON when written into the .mbtiles metadata table.) For example: diff --git a/src/shared_data.cpp b/src/shared_data.cpp index 887f6e6a..50f90b5f 100644 --- a/src/shared_data.cpp +++ b/src/shared_data.cpp @@ -8,6 +8,7 @@ class SharedData int threadNum; bool clippingBoxFromJSON; double minLon, minLat, maxLon, maxLat; + string defaultView; OSMObject osmObject; OSMStore *osmStore; bool includeID, compress, gzip; @@ -58,6 +59,11 @@ class SharedData clippingBox = Box(geom::make(minLon, lat2latp(minLat)), geom::make(maxLon, lat2latp(maxLat))); } + if (jsonConfig["settings"].HasMember("default_view")) { + defaultView = to_string(jsonConfig["settings"]["default_view"][0].GetDouble()) + "," + + to_string(jsonConfig["settings"]["default_view"][1].GetDouble()) + "," + + to_string(jsonConfig["settings"]["default_view"][2].GetInt()); + } // Check config is valid if (endZoom > baseZoom) { cerr << "maxzoom must be the same or smaller than basezoom." << endl; exit (EXIT_FAILURE); } diff --git a/src/tilemaker.cpp b/src/tilemaker.cpp index 32ac9cdc..d03d28ae 100644 --- a/src/tilemaker.cpp +++ b/src/tilemaker.cpp @@ -433,6 +433,7 @@ int main(int argc, char* argv[]) { sharedData.mbtiles.writeMetadata("bounds",bounds.str()); sharedData.mbtiles.writeMetadata("minzoom",to_string(sharedData.startZoom)); sharedData.mbtiles.writeMetadata("maxzoom",to_string(sharedData.endZoom)); + if (!sharedData.defaultView.empty()) { sharedData.mbtiles.writeMetadata("center",sharedData.defaultView); } } // ---- Read all PBFs