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: e0bc8fc084675d82dfe1414f599b32d22b3b4435525246580c7cd2af1f5e3afc
4
- data.tar.gz: 78b7e7fa4b2e3fe9f46931c4b5a0bcf14c3f518a9e813e48fcb3985ac1bd171f
3
+ metadata.gz: 628cd27715c5f59a917ef4cbf898194a16c4e321570e2278cf6231f6f9352d36
4
+ data.tar.gz: 8842b134b51ce6551b2c2863fc20b2e04847c123c19492e2db7dd64e68397608
5
5
  SHA512:
6
- metadata.gz: 1fe304ec107f4d9ca8537a4a665c118bb20a1365b2bee3a58d88bd2ccc65758a4906a812a09632ad779e2df60b715c100967e62bfb97e23c012e96a7d031f958
7
- data.tar.gz: ab611750f2a507937f0f3a62b120c619b7e2b3a9fda837657eeb844bd0e02911d3fd5419a779f60ed0d20bdee6b387e4fb2b9b51e814216b1a0a82bce11852b5
6
+ metadata.gz: 17c62ddbc19d6637529102d1d27fccf2887c5c34e93fc0e935807d97be8bea6c6a7bdb7847f82003e9eded6c016fea7dafe6211684444fe4f1e1c820a045de92
7
+ data.tar.gz: ce37c7824f8b31948f9c21d3cc2ad886a230f346bc540e5085a802019de0767070eedea7452a398c441801e51ffb6159960b67c11a3fd7f5da194ed37f5a0c3f
@@ -152,7 +152,7 @@ class AbstractFeature < ActiveRecord::Base
152
152
  end
153
153
 
154
154
  def feature_bounds
155
- {n: north, e: east, s: south, w: west}
155
+ slice(:north, :east, :south, :west)
156
156
  end
157
157
 
158
158
  def cache_derivatives(*args)
@@ -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
@@ -1,3 +1,3 @@
1
1
  module SpatialFeatures
2
- VERSION = "2.16.0"
2
+ VERSION = "2.17.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spatial_features
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.16.0
4
+ version: 2.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Wallace