diff --git a/geometry.cpp b/geometry.cpp index ab41010a..86285deb 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -663,6 +663,7 @@ static std::vector> clip_poly1(std::vector> clip_poly1(std::vector min && bbox[1] > min && bbox[2] < area && bbox[3] < area) { + return 1; + } + min -= buffer * area / 256; area += buffer * area / 256; + // bbox entirely within the tile, including its buffer + if (bbox[0] > min && bbox[1] > min && bbox[2] < area && bbox[3] < area) { + return 3; + } + // bbox entirely outside the tile if (bbox[0] > area || bbox[1] > area) { return 0; @@ -914,11 +928,6 @@ int quick_check(long long *bbox, int z, long long buffer) { return 0; } - // bbox entirely within the tile - if (bbox[0] > min && bbox[1] > min && bbox[2] < area && bbox[3] < area) { - return 1; - } - // some overlap of edge return 2; } diff --git a/tile.cpp b/tile.cpp index 566d87ad..3bbca4b1 100644 --- a/tile.cpp +++ b/tile.cpp @@ -1408,10 +1408,18 @@ bool clip_to_tile(serial_feature &sf, int z, long long buffer) { } } - if (quick == 0) { + if (quick == 0) { // entirely outside the tile return true; } + // if quick == 3 the feature touches the buffer, not just the tile proper, + // so we need to clip to add intersection points at the tile edge. + + // if quick == 2 it touches the buffer and beyond, so likewise + + // if quick == 1 we should be able to get away without clipping, because + // the feature is entirely within the tile proper. + // Can't accept the quick check if guaranteeing no duplication, since the // overlap might have been in the buffer. if (quick != 1 || prevent[P_DUPLICATION]) {