Class: GeoScript::Geom::MultiPolygon

Inherits:
JTSMultiPolygon
  • Object
show all
Includes:
GeoScript::Geom
Defined in:
lib/geoscript/geom/multipolygon.rb

Constant Summary

Constants included from GeoScript::Geom

GEOM_FACTORY, PREP_FACTORY

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from GeoScript::Geom

buffer, enhance, from_wkt, get_bounds, prepare, simplify, to_wkt

Constructor Details

#initialize(*polygons) ⇒ MultiPolygon

Returns a new instance of MultiPolygon.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/geoscript/geom/multipolygon.rb', line 10

def initialize(*polygons)
  polys = []

  if polygons.first.kind_of? JTSMultiPolygon
    multi_polygon = polygons.first
    for i in range(0...multi_polygon.num_geometries)
      polys << multi_polygon.get_geometry_n(i)
    end
  else
    polygons.each do |polygon|
      if polygon.kind_of? Java::ComVividsolutionsJtsGeom::Polygon
        polys << polygon
      else
        polys << Polygon.new(*polygon)
      end
    end
  end
  super(polys.to_java(com.vividsolutions.jts.geom.Polygon), GEOM_FACTORY)
end

Instance Attribute Details

#boundsObject

Returns the value of attribute bounds.



8
9
10
# File 'lib/geoscript/geom/multipolygon.rb', line 8

def bounds
  @bounds
end

Instance Method Details

#buffer(dist) ⇒ Object



30
31
32
# File 'lib/geoscript/geom/multipolygon.rb', line 30

def buffer(dist)
  Polygon.new super
end

#to_jsonObject



42
43
44
# File 'lib/geoscript/geom/multipolygon.rb', line 42

def to_json
  IO.write_json self
end

#to_wkbObject



38
39
40
# File 'lib/geoscript/geom/multipolygon.rb', line 38

def to_wkb
  IO.write_wkb self
end

#to_wktObject



34
35
36
# File 'lib/geoscript/geom/multipolygon.rb', line 34

def to_wkt
  IO.write_wkt self
end