spatial_features 1.4.9 → 1.5.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
  SHA1:
3
- metadata.gz: cf3dda9ab1fdf8948a6bab915004ea89a4775b47
4
- data.tar.gz: 05c63080928e3efad230b01cb4998c05b0b440ff
3
+ metadata.gz: 6cd096776f5bb77163b8212f69c6adb72e18eebe
4
+ data.tar.gz: 4e231bdbbdfb67a8eeb6834723813668d3680389
5
5
  SHA512:
6
- metadata.gz: 50badb4ab9d03d94cf50180f67624823cb600a646fcdc0185805dee2e04f2ada1140138131683cc038605b5237751d91450f340698cfdf97c32b024e2f6bed02
7
- data.tar.gz: 2171f215ae4801d28eb5ca1513aa82558706efa2537a4476555beeaabca921787ead65488671a3c30bf1847d9891dd1eff20c29a4fe0d3b695e65f18991d8408
6
+ metadata.gz: 691b52de13ba3bb0dcb984f5b8c13da76aa7f5c3f6022da16b5c2213c942dc5945c0f78ec3e274a7c20ba5ad2aa22effebbe640f69d084a58b9861071fa31ba3
7
+ data.tar.gz: fb09b3e7c0de8d60deeb2f5fe726b5628f8e052623c6d57a5ec9ad3a29fde465207e3a021218b7bd8ccb2bb593bd872223771ab6bb1213248523eee6fa10e4bb
@@ -39,7 +39,7 @@ module SpatialFeatures
39
39
  # This is because the cached intersection_area doesn't account for overlaps between the features in the scope.
40
40
  if options[:cache] != false && other.is_a?(ActiveRecord::Base)
41
41
  # Don't use the cache if it doesn't exist
42
- return all.extending(UncachedRelation) unless class_for(other).spatial_cache_for?(self, buffer_in_meters)
42
+ return all.extending(UncachedRelation) unless other.spatial_cache_for?(class_for(self), buffer_in_meters)
43
43
 
44
44
  scope = cached_spatial_join(other).select("#{table_name}.*")
45
45
  scope = scope.where("spatial_proximities.distance_in_meters <= ?", buffer_in_meters) if buffer_in_meters
@@ -74,18 +74,6 @@ module SpatialFeatures
74
74
  features.points
75
75
  end
76
76
 
77
- def spatial_cache_for?(other, buffer_in_meters)
78
- if cache = spatial_cache_for(other)
79
- return cache.intersection_cache_distance.nil? if buffer_in_meters.nil? # cache must be total if no buffer_in_meters
80
- return false if cache.stale? # cache must be for current features
81
- return true if cache.intersection_cache_distance.nil? # always good if cache is total
82
-
83
- return buffer_in_meters <= cache.intersection_cache_distance
84
- else
85
- return false
86
- end
87
- end
88
-
89
77
  def features
90
78
  Feature.where(:spatial_model_type => self, :spatial_model_id => all)
91
79
  end
@@ -128,10 +116,6 @@ module SpatialFeatures
128
116
  joins("INNER JOIN spatial_proximities ON spatial_proximities.#{self_column}_type = '#{self}' AND spatial_proximities.#{self_column}_id = #{table_name}.id AND spatial_proximities.#{other_column}_type = '#{other_class}' AND spatial_proximities.#{other_column}_id IN (#{ids_sql_for(other)})")
129
117
  end
130
118
 
131
- def spatial_cache_for(other)
132
- SpatialCache.where(:spatial_model_type => self, :intersection_model_type => class_for(other)).first
133
- end
134
-
135
119
  # Returns the class for the given, class, scope, or record
136
120
  def class_for(other)
137
121
  case other
@@ -208,6 +192,22 @@ module SpatialFeatures
208
192
  .try(:intersection_area_in_square_meters) || 0
209
193
  end
210
194
 
195
+ def spatial_cache_for?(klass, buffer_in_meters)
196
+ if cache = spatial_cache_for(klass)
197
+ return cache.intersection_cache_distance.nil? if buffer_in_meters.nil? # cache must be total if no buffer_in_meters
198
+ return false if cache.stale? # cache must be for current features
199
+ return true if cache.intersection_cache_distance.nil? # always good if cache is total
200
+
201
+ return buffer_in_meters <= cache.intersection_cache_distance
202
+ else
203
+ return false
204
+ end
205
+ end
206
+
207
+ def spatial_cache_for(klass)
208
+ spatial_cache.where(:intersection_model_type => klass).first
209
+ end
210
+
211
211
  def update_features_area
212
212
  update_column :features_area, features.area(:cache => false)
213
213
  end
@@ -1,3 +1,3 @@
1
1
  module SpatialFeatures
2
- VERSION = "1.4.9"
2
+ VERSION = "1.5.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: 1.4.9
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Wallace