Closed matkoniecz closed 8 years ago
node index.js export --help
:
Usage: node index.js export [project] [options]
project Project to export.
Options:
--mapnik-version Optional mapnik reference version to be passed to Carto [3.0.0]
--proxy Optional proxy to use when doing http requests
--keep-cache Do not flush cached metatiles on project load
--renderer Specify a renderer by its name, carto is the default. [carto]
--localconfig Path to local config file [Default: {projectpath}/localconfig.json|.js]
--output PATH Filepath to save in
--width INT Width of the export [1000]
--height INT Height of the export [1000]
--bbox minX,minY,maxX,maxY BBox to use [Default: project extent]
--scale INT Scale the exported image [1]
--format FORMAT Format of the export [xml]
How one may select zoom level for Kosmtik export? See https://github.com/kosmtik/kosmtik/issues/150 for search for z-level setter.
Kosmtik uses the node-mapnik implementation. I have started working on a node implementation of a mapdiff tool (independent of Kosmtik that also uses node-mapnik), but never finished it. Here is how I produced the zoom level images that I wanted:
var SphericalMercator = require('sphericalmercator');
...
var mercator = new SphericalMercator({
size: self.size // this is the image size (one side of quadratic image)
});
...
var latLngToXY = function (lat, lng, z) {
var n = Math.pow(2.0, z),
latRad = lat / 180.0 * Math.PI,
y = (1.0 - Math.log(Math.tan(latRad) + (1 / Math.cos(latRad))) / Math.PI) / 2.0 * n,
x = ((lng + 180.0) / 360.0) * n;
return [x, y];
};
...
var xy = latLngToXY(self.lat, self.lng, z);
map.zoomToBox(mercator.bbox(xy[0] - 0.5, xy[1] - 0.5, z, false, '900913'));
See also https://github.com/mapbox/node-sphericalmercator#bboxx-y-zoom-tms_style-srs.
self.lat
and self.lng
in combination with z
represent the center coordinates and the zoom level of the image. Since the upper left corner is expected by node-mapnik I subtract 0.5 after the conversion to XY.
Maybe you can use a similar logic to produce the bounding boxes needed by Kosmtik.
I am already doing something similar what is (hopefully) equivalent
def self.get_render_bbox_size(zlevel, wanted_image_size, latitude)
longitude_equator_rendered_length_in_pixels = 256 * 2**zlevel
longitude_size = 360 * wanted_image_size.to_f / longitude_equator_rendered_length_in_pixels
latitude_size = longitude_size * Math.cos(latitude * Math::PI / 180)
return [latitude_size, longitude_size]
end
The main problem will be for sythethic comparisons (stuff like https://cloud.githubusercontent.com/assets/899988/8719492/659a1770-2bac-11e5-8117-7156a0b89525.png - where each zoom level is using the same data, the same bbox, only different zoom level), but hopefully somewhere in Asia there is a large enough area without an unwanted coastline (currently I am rendering at [0, 20]).
@nebulon42 - thanks for finding --bounds
bug! It turned to be main obstacle, now things are starting to work correctly.
https://github.com/kosmtik/kosmtik