Skip to content

Commit

Permalink
Raise the triangle thickness minimum to 2
Browse files Browse the repository at this point in the history
  • Loading branch information
e-n-f committed Oct 27, 2023
1 parent 705da71 commit 93c7398
Show file tree
Hide file tree
Showing 61 changed files with 31,907 additions and 27,233 deletions.
19 changes: 17 additions & 2 deletions earcut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,30 @@ drawvec reinforce(drawvec const &pts, std::vector<std::vector<Point>> polygon, d
if (distance_from_line(pts[indices[v1]].x, pts[indices[v1]].y, // the point
pts[indices[v2]].x, pts[indices[v2]].y, // start of opposite side
pts[indices[v3]].x, pts[indices[v3]].y, // end of opposite side
&px, &py) < scale) {
&px, &py) < 2 * scale) {
double ang = atan2(pts[indices[v1]].y - py, pts[indices[v1]].x - px);

// make a new triangle that is not so flat
out2.push_back(draw(VT_MOVETO, pts[indices[v2]].x, pts[indices[v2]].y));
out2.push_back(draw(VT_LINETO, pts[indices[v3]].x, pts[indices[v3]].y));
out2.push_back(draw(VT_LINETO, px + scale * cos(ang), py + scale * sin(ang)));
out2.push_back(draw(VT_LINETO, px + scale * 2 * cos(ang), py + scale * 2 * sin(ang)));
out2.push_back(draw(VT_LINETO, pts[indices[v2]].x, pts[indices[v2]].y));
}

#if 0
long long dx = pts[indices[v2]].x - pts[indices[v1]].x;
long long dy = pts[indices[v2]].y - pts[indices[v1]].y;
double d = sqrt(dx * dx + dy * dy);
if (d < sqrt(2) * scale) {
// make a new triangle with a longer side
double ang = atan2(dy, dx);

out2.push_back(draw(VT_MOVETO, pts[indices[v3]].x, pts[indices[v3]].y));
out2.push_back(draw(VT_LINETO, pts[indices[v1]].x - sqrt(2) * scale * cos(ang), pts[indices[v1]].y - sqrt(2) * scale * sin(ang)));
out2.push_back(draw(VT_LINETO, pts[indices[v2]].x + sqrt(2) * scale * cos(ang), pts[indices[v2]].y + sqrt(2) * scale * sin(ang)));
out2.push_back(draw(VT_LINETO, pts[indices[v3]].x, pts[indices[v3]].y));
}
#endif
}
}

Expand Down
5 changes: 3 additions & 2 deletions geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,10 @@ drawvec reduce_tiny_poly(drawvec &geom, int z, int detail, bool *still_needs_sim
miny = std::min(miny, (long long) d.y);
maxy = std::max(maxy, (long long) d.y);
}
if (area > 0 && area < minx * maxx / 4) {
if (area > 0 && area <= pixel * pixel && area < (maxx - minx) * (maxy - miny) / 3) {
// if the polygon doesn't use most of its area,
// don't let it be dust.
// don't let it be dust, because the shape is
// probably something weird and interesting.
area = pixel * pixel * 2;
}

Expand Down
2,754 changes: 1,377 additions & 1,377 deletions tests/allow-existing/both.mbtiles.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

33 changes: 16 additions & 17 deletions tests/border/out/-z1_--detect-shared-borders.json

Large diffs are not rendered by default.

250 changes: 125 additions & 125 deletions tests/coalesce-id/out/-z1_--coalesce_--reorder.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions tests/curve/out/-z2.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
,
{ "type": "FeatureCollection", "properties": { "zoom": 1, "x": 0, "y": 1 }, "features": [
{ "type": "FeatureCollection", "properties": { "layer": "in", "version": 2, "extent": 4096 }, "features": [
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -93.779297, 3.513421 ], [ -92.680664, 0.000000 ], [ -82.001953, -33.027088 ], [ -62.973633, -62.995158 ], [ -27.993164, -72.996909 ], [ 0.000000, -73.239377 ], [ 3.515625, -73.264704 ], [ 3.515625, -77.617709 ], [ 0.000000, -77.551572 ], [ -33.002930, -76.999935 ], [ -74.970703, -66.000150 ], [ -96.987305, -37.996163 ], [ -109.687500, 0.000000 ], [ -110.786133, 3.513421 ], [ -93.779297, 3.513421 ] ] ] } }
{ "type": "Feature", "properties": { }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ -93.779297, 3.513421 ], [ -92.680664, 0.000000 ], [ -82.001953, -33.027088 ], [ -62.973633, -62.995158 ], [ -27.993164, -72.996909 ], [ 0.000000, -73.239377 ], [ 3.515625, -73.264704 ], [ 3.515625, -77.617709 ], [ 0.000000, -77.551572 ], [ -33.002930, -76.999935 ], [ -74.970703, -66.000150 ], [ -96.987305, -37.996163 ], [ -109.687500, 0.000000 ], [ -110.786133, 3.513421 ], [ -93.779297, 3.513421 ] ] ], [ [ [ -27.993164, -72.996909 ], [ 0.000000, -73.214013 ], [ 3.515625, -73.264704 ], [ -27.993164, -72.996909 ] ] ] ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -115.839844, 3.513421 ], [ -115.708008, 0.000000 ], [ -111.972656, -75.004940 ], [ -91.977539, -76.999935 ], [ 0.000000, -78.143526 ], [ 3.515625, -78.188586 ], [ 3.515625, -82.003058 ], [ -111.005859, -82.003058 ], [ -138.999023, -76.005470 ], [ -138.999023, 3.513421 ], [ -115.839844, 3.513421 ] ] ] } }
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -115.839844, 3.513421 ], [ -115.708008, 0.000000 ], [ -111.972656, -75.004940 ], [ -91.977539, -76.999935 ], [ 0.087891, -78.143526 ], [ 3.515625, -78.188586 ], [ 3.515625, -82.003058 ], [ -111.005859, -82.003058 ], [ -138.999023, -76.005470 ], [ -138.999023, 3.513421 ], [ -115.839844, 3.513421 ] ] ] } }
] }
] }
,
Expand All @@ -38,9 +38,9 @@
,
{ "type": "FeatureCollection", "properties": { "zoom": 1, "x": 1, "y": 1 }, "features": [
{ "type": "FeatureCollection", "properties": { "layer": "in", "version": 2, "extent": 4096 }, "features": [
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -3.515625, -73.214013 ], [ 0.000000, -73.239377 ], [ 90.000000, -74.007440 ], [ 145.019531, -74.007440 ], [ 145.019531, -76.999935 ], [ 93.032227, -79.004962 ], [ 0.000000, -77.551572 ], [ -3.515625, -77.494607 ], [ -3.515625, -73.214013 ] ] ] } }
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -3.515625, -73.214013 ], [ 0.087891, -73.239377 ], [ 90.000000, -74.007440 ], [ 145.019531, -74.007440 ], [ 145.019531, -76.999935 ], [ 93.032227, -79.004962 ], [ 0.000000, -77.551572 ], [ -3.515625, -77.494607 ], [ -3.515625, -73.214013 ] ] ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -3.515625, -78.098296 ], [ 0.000000, -78.143526 ], [ 170.024414, -80.004799 ], [ 160.004883, -82.003058 ], [ -3.515625, -82.003058 ], [ -3.515625, -78.098296 ] ] ] } }
{ "type": "Feature", "properties": { }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ -3.515625, -78.098296 ], [ 0.000000, -78.143526 ], [ 170.024414, -80.004799 ], [ 160.004883, -82.003058 ], [ -3.515625, -82.003058 ], [ -3.515625, -78.098296 ] ] ], [ [ [ -3.515625, -78.098296 ], [ 0.000000, -78.125454 ], [ 170.024414, -80.004799 ], [ -3.515625, -78.098296 ] ] ] ] } }
] }
] }
,
Expand All @@ -52,13 +52,13 @@
,
{ "type": "FeatureCollection", "properties": { "zoom": 2, "x": 0, "y": 3 }, "features": [
{ "type": "FeatureCollection", "properties": { "layer": "in", "version": 2, "extent": 4096 }, "features": [
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -112.895508, -65.802776 ], [ -112.829590, -66.513260 ], [ -111.994629, -74.999254 ], [ -91.999512, -76.999935 ], [ -90.000000, -77.024626 ], [ -88.242188, -77.049271 ], [ -88.242188, -82.000000 ], [ -111.005859, -82.000000 ], [ -138.999023, -76.000156 ], [ -138.999023, -65.802776 ], [ -112.895508, -65.802776 ] ] ] } }
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -112.895508, -65.802776 ], [ -112.829590, -66.513260 ], [ -111.994629, -74.999254 ], [ -91.999512, -76.999935 ], [ -90.000000, -77.014755 ], [ -88.242188, -77.049271 ], [ -88.242188, -82.000000 ], [ -111.005859, -82.000000 ], [ -138.999023, -76.000156 ], [ -138.999023, -65.802776 ], [ -112.895508, -65.802776 ] ] ] } }
] }
] }
,
{ "type": "FeatureCollection", "properties": { "zoom": 2, "x": 0, "y": 2 }, "features": [
{ "type": "FeatureCollection", "properties": { "layer": "in", "version": 2, "extent": 4096 }, "features": [
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -93.229980, 1.757537 ], [ -92.680664, 0.000000 ], [ -90.000000, -8.754795 ], [ -88.242188, -14.392118 ], [ -88.242188, -51.385495 ], [ -90.000000, -48.951366 ], [ -97.009277, -37.996163 ], [ -109.687500, 0.000000 ], [ -110.214844, 1.757537 ], [ -93.229980, 1.757537 ] ] ] } }
{ "type": "Feature", "properties": { }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ -93.229980, 1.757537 ], [ -92.680664, 0.000000 ], [ -90.000000, -8.754795 ], [ -88.242188, -14.392118 ], [ -88.242188, -51.385495 ], [ -90.000000, -48.951366 ], [ -97.009277, -37.996163 ], [ -109.687500, 0.000000 ], [ -110.214844, 1.757537 ], [ -93.229980, 1.757537 ] ] ], [ [ [ -92.680664, 0.000000 ], [ -89.956055, -8.754795 ], [ -88.242188, -14.392118 ], [ -92.680664, 0.000000 ] ] ] ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -115.773926, 1.757537 ], [ -115.729980, 0.000000 ], [ -112.829590, -66.513260 ], [ -112.785645, -67.204032 ], [ -138.999023, -67.204032 ], [ -138.999023, 1.757537 ], [ -115.773926, 1.757537 ] ] ] } }
] }
Expand All @@ -74,39 +74,39 @@
,
{ "type": "FeatureCollection", "properties": { "zoom": 2, "x": 0, "y": 0 }, "features": [
{ "type": "FeatureCollection", "properties": { "layer": "in", "version": 2, "extent": 4096 }, "features": [
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -99.008789, 82.999490 ], [ -90.000000, 82.486209 ], [ -88.242188, 82.382061 ], [ -88.242188, 79.835594 ], [ -90.000000, 79.125832 ], [ -105.996094, 69.998052 ], [ -105.556641, 66.513260 ], [ -105.490723, 65.802776 ], [ -117.180176, 65.802776 ], [ -117.158203, 66.513260 ], [ -117.004395, 71.002660 ], [ -99.008789, 82.999490 ] ] ] } }
{ "type": "Feature", "properties": { }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ -99.008789, 82.999490 ], [ -90.000000, 82.486209 ], [ -88.242188, 82.382061 ], [ -88.242188, 79.835594 ], [ -90.000000, 79.125832 ], [ -105.996094, 69.998052 ], [ -105.556641, 66.513260 ], [ -105.490723, 65.802776 ], [ -117.180176, 65.802776 ], [ -117.158203, 66.513260 ], [ -117.004395, 71.002660 ], [ -99.008789, 82.999490 ] ] ], [ [ [ -99.008789, 82.999490 ], [ -89.956055, 82.486209 ], [ -88.242188, 82.382061 ], [ -99.008789, 82.999490 ] ] ] ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -88.242188, 82.999490 ], [ -88.242188, 79.951265 ], [ -90.000000, 79.576460 ], [ -119.003906, 71.002660 ], [ -118.608398, 66.513260 ], [ -118.542480, 65.802776 ], [ -138.999023, 65.802776 ], [ -138.999023, 74.001385 ], [ -101.008301, 82.999490 ], [ -88.242188, 82.999490 ] ] ] } }
] }
] }
,
{ "type": "FeatureCollection", "properties": { "zoom": 2, "x": 1, "y": 3 }, "features": [
{ "type": "FeatureCollection", "properties": { "layer": "in", "version": 2, "extent": 4096 }, "features": [
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -54.624023, -65.802776 ], [ -52.338867, -66.513260 ], [ -27.993164, -72.996909 ], [ 0.000000, -73.239377 ], [ 1.757812, -73.258376 ], [ 1.757812, -77.584684 ], [ 0.000000, -77.556308 ], [ -33.002930, -76.999935 ], [ -73.498535, -66.513260 ], [ -74.992676, -66.000150 ], [ -75.212402, -65.802776 ], [ -54.624023, -65.802776 ] ] ] } }
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -54.624023, -65.802776 ], [ -52.338867, -66.513260 ], [ -27.993164, -72.996909 ], [ 0.000000, -73.226700 ], [ 1.757812, -73.258376 ], [ 1.757812, -77.584684 ], [ 0.000000, -77.556308 ], [ -33.002930, -76.999935 ], [ -73.498535, -66.513260 ], [ -74.992676, -66.000150 ], [ -75.212402, -65.802776 ], [ -54.624023, -65.802776 ] ] ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -91.757812, -77.004877 ], [ -90.000000, -77.024626 ], [ 0.000000, -78.143526 ], [ 1.757812, -78.161570 ], [ 1.757812, -82.000000 ], [ -91.757812, -82.000000 ], [ -91.757812, -77.004877 ] ] ] } }
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -91.757812, -77.004877 ], [ -90.000000, -77.014755 ], [ 0.000000, -78.143526 ], [ 1.757812, -78.161570 ], [ 1.757812, -82.000000 ], [ -91.757812, -82.000000 ], [ -91.757812, -77.004877 ] ] ] } }
] }
] }
,
{ "type": "FeatureCollection", "properties": { "zoom": 2, "x": 1, "y": 2 }, "features": [
{ "type": "FeatureCollection", "properties": { "layer": "in", "version": 2, "extent": 4096 }, "features": [
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -91.757812, -3.030812 ], [ -90.000000, -8.754795 ], [ -82.001953, -33.008663 ], [ -62.995605, -62.995158 ], [ -52.338867, -66.513260 ], [ -50.075684, -67.204032 ], [ -71.433105, -67.204032 ], [ -73.498535, -66.513260 ], [ -74.992676, -66.000150 ], [ -90.000000, -48.951366 ], [ -91.757812, -46.392411 ], [ -91.757812, -3.030812 ] ] ] } }
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -91.757812, -3.030812 ], [ -89.956055, -8.754795 ], [ -82.001953, -33.008663 ], [ -62.995605, -62.995158 ], [ -52.338867, -66.513260 ], [ -50.075684, -67.204032 ], [ -71.433105, -67.204032 ], [ -73.498535, -66.513260 ], [ -74.992676, -66.000150 ], [ -90.000000, -48.951366 ], [ -91.757812, -46.392411 ], [ -91.757812, -3.030812 ] ] ] } }
] }
] }
,
{ "type": "FeatureCollection", "properties": { "zoom": 2, "x": 1, "y": 0 }, "features": [
{ "type": "FeatureCollection", "properties": { "layer": "in", "version": 2, "extent": 4096 }, "features": [
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -91.757812, 82.588941 ], [ -90.000000, 82.486209 ], [ -82.001953, 82.000000 ], [ -90.000000, 79.125832 ], [ -91.757812, 78.367146 ], [ -91.757812, 82.588941 ] ] ] } }
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -91.757812, 82.588941 ], [ -89.956055, 82.486209 ], [ -82.001953, 82.000000 ], [ -90.000000, 79.125832 ], [ -91.757812, 78.367146 ], [ -91.757812, 82.588941 ] ] ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 1.757812, 82.999490 ], [ 1.757812, 80.000984 ], [ -88.000488, 80.000984 ], [ -90.000000, 79.576460 ], [ -91.757812, 79.187834 ], [ -91.757812, 82.999490 ], [ 1.757812, 82.999490 ] ] ] } }
] }
] }
,
{ "type": "FeatureCollection", "properties": { "zoom": 2, "x": 2, "y": 3 }, "features": [
{ "type": "FeatureCollection", "properties": { "layer": "in", "version": 2, "extent": 4096 }, "features": [
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -1.757812, -73.220358 ], [ 0.000000, -73.239377 ], [ 90.000000, -74.001385 ], [ 91.757812, -74.001385 ], [ 91.757812, -78.983989 ], [ 90.000000, -78.958769 ], [ 0.000000, -77.556308 ], [ -1.757812, -77.527868 ], [ -1.757812, -73.220358 ] ] ] } }
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 91.757812, -78.983989 ], [ 90.000000, -78.958769 ], [ 0.000000, -77.556308 ], [ -1.757812, -77.527868 ], [ -1.757812, -73.220358 ], [ 0.000000, -73.239377 ], [ 90.000000, -74.001385 ], [ 91.757812, -74.001385 ], [ 91.757812, -78.983989 ] ] ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -1.757812, -78.125454 ], [ 0.000000, -78.143526 ], [ 90.000000, -79.167206 ], [ 91.757812, -79.183712 ], [ 91.757812, -82.000000 ], [ -1.757812, -82.000000 ], [ -1.757812, -78.125454 ] ] ] } }
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -1.757812, -78.125454 ], [ 0.000000, -78.134493 ], [ 90.000000, -79.167206 ], [ 91.757812, -79.183712 ], [ 91.757812, -82.000000 ], [ -1.757812, -82.000000 ], [ -1.757812, -78.125454 ] ] ] } }
] }
] }
,
Expand All @@ -120,7 +120,7 @@
{ "type": "FeatureCollection", "properties": { "layer": "in", "version": 2, "extent": 4096 }, "features": [
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 88.242188, -73.989269 ], [ 90.000000, -74.001385 ], [ 144.997559, -74.001385 ], [ 144.997559, -76.999935 ], [ 93.010254, -79.000771 ], [ 90.000000, -78.958769 ], [ 88.242188, -78.929273 ], [ 88.242188, -73.989269 ] ] ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 88.242188, -79.146538 ], [ 90.000000, -79.167206 ], [ 170.002441, -80.000984 ], [ 160.004883, -82.000000 ], [ 88.242188, -82.000000 ], [ 88.242188, -79.146538 ] ] ] } }
{ "type": "Feature", "properties": { }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 88.242188, -79.146538 ], [ 90.000000, -79.167206 ], [ 170.002441, -80.000984 ], [ 160.004883, -82.000000 ], [ 88.242188, -82.000000 ], [ 88.242188, -79.146538 ] ] ], [ [ [ 88.242188, -79.146538 ], [ 90.000000, -79.158943 ], [ 170.002441, -80.000984 ], [ 88.242188, -79.146538 ] ] ] ] } }
] }
] }
,
Expand Down
Loading

0 comments on commit 93c7398

Please sign in to comment.