Class: Terraformer::FeatureCollection
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Primitive
#bbox, #envelope, #to_json, #type
Constructor Details
Returns a new instance of FeatureCollection.
63
64
65
66
67
68
69
|
# File 'lib/terraformer/feature.rb', line 63
def initialize *args
unless args.empty?
super *args do |arg|
self.features = arg['features'].map {|f| Terraformer.parse f unless Primitive === f}
end
end
end
|
Instance Attribute Details
#crs ⇒ Object
Returns the value of attribute crs.
53
54
55
|
# File 'lib/terraformer/feature.rb', line 53
def crs
@crs
end
|
#features ⇒ Object
71
72
73
|
# File 'lib/terraformer/feature.rb', line 71
def features
@features ||= []
end
|
Class Method Details
.with_features(*f) ⇒ Object
56
57
58
59
60
61
|
# File 'lib/terraformer/feature.rb', line 56
def self.with_features *f
raise ArgumentError unless f.all? {|e| Feature === e}
fc = FeatureCollection.new
fc.features = f
fc
end
|
Instance Method Details
#<<(feature) ⇒ Object
75
76
77
78
|
# File 'lib/terraformer/feature.rb', line 75
def << feature
raise ArgumentError unless Feature === feature
features << feature
end
|
#==(obj) ⇒ Object
89
90
91
92
|
# File 'lib/terraformer/feature.rb', line 89
def == obj
return false unless FeatureCollection === obj
to_hash == obj.to_hash
end
|
#convex_hull ⇒ Object
94
95
96
|
# File 'lib/terraformer/feature.rb', line 94
def convex_hull
ConvexHull.for features.map(&:geometry).map(&:coordinates)
end
|
#to_hash(*args) ⇒ Object
80
81
82
83
84
85
86
87
|
# File 'lib/terraformer/feature.rb', line 80
def to_hash *args
h = {
type: type,
features: features.map {|f| f.to_hash *args}
}
h[:crs] = crs if crs
h
end
|