Class: GeoScript::Geom::LineString
- Inherits:
-
JTSLineString
- Object
- GeoScript::Geom::LineString
- Includes:
- GeoScript::Geom
- Defined in:
- lib/geoscript/geom/linestring.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(*coords) ⇒ LineString
constructor
A new instance of LineString.
- #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(*coords) ⇒ LineString
Returns a new instance of LineString.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/geoscript/geom/linestring.rb', line 11 def initialize(*coords) if coords.size == 1 if coords.first.kind_of? JTSLineString elsif coords.kind_of? Array if coords.first.kind_of? Array l = [] coords.first.each do |coord| l << Coordinate.new(coord[0], coord[1]) l.last.z = coord[2] if coord[2] end if l.size > 0 ls = GEOM_FACTORY.create_line_string l.to_java(com.vividsolutions.jts.geom.Coordinate) end end end else l = [] coords.each do |coord| l << Coordinate.new(coord[0], coord[1]) l.last.z = coord[2] if coord[2] end if l.size > 0 ls = GEOM_FACTORY.create_line_string l.to_java(com.vividsolutions.jts.geom.Coordinate) end end if ls super(ls.coordinate_sequence, GEOM_FACTORY) else raise 'LineString could not be created. Check inputs.' end end |
Instance Attribute Details
#bounds ⇒ Object
Returns the value of attribute bounds.
9 10 11 |
# File 'lib/geoscript/geom/linestring.rb', line 9 def bounds @bounds end |
Instance Method Details
#buffer(dist) ⇒ Object
44 45 46 |
# File 'lib/geoscript/geom/linestring.rb', line 44 def buffer(dist) Polygon.new super end |
#to_json ⇒ Object
56 57 58 |
# File 'lib/geoscript/geom/linestring.rb', line 56 def to_json IO.write_json self end |