mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-05 09:55:41 +02:00
Further separate the post-calculation minzoom fixup from the calculation
This commit is contained in:
@@ -1073,15 +1073,15 @@ static double round_droprate(double r) {
|
|||||||
return std::round(r * 100000.0) / 100000.0;
|
return std::round(r * 100000.0) / 100000.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void calc_zooms_and_dropping(const int indexfd, const std::atomic<long long> &indexpos,
|
static struct index *calc_zooms_and_dropping(const int indexfd, const std::atomic<long long> &indexpos,
|
||||||
const int geomfd,
|
const bool guess_maxzoom, const bool guess_cluster_maxzoom,
|
||||||
const bool guess_maxzoom, const bool guess_cluster_maxzoom,
|
const double dist_sum, const size_t dist_count,
|
||||||
const double dist_sum, const size_t dist_count,
|
const double area_sum,
|
||||||
const double area_sum,
|
sqlite3 *outdb, const char *pgm,
|
||||||
sqlite3 *outdb, const char *pgm,
|
int &maxzoom, const int minimum_maxzoom, int &basezoom, const int minzoom,
|
||||||
int &maxzoom, const int minimum_maxzoom, int &basezoom, const int minzoom,
|
const int basezoom_marker_width,
|
||||||
const int basezoom_marker_width,
|
double &droprate, const double gamma,
|
||||||
double &droprate, const double gamma) {
|
bool &fix_dropping) {
|
||||||
struct index *map = (struct index *) mmap(NULL, indexpos, PROT_READ, MAP_PRIVATE, indexfd, 0);
|
struct index *map = (struct index *) mmap(NULL, indexpos, PROT_READ, MAP_PRIVATE, indexfd, 0);
|
||||||
if (map == MAP_FAILED) {
|
if (map == MAP_FAILED) {
|
||||||
perror("mmap index for basezoom");
|
perror("mmap index for basezoom");
|
||||||
@@ -1090,7 +1090,6 @@ static void calc_zooms_and_dropping(const int indexfd, const std::atomic<long lo
|
|||||||
madvise(map, indexpos, MADV_SEQUENTIAL);
|
madvise(map, indexpos, MADV_SEQUENTIAL);
|
||||||
madvise(map, indexpos, MADV_WILLNEED);
|
madvise(map, indexpos, MADV_WILLNEED);
|
||||||
long long indices = indexpos / sizeof(struct index);
|
long long indices = indexpos / sizeof(struct index);
|
||||||
bool fix_dropping = false;
|
|
||||||
|
|
||||||
if (guess_maxzoom) {
|
if (guess_maxzoom) {
|
||||||
double mean = 0;
|
double mean = 0;
|
||||||
@@ -1485,6 +1484,15 @@ static void calc_zooms_and_dropping(const int indexfd, const std::atomic<long lo
|
|||||||
fix_dropping = true;
|
fix_dropping = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
void fix_feature_minzooms(const bool fix_dropping, const int geomfd,
|
||||||
|
const int indexfd, const std::atomic<long long> &indexpos,
|
||||||
|
struct index *map,
|
||||||
|
const int maxzoom, const int basezoom, const double droprate, const double gamma) {
|
||||||
|
long long indices = indexpos / sizeof(struct index);
|
||||||
|
|
||||||
if (fix_dropping || drop_denser > 0) {
|
if (fix_dropping || drop_denser > 0) {
|
||||||
// Fix up the minzooms for features, now that we really know the base zoom
|
// Fix up the minzooms for features, now that we really know the base zoom
|
||||||
// and drop rate.
|
// and drop rate.
|
||||||
@@ -2785,15 +2793,21 @@ std::pair<int, metadata> read_input(std::vector<source> &sources, char *fname, i
|
|||||||
exit(EXIT_NODATA);
|
exit(EXIT_NODATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
calc_zooms_and_dropping(indexfd, indexpos,
|
bool fix_dropping = false;
|
||||||
geomfd,
|
struct index *map = calc_zooms_and_dropping(indexfd, indexpos,
|
||||||
guess_maxzoom, guess_cluster_maxzoom,
|
guess_maxzoom, guess_cluster_maxzoom,
|
||||||
dist_sum, dist_count,
|
dist_sum, dist_count,
|
||||||
area_sum,
|
area_sum,
|
||||||
outdb, pgm,
|
outdb, pgm,
|
||||||
maxzoom, minimum_maxzoom, basezoom, minzoom,
|
maxzoom, minimum_maxzoom, basezoom, minzoom,
|
||||||
basezoom_marker_width,
|
basezoom_marker_width,
|
||||||
droprate, gamma);
|
droprate, gamma,
|
||||||
|
fix_dropping);
|
||||||
|
|
||||||
|
fix_feature_minzooms(fix_dropping, geomfd,
|
||||||
|
indexfd, indexpos,
|
||||||
|
map,
|
||||||
|
maxzoom, basezoom, droprate, gamma);
|
||||||
|
|
||||||
/* Traverse and split the geometries for each zoom level */
|
/* Traverse and split the geometries for each zoom level */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user