Encapsulates a polygon consisting of a set of linear-rings in the xy-plane. It corresponds to the org.apache.cassandra.db.marshal.PolygonType column type in DSE.

A linear-ring is a LineString whose last point is the same as its first point. The first ring specified in a polygon defines the outer edges of the polygon and is called the exterior ring. A polygon may also have holes within it, specified by other linear-rings, and those holes may contain linear-rings indicating islands. All such rings are called interior rings.

See Also:

Inherits

Object

Includes

  • Cassandra::CustomData

Methods

self.

new

(*args)

Returns a new instance of Polygon

Examples:
Construct an empty Polygon
polygon = Polygon.new
Construct a Polygon with LineString objects.
exterior_ring = LineString.new(Point.new(0, 0), Point.new(10, 0), Point.new(10, 10), Point.new(0, 0))
interior_ring = LineString.new(Point.new(1, 1), Point.new(1, 5), Point.new(5, 1), Point.new(1, 1))
polygon = Polygon.new(exterior_ring, interior_ring)
Construct a line-string with a wkt string.
polygon = Polygon.new('POLYGON ((0.0 0.0, 10.0 0.0, 10.0 10.0, 0.0 0.0), ' \
                      '(1.0 1.0, 1.0 5.0, 5.0 1.0, 1.0 1.0))')
Parameters:
Name Type Details
args (Array<LineString> or Array<String>) varargs-style arguments in two forms:
  • ordered collection of linear-rings that make up this polygon. Can be empty.
  • one-element string array with the wkt representation.
self.

type

Returns type of column that is processed by this domain object class.

Returns:
Type Details
Cassandra::Types::Custom type of column that is processed by this domain object class.
self.

deserialize

(data)

Deserialize the given data into an instance of this domain object class.

Parameters:
Name Type Details
data String byte-array representation of a column value of this custom type.
Returns:
Type Details
Polygon
Raises:
Type Details
Cassandra::Errors::DecodingError upon failure.

exterior_ring

Returns linear-ring characterizing the exterior of the polygon. nil for empty polygon.

Returns:
Type Details
LineString linear-ring characterizing the exterior of the polygon. nil for empty polygon.

interior_rings

Returns ordered collection of linear-rings that make up the interior of this polygon. Empty if there are no interior rings.

Returns:
Type Details
Array<LineString> ordered collection of linear-rings that make up the interior of this polygon. Empty if there are no interior rings.

wkt

Returns well-known-text representation of this polygon.

Returns:
Type Details
String well-known-text representation of this polygon.

to_s

Returns a human-readable English string describing this Dse::Geometry::Polygon.

Returns:
Type Details
String a human-readable English string describing this Dse::Geometry::Polygon.

serialize

Serialize this domain object into a byte array to send to DSE.

Returns:
Type Details
String byte-array representation of this domain object.