Method: RGeo::Cartesian::ValidOpHelpers.check_connected_interiors

Defined in:
lib/rgeo/cartesian/valid_op.rb

.check_connected_interiors(poly) ⇒ String

Checks that the interior of a polygon is connected.

Process to do this is to walk around an interior cycle of the exterior shell in the polygon’s geometry graph. It will keep track of all the nodes it visited and if that set is a superset of the coordinates in the exterior_ring, the interior is connected, otherwise it is split somewhere.

Parameters:

Returns:

  • (String)

    invalid_reason



55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/rgeo/cartesian/valid_op.rb', line 55

def check_connected_interiors(poly)
  exterior_coords = poly.exterior_ring.coordinates.to_set

  visited = Set.new
  poly.send(:graph).geom_edges.first.exterior_edge.and_connected do |hedge|
    visited << hedge.origin.coordinates
  end

  return Error::DISCONNECTED_INTERIOR unless exterior_coords.subset?(visited)

  nil
end