Class: Geoq::Entity
- Inherits:
-
Object
show all
- Defined in:
- lib/geoq/entity.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(entity, raw) ⇒ Entity
Returns a new instance of Entity.
9
10
11
12
|
# File 'lib/geoq/entity.rb', line 9
def initialize(entity, raw)
@entity = entity
@raw = raw
end
|
Instance Attribute Details
#entity ⇒ Object
Returns the value of attribute entity.
7
8
9
|
# File 'lib/geoq/entity.rb', line 7
def entity
@entity
end
|
#raw ⇒ Object
Returns the value of attribute raw.
7
8
9
|
# File 'lib/geoq/entity.rb', line 7
def raw
@raw
end
|
Instance Method Details
#as_geojson(feature = false) ⇒ Object
14
15
16
17
18
19
20
21
22
23
|
# 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 ⇒ Object
41
42
43
|
# 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) ⇒ Object
45
46
47
|
# 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) ⇒ Object
33
34
35
36
37
38
39
|
# 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) ⇒ Object
25
26
27
|
# File 'lib/geoq/entity.rb', line 25
def to_geojson(feature = false)
as_geojson(feature).to_json
end
|
#to_wkt ⇒ Object
29
30
31
|
# File 'lib/geoq/entity.rb', line 29
def to_wkt
entity.as_text
end
|