Class: GeoCli::GeoJson

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

Instance Attribute Summary

Attributes inherited from Entity

#entity

Instance Method Summary collapse

Methods inherited from Entity

#initialize, #to_geojson, #to_wkt

Constructor Details

This class inherits a constructor from GeoCli::Entity

Instance Method Details

#as_geojson(feature = false) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/geo-cli/geom_reader.rb', line 64

def as_geojson(feature = false)
  if feature
    if entity.is_a?(RGeo::GeoJSON::Feature)
      RGeo::GeoJSON.encode(entity)
    else
      {type: "Feature",
       properties: {},
       geometry: RGeo::GeoJSON.encode(entity)}
    end
  else
    RGeo::GeoJSON.encode(entity)
  end
end