diff --git a/CHANGELOG.md b/CHANGELOG.md index d0f44aae..03372086 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,7 +44,11 @@ them and not the other, leaving a shard gap or overlap between them. Now the hot pixels of all the polygons in the layer are found first, and each polygon is snapped to the ones near it as well as its own, so shared borders are - snapped identically. For Dane County Census blocks at -D8 -d8 -pt -pn, this + snapped identically. In this mode the hot pixels are treated as half-open, + [x - 0.5, x + 0.5) by [y - 0.5, y + 0.5), as in Hobby's snap rounding, + rather than as closed squares, because edges passing diagonally through + pixel corners otherwise zigzagged through the same pixels in different + orders in different polygons, and could cross each other. For Dane County Census blocks at -D8 -d8 -pt -pn, this reduces the gaps between blocks at z9 and z10 from 55 and 155 pixels to 13 and 23, and the overlaps from 113 and 175 to 56 and 59, and takes about 7% longer for Natural Earth countries at -z8 -pn. diff --git a/mapbox/geometry/wagyu/ring.hpp b/mapbox/geometry/wagyu/ring.hpp index 05fe4cd8..15a9741b 100644 --- a/mapbox/geometry/wagyu/ring.hpp +++ b/mapbox/geometry/wagyu/ring.hpp @@ -162,7 +162,8 @@ struct ring_manager { // The hot pixels that are the rounded locations of intersections, sorted, // which edges must be snapped to even if they only touch their corners hot_pixel_vector intersection_hot_pixels; - // Snap edges to every hot pixel they touch, even ones whose corners they only touch + // Snapping to a common set of hot pixels shared with other geometries: + // treat pixels as half-open, and don't skip any corner touches that remain bool snap_all_corners = false; hot_pixel_itr current_hp_itr; std::deque> points; diff --git a/mapbox/geometry/wagyu/ring_util.hpp b/mapbox/geometry/wagyu/ring_util.hpp index 438952e1..11509375 100644 --- a/mapbox/geometry/wagyu/ring_util.hpp +++ b/mapbox/geometry/wagyu/ring_util.hpp @@ -189,6 +189,55 @@ inline T get_edge_max_x(edge const& edge, const T current_y, bool inward = fa } } +// The range of columns of hot pixels that an edge passes through within a row, +// treating each pixel as half-open, [x - 0.5, x + 0.5) by [y - 0.5, y + 0.5), +// which is consistent with the rounding of intersection points. Unlike the +// closed pixels used by get_edge_min_x and get_edge_max_x, a point on the +// boundary between two pixels belongs to only one of them, so an edge passing +// diagonally through a corner is not snapped to both of the pixels on either +// side of the corner. When several geometries are snapped to a common set of +// hot pixels, snapping to both made edges from different geometries zigzag +// through the same pixels in different orders and cross each other. +template +inline void get_edge_half_open_x_range(edge const& edge, const T current_y, T& x_min, T& x_max) { + if (is_horizontal(edge)) { + x_min = std::min(edge.bot.x, edge.top.x); + x_max = std::max(edge.bot.x, edge.top.x); + return; + } + + // edge.top has the smaller y and edge.bot the larger + double y_lo = static_cast(current_y) - 0.5; + double y_hi = static_cast(current_y) + 0.5; + bool hi_included = false; + if (y_lo < static_cast(edge.top.y)) { + y_lo = static_cast(edge.top.y); + } + if (y_hi >= static_cast(edge.bot.y)) { + y_hi = static_cast(edge.bot.y); + hi_included = true; + } + + double x_lo = static_cast(edge.bot.x) + edge.dx * (y_lo - static_cast(edge.bot.y)); + double x_hi = static_cast(edge.bot.x) + edge.dx * (y_hi - static_cast(edge.bot.y)); + + if (x_lo <= x_hi) { + x_min = static_cast(std::floor(x_lo + 0.5)); + if (hi_included) { + x_max = static_cast(std::floor(x_hi + 0.5)); + } else { + x_max = static_cast(std::ceil(x_hi + 0.5)) - 1; + } + } else { + x_max = static_cast(std::floor(x_lo + 0.5)); + if (hi_included) { + x_min = static_cast(std::floor(x_hi + 0.5)); + } else { + x_min = static_cast(std::floor(x_hi - 0.5)) + 1; + } + } +} + template void hot_pixel_set_left_to_right(T y, T start_x, @@ -207,8 +256,11 @@ void hot_pixel_set_left_to_right(T y, T x_min_inward = get_edge_min_x(*(bnd.current_edge), y, true); T x_max_inward = get_edge_max_x(*(bnd.current_edge), y, true); T x_min = get_edge_min_x(*(bnd.current_edge), y); - x_min = std::max(x_min, start_x); T x_max = get_edge_max_x(*(bnd.current_edge), y); + if (rings.snap_all_corners) { + get_edge_half_open_x_range(*(bnd.current_edge), y, x_min, x_max); + } + x_min = std::max(x_min, start_x); x_max = std::min(x_max, end_x); for (; itr != end; ++itr) { if (itr->x < x_min) { @@ -257,8 +309,11 @@ void hot_pixel_set_right_to_left(T y, T x_min_inward = get_edge_min_x(*(bnd.current_edge), y, true); T x_max_inward = get_edge_max_x(*(bnd.current_edge), y, true); T x_min = get_edge_min_x(*(bnd.current_edge), y); - x_min = std::max(x_min, end_x); T x_max = get_edge_max_x(*(bnd.current_edge), y); + if (rings.snap_all_corners) { + get_edge_half_open_x_range(*(bnd.current_edge), y, x_min, x_max); + } + x_min = std::max(x_min, end_x); x_max = std::min(x_max, start_x); for (; itr != end; ++itr) { if (itr->x > x_max) { diff --git a/tests/ne_110m_admin_0_countries/out/-z1_-yname_--no-simplification-of-shared-nodes.json b/tests/ne_110m_admin_0_countries/out/-z1_-yname_--no-simplification-of-shared-nodes.json index 61687959..0d3f30c9 100644 --- a/tests/ne_110m_admin_0_countries/out/-z1_-yname_--no-simplification-of-shared-nodes.json +++ b/tests/ne_110m_admin_0_countries/out/-z1_-yname_--no-simplification-of-shared-nodes.json @@ -107,7 +107,7 @@ , { "type": "Feature", "properties": { "name": "Paraguay" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -60.029297, -19.311143 ], [ -59.150391, -19.394068 ], [ -58.183594, -19.890723 ], [ -58.183594, -20.138470 ], [ -57.832031, -20.715015 ], [ -57.919922, -22.105999 ], [ -56.865234, -22.268764 ], [ -56.513672, -22.105999 ], [ -55.810547, -22.350076 ], [ -55.634766, -22.674847 ], [ -55.371094, -23.966176 ], [ -55.019531, -23.966176 ], [ -54.667969, -23.805450 ], [ -54.316406, -24.046464 ], [ -54.316406, -24.607069 ], [ -54.667969, -25.720735 ], [ -54.755859, -26.588527 ], [ -55.722656, -27.371767 ], [ -56.513672, -27.527758 ], [ -58.623047, -27.137368 ], [ -57.656250, -25.641526 ], [ -57.744141, -25.165173 ], [ -58.798828, -24.766785 ], [ -60.029297, -24.046464 ], [ -60.820312, -23.885838 ], [ -62.666016, -22.268764 ], [ -62.314453, -21.043491 ], [ -62.226562, -20.550509 ], [ -61.787109, -19.642588 ], [ -60.029297, -19.311143 ] ] ] } } , -{ "type": "Feature", "properties": { "name": "Chile" }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ -69.345703, -52.536273 ], [ -68.642578, -52.643063 ], [ -68.642578, -54.876607 ], [ -66.972656, -54.876607 ], [ -67.324219, -55.279115 ], [ -68.115234, -55.627996 ], [ -68.642578, -55.578345 ], [ -69.257812, -55.478853 ], [ -69.960938, -55.178868 ], [ -71.015625, -55.078367 ], [ -73.300781, -53.956086 ], [ -74.619141, -52.855864 ], [ -73.828125, -53.067627 ], [ -72.421875, -53.696706 ], [ -71.103516, -54.059388 ], [ -70.576172, -53.592505 ], [ -70.224609, -52.908902 ], [ -69.345703, -52.536273 ] ] ], [ [ [ -69.082031, -52.268157 ], [ -69.433594, -52.268157 ], [ -70.839844, -52.908902 ], [ -71.015625, -53.852527 ], [ -71.455078, -53.852527 ], [ -72.597656, -53.540307 ], [ -73.740234, -52.855864 ], [ -74.970703, -52.268157 ], [ -75.234375, -51.618017 ], [ -74.970703, -51.069017 ], [ -75.498047, -50.401515 ], [ -75.585938, -48.690960 ], [ -75.146484, -47.694974 ], [ -74.091797, -46.920255 ], [ -75.673828, -46.619261 ], [ -74.707031, -45.767523 ], [ -74.355469, -44.087585 ], [ -73.212891, -44.465151 ], [ -72.685547, -42.358544 ], [ -73.388672, -42.098222 ], [ -73.740234, -43.389082 ], [ -74.355469, -43.197167 ], [ -73.652344, -39.909736 ], [ -73.212891, -39.232253 ], [ -73.476562, -38.272689 ], [ -73.564453, -37.160317 ], [ -73.125000, -37.090240 ], [ -71.894531, -33.943360 ], [ -71.455078, -32.398516 ], [ -71.630859, -30.902225 ], [ -71.367188, -30.069094 ], [ -71.455078, -28.844674 ], [ -70.927734, -27.605671 ], [ -70.048828, -21.371244 ], [ -70.400391, -18.312811 ], [ -69.873047, -18.062312 ], [ -69.609375, -17.560247 ], [ -69.082031, -18.229351 ], [ -68.994141, -18.979026 ], [ -68.466797, -19.394068 ], [ -68.730469, -20.385825 ], [ -68.203125, -21.534847 ], [ -67.851562, -22.836946 ], [ -67.148438, -22.755921 ], [ -66.972656, -22.998852 ], [ -67.324219, -24.046464 ], [ -68.378906, -24.527135 ], [ -68.378906, -26.194877 ], [ -68.554688, -26.509905 ], [ -68.291016, -26.902477 ], [ -68.994141, -27.527758 ], [ -69.697266, -28.459033 ], [ -70.048828, -29.382175 ], [ -69.960938, -30.372875 ], [ -70.576172, -31.353637 ], [ -70.048828, -33.063924 ], [ -69.785156, -33.284620 ], [ -69.785156, -34.161818 ], [ -70.400391, -35.173808 ], [ -70.400391, -36.031332 ], [ -71.103516, -36.668419 ], [ -71.103516, -37.579413 ], [ -70.839844, -38.548165 ], [ -71.455078, -38.891033 ], [ -71.894531, -40.847060 ], [ -71.718750, -42.032974 ], [ -72.158203, -42.228517 ], [ -71.894531, -43.389082 ], [ -71.455078, -43.771094 ], [ -71.806641, -44.213710 ], [ -71.367188, -44.402392 ], [ -71.191406, -44.777936 ], [ -71.630859, -44.964798 ], [ -71.542969, -45.583290 ], [ -71.894531, -46.860191 ], [ -72.421875, -47.754098 ], [ -72.333984, -48.224673 ], [ -72.685547, -48.864715 ], [ -73.388672, -49.325122 ], [ -73.300781, -50.401515 ], [ -72.949219, -50.736455 ], [ -72.333984, -50.680797 ], [ -72.333984, -51.399206 ], [ -71.894531, -51.998410 ], [ -69.521484, -52.160455 ], [ -69.082031, -52.268157 ] ] ], [ [ [ -69.082031, -52.268157 ], [ -68.554688, -52.321911 ], [ -68.554688, -52.375599 ], [ -69.082031, -52.268157 ] ] ] ] } } +{ "type": "Feature", "properties": { "name": "Chile" }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ -69.345703, -52.536273 ], [ -68.642578, -52.643063 ], [ -68.642578, -54.876607 ], [ -66.972656, -54.876607 ], [ -67.324219, -55.279115 ], [ -68.115234, -55.627996 ], [ -68.642578, -55.578345 ], [ -69.257812, -55.478853 ], [ -69.960938, -55.178868 ], [ -71.015625, -55.078367 ], [ -73.300781, -53.956086 ], [ -74.619141, -52.855864 ], [ -73.828125, -53.067627 ], [ -72.421875, -53.696706 ], [ -71.103516, -54.059388 ], [ -70.576172, -53.592505 ], [ -70.224609, -52.908902 ], [ -69.345703, -52.536273 ] ] ], [ [ [ -69.609375, -17.560247 ], [ -69.082031, -18.229351 ], [ -68.994141, -18.979026 ], [ -68.466797, -19.394068 ], [ -68.730469, -20.385825 ], [ -68.203125, -21.534847 ], [ -67.851562, -22.836946 ], [ -67.148438, -22.755921 ], [ -66.972656, -22.998852 ], [ -67.324219, -24.046464 ], [ -68.378906, -24.527135 ], [ -68.378906, -26.194877 ], [ -68.554688, -26.509905 ], [ -68.291016, -26.902477 ], [ -68.994141, -27.527758 ], [ -69.697266, -28.459033 ], [ -70.048828, -29.382175 ], [ -69.960938, -30.372875 ], [ -70.576172, -31.353637 ], [ -70.048828, -33.063924 ], [ -69.785156, -33.284620 ], [ -69.785156, -34.161818 ], [ -70.400391, -35.173808 ], [ -70.400391, -36.031332 ], [ -71.103516, -36.668419 ], [ -71.103516, -37.579413 ], [ -70.839844, -38.548165 ], [ -71.455078, -38.891033 ], [ -71.894531, -40.847060 ], [ -71.718750, -42.032974 ], [ -72.158203, -42.228517 ], [ -71.894531, -43.389082 ], [ -71.455078, -43.771094 ], [ -71.806641, -44.213710 ], [ -71.367188, -44.402392 ], [ -71.191406, -44.777936 ], [ -71.630859, -44.964798 ], [ -71.542969, -45.583290 ], [ -71.894531, -46.860191 ], [ -72.421875, -47.754098 ], [ -72.333984, -48.224673 ], [ -72.685547, -48.864715 ], [ -73.388672, -49.325122 ], [ -73.300781, -50.401515 ], [ -72.949219, -50.736455 ], [ -72.333984, -50.680797 ], [ -72.333984, -51.399206 ], [ -71.894531, -51.998410 ], [ -69.521484, -52.160455 ], [ -68.554688, -52.321911 ], [ -68.554688, -52.375599 ], [ -69.082031, -52.268157 ], [ -69.433594, -52.268157 ], [ -70.839844, -52.908902 ], [ -71.015625, -53.852527 ], [ -71.455078, -53.852527 ], [ -72.597656, -53.540307 ], [ -73.740234, -52.855864 ], [ -74.970703, -52.268157 ], [ -75.234375, -51.618017 ], [ -74.970703, -51.069017 ], [ -75.498047, -50.401515 ], [ -75.585938, -48.690960 ], [ -75.146484, -47.694974 ], [ -74.091797, -46.920255 ], [ -75.673828, -46.619261 ], [ -74.707031, -45.767523 ], [ -74.355469, -44.087585 ], [ -73.212891, -44.465151 ], [ -72.685547, -42.358544 ], [ -73.388672, -42.098222 ], [ -73.740234, -43.389082 ], [ -74.355469, -43.197167 ], [ -73.652344, -39.909736 ], [ -73.212891, -39.232253 ], [ -73.476562, -38.272689 ], [ -73.564453, -37.160317 ], [ -73.125000, -37.090240 ], [ -71.894531, -33.943360 ], [ -71.455078, -32.398516 ], [ -71.630859, -30.902225 ], [ -71.367188, -30.069094 ], [ -71.455078, -28.844674 ], [ -70.927734, -27.605671 ], [ -70.048828, -21.371244 ], [ -70.400391, -18.312811 ], [ -69.873047, -18.062312 ], [ -69.609375, -17.560247 ] ] ] ] } } , { "type": "Feature", "properties": { "name": "Falkland Is." }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -58.535156, -51.124213 ], [ -57.744141, -51.563412 ], [ -58.007812, -51.890054 ], [ -59.414062, -52.214339 ], [ -59.853516, -51.835778 ], [ -60.732422, -52.321911 ], [ -61.171875, -51.835778 ], [ -60.029297, -51.234407 ], [ -59.150391, -51.508742 ], [ -58.535156, -51.124213 ] ] ] } } , @@ -147,11 +147,11 @@ , { "type": "Feature", "properties": { "name": "Montenegro" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 19.248047, 43.516689 ], [ 19.599609, 43.197167 ], [ 20.302734, 42.875964 ], [ 20.214844, 42.811522 ], [ 20.039062, 42.617791 ], [ 19.775391, 42.488302 ], [ 19.775391, 42.682435 ], [ 19.335938, 42.163403 ], [ 19.335938, 41.902277 ], [ 18.457031, 42.488302 ], [ 18.544922, 42.617791 ], [ 18.720703, 43.197167 ], [ 19.248047, 43.516689 ] ] ] } } , -{ "type": "Feature", "properties": { "name": "Kosovo" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 20.830078, 43.261206 ], [ 21.621094, 42.682435 ], [ 21.796875, 42.682435 ], [ 21.533203, 42.228517 ], [ 20.742188, 42.032974 ], [ 20.742188, 41.836828 ], [ 20.566406, 41.836828 ], [ 20.566406, 42.228517 ], [ 20.039062, 42.617791 ], [ 20.214844, 42.811522 ], [ 20.302734, 42.875964 ], [ 20.478516, 42.875964 ], [ 20.654297, 43.197167 ], [ 20.830078, 43.261206 ] ] ] } } +{ "type": "Feature", "properties": { "name": "Kosovo" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 20.830078, 43.261206 ], [ 21.621094, 42.682435 ], [ 21.796875, 42.682435 ], [ 21.533203, 42.228517 ], [ 20.742188, 42.032974 ], [ 20.742188, 41.836828 ], [ 20.566406, 41.836828 ], [ 20.566406, 42.228517 ], [ 20.039062, 42.617791 ], [ 20.214844, 42.811522 ], [ 20.478516, 42.875964 ], [ 20.654297, 43.197167 ], [ 20.830078, 43.261206 ] ] ] } } , { "type": "Feature", "properties": { "name": "Albania" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 19.775391, 42.682435 ], [ 19.775391, 42.488302 ], [ 20.039062, 42.617791 ], [ 20.566406, 42.228517 ], [ 20.566406, 41.836828 ], [ 20.478516, 41.508577 ], [ 20.566406, 41.112469 ], [ 21.005859, 40.847060 ], [ 21.005859, 40.580585 ], [ 20.654297, 40.446947 ], [ 20.654297, 40.111689 ], [ 20.126953, 39.639538 ], [ 19.951172, 39.707187 ], [ 19.951172, 39.909736 ], [ 19.423828, 40.245992 ], [ 19.335938, 40.713956 ], [ 19.511719, 41.705729 ], [ 19.335938, 42.163403 ], [ 19.775391, 42.682435 ] ] ] } } , -{ "type": "Feature", "properties": { "name": "Serbia" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 20.302734, 42.875964 ], [ 19.599609, 43.197167 ], [ 19.248047, 43.516689 ], [ 19.423828, 43.580391 ], [ 19.599609, 44.024422 ], [ 19.160156, 44.402392 ], [ 19.335938, 44.840291 ], [ 18.984375, 44.840291 ], [ 19.423828, 45.213004 ], [ 19.072266, 45.521744 ], [ 18.808594, 45.890008 ], [ 19.599609, 46.195042 ], [ 20.214844, 46.134170 ], [ 20.742188, 45.706179 ], [ 20.917969, 45.398450 ], [ 21.445312, 45.151053 ], [ 21.533203, 44.777936 ], [ 22.148438, 44.465151 ], [ 22.500000, 44.715514 ], [ 22.675781, 44.590467 ], [ 22.500000, 44.402392 ], [ 22.675781, 44.213710 ], [ 22.412109, 44.024422 ], [ 22.500000, 43.644026 ], [ 23.027344, 43.197167 ], [ 22.587891, 42.875964 ], [ 22.412109, 42.553080 ], [ 22.587891, 42.488302 ], [ 22.412109, 42.293564 ], [ 21.533203, 42.228517 ], [ 21.796875, 42.682435 ], [ 21.621094, 42.682435 ], [ 20.830078, 43.261206 ], [ 20.654297, 43.197167 ], [ 20.478516, 42.875964 ], [ 20.302734, 42.875964 ] ] ] } } +{ "type": "Feature", "properties": { "name": "Serbia" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 19.599609, 46.195042 ], [ 20.214844, 46.134170 ], [ 20.742188, 45.706179 ], [ 20.917969, 45.398450 ], [ 21.445312, 45.151053 ], [ 21.533203, 44.777936 ], [ 22.148438, 44.465151 ], [ 22.500000, 44.715514 ], [ 22.675781, 44.590467 ], [ 22.500000, 44.402392 ], [ 22.675781, 44.213710 ], [ 22.412109, 44.024422 ], [ 22.500000, 43.644026 ], [ 23.027344, 43.197167 ], [ 22.587891, 42.875964 ], [ 22.412109, 42.553080 ], [ 22.587891, 42.488302 ], [ 22.412109, 42.293564 ], [ 21.533203, 42.228517 ], [ 21.796875, 42.682435 ], [ 21.621094, 42.682435 ], [ 20.830078, 43.261206 ], [ 20.654297, 43.197167 ], [ 20.478516, 42.875964 ], [ 20.214844, 42.811522 ], [ 20.302734, 42.875964 ], [ 19.599609, 43.197167 ], [ 19.248047, 43.516689 ], [ 19.423828, 43.580391 ], [ 19.599609, 44.024422 ], [ 19.160156, 44.402392 ], [ 19.335938, 44.840291 ], [ 18.984375, 44.840291 ], [ 19.423828, 45.213004 ], [ 19.072266, 45.521744 ], [ 18.808594, 45.890008 ], [ 19.599609, 46.195042 ] ] ] } } , { "type": "Feature", "properties": { "name": "Latvia" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 25.136719, 57.984808 ], [ 26.455078, 57.468589 ], [ 27.246094, 57.468589 ], [ 27.773438, 57.231503 ], [ 27.861328, 56.752723 ], [ 28.212891, 56.170023 ], [ 26.455078, 55.627996 ], [ 25.576172, 56.121060 ], [ 24.960938, 56.170023 ], [ 24.873047, 56.365250 ], [ 23.906250, 56.267761 ], [ 22.236328, 56.316537 ], [ 21.093750, 56.022948 ], [ 21.093750, 56.800878 ], [ 21.621094, 57.421294 ], [ 22.500000, 57.751076 ], [ 23.291016, 56.992883 ], [ 24.082031, 57.040730 ], [ 24.345703, 57.797944 ], [ 25.136719, 57.984808 ] ] ] } } , @@ -405,7 +405,7 @@ , { "type": "Feature", "properties": { "name": "New Zealand" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -181.977539, -37.579413 ], [ -181.494141, -37.683820 ], [ -181.713867, -38.582526 ], [ -182.021484, -39.164141 ], [ -182.812500, -39.130060 ], [ -183.076172, -39.436193 ], [ -182.988281, -39.876019 ], [ -183.515625, -40.647304 ], [ -183.515625, -37.753344 ], [ -183.251953, -37.892196 ], [ -182.548828, -37.961523 ], [ -181.977539, -37.579413 ] ] ] } } , -{ "type": "Feature", "properties": { "name": "Antarctica" }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ -179.956055, -84.714152 ], [ -179.077148, -84.138452 ], [ -179.033203, -84.138452 ], [ -179.033203, -84.142939 ], [ -177.275391, -84.452865 ], [ -176.088867, -84.097922 ], [ -175.825195, -84.115970 ], [ -174.375000, -84.532994 ], [ -173.100586, -84.115970 ], [ -172.880859, -84.061661 ], [ -169.936523, -83.886366 ], [ -167.036133, -84.570546 ], [ -164.179688, -84.826305 ], [ -162.553711, -85.051129 ], [ -161.938477, -85.137560 ], [ -158.598633, -85.341758 ], [ -157.719727, -85.341758 ], [ -155.170898, -85.100168 ], [ -155.126953, -85.100168 ], [ -150.952148, -85.295131 ], [ -150.600586, -85.341758 ], [ -146.118164, -85.341758 ], [ -143.217773, -85.051129 ], [ -143.085938, -85.039743 ], [ -142.910156, -84.570546 ], [ -146.821289, -84.532994 ], [ -150.073242, -84.297818 ], [ -150.908203, -83.905058 ], [ -153.588867, -83.686615 ], [ -153.413086, -83.236426 ], [ -152.666016, -82.454537 ], [ -152.841797, -82.039656 ], [ -154.511719, -81.767353 ], [ -155.302734, -81.413933 ], [ -156.840820, -81.100015 ], [ -154.423828, -81.160996 ], [ -152.094727, -81.004326 ], [ -150.644531, -81.334844 ], [ -148.886719, -81.045460 ], [ -147.216797, -80.668436 ], [ -146.425781, -80.334887 ], [ -146.777344, -79.928236 ], [ -148.051758, -79.655668 ], [ -149.545898, -79.359590 ], [ -151.567383, -79.302640 ], [ -153.369141, -79.163075 ], [ -155.346680, -79.063478 ], [ -155.961914, -78.690491 ], [ -157.280273, -78.376004 ], [ -158.071289, -78.025574 ], [ -158.378906, -76.890745 ], [ -157.895508, -76.990046 ], [ -156.972656, -77.302864 ], [ -155.346680, -77.205912 ], [ -153.764648, -77.068954 ], [ -152.929688, -77.494607 ], [ -151.347656, -77.399095 ], [ -149.985352, -77.186434 ], [ -148.754883, -76.910665 ], [ -147.612305, -76.578159 ], [ -146.118164, -76.475773 ], [ -146.162109, -76.100796 ], [ -146.513672, -75.737303 ], [ -146.206055, -75.375605 ], [ -144.887695, -75.208245 ], [ -144.316406, -75.541113 ], [ -142.778320, -75.342282 ], [ -141.635742, -75.084326 ], [ -140.229492, -75.061686 ], [ -138.867188, -74.970791 ], [ -135.219727, -74.307353 ], [ -134.428711, -74.366675 ], [ -133.725586, -74.437572 ], [ -132.275391, -74.307353 ], [ -130.913086, -74.484662 ], [ -129.550781, -74.461134 ], [ -128.232422, -74.319235 ], [ -125.419922, -74.519889 ], [ -124.013672, -74.484662 ], [ -121.069336, -74.519889 ], [ -119.707031, -74.484662 ], [ -118.696289, -74.188052 ], [ -117.465820, -74.031637 ], [ -116.235352, -74.247813 ], [ -115.004883, -74.067866 ], [ -113.950195, -73.714276 ], [ -113.291016, -74.031637 ], [ -112.939453, -74.378513 ], [ -112.280273, -74.718037 ], [ -111.269531, -74.425777 ], [ -110.083008, -74.787379 ], [ -108.720703, -74.913708 ], [ -107.578125, -75.185789 ], [ -106.127930, -75.129504 ], [ -104.897461, -74.947983 ], [ -103.359375, -74.993566 ], [ -101.997070, -75.129504 ], [ -100.634766, -75.297735 ], [ -100.107422, -74.867889 ], [ -100.766602, -74.543330 ], [ -101.250000, -74.188052 ], [ -102.524414, -74.104015 ], [ -103.095703, -73.738905 ], [ -103.666992, -72.620252 ], [ -102.919922, -72.751039 ], [ -101.601562, -72.816074 ], [ -100.327148, -72.751039 ], [ -99.140625, -72.906723 ], [ -98.129883, -73.201317 ], [ -97.690430, -73.553302 ], [ -96.328125, -73.615397 ], [ -95.053711, -73.478485 ], [ -93.691406, -73.289993 ], [ -92.460938, -73.163173 ], [ -91.406250, -73.403338 ], [ -90.087891, -73.327858 ], [ -89.208984, -72.554498 ], [ -88.417969, -73.009755 ], [ -87.275391, -73.188612 ], [ -86.000977, -73.086633 ], [ -85.209961, -73.478485 ], [ -83.891602, -73.515935 ], [ -82.661133, -73.640171 ], [ -81.474609, -73.849286 ], [ -80.683594, -73.478485 ], [ -80.288086, -73.124945 ], [ -79.277344, -73.515935 ], [ -77.915039, -73.415885 ], [ -76.904297, -73.640171 ], [ -76.201172, -73.971078 ], [ -74.882812, -73.873717 ], [ -73.872070, -73.652545 ], [ -72.817383, -73.403338 ], [ -71.630859, -73.264704 ], [ -70.224609, -73.150440 ], [ -68.950195, -73.009755 ], [ -67.939453, -72.790088 ], [ -67.368164, -72.475276 ], [ -67.148438, -72.046840 ], [ -67.236328, -71.635993 ], [ -68.466797, -70.110485 ], [ -68.554688, -69.718107 ], [ -68.466797, -69.318320 ], [ -67.983398, -68.958391 ], [ -67.587891, -68.544315 ], [ -67.412109, -68.155209 ], [ -67.719727, -67.322924 ], [ -67.236328, -66.878345 ], [ -66.049805, -66.213739 ], [ -65.390625, -65.892680 ], [ -64.555664, -65.603878 ], [ -64.160156, -65.164579 ], [ -63.632812, -64.904910 ], [ -63.017578, -64.642704 ], [ -62.050781, -64.586185 ], [ -61.435547, -64.263684 ], [ -60.688477, -64.072200 ], [ -59.897461, -63.956673 ], [ -59.150391, -63.704722 ], [ -58.579102, -63.391522 ], [ -57.832031, -63.273182 ], [ -57.216797, -63.528971 ], [ -57.612305, -63.860036 ], [ -58.623047, -64.148952 ], [ -59.062500, -64.358931 ], [ -59.809570, -64.206377 ], [ -60.600586, -64.301822 ], [ -62.006836, -64.792848 ], [ -62.490234, -65.090646 ], [ -62.666016, -65.476508 ], [ -62.578125, -65.856756 ], [ -62.138672, -66.196009 ], [ -62.797852, -66.425537 ], [ -63.764648, -66.495740 ], [ -64.863281, -67.152898 ], [ -65.522461, -67.575717 ], [ -65.654297, -67.958148 ], [ -65.302734, -68.366801 ], [ -64.775391, -68.672544 ], [ -63.940430, -68.911005 ], [ -63.193359, -69.224997 ], [ -62.797852, -69.626510 ], [ -62.270508, -70.377854 ], [ -61.787109, -70.714471 ], [ -61.523438, -71.088305 ], [ -61.391602, -72.006158 ], [ -61.083984, -72.382410 ], [ -60.996094, -72.777081 ], [ -60.688477, -73.163173 ], [ -60.820312, -73.689611 ], [ -61.391602, -74.104015 ], [ -61.962891, -74.437572 ], [ -63.281250, -74.578426 ], [ -63.764648, -74.925142 ], [ -64.335938, -75.264239 ], [ -65.874023, -75.639536 ], [ -67.192383, -75.791336 ], [ -69.785156, -76.226907 ], [ -70.620117, -76.639226 ], [ -72.202148, -76.669656 ], [ -73.959961, -76.639226 ], [ -75.541992, -76.710125 ], [ -77.255859, -76.710125 ], [ -76.948242, -77.108231 ], [ -75.410156, -77.283532 ], [ -74.267578, -77.551572 ], [ -73.652344, -77.906466 ], [ -74.750977, -78.224513 ], [ -76.508789, -78.125454 ], [ -77.915039, -78.376004 ], [ -78.002930, -79.179588 ], [ -76.860352, -79.512662 ], [ -76.640625, -79.889737 ], [ -75.366211, -80.260828 ], [ -73.256836, -80.415707 ], [ -71.455078, -80.689789 ], [ -70.004883, -81.004326 ], [ -68.203125, -81.314959 ], [ -65.698242, -81.472780 ], [ -63.237305, -81.748454 ], [ -61.567383, -82.039656 ], [ -59.677734, -82.373317 ], [ -58.710938, -82.847913 ], [ -58.227539, -83.220882 ], [ -56.997070, -82.864308 ], [ -53.613281, -82.255779 ], [ -51.547852, -82.003058 ], [ -49.746094, -81.729511 ], [ -47.285156, -81.710526 ], [ -44.824219, -81.848756 ], [ -42.802734, -82.082145 ], [ -42.143555, -81.653308 ], [ -40.781250, -81.354684 ], [ -38.232422, -81.334844 ], [ -34.365234, -80.907616 ], [ -32.299805, -80.767668 ], [ -30.102539, -80.589727 ], [ -28.564453, -80.334887 ], [ -29.267578, -79.981891 ], [ -29.707031, -79.631968 ], [ -29.707031, -79.261777 ], [ -31.640625, -79.302640 ], [ -33.662109, -79.456522 ], [ -35.639648, -79.456522 ], [ -35.903320, -79.080140 ], [ -35.771484, -78.340533 ], [ -35.332031, -78.125454 ], [ -33.881836, -77.888038 ], [ -32.211914, -77.655346 ], [ -29.794922, -77.068954 ], [ -28.872070, -76.669656 ], [ -27.509766, -76.496311 ], [ -25.488281, -76.279122 ], [ -23.906250, -76.237366 ], [ -22.456055, -76.100796 ], [ -21.225586, -75.909504 ], [ -19.995117, -75.672197 ], [ -17.534180, -75.129504 ], [ -16.655273, -74.787379 ], [ -15.688477, -74.496413 ], [ -15.424805, -74.104015 ], [ -16.479492, -73.873717 ], [ -16.127930, -73.465984 ], [ -15.468750, -73.150440 ], [ -13.315430, -72.711903 ], [ -12.304688, -72.395706 ], [ -11.513672, -72.006158 ], [ -11.030273, -71.538830 ], [ -10.283203, -71.258480 ], [ -9.096680, -71.328950 ], [ -8.613281, -71.663663 ], [ -7.426758, -71.691293 ], [ -7.382812, -71.328950 ], [ -6.855469, -70.931004 ], [ -5.800781, -71.031249 ], [ -5.537109, -71.399165 ], [ -4.350586, -71.455153 ], [ -3.032227, -71.286699 ], [ -1.801758, -71.173578 ], [ -0.659180, -71.230221 ], [ -0.219727, -71.635993 ], [ 0.000000, -71.566641 ], [ 0.878906, -71.300793 ], [ 1.889648, -71.130988 ], [ 3.515625, -70.931004 ], [ 3.515625, -85.345325 ], [ -146.162109, -85.345325 ], [ -150.556641, -85.345325 ], [ -157.763672, -85.345325 ], [ -158.554688, -85.345325 ], [ -158.598633, -85.345325 ], [ -180.000000, -85.345325 ], [ -183.515625, -85.345325 ], [ -183.515625, -84.227529 ], [ -181.713867, -84.474065 ], [ -180.000000, -84.714152 ], [ -179.956055, -84.714152 ] ] ], [ [ [ -163.125000, -78.224513 ], [ -161.235352, -78.376004 ], [ -160.224609, -78.690491 ], [ -159.477539, -79.046790 ], [ -159.213867, -79.496652 ], [ -161.147461, -79.631968 ], [ -162.421875, -79.278140 ], [ -163.037109, -78.929273 ], [ -163.081055, -78.870048 ], [ -163.696289, -78.595299 ], [ -163.125000, -78.224513 ] ] ], [ [ [ -122.387695, -73.327858 ], [ -121.201172, -73.503461 ], [ -119.926758, -73.652545 ], [ -118.740234, -73.478485 ], [ -119.311523, -73.837058 ], [ -120.234375, -74.091974 ], [ -121.640625, -74.007440 ], [ -122.607422, -73.652545 ], [ -122.387695, -73.327858 ] ] ], [ [ [ -126.562500, -73.252045 ], [ -124.013672, -73.873717 ], [ -125.903320, -73.738905 ], [ -127.265625, -73.465984 ], [ -126.562500, -73.252045 ] ] ], [ [ [ -101.689453, -71.718882 ], [ -100.415039, -71.856229 ], [ -98.964844, -71.938158 ], [ -97.866211, -72.073911 ], [ -96.767578, -71.951778 ], [ -96.196289, -72.514931 ], [ -96.987305, -72.448792 ], [ -98.217773, -72.488504 ], [ -99.448242, -72.448792 ], [ -100.766602, -72.501722 ], [ -101.821289, -72.302431 ], [ -102.348633, -71.897238 ], [ -101.689453, -71.718882 ] ] ], [ [ [ -70.268555, -68.879358 ], [ -69.741211, -69.256149 ], [ -69.477539, -69.626510 ], [ -68.730469, -70.510241 ], [ -68.466797, -70.959697 ], [ -68.334961, -71.413177 ], [ -68.510742, -71.801410 ], [ -68.774414, -72.168351 ], [ -69.960938, -72.302431 ], [ -71.059570, -72.501722 ], [ -72.377930, -72.488504 ], [ -71.894531, -72.087432 ], [ -74.179688, -72.369105 ], [ -74.970703, -72.073911 ], [ -75.014648, -71.663663 ], [ -73.916016, -71.272595 ], [ -73.212891, -71.145195 ], [ -72.070312, -71.187754 ], [ -71.762695, -70.685421 ], [ -71.718750, -70.303933 ], [ -71.762695, -69.503765 ], [ -71.191406, -69.037142 ], [ -70.268555, -68.879358 ] ] ], [ [ [ -46.669922, -77.832589 ], [ -45.175781, -78.043795 ], [ -43.901367, -78.481780 ], [ -43.505859, -79.088462 ], [ -43.374023, -79.512662 ], [ -43.330078, -80.027655 ], [ -44.868164, -80.342262 ], [ -46.494141, -80.596909 ], [ -48.383789, -80.830907 ], [ -50.493164, -81.024916 ], [ -52.866211, -80.969904 ], [ -54.184570, -80.632740 ], [ -54.008789, -80.223588 ], [ -51.855469, -79.951265 ], [ -50.976562, -79.616138 ], [ -49.921875, -78.810511 ], [ -48.647461, -78.043795 ], [ -48.164062, -78.043795 ], [ -46.669922, -77.832589 ] ] ], [ [ [ -60.600586, -79.631968 ], [ -59.589844, -80.042864 ], [ -60.161133, -80.997452 ], [ -62.270508, -80.865854 ], [ -64.467773, -80.921494 ], [ -65.742188, -80.589727 ], [ -65.742188, -80.546518 ], [ -66.269531, -80.253391 ], [ -64.028320, -80.297927 ], [ -61.875000, -80.393732 ], [ -61.127930, -79.981891 ], [ -60.600586, -79.631968 ] ] ] ] } } +{ "type": "Feature", "properties": { "name": "Antarctica" }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ -179.956055, -84.714152 ], [ -179.077148, -84.138452 ], [ -179.033203, -84.138452 ], [ -179.033203, -84.142939 ], [ -177.275391, -84.452865 ], [ -176.088867, -84.097922 ], [ -175.825195, -84.115970 ], [ -174.375000, -84.532994 ], [ -173.100586, -84.115970 ], [ -172.880859, -84.061661 ], [ -169.936523, -83.886366 ], [ -167.036133, -84.570546 ], [ -164.179688, -84.826305 ], [ -162.553711, -85.051129 ], [ -161.938477, -85.137560 ], [ -158.598633, -85.341758 ], [ -157.719727, -85.341758 ], [ -155.170898, -85.100168 ], [ -155.126953, -85.100168 ], [ -150.952148, -85.295131 ], [ -150.600586, -85.341758 ], [ -146.118164, -85.341758 ], [ -143.217773, -85.051129 ], [ -143.085938, -85.039743 ], [ -142.910156, -84.570546 ], [ -146.821289, -84.532994 ], [ -150.073242, -84.297818 ], [ -150.908203, -83.905058 ], [ -153.588867, -83.686615 ], [ -153.413086, -83.236426 ], [ -152.666016, -82.454537 ], [ -152.841797, -82.039656 ], [ -154.511719, -81.767353 ], [ -155.302734, -81.413933 ], [ -156.840820, -81.100015 ], [ -154.423828, -81.160996 ], [ -152.094727, -81.004326 ], [ -150.644531, -81.334844 ], [ -148.886719, -81.045460 ], [ -147.216797, -80.668436 ], [ -146.425781, -80.334887 ], [ -146.777344, -79.928236 ], [ -148.051758, -79.655668 ], [ -149.545898, -79.359590 ], [ -151.567383, -79.302640 ], [ -153.369141, -79.163075 ], [ -155.346680, -79.063478 ], [ -155.961914, -78.690491 ], [ -157.280273, -78.376004 ], [ -158.071289, -78.025574 ], [ -158.378906, -76.890745 ], [ -157.895508, -76.990046 ], [ -156.972656, -77.302864 ], [ -155.346680, -77.205912 ], [ -153.764648, -77.068954 ], [ -152.929688, -77.494607 ], [ -151.347656, -77.399095 ], [ -149.985352, -77.186434 ], [ -148.754883, -76.910665 ], [ -147.612305, -76.578159 ], [ -146.118164, -76.475773 ], [ -146.162109, -76.100796 ], [ -146.513672, -75.737303 ], [ -146.206055, -75.375605 ], [ -144.887695, -75.208245 ], [ -144.316406, -75.541113 ], [ -142.778320, -75.342282 ], [ -141.635742, -75.084326 ], [ -140.229492, -75.061686 ], [ -138.867188, -74.970791 ], [ -135.219727, -74.307353 ], [ -134.428711, -74.366675 ], [ -133.725586, -74.437572 ], [ -132.275391, -74.307353 ], [ -130.913086, -74.484662 ], [ -129.550781, -74.461134 ], [ -128.232422, -74.319235 ], [ -125.419922, -74.519889 ], [ -124.013672, -74.484662 ], [ -121.069336, -74.519889 ], [ -119.707031, -74.484662 ], [ -118.696289, -74.188052 ], [ -117.465820, -74.031637 ], [ -116.235352, -74.247813 ], [ -115.004883, -74.067866 ], [ -113.950195, -73.714276 ], [ -113.291016, -74.031637 ], [ -112.939453, -74.378513 ], [ -112.280273, -74.718037 ], [ -111.269531, -74.425777 ], [ -110.083008, -74.787379 ], [ -108.720703, -74.913708 ], [ -107.578125, -75.185789 ], [ -106.127930, -75.129504 ], [ -104.897461, -74.947983 ], [ -103.359375, -74.993566 ], [ -101.997070, -75.129504 ], [ -100.634766, -75.297735 ], [ -100.107422, -74.867889 ], [ -100.766602, -74.543330 ], [ -101.250000, -74.188052 ], [ -102.524414, -74.104015 ], [ -103.095703, -73.738905 ], [ -103.666992, -72.620252 ], [ -102.919922, -72.751039 ], [ -101.601562, -72.816074 ], [ -100.327148, -72.751039 ], [ -99.140625, -72.906723 ], [ -98.129883, -73.201317 ], [ -97.690430, -73.553302 ], [ -96.328125, -73.615397 ], [ -95.053711, -73.478485 ], [ -93.691406, -73.289993 ], [ -92.460938, -73.163173 ], [ -91.406250, -73.403338 ], [ -90.087891, -73.327858 ], [ -89.208984, -72.554498 ], [ -88.417969, -73.009755 ], [ -87.275391, -73.188612 ], [ -86.000977, -73.086633 ], [ -85.209961, -73.478485 ], [ -83.891602, -73.515935 ], [ -82.661133, -73.640171 ], [ -81.474609, -73.849286 ], [ -80.683594, -73.478485 ], [ -80.288086, -73.124945 ], [ -79.277344, -73.515935 ], [ -77.915039, -73.415885 ], [ -76.904297, -73.640171 ], [ -76.201172, -73.971078 ], [ -74.882812, -73.873717 ], [ -73.872070, -73.652545 ], [ -72.817383, -73.403338 ], [ -71.630859, -73.264704 ], [ -70.224609, -73.150440 ], [ -68.950195, -73.009755 ], [ -67.939453, -72.790088 ], [ -67.368164, -72.475276 ], [ -67.148438, -72.046840 ], [ -67.236328, -71.635993 ], [ -68.466797, -70.110485 ], [ -68.554688, -69.718107 ], [ -68.466797, -69.318320 ], [ -67.983398, -68.958391 ], [ -67.587891, -68.544315 ], [ -67.412109, -68.155209 ], [ -67.719727, -67.322924 ], [ -67.236328, -66.878345 ], [ -66.049805, -66.213739 ], [ -65.390625, -65.892680 ], [ -64.555664, -65.603878 ], [ -64.160156, -65.164579 ], [ -63.632812, -64.904910 ], [ -63.017578, -64.642704 ], [ -62.050781, -64.586185 ], [ -61.435547, -64.263684 ], [ -60.688477, -64.072200 ], [ -59.897461, -63.956673 ], [ -59.150391, -63.704722 ], [ -58.579102, -63.391522 ], [ -57.832031, -63.273182 ], [ -57.216797, -63.528971 ], [ -57.612305, -63.860036 ], [ -58.623047, -64.148952 ], [ -59.062500, -64.358931 ], [ -59.809570, -64.206377 ], [ -60.600586, -64.301822 ], [ -62.006836, -64.792848 ], [ -62.490234, -65.090646 ], [ -62.666016, -65.476508 ], [ -62.578125, -65.856756 ], [ -62.138672, -66.196009 ], [ -62.797852, -66.425537 ], [ -63.764648, -66.495740 ], [ -64.863281, -67.152898 ], [ -65.522461, -67.575717 ], [ -65.654297, -67.958148 ], [ -65.302734, -68.366801 ], [ -64.775391, -68.672544 ], [ -63.940430, -68.911005 ], [ -63.193359, -69.224997 ], [ -62.797852, -69.626510 ], [ -62.270508, -70.377854 ], [ -61.787109, -70.714471 ], [ -61.523438, -71.088305 ], [ -61.391602, -72.006158 ], [ -61.083984, -72.382410 ], [ -60.996094, -72.777081 ], [ -60.688477, -73.163173 ], [ -60.820312, -73.689611 ], [ -61.391602, -74.104015 ], [ -61.962891, -74.437572 ], [ -63.281250, -74.578426 ], [ -63.764648, -74.925142 ], [ -64.335938, -75.264239 ], [ -65.874023, -75.639536 ], [ -67.192383, -75.791336 ], [ -69.785156, -76.226907 ], [ -70.620117, -76.639226 ], [ -72.202148, -76.669656 ], [ -73.959961, -76.639226 ], [ -75.541992, -76.710125 ], [ -77.255859, -76.710125 ], [ -76.948242, -77.108231 ], [ -75.410156, -77.283532 ], [ -74.267578, -77.551572 ], [ -73.652344, -77.906466 ], [ -74.750977, -78.224513 ], [ -76.508789, -78.125454 ], [ -77.915039, -78.376004 ], [ -78.002930, -79.179588 ], [ -76.860352, -79.512662 ], [ -76.640625, -79.889737 ], [ -75.366211, -80.260828 ], [ -73.256836, -80.415707 ], [ -71.455078, -80.689789 ], [ -70.004883, -81.004326 ], [ -68.203125, -81.314959 ], [ -65.698242, -81.472780 ], [ -63.237305, -81.748454 ], [ -61.567383, -82.039656 ], [ -59.677734, -82.373317 ], [ -58.710938, -82.847913 ], [ -58.227539, -83.220882 ], [ -56.997070, -82.864308 ], [ -53.613281, -82.255779 ], [ -51.547852, -82.003058 ], [ -49.746094, -81.729511 ], [ -47.285156, -81.710526 ], [ -44.824219, -81.848756 ], [ -42.802734, -82.082145 ], [ -42.143555, -81.653308 ], [ -40.781250, -81.354684 ], [ -38.232422, -81.334844 ], [ -34.365234, -80.907616 ], [ -32.299805, -80.767668 ], [ -30.102539, -80.589727 ], [ -28.564453, -80.334887 ], [ -29.267578, -79.981891 ], [ -29.707031, -79.631968 ], [ -29.707031, -79.261777 ], [ -31.640625, -79.302640 ], [ -33.662109, -79.456522 ], [ -35.639648, -79.456522 ], [ -35.903320, -79.080140 ], [ -35.771484, -78.340533 ], [ -35.332031, -78.125454 ], [ -33.881836, -77.888038 ], [ -32.211914, -77.655346 ], [ -29.794922, -77.068954 ], [ -28.872070, -76.669656 ], [ -27.509766, -76.496311 ], [ -25.488281, -76.279122 ], [ -23.906250, -76.237366 ], [ -22.456055, -76.100796 ], [ -21.225586, -75.909504 ], [ -19.995117, -75.672197 ], [ -17.534180, -75.129504 ], [ -16.655273, -74.787379 ], [ -15.688477, -74.496413 ], [ -15.424805, -74.104015 ], [ -16.479492, -73.873717 ], [ -16.127930, -73.465984 ], [ -15.468750, -73.150440 ], [ -13.315430, -72.711903 ], [ -12.304688, -72.395706 ], [ -11.513672, -72.006158 ], [ -11.030273, -71.538830 ], [ -10.283203, -71.258480 ], [ -9.096680, -71.328950 ], [ -8.613281, -71.663663 ], [ -7.426758, -71.691293 ], [ -7.382812, -71.328950 ], [ -6.855469, -70.931004 ], [ -5.800781, -71.031249 ], [ -5.537109, -71.399165 ], [ -4.350586, -71.455153 ], [ -3.032227, -71.286699 ], [ -1.801758, -71.173578 ], [ -0.659180, -71.230221 ], [ -0.219727, -71.635993 ], [ 0.000000, -71.566641 ], [ 0.878906, -71.300793 ], [ 1.889648, -71.130988 ], [ 3.515625, -70.931004 ], [ 3.515625, -85.345325 ], [ -146.162109, -85.345325 ], [ -150.556641, -85.345325 ], [ -157.763672, -85.345325 ], [ -158.554688, -85.345325 ], [ -158.554688, -85.348890 ], [ -158.598633, -85.345325 ], [ -180.000000, -85.345325 ], [ -183.515625, -85.345325 ], [ -183.515625, -84.227529 ], [ -181.713867, -84.474065 ], [ -180.000000, -84.714152 ], [ -179.956055, -84.714152 ] ] ], [ [ [ -163.125000, -78.224513 ], [ -161.235352, -78.376004 ], [ -160.224609, -78.690491 ], [ -159.477539, -79.046790 ], [ -159.213867, -79.496652 ], [ -161.147461, -79.631968 ], [ -162.421875, -79.278140 ], [ -163.037109, -78.929273 ], [ -163.081055, -78.870048 ], [ -163.696289, -78.595299 ], [ -163.125000, -78.224513 ] ] ], [ [ [ -122.387695, -73.327858 ], [ -121.201172, -73.503461 ], [ -119.926758, -73.652545 ], [ -118.740234, -73.478485 ], [ -119.311523, -73.837058 ], [ -120.234375, -74.091974 ], [ -121.640625, -74.007440 ], [ -122.607422, -73.652545 ], [ -122.387695, -73.327858 ] ] ], [ [ [ -126.562500, -73.252045 ], [ -124.013672, -73.873717 ], [ -125.903320, -73.738905 ], [ -127.265625, -73.465984 ], [ -126.562500, -73.252045 ] ] ], [ [ [ -101.689453, -71.718882 ], [ -100.415039, -71.856229 ], [ -98.964844, -71.938158 ], [ -97.866211, -72.073911 ], [ -96.767578, -71.951778 ], [ -96.196289, -72.514931 ], [ -96.987305, -72.448792 ], [ -98.217773, -72.488504 ], [ -99.448242, -72.448792 ], [ -100.766602, -72.501722 ], [ -101.821289, -72.302431 ], [ -102.348633, -71.897238 ], [ -101.689453, -71.718882 ] ] ], [ [ [ -70.268555, -68.879358 ], [ -69.741211, -69.256149 ], [ -69.477539, -69.626510 ], [ -68.730469, -70.510241 ], [ -68.466797, -70.959697 ], [ -68.334961, -71.413177 ], [ -68.510742, -71.801410 ], [ -68.774414, -72.168351 ], [ -69.960938, -72.302431 ], [ -71.059570, -72.501722 ], [ -72.377930, -72.488504 ], [ -71.894531, -72.087432 ], [ -74.179688, -72.369105 ], [ -74.970703, -72.073911 ], [ -75.014648, -71.663663 ], [ -73.916016, -71.272595 ], [ -73.212891, -71.145195 ], [ -72.070312, -71.187754 ], [ -71.762695, -70.685421 ], [ -71.718750, -70.303933 ], [ -71.762695, -69.503765 ], [ -71.191406, -69.037142 ], [ -70.268555, -68.879358 ] ] ], [ [ [ -46.669922, -77.832589 ], [ -45.175781, -78.043795 ], [ -43.901367, -78.481780 ], [ -43.505859, -79.088462 ], [ -43.374023, -79.512662 ], [ -43.330078, -80.027655 ], [ -44.868164, -80.342262 ], [ -46.494141, -80.596909 ], [ -48.383789, -80.830907 ], [ -50.493164, -81.024916 ], [ -52.866211, -80.969904 ], [ -54.184570, -80.632740 ], [ -54.008789, -80.223588 ], [ -51.855469, -79.951265 ], [ -50.976562, -79.616138 ], [ -49.921875, -78.810511 ], [ -48.647461, -78.043795 ], [ -48.164062, -78.043795 ], [ -46.669922, -77.832589 ] ] ], [ [ [ -60.600586, -79.631968 ], [ -59.589844, -80.042864 ], [ -60.161133, -80.997452 ], [ -62.270508, -80.865854 ], [ -64.467773, -80.921494 ], [ -65.742188, -80.589727 ], [ -65.742188, -80.546518 ], [ -66.269531, -80.253391 ], [ -64.028320, -80.297927 ], [ -61.875000, -80.393732 ], [ -61.127930, -79.981891 ], [ -60.600586, -79.631968 ] ] ] ] } } ] } ] } , diff --git a/tests/spindle-shared/out/-z7_-pn.json b/tests/spindle-shared/out/-z7_-pn.json index a848e1ba..f67a00dc 100644 --- a/tests/spindle-shared/out/-z7_-pn.json +++ b/tests/spindle-shared/out/-z7_-pn.json @@ -21,7 +21,7 @@ , { "type": "Feature", "properties": { "name": "A" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -99.492188, 39.977120 ], [ -100.019531, 39.977120 ], [ -100.019531, 40.044438 ], [ -99.931641, 40.044438 ], [ -99.755859, 40.044438 ], [ -99.492188, 39.977120 ] ] ] } } , -{ "type": "Feature", "properties": { "name": "B" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -99.755859, 40.044438 ], [ -99.492188, 39.977120 ], [ -99.316406, 39.977120 ], [ -99.316406, 39.909736 ], [ -100.019531, 39.909736 ], [ -100.019531, 39.977120 ], [ -100.019531, 40.044438 ], [ -99.931641, 40.044438 ], [ -99.755859, 40.044438 ] ] ] } } +{ "type": "Feature", "properties": { "name": "B" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -99.755859, 40.044438 ], [ -99.492188, 39.977120 ], [ -99.316406, 39.977120 ], [ -99.316406, 39.909736 ], [ -100.019531, 39.909736 ], [ -100.019531, 39.977120 ], [ -99.931641, 40.044438 ], [ -99.755859, 40.044438 ] ] ] } } ] } ] } , @@ -91,11 +91,11 @@ , { "type": "Feature", "properties": { "name": "R" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -99.448242, 39.749434 ], [ -99.420776, 39.740986 ], [ -99.385071, 39.743098 ], [ -99.354858, 39.728313 ], [ -99.319153, 39.726201 ], [ -99.297180, 39.717751 ], [ -99.297180, 39.713525 ], [ -99.319153, 39.721976 ], [ -99.354858, 39.724089 ], [ -99.385071, 39.738874 ], [ -99.420776, 39.736762 ], [ -99.448242, 39.745210 ], [ -99.489441, 39.728313 ], [ -99.519653, 39.728313 ], [ -99.555359, 39.713525 ], [ -99.582825, 39.719863 ], [ -99.618530, 39.715638 ], [ -99.654236, 39.732538 ], [ -99.684448, 39.732538 ], [ -99.717407, 39.745210 ], [ -99.753113, 39.734650 ], [ -99.783325, 39.736762 ], [ -99.819031, 39.719863 ], [ -99.854736, 39.719863 ], [ -99.882202, 39.711413 ], [ -99.917908, 39.724089 ], [ -99.953613, 39.726201 ], [ -99.981079, 39.740986 ], [ -100.000305, 39.740986 ], [ -100.000305, 39.745210 ], [ -99.981079, 39.745210 ], [ -99.953613, 39.730426 ], [ -99.917908, 39.728313 ], [ -99.882202, 39.715638 ], [ -99.854736, 39.724089 ], [ -99.819031, 39.724089 ], [ -99.783325, 39.740986 ], [ -99.753113, 39.738874 ], [ -99.717407, 39.749434 ], [ -99.684448, 39.736762 ], [ -99.654236, 39.736762 ], [ -99.618530, 39.719863 ], [ -99.582825, 39.724089 ], [ -99.555359, 39.717751 ], [ -99.519653, 39.732538 ], [ -99.489441, 39.732538 ], [ -99.448242, 39.749434 ] ] ] } } , -{ "type": "Feature", "properties": { "name": "P" }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ -99.717407, 40.000268 ], [ -99.747620, 39.985538 ], [ -99.753113, 39.985538 ], [ -99.717407, 40.000268 ] ] ], [ [ [ -99.783325, 39.989747 ], [ -99.813538, 39.985538 ], [ -99.819031, 39.987643 ], [ -99.783325, 39.989747 ] ] ], [ [ [ -99.582825, 40.010787 ], [ -99.555359, 39.996060 ], [ -99.519653, 39.993956 ], [ -99.555359, 39.993956 ], [ -99.582825, 40.010787 ] ] ] ] } } +{ "type": "Feature", "properties": { "name": "P" }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ -99.717407, 40.000268 ], [ -99.747620, 39.985538 ], [ -99.753113, 39.985538 ], [ -99.717407, 40.000268 ] ] ], [ [ [ -99.783325, 39.989747 ], [ -99.813538, 39.985538 ], [ -99.819031, 39.987643 ], [ -99.783325, 39.989747 ] ] ], [ [ [ -99.851990, 40.002372 ], [ -99.846497, 40.002372 ], [ -99.824524, 39.989747 ], [ -99.851990, 40.002372 ] ] ], [ [ [ -99.582825, 40.010787 ], [ -99.555359, 39.996060 ], [ -99.519653, 39.993956 ], [ -99.555359, 39.993956 ], [ -99.582825, 40.010787 ] ] ] ] } } , { "type": "Feature", "properties": { "name": "A" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -99.297180, 40.071766 ], [ -99.297180, 40.006580 ], [ -99.319153, 40.017098 ], [ -99.354858, 40.008683 ], [ -99.385071, 40.010787 ], [ -99.420776, 39.993956 ], [ -99.453735, 39.993956 ], [ -99.483948, 39.983434 ], [ -99.519653, 39.993956 ], [ -99.555359, 39.996060 ], [ -99.582825, 40.010787 ], [ -99.618530, 40.008683 ], [ -99.648743, 40.017098 ], [ -99.684448, 40.002372 ], [ -99.717407, 40.000268 ], [ -99.753113, 39.985538 ], [ -99.758606, 39.985538 ], [ -99.783325, 39.989747 ], [ -99.819031, 39.987643 ], [ -99.824524, 39.989747 ], [ -99.846497, 40.002372 ], [ -99.851990, 40.002372 ], [ -99.882202, 40.004476 ], [ -99.917908, 40.017098 ], [ -99.953613, 40.006580 ], [ -99.981079, 40.008683 ], [ -100.000305, 40.000268 ], [ -100.000305, 40.071766 ], [ -99.297180, 40.071766 ] ] ] } } , -{ "type": "Feature", "properties": { "name": "B" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -99.912415, 40.017098 ], [ -99.882202, 40.004476 ], [ -99.854736, 40.004476 ], [ -99.851990, 40.002372 ], [ -99.846497, 40.002372 ], [ -99.824524, 39.989747 ], [ -99.819031, 39.987643 ], [ -99.813538, 39.985538 ], [ -99.783325, 39.989747 ], [ -99.758606, 39.985538 ], [ -99.753113, 39.985538 ], [ -99.747620, 39.985538 ], [ -99.717407, 40.000268 ], [ -99.684448, 40.002372 ], [ -99.648743, 40.017098 ], [ -99.618530, 40.008683 ], [ -99.582825, 40.010787 ], [ -99.555359, 39.993956 ], [ -99.519653, 39.993956 ], [ -99.483948, 39.983434 ], [ -99.453735, 39.993956 ], [ -99.420776, 39.993956 ], [ -99.385071, 40.010787 ], [ -99.354858, 40.008683 ], [ -99.319153, 40.017098 ], [ -99.297180, 40.006580 ], [ -99.297180, 39.928695 ], [ -100.000305, 39.928695 ], [ -100.000305, 40.000268 ], [ -99.981079, 40.008683 ], [ -99.953613, 40.006580 ], [ -99.923401, 40.017098 ], [ -99.917908, 40.017098 ], [ -99.912415, 40.017098 ] ] ] } } +{ "type": "Feature", "properties": { "name": "B" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -99.912415, 40.017098 ], [ -99.882202, 40.004476 ], [ -99.854736, 40.004476 ], [ -99.851990, 40.002372 ], [ -99.824524, 39.989747 ], [ -99.819031, 39.987643 ], [ -99.813538, 39.985538 ], [ -99.783325, 39.989747 ], [ -99.758606, 39.985538 ], [ -99.753113, 39.985538 ], [ -99.747620, 39.985538 ], [ -99.717407, 40.000268 ], [ -99.684448, 40.002372 ], [ -99.648743, 40.017098 ], [ -99.618530, 40.008683 ], [ -99.582825, 40.010787 ], [ -99.555359, 39.993956 ], [ -99.519653, 39.993956 ], [ -99.483948, 39.983434 ], [ -99.453735, 39.993956 ], [ -99.420776, 39.993956 ], [ -99.385071, 40.010787 ], [ -99.354858, 40.008683 ], [ -99.319153, 40.017098 ], [ -99.297180, 40.006580 ], [ -99.297180, 39.928695 ], [ -100.000305, 39.928695 ], [ -100.000305, 40.000268 ], [ -99.981079, 40.008683 ], [ -99.953613, 40.006580 ], [ -99.923401, 40.017098 ], [ -99.917908, 40.017098 ], [ -99.912415, 40.017098 ] ] ] } } ] } ] } , diff --git a/unit.cpp b/unit.cpp index a7aa5920..91d5aff1 100644 --- a/unit.cpp +++ b/unit.cpp @@ -12,6 +12,7 @@ #include #include #include +#include TEST_CASE("UTF-8 enforcement", "[utf8]") { REQUIRE(check_utf8("") == std::string("")); @@ -756,3 +757,72 @@ TEST_CASE("Snapping to a layer's hot pixels keeps shared borders consistent", "[ REQUIRE(gaps == 0); REQUIRE(overlaps == 0); } + +TEST_CASE("Consistent snapping doesn't make neighboring polygons' edges cross", "[wagyu]") { + // Five Census blocks around a sliver whose sides crossed each other when + // rounded to tile coordinates. With closed hot pixels, edges passing + // diagonally through pixel corners were snapped into zigzags that visited + // the same pixels in different orders, and edges of two neighboring blocks + // crossed each other. With half-open hot pixels, they only meet at vertices. + auto parse = [](const char *s) { + drawvec g; + std::istringstream in(s); + std::string tok; + while (in >> tok) { + bool m = tok[0] == 'M'; + if (m) { + tok = tok.substr(1); + } + long long x, y; + sscanf(tok.c_str(), "%lld,%lld", &x, &y); + g.push_back(draw(m ? VT_MOVETO : VT_LINETO, x, y)); + } + g.push_back(draw(VT_LINETO, (long long) g[0].x, (long long) g[0].y)); + return g; + }; + std::vector in = { + parse("M196,147 196,147 196,149 199,147 198,146 199,146 200,147 200,148 201,149 200,150 203,150 203,155 204,154 204,155 207,158 207,158 201,152 203,153 203,150 200,150 201,149 198,146 199,148 197,148 198,149 196,147"), + parse("M196,149 196,147 199,145 200,147 199,146 198,146 199,147 196,149"), + parse("M198,146 201,149 200,150 203,150 203,153 201,152 207,158 206,162 192,162 192,148 196,147 198,149 197,148 199,148 198,146"), + parse("M200,148 207,148 207,158 204,155 204,154 203,155 203,150 200,150 201,149 200,148"), + parse("M199,145 207,144 207,148 200,148 200,147 199,145"), + }; + + std::vector ptrs; + for (auto const &g : in) { + ptrs.push_back(&g); + } + hot_pixel_list hot = layer_hot_pixels(ptrs); + + std::vector out; + for (auto const &g : in) { + bool ok; + out.push_back(clean_polygon_with_hot_pixels(g, hot, &ok)); + REQUIRE(ok); + } + + auto orient = [](draw const &a, draw const &b, draw const &c) { + long long v = ((long long) b.x - a.x) * ((long long) c.y - a.y) - ((long long) b.y - a.y) * ((long long) c.x - a.x); + return (v > 0) - (v < 0); + }; + size_t crossings = 0; + for (size_t a = 0; a < out.size(); a++) { + for (size_t b = a + 1; b < out.size(); b++) { + for (size_t i = 0; i + 1 < out[a].size(); i++) { + if (out[a][i + 1].op != VT_LINETO) { + continue; + } + for (size_t j = 0; j + 1 < out[b].size(); j++) { + if (out[b][j + 1].op != VT_LINETO) { + continue; + } + draw const &p1 = out[a][i], &p2 = out[a][i + 1], &q1 = out[b][j], &q2 = out[b][j + 1]; + if (orient(p1, p2, q1) * orient(p1, p2, q2) < 0 && orient(q1, q2, p1) * orient(q1, q2, p2) < 0) { + crossings++; + } + } + } + } + } + REQUIRE(crossings == 0); +}