Compare commits

..
Author SHA1 Message Date
Erica Fischer ae6eed17c1 Snap to the tile grid as each simplified point is chosen 2023-05-04 14:37:19 -07:00
6 changed files with 18 additions and 45 deletions
-8
View File
@@ -1,11 +1,3 @@
# 2.26.0
* Fix bugs in --no-simplification-of-shared-nodes
* Updated dockerfile (jtmiclat)
* Set build options to use C++-17 (james2432)
* Use std::fpclassify instead of plain fpclassify (james)
* Fix pmtiles warnings (bdon)
# 2.25.0
* Add `--include`/`-y` option to tile-join
+13 -5
View File
@@ -832,7 +832,7 @@ static double square_distance_from_line(long long point_x, long long point_y, lo
}
// https://github.com/Project-OSRM/osrm-backend/blob/733d1384a40f/Algorithms/DouglasePeucker.cpp
static void douglas_peucker(drawvec &geom, int start, int n, double e, size_t kept, size_t retain) {
static void douglas_peucker(drawvec &geom, int start, int n, double e, size_t kept, size_t retain, double res) {
e = e * e;
std::stack<int> recursion_stack;
@@ -875,7 +875,10 @@ static void douglas_peucker(drawvec &geom, int start, int n, double e, size_t ke
if (max_distance >= 0) {
// mark idx as necessary
geom[start + farthest_element_index].necessary = 1;
size_t k = start + farthest_element_index;
geom[k].necessary = 1;
geom[k].x = res * std::round((double) geom[k].x / res);
geom[k].y = res * std::round((double) geom[k].y / res);
kept++;
if (1 < farthest_element_index - first) {
@@ -933,8 +936,6 @@ drawvec simplify_lines(drawvec &geom, int z, int detail, bool mark_tile_bounds,
geom[i].necessary = 1;
} else if (geom[i].op == VT_LINETO) {
geom[i].necessary = 0;
// if this is actually the endpoint, not an intermediate point,
// it will be marked as necessary below
} else {
geom[i].necessary = 1;
}
@@ -963,6 +964,13 @@ drawvec simplify_lines(drawvec &geom, int z, int detail, bool mark_tile_bounds,
geom[i].necessary = 1;
geom[j - 1].necessary = 1;
for (size_t k = i; k < j; k++) {
if (geom[k].necessary) {
geom[k].x = res * std::round((double) geom[k].x / res);
geom[k].y = res * std::round((double) geom[k].y / res);
}
}
// empirical mapping from douglas-peucker simplifications
// to visvalingam simplifications that yield similar
// output sizes
@@ -974,7 +982,7 @@ drawvec simplify_lines(drawvec &geom, int z, int detail, bool mark_tile_bounds,
if (additional[A_VISVALINGAM]) {
visvalingam(geom, i, j, scale, retain);
} else {
douglas_peucker(geom, i, j - i, res * simplification, 2, retain);
douglas_peucker(geom, i, j - i, res * simplification, 2, retain, res);
}
}
i = j - 1;
-2
View File
@@ -1,2 +0,0 @@
{ "type": "Feature", "properties": { "LINEARID": "11074706697", "FULLNAME": "Fishers Pointe Blvd", "RTTYP": "M", "MTFCC": "S1400" }, "geometry": { "type": "LineString", "coordinates": [ [ -86.0174959, 39.951407 ], [ -86.0174409, 39.951459 ], [ -86.0173849, 39.951489 ], [ -86.0173059, 39.95151 ], [ -86.0172479, 39.951512 ], [ -86.0171679, 39.951503 ], [ -86.0171439, 39.951492 ], [ -86.0170519, 39.951437 ], [ -86.0170169, 39.951391 ], [ -86.0169949, 39.95133 ], [ -86.0169909, 39.951284 ], [ -86.0170079, 39.95123 ], [ -86.0170479, 39.951177 ], [ -86.0170959, 39.951141 ], [ -86.0171229, 39.95113 ] ] } }
{ "type": "Feature", "properties": { "LINEARID": "11074705426", "FULLNAME": "Fountainview Ln", "RTTYP": "M", "MTFCC": "S1400" }, "geometry": { "type": "LineString", "coordinates": [ [ -86.0174659, 39.954021 ], [ -86.0175089, 39.953939 ], [ -86.0175239, 39.953883 ], [ -86.0175299, 39.953807 ], [ -86.0175309, 39.953668 ], [ -86.0175259, 39.953265 ], [ -86.0175179, 39.953216 ], [ -86.0175009, 39.953166 ], [ -86.0174579, 39.953088 ], [ -86.0174149, 39.95304 ], [ -86.0173559, 39.952988 ], [ -86.0172939, 39.952953 ], [ -86.0170609, 39.952854 ], [ -86.0166669, 39.952699 ], [ -86.0165839, 39.952646 ], [ -86.0165439, 39.952598 ], [ -86.0165239, 39.952538 ], [ -86.0165139, 39.952467 ], [ -86.0165269, 39.952399 ], [ -86.0165629, 39.952339 ], [ -86.0171439, 39.951492 ] ] } }
@@ -1,22 +0,0 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "-86.017531,39.951130,-86.016514,39.954021",
"bounds": "-86.017531,39.951130,-86.016514,39.954021",
"center": "-86.017531,39.954021,11",
"description": "tests/intersection/out/-Z11_-z11_--extra-detail_13_--no-simplification-of-shared-nodes.json.check.mbtiles",
"format": "pbf",
"generator_options": "./tippecanoe -q -a@ -f -o tests/intersection/out/-Z11_-z11_--extra-detail_13_--no-simplification-of-shared-nodes.json.check.mbtiles -Z11 -z11 --extra-detail 13 --no-simplification-of-shared-nodes tests/intersection/in.json",
"json": "{\"vector_layers\":[{\"id\":\"in\",\"description\":\"\",\"minzoom\":11,\"maxzoom\":11,\"fields\":{\"FULLNAME\":\"String\",\"LINEARID\":\"String\",\"MTFCC\":\"String\",\"RTTYP\":\"String\"}}],\"tilestats\":{\"layerCount\":1,\"layers\":[{\"layer\":\"in\",\"count\":2,\"geometry\":\"LineString\",\"attributeCount\":4,\"attributes\":[{\"attribute\":\"FULLNAME\",\"count\":2,\"type\":\"string\",\"values\":[\"Fishers Pointe Blvd\",\"Fountainview Ln\"]},{\"attribute\":\"LINEARID\",\"count\":2,\"type\":\"string\",\"values\":[\"11074705426\",\"11074706697\"]},{\"attribute\":\"MTFCC\",\"count\":1,\"type\":\"string\",\"values\":[\"S1400\"]},{\"attribute\":\"RTTYP\",\"count\":1,\"type\":\"string\",\"values\":[\"M\"]}]}]}}",
"maxzoom": "11",
"minzoom": "11",
"name": "tests/intersection/out/-Z11_-z11_--extra-detail_13_--no-simplification-of-shared-nodes.json.check.mbtiles",
"type": "overlay",
"version": "2"
}, "features": [
{ "type": "FeatureCollection", "properties": { "zoom": 11, "x": 534, "y": 775 }, "features": [
{ "type": "FeatureCollection", "properties": { "layer": "in", "version": 2, "extent": 8192 }, "features": [
{ "type": "Feature", "properties": { "LINEARID": "11074705426", "FULLNAME": "Fountainview Ln", "RTTYP": "M", "MTFCC": "S1400" }, "geometry": { "type": "LineString", "coordinates": [ [ -86.017456, 39.954014 ], [ -86.017520, 39.953668 ], [ -86.017520, 39.953257 ], [ -86.017456, 39.953093 ], [ -86.017284, 39.952961 ], [ -86.016576, 39.952648 ], [ -86.016512, 39.952468 ], [ -86.017134, 39.951497 ] ] } }
,
{ "type": "Feature", "properties": { "LINEARID": "11074706697", "FULLNAME": "Fishers Pointe Blvd", "RTTYP": "M", "MTFCC": "S1400" }, "geometry": { "type": "LineString", "coordinates": [ [ -86.017499, 39.951415 ], [ -86.017306, 39.951513 ], [ -86.017134, 39.951497 ], [ -86.017027, 39.951398 ], [ -86.016984, 39.951283 ], [ -86.017113, 39.951135 ] ] } }
] }
] }
] }
+4 -7
View File
@@ -554,11 +554,7 @@ double simplify_partial(partial *p, drawvec &shared_nodes) {
// Only matters if simplification is set higher than the tiny polygon size.
// Tiny polygons that are part of a tiny multipolygon will still get simplified.
if (!p->reduced) {
// These aren't necessarily actually no-ops until we scale down.
// Don't do it if we are trying to preserve intersections, because
// it might wipe out the intersection and spoil the matching even though
// it would leave something else within the same tile pixel.
if (t == VT_LINE && !prevent[P_SIMPLIFY_SHARED_NODES]) {
if (t == VT_LINE) {
// continues to deduplicate to line_detail even if we have extra detail
geom = remove_noop(geom, t, 32 - z - line_detail);
}
@@ -577,6 +573,7 @@ double simplify_partial(partial *p, drawvec &shared_nodes) {
}
// continues to simplify to line_detail even if we have extra detail
// should this change since we are now snapping as part of simplifying?
drawvec ngeom = simplify_lines(geom, z, line_detail, !(prevent[P_CLIPPING] || prevent[P_DUPLICATION]), p->simplification, t == VT_POLYGON ? 4 : 0, shared_nodes);
if (t != VT_POLYGON || ngeom.size() >= 3) {
@@ -2257,7 +2254,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
partials.push_back(p);
unsimplified_geometry_size += sf.geometry.size() * sizeof(draw);
if (unsimplified_geometry_size > 10 * 1024 * 1024 && !additional[A_DETECT_SHARED_BORDERS] && !prevent[P_SIMPLIFY_SHARED_NODES]) {
if (unsimplified_geometry_size > 10 * 1024 * 1024 && !additional[A_DETECT_SHARED_BORDERS]) {
drawvec dv;
for (; simplified_geometry_through < partials.size(); simplified_geometry_through++) {
@@ -2288,7 +2285,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
just_shared_nodes.push_back(shared_nodes[i]);
draw d = shared_nodes[i];
i++; // consume the first, point at the duplicate
i++;
while (i + 1 < shared_nodes.size() && shared_nodes[i + 1] == d) {
i++;
}
+1 -1
View File
@@ -1,6 +1,6 @@
#ifndef VERSION_HPP
#define VERSION_HPP
#define VERSION "v2.26.0"
#define VERSION "v2.25.0"
#endif