Class: GeoScript::Geom::Polygon
- Inherits:
-
JTSPolygon
- Object
- GeoScript::Geom::Polygon
- Includes:
- GeoScript::Geom
- Defined in:
- lib/geoscript/geom/polygon.rb
Constant Summary
Constants included from GeoScript::Geom
Instance Attribute Summary collapse
-
#bounds ⇒ Object
Returns the value of attribute bounds.
Instance Method Summary collapse
- #buffer(dist) ⇒ Object
-
#initialize(*rings) ⇒ Polygon
constructor
A new instance of Polygon.
- #to_json ⇒ Object
- #to_wkb ⇒ Object
- #to_wkt ⇒ Object
Methods included from GeoScript::Geom
buffer, enhance, from_wkt, get_bounds, prepare, simplify, to_wkt
Constructor Details
#initialize(*rings) ⇒ Polygon
Returns a new instance of Polygon.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/geoscript/geom/polygon.rb', line 10 def initialize(*rings) if rings.first.kind_of? JTSPolygon interior_rings = [] num_rings = rings.first.num_interior_ring for i in (0...num_rings) interior_rings << rings.first.get_interior_ring_n(i) end shell = rings.first.exterior_ring holes = interior_rings.to_java(com.vividsolutions.jts.geom.LinearRing) else linear_rings = [] rings.each do |ring| if ring.kind_of? LinearRing linear_rings << ring else linear_rings << LinearRing.new(*ring) end end shell = linear_rings.first holes = linear_rings[1..linear_rings.size].to_java(com.vividsolutions.jts.geom.LinearRing) end super(shell, holes, GEOM_FACTORY) end |
Instance Attribute Details
#bounds ⇒ Object
Returns the value of attribute bounds.
8 9 10 |
# File 'lib/geoscript/geom/polygon.rb', line 8 def bounds @bounds end |
Instance Method Details
#buffer(dist) ⇒ Object
35 36 37 |
# File 'lib/geoscript/geom/polygon.rb', line 35 def buffer(dist) Polygon.new super end |
#to_json ⇒ Object
47 48 49 |
# File 'lib/geoscript/geom/polygon.rb', line 47 def to_json IO.write_json self end |