spatial_features 1.3.6 → 1.3.7
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 436fef303733276633ff5c6055541d20d1139d0e
|
4
|
+
data.tar.gz: cfddf894cb3a79e5beb9662069e7210a6c43035d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a36136f66dc0c2a7c9c419ed3d7cab05f21c8abeacb6e58995e3bef4410ca6664b2886a7ab1849ec308a1b2d4b69740d143ad360bf0905a3b5e78620bb1c114f
|
7
|
+
data.tar.gz: 0fe23f41fb24a53e30859653c807fca288173d8172245d0cd58c1be493a9999b4adc1fee79a6d595dc5a7ca3f47c914f4d78a3a2b16b69dacf501edde0b7f162
|
data/README.md
CHANGED
@@ -12,11 +12,32 @@ execute("
|
|
12
12
|
name character varying(255),
|
13
13
|
feature_type character varying(255),
|
14
14
|
geog geography,
|
15
|
+
kml text,
|
15
16
|
geog_lowres geography(Geometry,4326),
|
16
17
|
geom geometry(Geometry,26910),
|
17
|
-
|
18
|
+
metadata hstore,
|
18
19
|
kml_lowres text,
|
19
|
-
|
20
|
+
area double precision
|
20
21
|
);
|
22
|
+
|
23
|
+
CREATE TABLE spatial_caches (
|
24
|
+
id integer NOT NULL,
|
25
|
+
intersection_model_type character varying(255),
|
26
|
+
spatial_model_type character varying(255),
|
27
|
+
spatial_model_id integer,
|
28
|
+
created_at timestamp without time zone,
|
29
|
+
updated_at timestamp without time zone,
|
30
|
+
intersection_cache_distance double precision
|
31
|
+
);
|
32
|
+
|
33
|
+
CREATE TABLE spatial_proximities (
|
34
|
+
id integer NOT NULL,
|
35
|
+
model_a_type character varying(255),
|
36
|
+
model_a_id integer,
|
37
|
+
model_b_type character varying(255),
|
38
|
+
model_b_id integer,
|
39
|
+
distance_in_meters double precision,
|
40
|
+
intersection_area_in_square_meters double precision
|
41
|
+
);
|
21
42
|
")
|
22
43
|
```
|
@@ -139,7 +139,7 @@ module SpatialFeatures
|
|
139
139
|
end
|
140
140
|
|
141
141
|
def features_area_in_square_meters
|
142
|
-
@features_area_in_square_meters ||= features.sum('
|
142
|
+
@features_area_in_square_meters ||= features.sum('features.area')
|
143
143
|
end
|
144
144
|
|
145
145
|
def features_area_in_hectares
|
@@ -152,10 +152,10 @@ module SpatialFeatures
|
|
152
152
|
|
153
153
|
def spatial_cache_for?(klass, buffer_in_meters)
|
154
154
|
if cache = spatial_cache_for(klass)
|
155
|
-
return cache.
|
156
|
-
return true if cache.
|
155
|
+
return cache.intersection_cache_distance.nil? if buffer_in_meters.nil? # cache must be total if no buffer_in_meters
|
156
|
+
return true if cache.intersection_cache_distance.nil? # always good if cache is total
|
157
157
|
|
158
|
-
return buffer_in_meters <= cache.
|
158
|
+
return buffer_in_meters <= cache.intersection_cache_distance
|
159
159
|
else
|
160
160
|
return false
|
161
161
|
end
|
@@ -31,6 +31,10 @@ class Feature < ActiveRecord::Base
|
|
31
31
|
select('features.*, ST_IsValidReason(geog::geometry) AS invalid_geometry_message').where.not('ST_IsValid(geog::geometry)')
|
32
32
|
end
|
33
33
|
|
34
|
+
def self.valid
|
35
|
+
where('ST_IsValid(geog::geometry)')
|
36
|
+
end
|
37
|
+
|
34
38
|
def envelope(buffer_in_meters = 0)
|
35
39
|
envelope_json = JSON.parse(self.class.select("ST_AsGeoJSON(ST_Envelope(ST_Buffer(features.geog, #{buffer_in_meters})::geometry)) AS result").where(:id => id).first.result)
|
36
40
|
envelope_json = envelope_json["coordinates"].first
|
@@ -43,7 +47,8 @@ class Feature < ActiveRecord::Base
|
|
43
47
|
def self.cache_derivatives(options = {})
|
44
48
|
options.reverse_merge! :lowres_simplification => 0.0001, :lowres_precision => 5
|
45
49
|
|
46
|
-
update_all("
|
50
|
+
update_all("area = ST_Area(geog),
|
51
|
+
geom = ST_Transform(geog::geometry, 26910),
|
47
52
|
geog_lowres = ST_SimplifyPreserveTopology(geog::geometry, #{options[:lowres_simplification]})"
|
48
53
|
.squish)
|
49
54
|
update_all("kml = ST_AsKML(features.geog, 6),
|
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.7
|
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-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|