Module: RGeo::Cartesian::ValidOpHelpers
- Includes:
- ImplHelper::ValidOpHelpers
- Defined in:
- lib/rgeo/cartesian/valid_op.rb
Class Method Summary collapse
-
.check_connected_interiors(poly) ⇒ String
Checks that the interior of a polygon is connected.
-
.check_consistent_area(poly) ⇒ String
Checks that there are no invalid intersections between the components of a polygon.
Methods included from ImplHelper::ValidOpHelpers
check_consistent_area_mp, check_holes_in_shell, check_holes_not_nested, check_invalid_coordinate, check_no_self_intersecting_rings, check_no_self_intersections, check_shells_not_nested
Class Method Details
.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.
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 |
.check_consistent_area(poly) ⇒ String
Checks that there are no invalid intersections between the components of a polygon.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rgeo/cartesian/valid_op.rb', line 26 def check_consistent_area(poly) # Get set of unique coords pts = poly.exterior_ring.coordinates.to_set poly.interior_rings.each do |ring| pts += ring.coordinates end num_points = pts.size # if additional nodes were added, there must be an intersection # through a boundary. return Error::SELF_INTERSECTION if poly.send(:graph).incident_edges.size > num_points rings = [poly.exterior_ring] + poly.interior_rings return Error::SELF_INTERSECTION if rings.uniq.size != rings.size nil end |