spatial_features 1.5.11 → 1.5.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/feature.rb +13 -4
- data/lib/spatial_features/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73e929f19dbe88a8a660db9905520f65298ae749
|
4
|
+
data.tar.gz: ea15f17e06a0c28e3737acde7d102a8111e9624f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0bfdb3c23c67fd37602798cd56702d87ffb74bb56f1f56066620cec18d40be2e350f761e9442b4007faa3c79df4f09836857f4fa446ef27ed0ce9c0232a9de17
|
7
|
+
data.tar.gz: 8531be35e8009f784944d55d979c7450304141736d6f0805dbb21c844452da039b883177a9bd539aac47ff9ca814b6eb2f7ccc32fd263270798e286f448768f1
|
data/app/models/feature.rb
CHANGED
@@ -33,11 +33,16 @@ class Feature < ActiveRecord::Base
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def self.total_intersection_area_in_square_meters(other)
|
36
|
-
|
37
|
-
.where('ST_Intersects(features.geog_lowres, other_features.geog_lowres)')
|
38
|
-
.select('ST_Area(ST_Intersection(ST_Union(features.geog_lowres::geometry), ST_Union(other_features.geog_lowres::geometry))::geography) AS intersection_area_in_square_meters')
|
36
|
+
other_features = unscoped.flattened_features.where(:id => intersecting(other).select('other_features.id'))
|
39
37
|
|
40
|
-
|
38
|
+
unscoped
|
39
|
+
.from("(#{flattened_features.to_sql}) features, (#{other_features.to_sql}) other_features")
|
40
|
+
.pluck('ST_Area(ST_Intersection(features.geom, other_features.geom))')
|
41
|
+
.first.to_f
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.intersecting(other)
|
45
|
+
join_other_features(other).where('ST_Intersects(features.geog_lowres, other_features.geog_lowres)').uniq
|
41
46
|
end
|
42
47
|
|
43
48
|
def self.invalid
|
@@ -87,6 +92,10 @@ class Feature < ActiveRecord::Base
|
|
87
92
|
|
88
93
|
private
|
89
94
|
|
95
|
+
def self.flattened_features
|
96
|
+
select('ST_Union(features.geom) AS geom')
|
97
|
+
end
|
98
|
+
|
90
99
|
def self.detect_srid(column_name)
|
91
100
|
connection.select_value("SELECT Find_SRID('public', '#{table_name}', '#{column_name}')")
|
92
101
|
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.5.
|
4
|
+
version: 1.5.12
|
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: 2016-07-
|
12
|
+
date: 2016-07-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|