class Geoq::Entity

Attributes

entity[R]
raw[R]

Public Class Methods

new(entity, raw) click to toggle source
# File lib/geoq/entity.rb, line 9
def initialize(entity, raw)
  @entity = entity
  @raw = raw
end

Public Instance Methods

as_geojson(feature = false) click to toggle source
# File lib/geoq/entity.rb, line 14
def as_geojson(feature = false)
  geom = RGeo::GeoJSON.encode(entity)
  if feature
    {type: "Feature",
     properties: {},
     geometry: geom}
  else
    geom
  end
end
gh_children() click to toggle source
# File lib/geoq/entity.rb, line 41
def gh_children
  raise RepresentationError.new("GeoHash children not supported for #{entity.to_s}")
end
gh_neighbors(inclusive = false) click to toggle source
# File lib/geoq/entity.rb, line 45
def gh_neighbors(inclusive = false)
  raise RepresentationError.new("GeoHash neighbors not supported for #{entity.to_s}")
end
gh_string(level) click to toggle source
# File lib/geoq/entity.rb, line 33
def gh_string(level)
  if entity.dimension == 0
    GeoHash.encode(entity.y, entity.x, level)
  else
    raise RepresentationError.new("GeoHash representation not supported for #{entity.to_s}")
  end
end
to_geojson(feature = false) click to toggle source
# File lib/geoq/entity.rb, line 25
def to_geojson(feature = false)
  as_geojson(feature).to_json
end
to_wkt() click to toggle source
# File lib/geoq/entity.rb, line 29
def to_wkt
  entity.as_text
end