Class: GeoCli::Entity
- Inherits:
-
Object
- Object
- GeoCli::Entity
- Defined in:
- lib/geo-cli/geom_reader.rb
Instance Attribute Summary collapse
-
#entity ⇒ Object
readonly
Returns the value of attribute entity.
Instance Method Summary collapse
- #as_geojson(feature = false) ⇒ Object
-
#initialize(entity) ⇒ Entity
constructor
A new instance of Entity.
- #to_geojson(feature = false) ⇒ Object
- #to_wkt ⇒ Object
Constructor Details
#initialize(entity) ⇒ Entity
Returns a new instance of Entity.
33 34 35 |
# File 'lib/geo-cli/geom_reader.rb', line 33 def initialize(entity) @entity = entity end |
Instance Attribute Details
#entity ⇒ Object (readonly)
Returns the value of attribute entity.
31 32 33 |
# File 'lib/geo-cli/geom_reader.rb', line 31 def entity @entity end |
Instance Method Details
#as_geojson(feature = false) ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/geo-cli/geom_reader.rb', line 37 def as_geojson(feature = false) geom = RGeo::GeoJSON.encode(entity) if feature {type: "Feature", properties: {}, geometry: geom} else geom end end |
#to_geojson(feature = false) ⇒ Object
48 49 50 |
# File 'lib/geo-cli/geom_reader.rb', line 48 def to_geojson(feature = false) as_geojson(feature).to_json end |
#to_wkt ⇒ Object
52 53 54 |
# File 'lib/geo-cli/geom_reader.rb', line 52 def to_wkt entity.as_text end |