Class: EsriShapefile::Shapes::Polygon

Inherits:
Object
  • Object
show all
Includes:
ByteModel
Defined in:
lib/esri_shapefile/models/shapes/polygon.rb

Overview

A polygon consists of one or more rings. A ring is a connected sequence of four or more points that form a closed, non-self-intersecting loop. A polygon may contain multiple outer rings. The order of vertices or orientation for a ring indicates which side of the ring is the interior of the polygon. The neighborhood to the right of an observer walking along the ring in vertex order is the neighborhood inside the polygon. Vertices of rings defining holes in polygons are in counterclockwise direction. Vertices for a single, ringed polygon are, therefore, always in clockwise order. The rings of a polygon are referred to as its parts.

Because this specification does not forbid consecutive points with identical coordinates, shapefile readers must handle such cases. On the other hand, the degenerate, zero length or zero area parts that might result are not allowed.

The Polygon structure is identical to the PolyLine structure.

Instance Attribute Summary

Attributes included from ByteModel

#metadata

Instance Method Summary collapse

Methods included from ByteModel

extended, included

Instance Method Details

#ringsObject



36
37
38
39
40
41
42
43
# File 'lib/esri_shapefile/models/shapes/polygon.rb', line 36

def rings
  @rings ||= begin
    ring_parts = (parts + [points.size])
    ring_parts.each_cons(2).map do |ring_start_index, next_ring_index|
      Ring.new(points[ring_start_index...next_ring_index])
    end
  end
end