spatial_features 1.3.9 → 1.3.10

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: 7c5c3df04e153958e386e890dbcf7e86915bf705
4
- data.tar.gz: b849fe76a613db9e7a9daf97db26fd631a3fdd22
3
+ metadata.gz: 8a4f197e3ba07d1cc425b2b8b8367603c1434643
4
+ data.tar.gz: 3b6ad7bbd92da3ba7d2b781305463807181a8eb5
5
5
  SHA512:
6
- metadata.gz: 7b3cdc03291c86cfd144a7184b90bda8aadec8fb75444b88f847a66dad032a4a56fa1bb5528b612f2f9ea1d888272793081f9713c45cac1ae9475bffd5ea8bab
7
- data.tar.gz: bd4cf7d8f493cb60bd84df99cb25c3f18422936c9e574b517b807d0ca57612b1680357405c85ce091c3e4e59b4f048d2e8e40ab63ff618ba681abca181297471
6
+ metadata.gz: d03677e9c02f0d812740eab6e283a83a8b64f83a39d179199149a375dc5c6f6920c1ce63754b75c1f1975fbfee592553946585994bc77cc480c62e9067cfad54
7
+ data.tar.gz: 5eb03110f86a432f45dea48fad7fdb4fdfd155178fc0e0f255a666b291830f732ba6ba02b6c7296761de13e84140ff38a093d1cd0458a2a92b5b11727b0aeefa
data/README.md CHANGED
@@ -27,7 +27,8 @@ execute("
27
27
  spatial_model_id integer,
28
28
  created_at timestamp without time zone,
29
29
  updated_at timestamp without time zone,
30
- intersection_cache_distance double precision
30
+ intersection_cache_distance double precision,
31
+ features_hash character varying(255)
31
32
  );
32
33
 
33
34
  CREATE TABLE spatial_proximities (
@@ -38,6 +39,6 @@ execute("
38
39
  model_b_id integer,
39
40
  distance_in_meters double precision,
40
41
  intersection_area_in_square_meters double precision
41
- );
42
+ );
42
43
  ")
43
44
  ```
@@ -49,18 +49,21 @@ module SpatialFeatures
49
49
 
50
50
  scope = klass.within_buffer(record, default_cache_buffer_in_meters, :intersection_area => true, :distance => true, :cache => false)
51
51
  scope.find_each do |klass_record|
52
- SpatialProximity.create!(
53
- :model_a => record_is_a ? record : klass_record,
54
- :model_b => record_is_a ? klass_record : record,
55
- :distance_in_meters => klass_record.distance_in_meters,
56
- :intersection_area_in_square_meters => klass_record.intersection_area_in_square_meters)
52
+ SpatialProximity.create! do |proximity|
53
+ proximity.model_a = record_is_a ? record : klass_record
54
+ proximity.model_b = record_is_a ? klass_record : record
55
+ proximity.distance_in_meters = klass_record.distance_in_meters
56
+ proximity.intersection_area_in_square_meters = klass_record.intersection_area_in_square_meters
57
+ end
57
58
  end
58
59
  end
59
60
 
60
61
  def self.create_spatial_cache(model, klass)
61
- SpatialCache.create!(
62
- :spatial_model => model,
63
- :intersection_model_type => klass.name,
64
- :intersection_cache_distance => default_cache_buffer_in_meters)
62
+ SpatialCache.create! do |cache|
63
+ cache.spatial_model = model
64
+ cache.intersection_model_type = klass.name
65
+ cache.intersection_cache_distance = default_cache_buffer_in_meters
66
+ cache.features_hash = model.features_hash if model.has_spatial_features_hash?
67
+ end
65
68
  end
66
69
  end
@@ -153,6 +153,7 @@ module SpatialFeatures
153
153
  def spatial_cache_for?(klass, buffer_in_meters)
154
154
  if cache = spatial_cache_for(klass)
155
155
  return cache.intersection_cache_distance.nil? if buffer_in_meters.nil? # cache must be total if no buffer_in_meters
156
+ return false if cache.stale? # cache must be for current features
156
157
  return true if cache.intersection_cache_distance.nil? # always good if cache is total
157
158
 
158
159
  return buffer_in_meters <= cache.intersection_cache_distance
@@ -1,3 +1,7 @@
1
1
  class SpatialCache < ActiveRecord::Base
2
- belongs_to :spatial_model, :polymorphic => true
2
+ belongs_to :spatial_model, :polymorphic => true, :inverse_of => :spatial_cache
3
+
4
+ def stale?
5
+ spatial_model.has_spatial_features_hash? && self.features_hash != spatial_model.features_hash
6
+ end
3
7
  end
@@ -1,3 +1,3 @@
1
1
  module SpatialFeatures
2
- VERSION = "1.3.9"
2
+ VERSION = "1.3.10"
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.3.9
4
+ version: 1.3.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Wallace
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-07-20 00:00:00.000000000 Z
12
+ date: 2015-07-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails