Make the extra detail settable rather than always maximizing it

This commit is contained in:
Erica Fischer
2022-08-29 12:14:29 -07:00
parent 56259e4a16
commit 3668bb9db9
7 changed files with 26 additions and 13 deletions
+1 -1
View File
@@ -383,7 +383,7 @@ zoom level | precision (ft) | precision (m) | map scale
* `-d` _detail_ or `--full-detail=`_detail_: Detail at max zoom level (default 12, for tile resolution of 2^12=4096)
* `-D` _detail_ or `--low-detail=`_detail_: Detail at lower zoom levels (default 12, for tile resolution of 2^12=4096)
* `-m` _detail_ or `--minimum-detail=`_detail_: Minimum detail that it will try if tiles are too big at regular detail (default 7)
* `-aE` or `--extra-detail`: Generate tiles with even more detail than the "full" detail at the max zoom level, to maximize location precision. These tiles may not work with some rendering software that internally limits detail to 12 or 13. The extra detail does not affect the choice of maxzoom guessing, the amount of simplification, or the "tiny polygon" threshold as `--full-detail` does. The tiles should look the same as they did without it, except that they will be more precise when overzoomed.
* `--extra-detail=`_detail_: Generate tiles with even more detail than the "full" detail at the max zoom level, to maximize location precision. These tiles may not work with some rendering software that internally limits detail to 12 or 13. The extra detail does not affect the choice of maxzoom guessing, the amount of simplification, or the "tiny polygon" threshold as `--full-detail` does. The tiles should look the same as they did without it, except that they will be more precise when overzoomed.
All internal math is done in terms of a 32-bit tile coordinate system, so 1/(2^32) of the size of Earth,
or about 1cm, is the smallest distinguishable distance. If _maxzoom_ + _detail_ > 32, no additional
+12 -2
View File
@@ -66,6 +66,7 @@
static int low_detail = 12;
static int full_detail = -1;
static int min_detail = 7;
int extra_detail = -1;
int quiet = 0;
int quiet_progress = 0;
@@ -2654,7 +2655,7 @@ int main(int argc, char **argv) {
{"full-detail", required_argument, 0, 'd'},
{"low-detail", required_argument, 0, 'D'},
{"minimum-detail", required_argument, 0, 'm'},
{"extra-detail", no_argument, &additional[A_EXTRA_DETAIL], 1},
{"extra-detail", required_argument, 0, '~'},
{"Filtering feature attributes", 0, 0, 0},
{"exclude", required_argument, 0, 'x'},
@@ -2840,6 +2841,15 @@ int main(int argc, char **argv) {
}
} else if (strcmp(opt, "tiny-polygon-size") == 0) {
tiny_polygon_size = atoi(optarg);
} else if (strcmp(opt, "extra-detail") == 0) {
extra_detail = atoi_require(optarg, "Extra detail");
if (extra_detail > 30) {
// So the maximum geometry delta of just under 2 tile extents
// is less than 2^31
fprintf(stderr, "%s: --extra-detail can be at most 30\n", argv[0]);
exit(EXIT_FAILURE);
}
} else {
fprintf(stderr, "%s: Unrecognized option --%s\n", argv[0], opt);
exit(EXIT_FAILURE);
@@ -3271,7 +3281,7 @@ int main(int argc, char **argv) {
}
}
if (additional[A_EXTRA_DETAIL]) {
if (extra_detail >= 0) {
geometry_scale = 0;
} else {
geometry_scale = 32 - (full_detail + maxzoom);
+1
View File
@@ -43,6 +43,7 @@ extern int quiet_progress;
extern json_logger logger;
extern double progress_interval;
extern std::atomic<double> last_progress;
extern int extra_detail;
extern size_t CPUS;
extern size_t TEMP_FILES;
+1 -1
View File
@@ -476,7 +476,7 @@ zoom level precision (ft) precision (m) map scale
.IP \(bu 2
\fB\fC\-m\fR \fIdetail\fP or \fB\fC\-\-minimum\-detail=\fR\fIdetail\fP: Minimum detail that it will try if tiles are too big at regular detail (default 7)
.IP \(bu 2
\fB\fC\-aE\fR or \fB\fC\-\-extra\-detail\fR: Generate tiles with even more detail than the "full" detail at the max zoom level, to maximize location precision. These tiles may not work with some rendering software that internally limits detail to 12 or 13. The extra detail does not affect the choice of maxzoom guessing, the amount of simplification, or the "tiny polygon" threshold as \fB\fC\-\-full\-detail\fR does. The tiles should look the same as they did without it, except that they will be more precise when overzoomed.
\fB\fC\-\-extra\-detail=\fR\fIdetail\fP: Generate tiles with even more detail than the "full" detail at the max zoom level, to maximize location precision. These tiles may not work with some rendering software that internally limits detail to 12 or 13. The extra detail does not affect the choice of maxzoom guessing, the amount of simplification, or the "tiny polygon" threshold as \fB\fC\-\-full\-detail\fR does. The tiles should look the same as they did without it, except that they will be more precise when overzoomed.
.RE
.PP
All internal math is done in terms of a 32\-bit tile coordinate system, so 1/(2 of the size of Earth,
-1
View File
@@ -25,7 +25,6 @@
#define A_GENERATE_IDS ((int) 'i')
#define A_CONVERT_NUMERIC_IDS ((int) 'I')
#define A_HILBERT ((int) 'h')
#define A_EXTRA_DETAIL ((int) 'E')
#define P_SIMPLIFY ((int) 's')
#define P_SIMPLIFY_LOW ((int) 'S')
+8 -5
View File
@@ -453,7 +453,7 @@ void *partial_feature_worker(void *v) {
signed char t = (*partials)[i].t;
int z = (*partials)[i].z;
int line_detail = (*partials)[i].line_detail;
int extra_detail = (*partials)[i].extra_detail;
int out_detail = (*partials)[i].extra_detail;
int maxzoom = (*partials)[i].maxzoom;
if (additional[A_GRID_LOW_ZOOMS] && z < maxzoom) {
@@ -496,7 +496,7 @@ void *partial_feature_worker(void *v) {
geom = reorder_lines(geom);
}
to_tile_scale(geom, z, extra_detail);
to_tile_scale(geom, z, out_detail);
std::vector<drawvec> geoms;
geoms.push_back(geom);
@@ -514,7 +514,7 @@ void *partial_feature_worker(void *v) {
if (geoms[g].size() < 3) {
if (area > 0) {
// area is in world coordinates, calculated before scaling down
geoms[g] = revive_polygon(before, area / geoms.size(), z, extra_detail);
geoms[g] = revive_polygon(before, area / geoms.size(), z, out_detail);
} else {
geoms[g].clear();
}
@@ -2037,10 +2037,13 @@ long long write_tile(FILE *geoms, std::atomic<long long> *geompos_in, char *meta
p.extent = sf.extent;
p.clustered = 0;
if (line_detail == detail && additional[A_EXTRA_DETAIL] && z == maxzoom) {
if (line_detail == detail && extra_detail >= 0 && z == maxzoom) {
p.extra_detail = extra_detail;
// maximum allowed coordinate delta in geometries is 2^31 - 1
// so we need to stay under that, including the buffer
p.extra_detail = 30 - z;
if (p.extra_detail >= 30 - z) {
p.extra_detail = 30 - z;
}
tile_detail = p.extra_detail;
}