Class: DroneApi::GeoJson

Inherits:
Object
  • Object
show all
Defined in:
lib/drone_api/geo_json.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(properties = {}, coordinates = []) ⇒ GeoJson

Returns a new instance of GeoJson.



5
6
7
8
# File 'lib/drone_api/geo_json.rb', line 5

def initialize(properties={}, coordinates=[])
	@properties = properties
	@coordinates = coordinates
end

Instance Attribute Details

#coordinatesObject

Returns the value of attribute coordinates.



3
4
5
# File 'lib/drone_api/geo_json.rb', line 3

def coordinates
  @coordinates
end

#propertiesObject

Returns the value of attribute properties.



3
4
5
# File 'lib/drone_api/geo_json.rb', line 3

def properties
  @properties
end

Class Method Details

.json_create(o) ⇒ Object



29
30
31
32
33
# File 'lib/drone_api/geo_json.rb', line 29

def self.json_create(o)
	GeoJson.new(
		o['properties'], o['geometry']['coordinates']
	)
end

Instance Method Details

#[](key) ⇒ Object



10
11
12
# File 'lib/drone_api/geo_json.rb', line 10

def [](key)
	@properties[key]
end

#[]=(key, value) ⇒ Object



14
15
16
# File 'lib/drone_api/geo_json.rb', line 14

def []=(key, value)
	@properties[key] = value
end

#to_json(*a) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/drone_api/geo_json.rb', line 18

def to_json(*a)
{ 
	"type" => "Feature", 
	"properties" => @properties, 
	"geometry" => {
		"type" => "Point", 
		"coordinates" => @coordinates
	} 
}.to_json(a)
end