mirror of
https://github.com/felt/tippecanoe.git
synced 2026-11-29 11:51:19 +01:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
318f05ad45 | ||
|
|
15a3e313ff |
@@ -1,3 +1,7 @@
|
||||
# 2.38.0
|
||||
|
||||
* Tolerate polygon rings with insuffiently many points in input
|
||||
|
||||
# 2.37.1
|
||||
|
||||
* Reduce maximum memory used for vertex sorting
|
||||
|
||||
@@ -249,7 +249,7 @@ static void decode_clipped(mapbox::geometry::multi_polygon<long long> &t, drawve
|
||||
}
|
||||
}
|
||||
|
||||
drawvec clean_or_clip_poly(drawvec &geom, int z, int buffer, bool clip, bool try_scaling) {
|
||||
drawvec clean_or_clip_poly(drawvec &geom, int z, int buffer, bool clip, bool try_scaling, bool even_odd) {
|
||||
geom = remove_noop(geom, VT_POLYGON, 0);
|
||||
mapbox::geometry::multi_polygon<long long> result;
|
||||
|
||||
@@ -308,7 +308,11 @@ drawvec clean_or_clip_poly(drawvec &geom, int z, int buffer, bool clip, bool try
|
||||
|
||||
try {
|
||||
result.clear();
|
||||
wagyu.execute(mapbox::geometry::wagyu::clip_type_union, result, mapbox::geometry::wagyu::fill_type_positive, mapbox::geometry::wagyu::fill_type_positive);
|
||||
if (even_odd) {
|
||||
wagyu.execute(mapbox::geometry::wagyu::clip_type_union, result, mapbox::geometry::wagyu::fill_type_even_odd, mapbox::geometry::wagyu::fill_type_even_odd);
|
||||
} else {
|
||||
wagyu.execute(mapbox::geometry::wagyu::clip_type_union, result, mapbox::geometry::wagyu::fill_type_positive, mapbox::geometry::wagyu::fill_type_positive);
|
||||
}
|
||||
} catch (std::runtime_error &e) {
|
||||
FILE *f = fopen("/tmp/wagyu.log", "w");
|
||||
fprintf(f, "%s\n", e.what());
|
||||
@@ -858,7 +862,8 @@ std::string overzoom(mvt_tile tile, int oz, int ox, int oy, int nz, int nx, int
|
||||
|
||||
geom = remove_noop(geom, t, 0);
|
||||
if (t == VT_POLYGON) {
|
||||
geom = clean_or_clip_poly(geom, 0, 0, false, false);
|
||||
// this is after scaling, so even-odd to balance scaling errors between features
|
||||
geom = clean_or_clip_poly(geom, 0, 0, false, false, true);
|
||||
geom = close_poly(geom);
|
||||
}
|
||||
|
||||
|
||||
+9
-2
@@ -642,9 +642,9 @@ drawvec fix_polygon(drawvec &geom) {
|
||||
|
||||
// A polygon ring must contain at least three points
|
||||
// (and really should contain four). If this one does
|
||||
// not have enough, avoid a division by zero trying to
|
||||
// not have any, avoid a division by zero trying to
|
||||
// calculate the centroid below.
|
||||
if (j - i < 3) {
|
||||
if (j - i < 1) {
|
||||
i = j - 1;
|
||||
outer = 0;
|
||||
continue;
|
||||
@@ -661,6 +661,13 @@ drawvec fix_polygon(drawvec &geom) {
|
||||
ring.push_back(ring[0]);
|
||||
}
|
||||
|
||||
// A polygon ring at this point should contain at least four points.
|
||||
// Flesh it out with some vertex copies if it doesn't.
|
||||
|
||||
while (ring.size() < 4) {
|
||||
ring.push_back(ring[0]);
|
||||
}
|
||||
|
||||
// Reverse ring if winding order doesn't match
|
||||
// inner/outer expectation
|
||||
|
||||
|
||||
+1
-1
@@ -70,7 +70,7 @@ void to_tile_scale(drawvec &geom, int z, int detail);
|
||||
drawvec from_tile_scale(drawvec const &geom, int z, int detail);
|
||||
drawvec remove_noop(drawvec geom, int type, int shift);
|
||||
drawvec clip_point(drawvec &geom, int z, long long buffer);
|
||||
drawvec clean_or_clip_poly(drawvec &geom, int z, int buffer, bool clip, bool try_scaling);
|
||||
drawvec clean_or_clip_poly(drawvec &geom, int z, int buffer, bool clip, bool try_scaling, bool even_odd);
|
||||
drawvec close_poly(drawvec &geom);
|
||||
drawvec reduce_tiny_poly(drawvec &geom, int z, int detail, bool *still_needs_simplification, bool *reduced_away, double *accum_area, serial_feature *this_feature, serial_feature *tiny_feature);
|
||||
int clip(long long *x0, long long *y0, long long *x1, long long *y1, long long xmin, long long ymin, long long xmax, long long ymax);
|
||||
|
||||
+2
-1
@@ -203,7 +203,8 @@ std::vector<mvt_layer> parse_layers(int fd, int z, unsigned x, unsigned y, std::
|
||||
|
||||
if (mb_geometry[t] == VT_POLYGON) {
|
||||
// we can try scaling up because these are tile coordinates
|
||||
dv = clean_or_clip_poly(dv, 0, 0, false, true);
|
||||
// these are already scaled, so even-odd winding
|
||||
dv = clean_or_clip_poly(dv, 0, 0, false, true, true);
|
||||
if (dv.size() < 3) {
|
||||
dv.clear();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
{ "type": "FeatureCollection", "properties": {
|
||||
"antimeridian_adjusted_bounds": "1.000000,2.000000,1.000000,2.000000",
|
||||
"bounds": "1.000000,2.000000,1.000000,2.000000",
|
||||
"center": "1.000000,2.000000,0",
|
||||
"description": "tests/invalid-linestring/out/-z0.json.check.mbtiles",
|
||||
"format": "pbf",
|
||||
"generator_options": "./tippecanoe -q -a@ -f -o tests/invalid-linestring/out/-z0.json.check.mbtiles -z0 tests/invalid-linestring/too-few.json",
|
||||
"json": "{\"vector_layers\":[{\"id\":\"toofew\",\"description\":\"\",\"minzoom\":0,\"maxzoom\":0,\"fields\":{}}],\"tilestats\":{\"layerCount\":1,\"layers\":[{\"layer\":\"toofew\",\"count\":1,\"geometry\":\"LineString\",\"attributeCount\":0,\"attributes\":[]}]}}",
|
||||
"maxzoom": "0",
|
||||
"minzoom": "0",
|
||||
"name": "tests/invalid-linestring/out/-z0.json.check.mbtiles",
|
||||
"type": "overlay",
|
||||
"version": "2"
|
||||
}, "features": [
|
||||
] }
|
||||
@@ -0,0 +1 @@
|
||||
{ "type": "Feature", "properties": {}, "geometry": { "type": "LineString", "coordinates": [ [ 1, 2 ] ] } }
|
||||
@@ -0,0 +1 @@
|
||||
{ "type": "Feature", "properties": { "handle": 717, "block": -1, "etype": 13, "space": 0, "layer": "0", "olinetype": "BYLAYER", "linetype": "", "color": "0,0,0,255", "ocolor": 7, "color24": -1, "transparency": 0, "lweight": -1, "linewidth": 0.0, "ltscale": 1.0, "visible": 1, "thickness": 0.0, "ext": null, "name": "SOLID", "solid": 1, "associative": 0, "hstyle": 1, "hpattern": 1, "doubleflag": 0, "angle": 0.0, "scale": 0.0, "deflines": 0 }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ -135.2329619, -85.526118 ], [ -135.2329619, -85.526118 ] ] ] ] } }
|
||||
@@ -0,0 +1,15 @@
|
||||
{ "type": "FeatureCollection", "properties": {
|
||||
"antimeridian_adjusted_bounds": "180.000000,85.051129,-180.000000,-85.051129",
|
||||
"bounds": "-135.232962,-85.051129,-135.232962,-85.051129",
|
||||
"center": "-135.232962,-85.051129,0",
|
||||
"description": "tests/invalid-polygon/out/-z0.json.check.mbtiles",
|
||||
"format": "pbf",
|
||||
"generator_options": "./tippecanoe -q -a@ -f -o tests/invalid-polygon/out/-z0.json.check.mbtiles -z0 tests/invalid-polygon/in.json",
|
||||
"json": "{\"vector_layers\":[{\"id\":\"in\",\"description\":\"\",\"minzoom\":0,\"maxzoom\":0,\"fields\":{\"angle\":\"Number\",\"associative\":\"Number\",\"block\":\"Number\",\"color\":\"String\",\"color24\":\"Number\",\"deflines\":\"Number\",\"doubleflag\":\"Number\",\"etype\":\"Number\",\"handle\":\"Number\",\"hpattern\":\"Number\",\"hstyle\":\"Number\",\"layer\":\"String\",\"linetype\":\"String\",\"linewidth\":\"Number\",\"ltscale\":\"Number\",\"lweight\":\"Number\",\"name\":\"String\",\"ocolor\":\"Number\",\"olinetype\":\"String\",\"scale\":\"Number\",\"solid\":\"Number\",\"space\":\"Number\",\"thickness\":\"Number\",\"transparency\":\"Number\",\"visible\":\"Number\"}}],\"tilestats\":{\"layerCount\":1,\"layers\":[{\"layer\":\"in\",\"count\":1,\"geometry\":\"Polygon\",\"attributeCount\":25,\"attributes\":[{\"attribute\":\"angle\",\"count\":1,\"type\":\"number\",\"values\":[0],\"min\":0,\"max\":0},{\"attribute\":\"associative\",\"count\":1,\"type\":\"number\",\"values\":[0],\"min\":0,\"max\":0},{\"attribute\":\"block\",\"count\":1,\"type\":\"number\",\"values\":[-1],\"min\":-1,\"max\":-1},{\"attribute\":\"color\",\"count\":1,\"type\":\"string\",\"values\":[\"0,0,0,255\"]},{\"attribute\":\"color24\",\"count\":1,\"type\":\"number\",\"values\":[-1],\"min\":-1,\"max\":-1},{\"attribute\":\"deflines\",\"count\":1,\"type\":\"number\",\"values\":[0],\"min\":0,\"max\":0},{\"attribute\":\"doubleflag\",\"count\":1,\"type\":\"number\",\"values\":[0],\"min\":0,\"max\":0},{\"attribute\":\"etype\",\"count\":1,\"type\":\"number\",\"values\":[13],\"min\":13,\"max\":13},{\"attribute\":\"handle\",\"count\":1,\"type\":\"number\",\"values\":[717],\"min\":717,\"max\":717},{\"attribute\":\"hpattern\",\"count\":1,\"type\":\"number\",\"values\":[1],\"min\":1,\"max\":1},{\"attribute\":\"hstyle\",\"count\":1,\"type\":\"number\",\"values\":[1],\"min\":1,\"max\":1},{\"attribute\":\"layer\",\"count\":1,\"type\":\"string\",\"values\":[\"0\"]},{\"attribute\":\"linetype\",\"count\":1,\"type\":\"string\",\"values\":[\"\"]},{\"attribute\":\"linewidth\",\"count\":1,\"type\":\"number\",\"values\":[0],\"min\":0,\"max\":0},{\"attribute\":\"ltscale\",\"count\":1,\"type\":\"number\",\"values\":[1],\"min\":1,\"max\":1},{\"attribute\":\"lweight\",\"count\":1,\"type\":\"number\",\"values\":[-1],\"min\":-1,\"max\":-1},{\"attribute\":\"name\",\"count\":1,\"type\":\"string\",\"values\":[\"SOLID\"]},{\"attribute\":\"ocolor\",\"count\":1,\"type\":\"number\",\"values\":[7],\"min\":7,\"max\":7},{\"attribute\":\"olinetype\",\"count\":1,\"type\":\"string\",\"values\":[\"BYLAYER\"]},{\"attribute\":\"scale\",\"count\":1,\"type\":\"number\",\"values\":[0],\"min\":0,\"max\":0},{\"attribute\":\"solid\",\"count\":1,\"type\":\"number\",\"values\":[1],\"min\":1,\"max\":1},{\"attribute\":\"space\",\"count\":1,\"type\":\"number\",\"values\":[0],\"min\":0,\"max\":0},{\"attribute\":\"thickness\",\"count\":1,\"type\":\"number\",\"values\":[0],\"min\":0,\"max\":0},{\"attribute\":\"transparency\",\"count\":1,\"type\":\"number\",\"values\":[0],\"min\":0,\"max\":0},{\"attribute\":\"visible\",\"count\":1,\"type\":\"number\",\"values\":[1],\"min\":1,\"max\":1}]}]}}",
|
||||
"maxzoom": "0",
|
||||
"minzoom": "0",
|
||||
"name": "tests/invalid-polygon/out/-z0.json.check.mbtiles",
|
||||
"type": "overlay",
|
||||
"version": "2"
|
||||
}, "features": [
|
||||
] }
|
||||
@@ -578,7 +578,8 @@ double simplify_partial(partial *p, drawvec const &shared_nodes, node *shared_no
|
||||
// unioned exactly
|
||||
//
|
||||
// don't try to scale up because these are still world coordinates
|
||||
geom = clean_or_clip_poly(geom, 0, 0, false, false);
|
||||
// positive winding because these are world coordinates
|
||||
geom = clean_or_clip_poly(geom, 0, 0, false, false, true);
|
||||
}
|
||||
|
||||
// continues to simplify to line_detail even if we have extra detail
|
||||
@@ -611,7 +612,42 @@ void *partial_feature_worker(void *v) {
|
||||
int z = (*partials)[i].z;
|
||||
int out_detail = (*partials)[i].extra_detail;
|
||||
|
||||
#if 0
|
||||
if ((*partials)[i].geoms[0].size() < 1) {
|
||||
fprintf(stderr, "expected at least one geometry in partial_feature_worker\n");
|
||||
exit(EXIT_IMPOSSIBLE);
|
||||
}
|
||||
for (size_t x = 1; x < (*partials)[i].geoms.size(); x++) {
|
||||
for (auto const &d : (*partials)[i].geoms[x]) {
|
||||
(*partials)[i].geoms[0].push_back(d);
|
||||
}
|
||||
}
|
||||
(*partials)[i].geoms.resize(1);
|
||||
#endif
|
||||
|
||||
if ((*partials)[i].geoms.size() != 1) {
|
||||
fprintf(stderr, "expected single geometry in partial_feature_worker\n");
|
||||
exit(EXIT_IMPOSSIBLE);
|
||||
}
|
||||
drawvec geom = (*partials)[i].geoms[0];
|
||||
|
||||
if (t == VT_POLYGON) {
|
||||
// clean multi-ring polygons with positive winding before scaling
|
||||
// so that polygon dust will be unioned on positively
|
||||
|
||||
size_t ring_count = 0;
|
||||
for (size_t x = 0; x < geom.size(); x++) {
|
||||
if (geom[x].op == VT_MOVETO) {
|
||||
ring_count++;
|
||||
|
||||
if (ring_count == 2) {
|
||||
geom = clean_or_clip_poly(geom, 0, 0, false, false, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
to_tile_scale(geom, z, out_detail);
|
||||
|
||||
if (t == VT_POLYGON) {
|
||||
@@ -620,7 +656,8 @@ void *partial_feature_worker(void *v) {
|
||||
{
|
||||
drawvec before = geom;
|
||||
// we can try scaling up because this is now tile scale
|
||||
geom = clean_or_clip_poly(geom, 0, 0, false, true);
|
||||
// even-odd since we have scaled
|
||||
geom = clean_or_clip_poly(geom, 0, 0, false, true, true);
|
||||
if (additional[A_DEBUG_POLYGON]) {
|
||||
check_polygon(geom);
|
||||
}
|
||||
@@ -2293,7 +2330,8 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
for (auto &g : partials[simplified_geometry_through].geoms) {
|
||||
if (partials[simplified_geometry_through].t == VT_POLYGON) {
|
||||
// don't scale up because this is still world coordinates
|
||||
g = clean_or_clip_poly(g, 0, 0, false, false);
|
||||
// positive winding because this before scaling
|
||||
g = clean_or_clip_poly(g, 0, 0, false, false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2533,7 +2571,8 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
if (layer_features[x].type == VT_POLYGON) {
|
||||
if (layer_features[x].coalesced) {
|
||||
// we can try scaling up because this is tile coordinates
|
||||
layer_features[x].geom = clean_or_clip_poly(layer_features[x].geom, 0, 0, false, true);
|
||||
// positive winding because we are trying to union features here
|
||||
layer_features[x].geom = clean_or_clip_poly(layer_features[x].geom, 0, 0, false, true, false);
|
||||
}
|
||||
|
||||
layer_features[x].geom = close_poly(layer_features[x].geom);
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#ifndef VERSION_HPP
|
||||
#define VERSION_HPP
|
||||
|
||||
#define VERSION "v2.37.1"
|
||||
#define VERSION "v2.38.0"
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user