Class: GeoCli::Entity

Inherits:
Object
  • Object
show all
Defined in:
lib/geo-cli/geom_reader.rb

Direct Known Subclasses

GeoJson, Geohash, Wkt

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#entityObject (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_wktObject



52
53
54
# File 'lib/geo-cli/geom_reader.rb', line 52

def to_wkt
  entity.as_text
end