mirror of
https://github.com/felt/tippecanoe.git
synced 2026-12-01 04:41:21 +01:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
231c62c25a |
@@ -36,3 +36,22 @@ jobs:
|
||||
echo "::error::man/tippecanoe.1 is out of date. Run 'make docs' and commit the result."
|
||||
exit 1
|
||||
}
|
||||
|
||||
indent:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
# Pinned, because different clang-format versions format the same input
|
||||
# differently, which would make this check fail spuriously.
|
||||
- name: Install clang-format
|
||||
run: |
|
||||
python3 -m venv /tmp/clang-format
|
||||
/tmp/clang-format/bin/pip install clang-format==18.1.8
|
||||
- name: Reformat the sources
|
||||
run: PATH="/tmp/clang-format/bin:$PATH" make indent
|
||||
- name: Check that the sources are correctly formatted
|
||||
run: |
|
||||
git diff --exit-code || {
|
||||
echo "::error::Sources are not correctly formatted. Run 'make indent' and commit the result."
|
||||
exit 1
|
||||
}
|
||||
|
||||
@@ -127,8 +127,13 @@ tippecanoe-overzoom: overzoom.o mvt.o clip.o evaluator.o jsonpull/jsonpull.o tex
|
||||
clean:
|
||||
rm -f ./tippecanoe ./tippecanoe-* ./tile-join ./unit *.o *.d */*.o */*.d tests/**/*.mbtiles tests/**/*.check
|
||||
|
||||
# CI checks that the committed sources match what this produces, so run it before
|
||||
# sending a pull request. Different clang-format versions format the same input
|
||||
# differently, so the CI job pins one (see .github/workflows/test.yml); if your
|
||||
# local version disagrees with it, let the job tell you what to fix rather than
|
||||
# committing its idea of the formatting.
|
||||
indent:
|
||||
clang-format -i -style="{BasedOnStyle: Google, IndentWidth: 8, UseTab: Always, AllowShortIfStatementsOnASingleLine: false, ColumnLimit: 0, ContinuationIndentWidth: 8, SpaceAfterCStyleCast: true, IndentCaseLabels: false, AllowShortBlocksOnASingleLine: false, AllowShortFunctionsOnASingleLine: false, SortIncludes: false}" $(filter-out flatgeobuf.cpp,$(C)) $(H) jsonpull/*.[ch]
|
||||
clang-format -i -style="{BasedOnStyle: Google, IndentWidth: 8, UseTab: Always, AllowShortIfStatementsOnASingleLine: false, ColumnLimit: 0, ContinuationIndentWidth: 8, SpaceAfterCStyleCast: true, IndentCaseLabels: false, AllowShortBlocksOnASingleLine: false, AllowShortFunctionsOnASingleLine: false, SortIncludes: false, PointerAlignment: Right, DerivePointerAlignment: false}" $(C) $(H) jsonpull/*.[ch]
|
||||
|
||||
TESTS = $(wildcard tests/*/out/*.json)
|
||||
SPACE = $(NULL) $(NULL)
|
||||
@@ -144,7 +149,6 @@ suffixes = json json.gz
|
||||
# %22 for quoted quote
|
||||
# %2f for /
|
||||
# %3a for :
|
||||
# %3d for =
|
||||
# %5f for _
|
||||
# %7b for {
|
||||
|
||||
@@ -152,11 +156,10 @@ testargs = \
|
||||
$(subst %20,' ',\
|
||||
$(subst %22,'"',\
|
||||
$(subst %3a,:,\
|
||||
$(subst %3d,=,\
|
||||
$(subst %2f,/,\
|
||||
$(subst %7b,'{',\
|
||||
$(subst %5f,'_',\
|
||||
$(subst _, ,$(1)))))))))
|
||||
$(subst %2f,/,\
|
||||
$(subst %7b,'{',\
|
||||
$(subst %5f,'_',\
|
||||
$(subst _, ,$(1))))))))
|
||||
|
||||
%.json.check:
|
||||
./tippecanoe -q -a@ -f -o $@.mbtiles $(call testargs,$(patsubst %.json.check,%,$(word 4,$(subst /, ,$@)))) $(foreach suffix,$(suffixes),$(sort $(wildcard $(subst $(SPACE),/,$(wordlist 1,2,$(subst /, ,$@)))/*.$(suffix)))) < /dev/null
|
||||
@@ -440,7 +443,7 @@ overzoom-test: tippecanoe-overzoom
|
||||
./tippecanoe-overzoom -b0 --deduplicate-by-id -o tests/pbf/merged-dedup.pbf -t 1/1/0 tests/pbf/1.json.dir/0/0/0.pbf 0/0/0 tests/pbf/2.json.dir/0/0/0.pbf 0/0/0
|
||||
./tippecanoe-decode tests/pbf/merged-dedup.pbf 1 1 0 > tests/pbf/merged-dedup.pbf.json.check
|
||||
cmp tests/pbf/merged-dedup.pbf.json.check tests/pbf/merged-dedup.pbf.json
|
||||
rm -r tests/pbf/1.json.dir tests/pbf/2.json.dir tests/pbf/merged-nodedup.pbf tests/pbf/merged-nodedup.pbf.json.check tests/pbf/merged-dedup.pbf tests/pbf/merged-dedup.pbf.json.check
|
||||
rm -r tests/pbf/1.json.dir tests/pbf/2.json.dir tests/pbf/merged-nodedup.pbf tests/pbf/merged-nodedup.pbf.json.check tests/pbf/merged-dedup.pbf.json.check
|
||||
|
||||
join-test: tippecanoe tippecanoe-decode tile-join
|
||||
./tippecanoe -q -f -z12 -o tests/join-population/tabblock_06001420.mbtiles -YALAND10:'Land area' -L'{"file": "tests/join-population/tabblock_06001420.json", "description": "population"}'
|
||||
|
||||
@@ -357,7 +357,7 @@ Parallel processing will also be automatic if the input file is in FlatGeobuf fo
|
||||
specified maximum zoom and to any levels added beyond that.
|
||||
* `--extend-zooms-if-still-dropping-maximum=`_count_: Increase the maxzoom if features are still being dropped at that zoom level
|
||||
by up to _count_ zoom levels.
|
||||
* `-at` or `--generate-variable-depth-tile-pyramid`: Don't produce child tiles for any tile that should be sufficient to be overzoomed to any higher zoom level. Such tiles will be produced with maximum detail, retaining every vertex that is not collinear with its neighbors, but their polygons are still cleaned so that overlapping areas are merged rather than left stacked. Tiles with point features below the basezoom, or which contain too many features or bytes with full detail, will be written out with normal detail and split into child tiles. If any features have to be dropped dynamically at a zoom level, no tile in that zoom level is truncated, so that the whole zoom level is reduced consistently; any tile that was already being skipped because an ancestor had been truncated is written out after all. Tilesets generated with this option are suitable for use only with tile servers that will find the appropriate tile to overzoom from and will simplify the geometries appropriately before serving the tile.
|
||||
* `-at` or `--generate-variable-depth-tile-pyramid`: Don't produce child tiles for any tile that should be sufficient to be overzoomed to any higher zoom level. Such tiles will be produced with maximum detail and no simplification or polygon cleaning. Tiles with point features below the basezoom or where any features have to be dropped dynamically, or which contain too many features or bytes with full detail, will be written out with normal detail and split into child tiles. Tilesets generated with this option are suitable for use only with tile servers that will find the appropriate tile to overzoom from and will simplify and clean the geometries appropriately before serving the tile.
|
||||
* `-R` _zoom_`/`_x_`/`_y_ or `--one-tile=`_zoom_`/`_x_`/`_y_: Set the minzoom and maxzoom to _zoom_ and produce only
|
||||
the single specified tile at that zoom level.
|
||||
|
||||
|
||||
+64
-61
@@ -9,43 +9,42 @@
|
||||
#include "errors.hpp"
|
||||
#include "thread.hpp"
|
||||
|
||||
static constexpr uint8_t magicbytes[8] = { 0x66, 0x67, 0x62, 0x03, 0x66, 0x67, 0x62, 0x01 };
|
||||
static constexpr uint8_t magicbytes[8] = {0x66, 0x67, 0x62, 0x03, 0x66, 0x67, 0x62, 0x01};
|
||||
|
||||
struct NodeItem {
|
||||
double minX;
|
||||
double minY;
|
||||
double maxX;
|
||||
double maxY;
|
||||
uint64_t offset;
|
||||
double minX;
|
||||
double minY;
|
||||
double maxX;
|
||||
double maxY;
|
||||
uint64_t offset;
|
||||
};
|
||||
|
||||
// copied from https://github.com/flatgeobuf/flatgeobuf/blob/master/src/cpp/packedrtree.cpp#L365
|
||||
uint64_t PackedRTreeSize(const uint64_t numItems, const uint16_t nodeSize)
|
||||
{
|
||||
if (nodeSize < 2)
|
||||
throw std::invalid_argument("Node size must be at least 2");
|
||||
if (numItems == 0)
|
||||
throw std::invalid_argument("Number of items must be greater than 0");
|
||||
const uint16_t nodeSizeMin = std::min(std::max(nodeSize, static_cast<uint16_t>(2)), static_cast<uint16_t>(65535));
|
||||
// limit so that resulting size in bytes can be represented by uint64_t
|
||||
if (numItems > static_cast<uint64_t>(1) << 56)
|
||||
throw std::overflow_error("Number of items must be less than 2^56");
|
||||
uint64_t n = numItems;
|
||||
uint64_t numNodes = n;
|
||||
do {
|
||||
n = (n + nodeSizeMin - 1) / nodeSizeMin;
|
||||
numNodes += n;
|
||||
} while (n != 1);
|
||||
return numNodes * sizeof(NodeItem);
|
||||
uint64_t PackedRTreeSize(const uint64_t numItems, const uint16_t nodeSize) {
|
||||
if (nodeSize < 2)
|
||||
throw std::invalid_argument("Node size must be at least 2");
|
||||
if (numItems == 0)
|
||||
throw std::invalid_argument("Number of items must be greater than 0");
|
||||
const uint16_t nodeSizeMin = std::min(std::max(nodeSize, static_cast<uint16_t>(2)), static_cast<uint16_t>(65535));
|
||||
// limit so that resulting size in bytes can be represented by uint64_t
|
||||
if (numItems > static_cast<uint64_t>(1) << 56)
|
||||
throw std::overflow_error("Number of items must be less than 2^56");
|
||||
uint64_t n = numItems;
|
||||
uint64_t numNodes = n;
|
||||
do {
|
||||
n = (n + nodeSizeMin - 1) / nodeSizeMin;
|
||||
numNodes += n;
|
||||
} while (n != 1);
|
||||
return numNodes * sizeof(NodeItem);
|
||||
}
|
||||
|
||||
drawvec readPoints(const FlatGeobuf::Geometry *geometry) {
|
||||
auto xy = geometry->xy();
|
||||
drawvec dv;
|
||||
|
||||
for (unsigned int i = 0; i < xy->size(); i+=2) {
|
||||
for (unsigned int i = 0; i < xy->size(); i += 2) {
|
||||
long long x, y;
|
||||
projection->project(xy->Get(i), xy->Get(i+1), 32, &x, &y);
|
||||
projection->project(xy->Get(i), xy->Get(i + 1), 32, &x, &y);
|
||||
dv.push_back(draw(VT_MOVETO, x, y));
|
||||
}
|
||||
return dv;
|
||||
@@ -57,12 +56,13 @@ drawvec readLinePart(const FlatGeobuf::Geometry *geometry) {
|
||||
size_t current_end = 0;
|
||||
drawvec dv;
|
||||
|
||||
for (unsigned int i = 0; i < xy->size(); i+=2) {
|
||||
for (unsigned int i = 0; i < xy->size(); i += 2) {
|
||||
long long x, y;
|
||||
projection->project(xy->Get(i), xy->Get(i+1), 32, &x, &y);
|
||||
if (i == 0 || (ends != NULL && current_end < ends->size() && i == ends->Get(current_end)*2)) {
|
||||
projection->project(xy->Get(i), xy->Get(i + 1), 32, &x, &y);
|
||||
if (i == 0 || (ends != NULL && current_end < ends->size() && i == ends->Get(current_end) * 2)) {
|
||||
dv.push_back(draw(VT_MOVETO, x, y));
|
||||
if (i > 0) current_end++;
|
||||
if (i > 0)
|
||||
current_end++;
|
||||
} else {
|
||||
dv.push_back(draw(VT_LINETO, x, y));
|
||||
}
|
||||
@@ -72,12 +72,13 @@ drawvec readLinePart(const FlatGeobuf::Geometry *geometry) {
|
||||
|
||||
drawvec readGeometry(const FlatGeobuf::Geometry *geometry, FlatGeobuf::GeometryType h_geometry_type) {
|
||||
FlatGeobuf::GeometryType geometry_type = h_geometry_type;
|
||||
if (h_geometry_type == FlatGeobuf::GeometryType_Unknown) geometry_type = geometry->type();
|
||||
if (h_geometry_type == FlatGeobuf::GeometryType_Unknown)
|
||||
geometry_type = geometry->type();
|
||||
|
||||
if (geometry_type == FlatGeobuf::GeometryType_Point) {
|
||||
return readPoints(geometry);
|
||||
} else if (geometry_type == FlatGeobuf::GeometryType_MultiPoint) {
|
||||
return readPoints(geometry);
|
||||
return readPoints(geometry);
|
||||
} else if (geometry_type == FlatGeobuf::GeometryType_LineString) {
|
||||
return readLinePart(geometry);
|
||||
} else if (geometry_type == FlatGeobuf::GeometryType_MultiLineString) {
|
||||
@@ -85,7 +86,7 @@ drawvec readGeometry(const FlatGeobuf::Geometry *geometry, FlatGeobuf::GeometryT
|
||||
} else if (geometry_type == FlatGeobuf::GeometryType_Polygon) {
|
||||
return readLinePart(geometry);
|
||||
} else if (geometry_type == FlatGeobuf::GeometryType_MultiPolygon) {
|
||||
// if it is a GeometryCollection, parse Parts, ignore XY
|
||||
// if it is a GeometryCollection, parse Parts, ignore XY
|
||||
drawvec dv;
|
||||
for (size_t part = 0; part < geometry->parts()->size(); part++) {
|
||||
drawvec dv2 = readLinePart(geometry->parts()->Get(part));
|
||||
@@ -96,7 +97,7 @@ drawvec readGeometry(const FlatGeobuf::Geometry *geometry, FlatGeobuf::GeometryT
|
||||
}
|
||||
return dv;
|
||||
} else {
|
||||
fprintf(stderr, "flatgeobuf has unsupported geometry type %u\n", (unsigned int)h_geometry_type);
|
||||
fprintf(stderr, "flatgeobuf has unsupported geometry type %u\n", (unsigned int) h_geometry_type);
|
||||
exit(EXIT_IMPOSSIBLE);
|
||||
}
|
||||
}
|
||||
@@ -107,26 +108,27 @@ void readFeature(const FlatGeobuf::Feature *feature, long long feature_sequence_
|
||||
int drawvec_type = -1;
|
||||
|
||||
FlatGeobuf::GeometryType geometry_type = h_geometry_type;
|
||||
if (h_geometry_type == FlatGeobuf::GeometryType_Unknown) geometry_type = feature->geometry()->type();
|
||||
if (h_geometry_type == FlatGeobuf::GeometryType_Unknown)
|
||||
geometry_type = feature->geometry()->type();
|
||||
|
||||
switch (geometry_type) {
|
||||
case FlatGeobuf::GeometryType_Point :
|
||||
case FlatGeobuf::GeometryType_MultiPoint :
|
||||
drawvec_type = 1;
|
||||
break;
|
||||
case FlatGeobuf::GeometryType_LineString :
|
||||
case FlatGeobuf::GeometryType_MultiLineString :
|
||||
drawvec_type = 2;
|
||||
break;
|
||||
case FlatGeobuf::GeometryType_Polygon :
|
||||
case FlatGeobuf::GeometryType_MultiPolygon :
|
||||
drawvec_type = 3;
|
||||
break;
|
||||
case FlatGeobuf::GeometryType_Unknown :
|
||||
case FlatGeobuf::GeometryType_GeometryCollection :
|
||||
default:
|
||||
fprintf(stderr, "flatgeobuf has unsupported geometry type %u\n", (unsigned int)h_geometry_type);
|
||||
exit(EXIT_IMPOSSIBLE);
|
||||
case FlatGeobuf::GeometryType_Point:
|
||||
case FlatGeobuf::GeometryType_MultiPoint:
|
||||
drawvec_type = 1;
|
||||
break;
|
||||
case FlatGeobuf::GeometryType_LineString:
|
||||
case FlatGeobuf::GeometryType_MultiLineString:
|
||||
drawvec_type = 2;
|
||||
break;
|
||||
case FlatGeobuf::GeometryType_Polygon:
|
||||
case FlatGeobuf::GeometryType_MultiPolygon:
|
||||
drawvec_type = 3;
|
||||
break;
|
||||
case FlatGeobuf::GeometryType_Unknown:
|
||||
case FlatGeobuf::GeometryType_GeometryCollection:
|
||||
default:
|
||||
fprintf(stderr, "flatgeobuf has unsupported geometry type %u\n", (unsigned int) h_geometry_type);
|
||||
exit(EXIT_IMPOSSIBLE);
|
||||
}
|
||||
|
||||
serial_feature sf;
|
||||
@@ -148,7 +150,7 @@ void readFeature(const FlatGeobuf::Feature *feature, long long feature_sequence_
|
||||
|
||||
std::vector<std::shared_ptr<std::string>> full_keys;
|
||||
std::vector<serial_val> full_values;
|
||||
key_pool key_pool;
|
||||
key_pool key_pool;
|
||||
|
||||
// assume tabular schema with columns in header
|
||||
size_t p_pos = 0;
|
||||
@@ -236,12 +238,12 @@ void readFeature(const FlatGeobuf::Feature *feature, long long feature_sequence_
|
||||
sv.type = mvt_string;
|
||||
uint32_t val_len;
|
||||
memcpy(&val_len, feature->properties()->data() + p_pos + sizeof(uint16_t), sizeof(val_len));
|
||||
std::string s{reinterpret_cast<const char*>(feature->properties()->data() + p_pos + sizeof(uint16_t) + sizeof(uint32_t)), val_len};
|
||||
std::string s{reinterpret_cast<const char *>(feature->properties()->data() + p_pos + sizeof(uint16_t) + sizeof(uint32_t)), val_len};
|
||||
sv.s = s;
|
||||
p_pos += sizeof(uint16_t) + sizeof(uint32_t) + val_len;
|
||||
} else {
|
||||
// Binary is not representable in MVT
|
||||
fprintf(stderr, "flatgeobuf has unsupported column type %u\n", (unsigned int)col_type);
|
||||
fprintf(stderr, "flatgeobuf has unsupported column type %u\n", (unsigned int) col_type);
|
||||
exit(EXIT_IMPOSSIBLE);
|
||||
}
|
||||
full_keys.push_back(key_pool.pool(h_column_names[col_idx]));
|
||||
@@ -347,9 +349,9 @@ void queueFeature(const FlatGeobuf::Feature *feature, long long feature_sequence
|
||||
}
|
||||
|
||||
void parse_flatgeobuf(std::vector<struct serialization_state> *sst, const char *src, size_t len, int layer, std::string layername) {
|
||||
auto header_size = flatbuffers::GetPrefixedSize((const uint8_t *)src + sizeof(magicbytes));
|
||||
auto header_size = flatbuffers::GetPrefixedSize((const uint8_t *) src + sizeof(magicbytes));
|
||||
|
||||
flatbuffers::Verifier v((const uint8_t *)src+sizeof(magicbytes),header_size+sizeof(uint32_t));
|
||||
flatbuffers::Verifier v((const uint8_t *) src + sizeof(magicbytes), header_size + sizeof(uint32_t));
|
||||
const auto ok = FlatGeobuf::VerifySizePrefixedHeaderBuffer(v);
|
||||
if (!ok) {
|
||||
fprintf(stderr, "flatgeobuf header verification failed\n");
|
||||
@@ -378,15 +380,15 @@ void parse_flatgeobuf(std::vector<struct serialization_state> *sst, const char *
|
||||
if (!quiet) {
|
||||
fprintf(stderr, "detected indexed FlatGeobuf: assigning feature IDs by sequence\n");
|
||||
}
|
||||
index_size = PackedRTreeSize(features_count,node_size);
|
||||
index_size = PackedRTreeSize(features_count, node_size);
|
||||
feature_sequence_id = 0;
|
||||
}
|
||||
const char* start = src + sizeof(magicbytes) + sizeof(uint32_t) + header_size + index_size;
|
||||
const char *start = src + sizeof(magicbytes) + sizeof(uint32_t) + header_size + index_size;
|
||||
|
||||
while (start < src + len) {
|
||||
auto feature_size = flatbuffers::GetPrefixedSize((const uint8_t *)start);
|
||||
auto feature_size = flatbuffers::GetPrefixedSize((const uint8_t *) start);
|
||||
|
||||
flatbuffers::Verifier v2((const uint8_t *)start,feature_size+sizeof(uint32_t));
|
||||
flatbuffers::Verifier v2((const uint8_t *) start, feature_size + sizeof(uint32_t));
|
||||
const auto ok2 = FlatGeobuf::VerifySizePrefixedFeatureBuffer(v2);
|
||||
if (!ok2) {
|
||||
fprintf(stderr, "flatgeobuf feature buffer verification failed\n");
|
||||
@@ -397,7 +399,8 @@ void parse_flatgeobuf(std::vector<struct serialization_state> *sst, const char *
|
||||
|
||||
queueFeature(feature, feature_sequence_id, h_geometry_type, h_column_names, h_column_types, sst, layer, layername);
|
||||
|
||||
if (feature_sequence_id >= 0) feature_sequence_id ++;
|
||||
if (feature_sequence_id >= 0)
|
||||
feature_sequence_id++;
|
||||
start += sizeof(uint32_t) + feature_size;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -693,7 +693,7 @@ struct sorty {
|
||||
struct sorty_sorter {
|
||||
int kind;
|
||||
sorty_sorter(int k)
|
||||
: kind(k){};
|
||||
: kind(k) {};
|
||||
|
||||
bool operator()(const sorty &a, const sorty &b) const {
|
||||
long long xa, ya, xb, yb;
|
||||
|
||||
+1
-1
@@ -357,7 +357,7 @@ specified maximum zoom and to any levels added beyond that.
|
||||
\fB--extend-zooms-if-still-dropping-maximum=\fR\fIcount\fP: Increase the maxzoom if features are still being dropped at that zoom level
|
||||
by up to \fIcount\fP zoom levels.
|
||||
.IP \(bu 2
|
||||
\fB-at\fR or \fB--generate-variable-depth-tile-pyramid\fR: Don't produce child tiles for any tile that should be sufficient to be overzoomed to any higher zoom level. Such tiles will be produced with maximum detail, retaining every vertex that is not collinear with its neighbors, but their polygons are still cleaned so that overlapping areas are merged rather than left stacked. Tiles with point features below the basezoom, or which contain too many features or bytes with full detail, will be written out with normal detail and split into child tiles. If any features have to be dropped dynamically at a zoom level, no tile in that zoom level is truncated, so that the whole zoom level is reduced consistently; any tile that was already being skipped because an ancestor had been truncated is written out after all. Tilesets generated with this option are suitable for use only with tile servers that will find the appropriate tile to overzoom from and will simplify the geometries appropriately before serving the tile.
|
||||
\fB-at\fR or \fB--generate-variable-depth-tile-pyramid\fR: Don't produce child tiles for any tile that should be sufficient to be overzoomed to any higher zoom level. Such tiles will be produced with maximum detail and no simplification or polygon cleaning. Tiles with point features below the basezoom or where any features have to be dropped dynamically, or which contain too many features or bytes with full detail, will be written out with normal detail and split into child tiles. Tilesets generated with this option are suitable for use only with tile servers that will find the appropriate tile to overzoom from and will simplify and clean the geometries appropriately before serving the tile.
|
||||
.IP \(bu 2
|
||||
\fB-R\fR \fIzoom\fP\fB/\fR\fIx\fP\fB/\fR\fIy\fP or \fB--one-tile=\fR\fIzoom\fP\fB/\fR\fIx\fP\fB/\fR\fIy\fP: Set the minzoom and maxzoom to \fIzoom\fP and produce only
|
||||
the single specified tile at that zoom level.
|
||||
|
||||
@@ -407,7 +407,7 @@ std::string mvt_tile::encode() {
|
||||
std::string feature_string;
|
||||
protozero::pbf_writer feature_writer(feature_string);
|
||||
|
||||
if (layers[i].features[f].type >= 0)
|
||||
if (layers[i].features[f].type >= 0)
|
||||
feature_writer.add_enum(3, layers[i].features[f].type);
|
||||
|
||||
std::vector<unsigned> sorted_tags = layers[i].features[f].tags;
|
||||
|
||||
+1
-1
@@ -676,7 +676,7 @@ int serialize_feature(struct serialization_state *sst, serial_feature &sf, std::
|
||||
} else if (extent < 0) {
|
||||
sf.extent = LLONG_MIN;
|
||||
} else {
|
||||
sf.extent = LLONG_MAX; // also the NaN case
|
||||
sf.extent = LLONG_MAX; // also the NaN case
|
||||
}
|
||||
|
||||
if (sst->want_dist && sf.t == VT_POLYGON) {
|
||||
|
||||
+779
-549
File diff suppressed because one or more lines are too long
-2434
File diff suppressed because one or more lines are too long
-2426
File diff suppressed because one or more lines are too long
-1906
File diff suppressed because one or more lines are too long
+1
-1
@@ -336,7 +336,7 @@ void append_tile(std::string message, int z, unsigned x, unsigned y, std::map<st
|
||||
outfeature.geometry[i].x = outfeature.geometry[i].x * outlayer.extent / layer.extent;
|
||||
outfeature.geometry[i].y = outfeature.geometry[i].y * outlayer.extent / layer.extent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (auto const &g : outfeature.geometry) {
|
||||
if (g.op == mvt_moveto || g.op == mvt_lineto) {
|
||||
|
||||
@@ -538,6 +538,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;
|
||||
@@ -672,7 +673,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;
|
||||
@@ -687,18 +690,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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -827,7 +832,7 @@ static double choose_minattribute(std::vector<double> &attribute_values, double
|
||||
if (descending) {
|
||||
// For descending: drop features > threshold, keep features <= threshold
|
||||
// ix points at the last value to keep
|
||||
size_t ix = (size_t)((attribute_values.size() - 1) * f);
|
||||
size_t ix = (size_t) ((attribute_values.size() - 1) * f);
|
||||
while (ix > 0 && attribute_values[ix] >= existing_attribute) {
|
||||
ix--;
|
||||
}
|
||||
@@ -840,7 +845,7 @@ static double choose_minattribute(std::vector<double> &attribute_values, double
|
||||
} else {
|
||||
// For ascending: drop features < threshold, keep features >= threshold
|
||||
// ix points at the first value to keep
|
||||
size_t ix = (size_t)ceil((double)(attribute_values.size() - 1) * (1 - f));
|
||||
size_t ix = (size_t) ceil((double) (attribute_values.size() - 1) * (1 - f));
|
||||
if (ix >= attribute_values.size()) {
|
||||
ix = attribute_values.size() - 1;
|
||||
}
|
||||
@@ -921,12 +926,8 @@ struct write_tile_args {
|
||||
long long minextent_out = 0;
|
||||
unsigned long long mindrop_sequence = 0;
|
||||
unsigned long long mindrop_sequence_out = 0;
|
||||
// the infinity that excludes nothing, for the ascending order that
|
||||
// drop_by_attribute_descending also defaults to. dropping_features()
|
||||
// reads these, so they must not start out at a value that looks like
|
||||
// a threshold that has already been chosen.
|
||||
double minattribute = -HUGE_VAL;
|
||||
double minattribute_out = -HUGE_VAL;
|
||||
double minattribute = 0;
|
||||
double minattribute_out = 0;
|
||||
std::string const *drop_by_attribute_as_needed_attribute = NULL;
|
||||
bool drop_by_attribute_descending = false;
|
||||
size_t tile_size_out = 0;
|
||||
@@ -948,26 +949,8 @@ struct write_tile_args {
|
||||
std::string const *shared_nodes_bloom;
|
||||
std::set<zxy> const *skip_children; // what is being skipped at this zoom
|
||||
std::set<zxy> skip_children_out; // what will be skipped in the next zoom
|
||||
bool first_dropping_pass = false; // is this the first pass of this zoom that is dropping features?
|
||||
};
|
||||
|
||||
// Is this zoom level discarding features to make its tiles fit? The thresholds
|
||||
// start out excluding nothing, and only move inward once some tile in the zoom
|
||||
// fails to fit and the whole zoom is retried with a threshold for discarding
|
||||
// features. For mingap, minextent, and mindrop_sequence that starting point is
|
||||
// zero; for minattribute it is the infinity on whichever side is being kept.
|
||||
//
|
||||
// Pyramid truncation is disabled while this is true, so that every tile in the
|
||||
// zoom is reduced consistently, and tiles that were skipped because an ancestor
|
||||
// truncated its pyramid are revived.
|
||||
static bool dropping_features(unsigned long long mingap, long long minextent, unsigned long long mindrop_sequence, double minattribute, bool drop_by_attribute_descending) {
|
||||
bool dropping_by_attribute = drop_by_attribute_descending
|
||||
? minattribute != HUGE_VAL
|
||||
: minattribute != -HUGE_VAL;
|
||||
|
||||
return mingap != 0 || minextent != 0 || mindrop_sequence != 0 || dropping_by_attribute;
|
||||
}
|
||||
|
||||
// Clips a feature's geometry to the tile bounds at the specified zoom level
|
||||
// with the specified buffer. Returns true if the feature was entirely clipped away
|
||||
// by bounding box alone; otherwise returns false.
|
||||
@@ -1119,7 +1102,7 @@ struct next_feature_state {
|
||||
// This function is called repeatedly from write_tile() to retrieve the next feature
|
||||
// from the input stream. If the stream is at an end, it returns a feature with the
|
||||
// geometry type set to -2.
|
||||
static serial_feature next_feature(decompressor *geoms, std::atomic<long long> *geompos_in, int z, unsigned tx, unsigned ty, unsigned *initial_x, unsigned *initial_y, long long *original_features, long long *unclipped_features, int nextzoom, int maxzoom, int minzoom, int max_zoom_increment, size_t pass, std::atomic<long long> *along, long long alongminus, int buffer, std::atomic<bool> *within, compressor **geomfile, std::atomic<long long> *geompos, long long start_geompos[], std::atomic<double> *oprogress, double todo, const char *fname, int child_shards, json_object *filter, const char *global_stringpool, long long *pool_off, std::vector<std::vector<std::string>> *layer_unmaps, bool first_time, bool write_children, bool compressed, multiplier_state *multiplier_state, std::shared_ptr<std::string> &tile_stringpool, std::vector<std::string> const &unidecode_data, next_feature_state &next_feature_state, double droprate) {
|
||||
static serial_feature next_feature(decompressor *geoms, std::atomic<long long> *geompos_in, int z, unsigned tx, unsigned ty, unsigned *initial_x, unsigned *initial_y, long long *original_features, long long *unclipped_features, int nextzoom, int maxzoom, int minzoom, int max_zoom_increment, size_t pass, std::atomic<long long> *along, long long alongminus, int buffer, std::atomic<bool> *within, compressor **geomfile, std::atomic<long long> *geompos, long long start_geompos[], std::atomic<double> *oprogress, double todo, const char *fname, int child_shards, json_object *filter, const char *global_stringpool, long long *pool_off, std::vector<std::vector<std::string>> *layer_unmaps, bool first_time, bool compressed, multiplier_state *multiplier_state, std::shared_ptr<std::string> &tile_stringpool, std::vector<std::string> const &unidecode_data, next_feature_state &next_feature_state, double droprate) {
|
||||
double extra_multiplier_zooms = log(retain_points_multiplier) / log(droprate);
|
||||
|
||||
while (1) {
|
||||
@@ -1208,7 +1191,7 @@ static serial_feature next_feature(decompressor *geoms, std::atomic<long long> *
|
||||
// XXX should continue, but affects test outputs
|
||||
}
|
||||
|
||||
if (first_time && write_children) { /* only write out the next zoom once, even if we retry */
|
||||
if (first_time && pass == 0) { /* only write out the next zoom once, even if we retry */
|
||||
if (sf.tippecanoe_maxzoom == -1 || sf.tippecanoe_maxzoom >= nextzoom) {
|
||||
rewrite(sf, z, nextzoom, maxzoom, tx, ty, buffer, within, geompos, start_geompos, geomfile, fname, child_shards, max_zoom_increment, sf.segment, initial_x, initial_y);
|
||||
}
|
||||
@@ -1373,7 +1356,6 @@ struct run_prefilter_args {
|
||||
json_object *filter = NULL;
|
||||
std::vector<std::string> const *unidecode_data;
|
||||
bool first_time = false;
|
||||
bool write_children = false;
|
||||
bool compressed = false;
|
||||
double droprate = 1;
|
||||
};
|
||||
@@ -1386,7 +1368,7 @@ void *run_prefilter(void *v) {
|
||||
next_feature_state next_feature_state;
|
||||
|
||||
while (1) {
|
||||
serial_feature sf = next_feature(rpa->geoms, rpa->geompos_in, rpa->z, rpa->tx, rpa->ty, rpa->initial_x, rpa->initial_y, rpa->original_features, rpa->unclipped_features, rpa->nextzoom, rpa->maxzoom, rpa->minzoom, rpa->max_zoom_increment, rpa->pass, rpa->along, rpa->alongminus, rpa->buffer, rpa->within, rpa->geomfile, rpa->geompos, rpa->start_geompos, rpa->oprogress, rpa->todo, rpa->fname, rpa->child_shards, rpa->filter, rpa->global_stringpool, rpa->pool_off, rpa->layer_unmaps, rpa->first_time, rpa->write_children, rpa->compressed, &multiplier_state, tile_stringpool, *(rpa->unidecode_data), next_feature_state, rpa->droprate);
|
||||
serial_feature sf = next_feature(rpa->geoms, rpa->geompos_in, rpa->z, rpa->tx, rpa->ty, rpa->initial_x, rpa->initial_y, rpa->original_features, rpa->unclipped_features, rpa->nextzoom, rpa->maxzoom, rpa->minzoom, rpa->max_zoom_increment, rpa->pass, rpa->along, rpa->alongminus, rpa->buffer, rpa->within, rpa->geomfile, rpa->geompos, rpa->start_geompos, rpa->oprogress, rpa->todo, rpa->fname, rpa->child_shards, rpa->filter, rpa->global_stringpool, rpa->pool_off, rpa->layer_unmaps, rpa->first_time, rpa->compressed, &multiplier_state, tile_stringpool, *(rpa->unidecode_data), next_feature_state, rpa->droprate);
|
||||
if (sf.t < 0) {
|
||||
break;
|
||||
}
|
||||
@@ -1662,7 +1644,7 @@ void skip_tile(decompressor *geoms, std::atomic<long long> *geompos_in, bool com
|
||||
}
|
||||
}
|
||||
|
||||
long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, char *global_stringpool, int z, const unsigned tx, const unsigned ty, const int detail, int min_detail, sqlite3 *outdb, const char *outdir, int buffer, const char *fname, compressor **geomfile, std::atomic<long long> *geompos, int minzoom, int maxzoom, double todo, std::atomic<long long> *along, long long alongminus, double gamma, int child_shards, long long *pool_off, unsigned *initial_x, unsigned *initial_y, std::atomic<int> *running, double simplification, std::vector<std::map<std::string, layermap_entry>> *layermaps, std::vector<std::vector<std::string>> *layer_unmaps, size_t tiling_seg, size_t pass, unsigned long long mingap, long long minextent, unsigned long long mindrop_sequence, double minattribute, const char *prefilter, const char *postfilter, json_object *filter, write_tile_args *arg, atomic_strategy *strategy_out, bool compressed_input, node *shared_nodes_map, size_t nodepos, std::string const &shared_nodes_bloom, std::vector<std::string> const &unidecode_data, long long estimated_complexity, bool write_children, std::set<zxy> &skip_children_out) {
|
||||
long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, char *global_stringpool, int z, const unsigned tx, const unsigned ty, const int detail, int min_detail, sqlite3 *outdb, const char *outdir, int buffer, const char *fname, compressor **geomfile, std::atomic<long long> *geompos, int minzoom, int maxzoom, double todo, std::atomic<long long> *along, long long alongminus, double gamma, int child_shards, long long *pool_off, unsigned *initial_x, unsigned *initial_y, std::atomic<int> *running, double simplification, std::vector<std::map<std::string, layermap_entry>> *layermaps, std::vector<std::vector<std::string>> *layer_unmaps, size_t tiling_seg, size_t pass, unsigned long long mingap, long long minextent, unsigned long long mindrop_sequence, double minattribute, const char *prefilter, const char *postfilter, json_object *filter, write_tile_args *arg, atomic_strategy *strategy_out, bool compressed_input, node *shared_nodes_map, size_t nodepos, std::string const &shared_nodes_bloom, std::vector<std::string> const &unidecode_data, long long estimated_complexity, std::set<zxy> &skip_children_out) {
|
||||
double merge_fraction = 1;
|
||||
double mingap_fraction = 1;
|
||||
double minextent_fraction = 1;
|
||||
@@ -1698,7 +1680,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] && !dropping_features(mingap, minextent, mindrop_sequence, minattribute, arg->drop_by_attribute_descending)) {
|
||||
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.
|
||||
|
||||
@@ -1762,7 +1744,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
|
||||
key_pool key_pool;
|
||||
|
||||
std::vector<std::atomic<bool> > within(child_shards);
|
||||
std::vector<std::atomic<bool>> within(child_shards);
|
||||
std::vector<long long> start_geompos(child_shards);
|
||||
for (size_t i = 0; i < (size_t) child_shards; i++) {
|
||||
within[i] = false;
|
||||
@@ -1843,7 +1825,6 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
rpa.filter = filter;
|
||||
rpa.unidecode_data = &unidecode_data;
|
||||
rpa.first_time = first_time;
|
||||
rpa.write_children = write_children;
|
||||
rpa.compressed = compressed_input;
|
||||
rpa.droprate = arg->droprate;
|
||||
|
||||
@@ -1877,7 +1858,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
ssize_t which_serial_feature = -1;
|
||||
|
||||
if (prefilter == NULL) {
|
||||
sf = next_feature(geoms, geompos_in, z, tx, ty, initial_x, initial_y, &original_features, &unclipped_features, nextzoom, maxzoom, minzoom, max_zoom_increment, pass, along, alongminus, buffer, within.data(), geomfile, geompos, start_geompos.data(), &oprogress, todo, fname, child_shards, filter, global_stringpool, pool_off, layer_unmaps, first_time, write_children, compressed_input, &multiplier_state, tile_stringpool, unidecode_data, next_feature_state, arg->droprate);
|
||||
sf = next_feature(geoms, geompos_in, z, tx, ty, initial_x, initial_y, &original_features, &unclipped_features, nextzoom, maxzoom, minzoom, max_zoom_increment, pass, along, alongminus, buffer, within.data(), geomfile, geompos, start_geompos.data(), &oprogress, todo, fname, child_shards, filter, global_stringpool, pool_off, layer_unmaps, first_time, compressed_input, &multiplier_state, tile_stringpool, unidecode_data, next_feature_state, arg->droprate);
|
||||
} else {
|
||||
sf = parse_feature(prefilter_jp, z, tx, ty, layermaps, tiling_seg, layer_unmaps, postfilter != NULL, key_pool);
|
||||
}
|
||||
@@ -2132,8 +2113,8 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
if (attr_valid) {
|
||||
add_sample_to(attribute_values, attr_numeric, attribute_values_increment, seq);
|
||||
bool should_drop = arg->drop_by_attribute_descending
|
||||
? (minattribute != HUGE_VAL && attr_numeric > minattribute)
|
||||
: (minattribute != -HUGE_VAL && attr_numeric < minattribute);
|
||||
? (minattribute != HUGE_VAL && attr_numeric > minattribute)
|
||||
: (minattribute != -HUGE_VAL && attr_numeric < minattribute);
|
||||
if (should_drop) {
|
||||
can_stop_early = false;
|
||||
if (drop_feature_unless_it_can_be_added_to_a_multiplier_cluster(layer, sf, layer_unmaps, strategy, drop_rest, arg->attribute_accum, key_pool)) {
|
||||
@@ -2267,12 +2248,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
|
||||
@@ -2481,6 +2456,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) {
|
||||
@@ -2801,7 +2777,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
}
|
||||
} else if (additional[A_DROP_BY_ATTRIBUTE_AS_NEEDED]) {
|
||||
minattribute_fraction = minattribute_fraction *
|
||||
adjusted_max_tile_features / adjusted_feature_count * 0.75;
|
||||
adjusted_max_tile_features / adjusted_feature_count * 0.75;
|
||||
if (minattribute_fraction > 0.80) {
|
||||
if (!quiet) {
|
||||
fprintf(stderr,
|
||||
@@ -2907,6 +2883,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;
|
||||
}
|
||||
|
||||
@@ -3169,41 +3146,12 @@ exit(EXIT_IMPOSSIBLE);
|
||||
long long len;
|
||||
|
||||
struct zxy parent(z - 1, x / 2, y / 2);
|
||||
bool skip = false;
|
||||
|
||||
// Normally a tile writes the geometry for its children on pass 0, and the
|
||||
// later passes of the same zoom, which are only retries with new thresholds,
|
||||
// must not write it again.
|
||||
bool write_children = (arg->pass == 0);
|
||||
|
||||
if (arg->skip_children->count(parent) > 0) {
|
||||
if (dropping_features(arg->mingap, arg->minextent, arg->mindrop_sequence, arg->minattribute, arg->drop_by_attribute_descending)) {
|
||||
// The parent truncated its pyramid here, but the zoom has since had to
|
||||
// start dropping features, so the truncation no longer holds and this
|
||||
// tile has to be written after all. Its geometry is still in the stream.
|
||||
skip = false;
|
||||
|
||||
// It was skipped on every earlier pass of this zoom, so its children
|
||||
// have never been written out. Write them on the first pass that
|
||||
// actually tiles it, rather than on pass 0 as usual. The thresholds
|
||||
// only ever increase within a zoom, so that is exactly the pass on
|
||||
// which this zoom started dropping.
|
||||
write_children = arg->first_dropping_pass;
|
||||
} 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 {
|
||||
arg->wrote_zoom = z;
|
||||
len = write_tile(&dc, &geompos, arg->global_stringpool, z, x, y, z == arg->maxzoom ? arg->full_detail : arg->low_detail, arg->min_detail, arg->outdb, arg->outdir, arg->buffer, arg->fname, arg->geomfile, arg->geompos, arg->minzoom, arg->maxzoom, arg->todo, arg->along, geompos, arg->gamma, arg->child_shards, arg->pool_off, arg->initial_x, arg->initial_y, arg->running, arg->simplification, arg->layermaps, arg->layer_unmaps, arg->tiling_seg, arg->pass, arg->mingap, arg->minextent, arg->mindrop_sequence, arg->minattribute, arg->prefilter, arg->postfilter, arg->filter, arg, arg->strategy, arg->compressed, arg->shared_nodes_map, arg->nodepos, *(arg->shared_nodes_bloom), (*arg->unidecode_data), estimated_complexity, write_children, arg->skip_children_out);
|
||||
len = write_tile(&dc, &geompos, arg->global_stringpool, z, x, y, z == arg->maxzoom ? arg->full_detail : arg->low_detail, arg->min_detail, arg->outdb, arg->outdir, arg->buffer, arg->fname, arg->geomfile, arg->geompos, arg->minzoom, arg->maxzoom, arg->todo, arg->along, geompos, arg->gamma, arg->child_shards, arg->pool_off, arg->initial_x, arg->initial_y, arg->running, arg->simplification, arg->layermaps, arg->layer_unmaps, arg->tiling_seg, arg->pass, arg->mingap, arg->minextent, arg->mindrop_sequence, arg->minattribute, arg->prefilter, arg->postfilter, arg->filter, arg, arg->strategy, arg->compressed, arg->shared_nodes_map, arg->nodepos, *(arg->shared_nodes_bloom), (*arg->unidecode_data), estimated_complexity, arg->skip_children_out);
|
||||
}
|
||||
|
||||
if (pthread_mutex_lock(&var_lock) != 0) {
|
||||
@@ -3303,7 +3251,7 @@ int traverse_zooms(int *geomfd, off_t *geom_size, char *global_stringpool, std::
|
||||
|
||||
std::vector<compressor> compressors(TEMP_FILES);
|
||||
std::vector<compressor *> sub(TEMP_FILES);
|
||||
std::vector<std::atomic<long long> > subpos(TEMP_FILES);
|
||||
std::vector<std::atomic<long long>> subpos(TEMP_FILES);
|
||||
std::vector<int> subfd(TEMP_FILES);
|
||||
for (size_t j = 0; j < TEMP_FILES; j++) {
|
||||
std::string geomname = std::string(tmpdir) + "/geom" + std::to_string(j) + ".XXXXXXXX";
|
||||
@@ -3387,16 +3335,8 @@ int traverse_zooms(int *geomfd, off_t *geom_size, char *global_stringpool, std::
|
||||
size_t zoom_tile_size = 0;
|
||||
size_t zoom_feature_count = 0;
|
||||
std::set<zxy> skip_children_out;
|
||||
bool was_dropping = false;
|
||||
|
||||
for (size_t pass = 0;; pass++) {
|
||||
// Tiles that were skipped because an ancestor truncated its pyramid are
|
||||
// revived on the pass where this zoom starts dropping features, and that
|
||||
// is the pass on which they have to write out their children.
|
||||
bool is_dropping = dropping_features(zoom_mingap, zoom_minextent, zoom_mindrop_sequence, zoom_minattribute, drop_by_attribute_descending);
|
||||
bool first_dropping_pass = is_dropping && !was_dropping;
|
||||
was_dropping = is_dropping;
|
||||
|
||||
std::vector<pthread_t> pthreads(threads);
|
||||
std::vector<write_tile_args> args;
|
||||
args.resize(threads);
|
||||
@@ -3478,7 +3418,6 @@ int traverse_zooms(int *geomfd, off_t *geom_size, char *global_stringpool, std::
|
||||
args[thread].shared_nodes_bloom = &shared_nodes_bloom;
|
||||
args[thread].skip_children = &skip_children;
|
||||
args[thread].skip_children_out.clear();
|
||||
args[thread].first_dropping_pass = first_dropping_pass;
|
||||
|
||||
if (thread_create(&pthreads[thread], NULL, run_thread, &args[thread]) != 0) {
|
||||
perror("pthread_create");
|
||||
@@ -3520,8 +3459,8 @@ int traverse_zooms(int *geomfd, off_t *geom_size, char *global_stringpool, std::
|
||||
again = true;
|
||||
}
|
||||
bool attr_propagate = drop_by_attribute_descending
|
||||
? args[thread].minattribute_out < zoom_minattribute
|
||||
: args[thread].minattribute_out > zoom_minattribute;
|
||||
? args[thread].minattribute_out < zoom_minattribute
|
||||
: args[thread].minattribute_out > zoom_minattribute;
|
||||
if (attr_propagate) {
|
||||
zoom_minattribute = args[thread].minattribute_out;
|
||||
again = true;
|
||||
|
||||
@@ -145,8 +145,8 @@ TEST_CASE("Polygon cleaning drops a hole that no ring can parent", "[wagyu]") {
|
||||
// through the "Could not properly place hole to a parent." handler in
|
||||
// clean_or_clip_poly instead of returning.
|
||||
static const std::vector<std::vector<std::pair<long long, long long>>> rings = {
|
||||
{{0, 5}, {5, 4}, {5, 1}, {4, 4}, {4, 2}, {7, 1}, {0, 5}},
|
||||
{{0, 5}, {7, 1}, {4, 2}, {4, 4}, {5, 1}, {5, 4}, {0, 0}, {0, 5}},
|
||||
{{0, 5}, {5, 4}, {5, 1}, {4, 4}, {4, 2}, {7, 1}, {0, 5}},
|
||||
{{0, 5}, {7, 1}, {4, 2}, {4, 4}, {5, 1}, {5, 4}, {0, 0}, {0, 5}},
|
||||
};
|
||||
|
||||
drawvec geom;
|
||||
|
||||
Reference in New Issue
Block a user