mirror of
https://github.com/mapbox/tippecanoe.git
synced 2025-04-27 06:20:04 +00:00
Add the option to use a different simplification level at maxzoom (#17)
* Add an option to specify a different simplification at maxzoom * Add test
This commit is contained in:
parent
4ef430b913
commit
a6abb0bc30
@ -1,3 +1,7 @@
|
||||
## 2.8.0
|
||||
|
||||
* Add the option to use a different simplification level at maxzoom
|
||||
|
||||
## 2.7.0
|
||||
|
||||
* Add the option to use the Visvalingam simplification algorithm
|
||||
|
@ -480,6 +480,7 @@ the same layer, enclose them in an `all` expression so they will all be evaluate
|
||||
the line or polygon within one tile unit of its proper location. You can probably go up to about 10 without too much visible difference.
|
||||
* `-ps` or `--no-line-simplification`: Don't simplify lines and polygons
|
||||
* `-pS` or `--simplify-only-low-zooms`: Don't simplify lines and polygons at maxzoom (but do simplify at lower zooms)
|
||||
* `--simplification-at-maximum-zoom=`_scale_: Use the specified _scale_ at maxzoom instead of the standard simplification scale (which still applies at lower zooms)
|
||||
* `-pn` or `--no-simplification-of-shared-nodes`: Don't simplify away nodes that appear in more than one feature or are used multiple times within the same feature, so that the intersection node will not be lost from intersecting roads. (This will not be effective if you also use `--coalesce` or `--detect-shared-borders`.)
|
||||
* `-pt` or `--no-tiny-polygon-reduction`: Don't combine the area of very small polygons into small squares that represent their combined area.
|
||||
* `--tiny-polygon-size=`_size_: Use the specified _size_ for tiny polygons instead of the default 2. Anything above 6 or so will lead to visible artifacts with the default tile detail.
|
||||
|
11
main.cpp
11
main.cpp
@ -76,6 +76,7 @@ double progress_interval = 0;
|
||||
std::atomic<double> last_progress(0);
|
||||
int geometry_scale = 0;
|
||||
double simplification = 1;
|
||||
double maxzoom_simplification = -1;
|
||||
size_t max_tile_size = 500000;
|
||||
size_t max_tile_features = 200000;
|
||||
int cluster_distance = 0;
|
||||
@ -2421,7 +2422,7 @@ int read_input(std::vector<source> &sources, char *fname, int maxzoom, int minzo
|
||||
std::atomic<unsigned> midx(0);
|
||||
std::atomic<unsigned> midy(0);
|
||||
std::vector<strategy> strategies;
|
||||
int written = traverse_zooms(fd, size, meta, stringpool, &midx, &midy, maxzoom, minzoom, outdb, outdir, buffer, fname, tmpdir, gamma, full_detail, low_detail, min_detail, meta_off, pool_off, initial_x, initial_y, simplification, layermaps, prefilter, postfilter, attribute_accum, filter, strategies);
|
||||
int written = traverse_zooms(fd, size, meta, stringpool, &midx, &midy, maxzoom, minzoom, outdb, outdir, buffer, fname, tmpdir, gamma, full_detail, low_detail, min_detail, meta_off, pool_off, initial_x, initial_y, simplification, maxzoom_simplification, layermaps, prefilter, postfilter, attribute_accum, filter, strategies);
|
||||
|
||||
if (maxzoom != written) {
|
||||
if (written > minzoom) {
|
||||
@ -2727,6 +2728,7 @@ int main(int argc, char **argv) {
|
||||
{"simplification", required_argument, 0, 'S'},
|
||||
{"no-line-simplification", no_argument, &prevent[P_SIMPLIFY], 1},
|
||||
{"simplify-only-low-zooms", no_argument, &prevent[P_SIMPLIFY_LOW], 1},
|
||||
{"simplification-at-maximum-zoom", required_argument, 0, '~'},
|
||||
{"no-tiny-polygon-reduction", no_argument, &prevent[P_TINY_POLYGON_REDUCTION], 1},
|
||||
{"tiny-polygon-size", required_argument, 0, '~'},
|
||||
{"no-simplification-of-shared-nodes", no_argument, &prevent[P_SIMPLIFY_SHARED_NODES], 1},
|
||||
@ -2884,6 +2886,13 @@ int main(int argc, char **argv) {
|
||||
order_by.push_back(order_field(optarg, false));
|
||||
} else if (strcmp(opt, "order-descending-by") == 0) {
|
||||
order_by.push_back(order_field(optarg, true));
|
||||
} else if (strcmp(opt, "simplification-at-maximum-zoom") == 0) {
|
||||
maxzoom_simplification = atof_require(optarg, "Mazoom simplification");
|
||||
if (maxzoom_simplification <= 0) {
|
||||
fprintf(stderr, "%s: --simplification-at-maximum-zoom must be > 0\n", argv[0]);
|
||||
exit(EXIT_ARGS);
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
fprintf(stderr, "%s: Unrecognized option --%s\n", argv[0], opt);
|
||||
exit(EXIT_ARGS);
|
||||
|
@ -611,6 +611,8 @@ the line or polygon within one tile unit of its proper location. You can probabl
|
||||
.IP \(bu 2
|
||||
\fB\fC\-pS\fR or \fB\fC\-\-simplify\-only\-low\-zooms\fR: Don't simplify lines and polygons at maxzoom (but do simplify at lower zooms)
|
||||
.IP \(bu 2
|
||||
\fB\fC\-\-simplification\-at\-maximum\-zoom=\fR\fIscale\fP: Use the specified \fIscale\fP at maxzoom instead of the standard simplification scale (which still applies at lower zooms)
|
||||
.IP \(bu 2
|
||||
\fB\fC\-pn\fR or \fB\fC\-\-no\-simplification\-of\-shared\-nodes\fR: Don't simplify away nodes that appear in more than one feature or are used multiple times within the same feature, so that the intersection node will not be lost from intersecting roads. (This will not be effective if you also use \fB\fC\-\-coalesce\fR or \fB\fC\-\-detect\-shared\-borders\fR\&.)
|
||||
.IP \(bu 2
|
||||
\fB\fC\-pt\fR or \fB\fC\-\-no\-tiny\-polygon\-reduction\fR: Don't combine the area of very small polygons into small squares that represent their combined area.
|
||||
|
File diff suppressed because one or more lines are too long
7
tile.cpp
7
tile.cpp
@ -2799,7 +2799,7 @@ void *run_thread(void *vargs) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int traverse_zooms(int *geomfd, off_t *geom_size, char *metabase, char *stringpool, std::atomic<unsigned> *midx, std::atomic<unsigned> *midy, int &maxzoom, int minzoom, sqlite3 *outdb, const char *outdir, int buffer, const char *fname, const char *tmpdir, double gamma, int full_detail, int low_detail, int min_detail, long long *meta_off, long long *pool_off, unsigned *initial_x, unsigned *initial_y, double simplification, std::vector<std::map<std::string, layermap_entry>> &layermaps, const char *prefilter, const char *postfilter, std::map<std::string, attribute_op> const *attribute_accum, struct json_object *filter, std::vector<strategy> &strategies) {
|
||||
int traverse_zooms(int *geomfd, off_t *geom_size, char *metabase, char *stringpool, std::atomic<unsigned> *midx, std::atomic<unsigned> *midy, int &maxzoom, int minzoom, sqlite3 *outdb, const char *outdir, int buffer, const char *fname, const char *tmpdir, double gamma, int full_detail, int low_detail, int min_detail, long long *meta_off, long long *pool_off, unsigned *initial_x, unsigned *initial_y, double simplification, double maxzoom_simplification, std::vector<std::map<std::string, layermap_entry>> &layermaps, const char *prefilter, const char *postfilter, std::map<std::string, attribute_op> const *attribute_accum, struct json_object *filter, std::vector<strategy> &strategies) {
|
||||
last_progress = 0;
|
||||
|
||||
// The existing layermaps are one table per input thread.
|
||||
@ -2970,7 +2970,12 @@ int traverse_zooms(int *geomfd, off_t *geom_size, char *metabase, char *stringpo
|
||||
args[thread].fraction_out = zoom_fraction;
|
||||
args[thread].tile_size_out = 0;
|
||||
args[thread].child_shards = TEMP_FILES / threads;
|
||||
|
||||
if (i == maxzoom && maxzoom_simplification > 0) {
|
||||
args[thread].simplification = maxzoom_simplification;
|
||||
} else {
|
||||
args[thread].simplification = simplification;
|
||||
}
|
||||
|
||||
args[thread].geomfd = geomfd;
|
||||
args[thread].geom_size = geom_size;
|
||||
|
2
tile.hpp
2
tile.hpp
@ -61,7 +61,7 @@ struct strategy {
|
||||
|
||||
long long write_tile(char **geom, char *metabase, char *stringpool, unsigned *file_bbox, int z, unsigned x, unsigned y, int detail, int min_detail, int basezoom, sqlite3 *outdb, const char *outdir, double droprate, int buffer, const char *fname, FILE **geomfile, int file_minzoom, int file_maxzoom, double todo, char *geomstart, long long along, double gamma, int nlayers, std::atomic<strategy> *strategy);
|
||||
|
||||
int traverse_zooms(int *geomfd, off_t *geom_size, char *metabase, char *stringpool, std::atomic<unsigned> *midx, std::atomic<unsigned> *midy, int &maxzoom, int minzoom, sqlite3 *outdb, const char *outdir, int buffer, const char *fname, const char *tmpdir, double gamma, int full_detail, int low_detail, int min_detail, long long *meta_off, long long *pool_off, unsigned *initial_x, unsigned *initial_y, double simplification, std::vector<std::map<std::string, layermap_entry> > &layermap, const char *prefilter, const char *postfilter, std::map<std::string, attribute_op> const *attribute_accum, struct json_object *filter, std::vector<strategy> &strategies);
|
||||
int traverse_zooms(int *geomfd, off_t *geom_size, char *metabase, char *stringpool, std::atomic<unsigned> *midx, std::atomic<unsigned> *midy, int &maxzoom, int minzoom, sqlite3 *outdb, const char *outdir, int buffer, const char *fname, const char *tmpdir, double gamma, int full_detail, int low_detail, int min_detail, long long *meta_off, long long *pool_off, unsigned *initial_x, unsigned *initial_y, double simplification, double maxzoom_simplification, std::vector<std::map<std::string, layermap_entry> > &layermap, const char *prefilter, const char *postfilter, std::map<std::string, attribute_op> const *attribute_accum, struct json_object *filter, std::vector<strategy> &strategies);
|
||||
|
||||
int manage_gap(unsigned long long index, unsigned long long *previndex, double scale, double gamma, double *gap);
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#ifndef VERSION_HPP
|
||||
#define VERSION_HPP
|
||||
|
||||
#define VERSION "v2.7.0"
|
||||
#define VERSION "v2.8.0"
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user