Small integer multipolygon (sym_)difference failure case post traversal rewrite · Issue #1421 · boostorg/geometry · GitHub
Skip to content

Small integer multipolygon (sym_)difference failure case post traversal rewrite #1421

Open

Description

@tinko92

Here is a very small failure case for both difference and sym_difference that first fails on commit 805ff65, i.e. the traversal rewrite.

#include <boost/geometry.hpp>

namespace bg = boost::geometry;

using point = bg::model::d2::point_xy<int>;
using polygon = bg::model::polygon<point>;
using multi_polygon = bg::model::multi_polygon<polygon>;

int main() {
  const auto geo1 = bg::from_wkt<multi_polygon>("MULTIPOLYGON(((8 8,8 6,8 4,6 4,6 2,6 0,0 0,0 6,2 6,2 8,8 8),(2 4,2 2,4 2,4 4,2 4),(6 6,4 6,4 4,6 4,6 6)))");
  const auto geo2 = bg::from_wkt<multi_polygon>("MULTIPOLYGON(((6 6,6 4,4 4,4 6,6 6)),((6 6,6 8,8 8,8 6,6 6)),((4 6,2 6,2 8,4 8,4 6)),((4 4,4 2,2 2,2 4,4 4)),((4 2,6 2,6 0,4 0,4 2)),((2 6,2 4,0 4,0 6,2 6)),((2 2,2 0,0 0,0 2,2 2)),((6 2,6 4,8 4,8 2,6 2)))");
  multi_polygon diff, symdiff;
  bg::difference(geo1, geo2, diff);
  bg::sym_difference(geo1, geo2, symdiff);

  std::cout << "Diff:\t\t" << bg::to_wkt(diff) << '\n';
  std::cout << "Symdiff:\t" << bg::to_wkt(symdiff) << '\n';
  return 0;
}

Prints

Diff:           MULTIPOLYGON(((8 6,8 4,6 4,6 6,8 6)),((2 2,4 2,4 0,2 0,2 2)),((2 4,2 2,0 2,0 4,2 4)),((6 6,4 6,4 8,6 8,6 6)))
Symdiff:        MULTIPOLYGON(((8 2,6 2,6 4,4 4,4 6,4 8,6 8,6 6,8 6,8 2)),((4 0,2 0,2 2,0 2,0 4,4 4,4 0)))

should print

Diff:           MULTIPOLYGON(((8 6,8 4,6 4,6 6,8 6)),((4 0,2 0,2 2,4 2,4 0)),((0 4,2 4,2 2,0 2,0 4)),((6 8,6 6,4 6,4 8,6 8)),((6 4,6 2,4 2,4 4,6 4)),((2 6,4 6,4 4,2 4,2 6)))
Symdiff:        MULTIPOLYGON(((8 2,4 2,4 0,2 0,2 2,0 2,0 4,2 4,2 6,4 6,4 8,6 8,6 6,8 6,8 2)))

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions