spatial_features 2.16.0 → 2.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 628cd27715c5f59a917ef4cbf898194a16c4e321570e2278cf6231f6f9352d36
|
4
|
+
data.tar.gz: 8842b134b51ce6551b2c2863fc20b2e04847c123c19492e2db7dd64e68397608
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17c62ddbc19d6637529102d1d27fccf2887c5c34e93fc0e935807d97be8bea6c6a7bdb7847f82003e9eded6c016fea7dafe6211684444fe4f1e1c820a045de92
|
7
|
+
data.tar.gz: ce37c7824f8b31948f9c21d3cc2ad886a230f346bc540e5085a802019de0767070eedea7452a398c441801e51ffb6159960b67c11a3fd7f5da194ed37f5a0c3f
|
@@ -201,6 +201,15 @@ module SpatialFeatures
|
|
201
201
|
self.class.unscoped { self.class.intersecting(other).exists?(id) }
|
202
202
|
end
|
203
203
|
|
204
|
+
def bounds
|
205
|
+
if association(:aggregate_feature).loaded?
|
206
|
+
aggregate_feature.feature_bounds
|
207
|
+
else
|
208
|
+
result = aggregate_features.pluck(:north, :east, :south, :west).first
|
209
|
+
[:north, :east, :south, :west].zip(result.map {|bound| BigDecimal(bound) }).to_h.with_indifferent_access if result
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
204
213
|
def total_intersection_area_percentage(klass)
|
205
214
|
return 0.0 unless features_area_in_square_meters > 0
|
206
215
|
|
@@ -228,6 +237,11 @@ module SpatialFeatures
|
|
228
237
|
return false
|
229
238
|
end
|
230
239
|
end
|
240
|
+
|
241
|
+
# Scope to perform SQL-only calculations on a record's aggregate feature. This avoids loading the large data payload if all that is needed is metadata
|
242
|
+
def aggregate_features
|
243
|
+
self.class.where(id: id).aggregate_features
|
244
|
+
end
|
231
245
|
end
|
232
246
|
|
233
247
|
module FeaturesAssociationExtensions
|