mirror of
https://github.com/openstreetmap/mod_tile.git
synced 2025-08-03 07:49:53 +00:00
Merge pull request #82 from Zverik/retina
SCALE option to produce retina tiles
This commit is contained in:
@ -37,6 +37,7 @@ typedef struct {
|
|||||||
char tile_dir[PATH_MAX];
|
char tile_dir[PATH_MAX];
|
||||||
char parameterization[PATH_MAX];
|
char parameterization[PATH_MAX];
|
||||||
int tile_px_size;
|
int tile_px_size;
|
||||||
|
double scale_factor;
|
||||||
int min_zoom;
|
int min_zoom;
|
||||||
int max_zoom;
|
int max_zoom;
|
||||||
int num_threads;
|
int num_threads;
|
||||||
|
@ -40,6 +40,7 @@ TILESIZE=256
|
|||||||
;CORS=http://www.openstreetmap.org
|
;CORS=http://www.openstreetmap.org
|
||||||
;ASPECTX=1
|
;ASPECTX=1
|
||||||
;ASPECTY=1
|
;ASPECTY=1
|
||||||
|
;SCALE=1.0
|
||||||
|
|
||||||
;[style2]
|
;[style2]
|
||||||
;URI=/osm_tiles2/
|
;URI=/osm_tiles2/
|
||||||
|
@ -758,6 +758,14 @@ int main(int argc, char **argv)
|
|||||||
exit(7);
|
exit(7);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sprintf(buffer, "%s:scale", name);
|
||||||
|
char *ini_scale = iniparser_getstring(ini, buffer, (char *) "1.0");
|
||||||
|
maps[iconf].scale_factor = atof(ini_scale);
|
||||||
|
if (maps[iconf].scale_factor < 0.1 || maps[iconf].scale_factor > 8.0) {
|
||||||
|
fprintf(stderr, "Scale factor is invalid: %s\n", ini_scale);
|
||||||
|
exit(7);
|
||||||
|
}
|
||||||
|
|
||||||
sprintf(buffer, "%s:tiledir", name);
|
sprintf(buffer, "%s:tiledir", name);
|
||||||
char *ini_tiledir = iniparser_getstring(ini, buffer, (char *) config.tile_dir);
|
char *ini_tiledir = iniparser_getstring(ini, buffer, (char *) config.tile_dir);
|
||||||
if (strlen(ini_tiledir) >= (PATH_MAX - 1)) {
|
if (strlen(ini_tiledir) >= (PATH_MAX - 1)) {
|
||||||
|
@ -81,6 +81,7 @@ struct xmlmapconfig {
|
|||||||
char htcphost[PATH_MAX];
|
char htcphost[PATH_MAX];
|
||||||
int htcpsock;
|
int htcpsock;
|
||||||
int tilesize;
|
int tilesize;
|
||||||
|
double scale;
|
||||||
int minzoom;
|
int minzoom;
|
||||||
int maxzoom;
|
int maxzoom;
|
||||||
int ok;
|
int ok;
|
||||||
@ -235,7 +236,7 @@ static enum protoCmd render(struct xmlmapconfig * map, int x, int y, int z, char
|
|||||||
map->map.resize(render_size_tx*map->tilesize, render_size_ty*map->tilesize);
|
map->map.resize(render_size_tx*map->tilesize, render_size_ty*map->tilesize);
|
||||||
map->map.zoom_to_box(tile2prjbounds(map->prj, x, y, z));
|
map->map.zoom_to_box(tile2prjbounds(map->prj, x, y, z));
|
||||||
if (map->map.buffer_size() == 0) { // Only set buffer size if the buffer size isn't explicitly set in the mapnik stylesheet.
|
if (map->map.buffer_size() == 0) { // Only set buffer size if the buffer size isn't explicitly set in the mapnik stylesheet.
|
||||||
map->map.set_buffer_size(128);
|
map->map.set_buffer_size((map->tilesize >> 1) * map->scale);
|
||||||
}
|
}
|
||||||
//m.zoom(size+1);
|
//m.zoom(size+1);
|
||||||
|
|
||||||
@ -244,7 +245,7 @@ static enum protoCmd render(struct xmlmapconfig * map, int x, int y, int z, char
|
|||||||
Map map_parameterized = map->map;
|
Map map_parameterized = map->map;
|
||||||
if (map->parameterize_function)
|
if (map->parameterize_function)
|
||||||
map->parameterize_function(map_parameterized, options);
|
map->parameterize_function(map_parameterized, options);
|
||||||
mapnik::agg_renderer<mapnik::image_32> ren(map_parameterized,buf);
|
mapnik::agg_renderer<mapnik::image_32> ren(map_parameterized,buf,map->scale);
|
||||||
ren.apply();
|
ren.apply();
|
||||||
} catch (std::exception const& ex) {
|
} catch (std::exception const& ex) {
|
||||||
syslog(LOG_ERR, "ERROR: failed to render TILE %s %d %d-%d %d-%d", map->xmlname, z, x, x+render_size_tx-1, y, y+render_size_ty-1);
|
syslog(LOG_ERR, "ERROR: failed to render TILE %s %d %d-%d %d-%d", map->xmlname, z, x, x+render_size_tx-1, y, y+render_size_ty-1);
|
||||||
@ -329,6 +330,7 @@ void *render_thread(void * arg)
|
|||||||
strcpy(maps[iMaxConfigs].xmlfile, parentxmlconfig[iMaxConfigs].xmlfile);
|
strcpy(maps[iMaxConfigs].xmlfile, parentxmlconfig[iMaxConfigs].xmlfile);
|
||||||
maps[iMaxConfigs].store = init_storage_backend(parentxmlconfig[iMaxConfigs].tile_dir);
|
maps[iMaxConfigs].store = init_storage_backend(parentxmlconfig[iMaxConfigs].tile_dir);
|
||||||
maps[iMaxConfigs].tilesize = parentxmlconfig[iMaxConfigs].tile_px_size;
|
maps[iMaxConfigs].tilesize = parentxmlconfig[iMaxConfigs].tile_px_size;
|
||||||
|
maps[iMaxConfigs].scale = parentxmlconfig[iMaxConfigs].scale_factor;
|
||||||
maps[iMaxConfigs].minzoom = parentxmlconfig[iMaxConfigs].min_zoom;
|
maps[iMaxConfigs].minzoom = parentxmlconfig[iMaxConfigs].min_zoom;
|
||||||
maps[iMaxConfigs].maxzoom = parentxmlconfig[iMaxConfigs].max_zoom;
|
maps[iMaxConfigs].maxzoom = parentxmlconfig[iMaxConfigs].max_zoom;
|
||||||
maps[iMaxConfigs].parameterize_function = init_parameterization_function(parentxmlconfig[iMaxConfigs].parameterization);
|
maps[iMaxConfigs].parameterize_function = init_parameterization_function(parentxmlconfig[iMaxConfigs].parameterization);
|
||||||
|
Reference in New Issue
Block a user