Skip to content

[Bug] Specific Polygons That Won't Union #78

Open

Description

@therobotreader

Hi,
I have two polygons:

geo1 = Geometry::Polygon.new(Geometry::Point[1691, 957], Geometry::Point[1677, 1175], Geometry::Point[1635, 1173], Geometry::Point[1649, 951])
geo2 = Geometry::Polygon.new(Geometry::Point[1690, 1033], Geometry::Point[1687, 1139], Geometry::Point[1670, 1138], Geometry::Point[1673, 1030])

When I call geo1.union(geo2) it throws an error:

Error:
TestBox#test_broken_box:
NoMethodError: undefined method `first' for nil:NilClass
    /home/deus-ex/.gem/ruby/2.7.1/gems/geometry-6.5/lib/geometry/polyline.rb:143:in `close!'
    /home/deus-ex/.gem/ruby/2.7.1/gems/geometry-6.5/lib/geometry/polygon.rb:32:in `initialize'
    /home/deus-ex/.gem/ruby/2.7.1/gems/geometry-6.5/lib/geometry/polygon.rb:174:in `new'
    /home/deus-ex/.gem/ruby/2.7.1/gems/geometry-6.5/lib/geometry/polygon.rb:174:in `union'
    /home/deus-ex/code/title_reader/test/test_box.rb:147:in `test_broken_box'

However, if I call geo2.union(geo1) it works fine. It also works if I change the first point in geo2 to Geometry::Point[1695, 1033]. I don't know enough about geometry to debug this further.

Thanks!

Activity

  1. therobotreader commented on Oct 13, 2020

    @therobotreader
    Author

    This is geometry version 6.5.

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions