Compare commits

..
6 changed files with 1792 additions and 2411 deletions
+548 -466
View File
File diff suppressed because it is too large Load Diff
+7 -5
View File
@@ -11,15 +11,17 @@
#include "serial.hpp"
struct index {
long long start = 0;
long long start = 0; // offset of data in geom file
long long end = 0;
unsigned long long ix = 0;
short segment = 0;
unsigned short t : 2;
unsigned long long seq : (64 - 18); // pack with segment and t to stay in 32 bytes
unsigned long long ix = 0; // quadkey or hilbert index
unsigned short segment; // which reader thread produced this feature
unsigned short t : 2; // geometry type
unsigned short dup : 8; // instance number of identical geometry
unsigned long long seq : (64 - 16 - 2 - 8); // input sequence number; pack with segment and t and dup to stay in 32 bytes
index()
: t(0),
dup(0),
seq(0) {
}
};
+1 -1
View File
@@ -882,8 +882,8 @@ int serialize_feature(struct serialization_state *sst, serial_feature &sf, std::
struct index index;
index.start = geomstart;
index.end = r->geompos;
index.segment = sst->segment;
index.seq = *(sst->layer_seq);
index.segment = sst->segment;
index.t = sf.t;
index.ix = bbox_index;
+20 -33
View File
@@ -541,6 +541,7 @@ struct simplification_worker_arg {
std::vector<std::shared_ptr<serial_feature>> *features = NULL;
int task = 0;
int tasks = 0;
bool trying_to_stop_early = false;
drawvec *shared_nodes;
node *shared_nodes_map;
@@ -675,7 +676,9 @@ static void *simplification_worker(void *v) {
for (size_t i = a->task; i < (*features).size(); i += a->tasks) {
double area = 0;
area = simplify_feature(&*((*features)[i]), *(a->shared_nodes), a->shared_nodes_map, a->nodepos, *(a->shared_nodes_bloom));
if (!a->trying_to_stop_early) {
area = simplify_feature(&*((*features)[i]), *(a->shared_nodes), a->shared_nodes_map, a->nodepos, *(a->shared_nodes_bloom));
}
signed char t = (*features)[i]->t;
int z = (*features)[i]->z;
@@ -690,18 +693,20 @@ static void *simplification_worker(void *v) {
{
drawvec before = geom;
// we can try scaling up because this is now tile scale
coalesce_polygon(geom, true);
if (additional[A_DEBUG_POLYGON]) {
check_polygon(geom);
}
if (!a->trying_to_stop_early) {
// we can try scaling up because this is now tile scale
coalesce_polygon(geom, true);
if (additional[A_DEBUG_POLYGON]) {
check_polygon(geom);
}
if (geom.size() < 3) {
if (area > 0) {
// area is in world coordinates, calculated before scaling down
geom = revive_polygon(before, area, z, out_detail);
} else {
geom.clear();
if (geom.size() < 3) {
if (area > 0) {
// area is in world coordinates, calculated before scaling down
geom = revive_polygon(before, area, z, out_detail);
} else {
geom.clear();
}
}
}
}
@@ -1648,7 +1653,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
int first_detail = detail, second_detail = detail - 1;
bool trying_to_stop_early = false;
bool can_stop_early = true;
if (additional[A_VARIABLE_DEPTH_PYRAMID] && mingap == 0 && minextent == 0 && mindrop_sequence == 0) {
if (additional[A_VARIABLE_DEPTH_PYRAMID]) {
// If we are trying to stop early, there is an extra first pass with full+extra detail,
// and which loops if everything doesn't fit rather than trying to drop or union features.
@@ -2180,12 +2185,6 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
sf.clustered = 0;
sf.tile_stringpool = tile_stringpool;
if (trying_to_stop_early && line_detail == first_detail) {
// only remove collinearities;
// leave all other vertices for extreme overzooming
sf.simplification = 0;
}
if (line_detail == detail && extra_detail >= 0 && z == maxzoom) {
sf.extra_detail = extra_detail;
// maximum allowed coordinate delta in geometries is 2^31 - 1
@@ -2394,6 +2393,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
args[i].shared_nodes_map = shared_nodes_map;
args[i].nodepos = nodepos;
args[i].shared_nodes_bloom = &shared_nodes_bloom;
args[i].trying_to_stop_early = trying_to_stop_early;
if (tasks > 1) {
if (thread_create(&pthreads[i], NULL, simplification_worker, &args[i]) != 0) {
@@ -2781,6 +2781,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
if (trying_to_stop_early && line_detail == first_detail) {
// didn't work, try a lower detail
detail_reduced++;
continue;
}
@@ -3011,21 +3012,7 @@ exit(EXIT_IMPOSSIBLE);
long long len;
struct zxy parent(z - 1, x / 2, y / 2);
bool skip = false;
if (arg->skip_children->count(parent) > 0) {
if (arg->mingap != 0 || arg->minextent != 0 || arg->mindrop_sequence != 0) {
// revive if we are trying to drop features and we still have the data
skip = false;
} else {
// skip if the parent tile finished at the last zoom level and we aren't trying to drop
skip = true;
}
} else {
// do the tile if the parent didn't finish early
skip = false;
}
if (skip) {
skip_tile(&dc, &geompos, arg->compressed);
len = 1;
} else {