spatial_features 1.3.9 → 1.3.10
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a4f197e3ba07d1cc425b2b8b8367603c1434643
|
4
|
+
data.tar.gz: 3b6ad7bbd92da3ba7d2b781305463807181a8eb5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
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
|
-
|
63
|
-
|
64
|
-
|
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
|
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.
|
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-
|
12
|
+
date: 2015-07-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|