spatial_features 1.0.1 → 1.0.2
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: 2502710a77234436e9df31b696307aec48406c4c
|
4
|
+
data.tar.gz: 256709db267694b3313f8b848f4b8273e0d1ae40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: def0c22906ea9400a2b5985e53af034bb83b23f1d554cedc1400e0ca3e39265ea7900c8f10366d44bf1a2f29a26fe879f5230a3b06638ef1157faf61cc8f745d
|
7
|
+
data.tar.gz: cdf4ca117eee31b4885fda6a1267b1284ebaed3efbc29202ceeacaef2e679c49e079c203df09af6af1446c201f9e9d7d86cc23ce84a439dd3489046d83645298
|
@@ -14,7 +14,7 @@ module SpatialExtensions
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def abstract_venn_polygons_action(scope, target, &block)
|
17
|
-
@venn_polygons = SpatialFeatures.venn_polygons(scope_for_search(scope).intersecting(target), target.class.where(:id => target), :
|
17
|
+
@venn_polygons = SpatialFeatures.venn_polygons(scope_for_search(scope).intersecting(target), target.class.where(:id => target), :target => target)
|
18
18
|
@klass = klass_for_search(scope)
|
19
19
|
@target = target
|
20
20
|
|
@@ -32,4 +32,4 @@ module SpatialExtensions
|
|
32
32
|
def scope_for_search(scope)
|
33
33
|
params.key?(:ids) ? scope.where(:id => params[:ids]) : scope
|
34
34
|
end
|
35
|
-
end
|
35
|
+
end
|
@@ -3,13 +3,12 @@ module SpatialFeatures
|
|
3
3
|
# with kml for the overlapping area and a list of the record ids whose kml overlapped within that area
|
4
4
|
def self.venn_polygons(*scopes)
|
5
5
|
options = scopes.extract_options!
|
6
|
-
column = options[:simplified] ? 'geog_lowres' : 'geog'
|
7
6
|
scope = scopes.collect do |scope|
|
8
|
-
scope.klass.from(scope, scope.klass.table_name).joins(:features).where('features.feature_type = ?', 'polygon').select("features
|
7
|
+
scope.klass.from(scope, scope.klass.table_name).joins(:features).where('features.feature_type = ?', 'polygon').select("features.geom AS the_geom").to_sql
|
9
8
|
end.join(' UNION ')
|
10
9
|
|
11
10
|
sql = "
|
12
|
-
SELECT scope.id, scope.type, ST_AsKML(geom) AS kml FROM ST_Dump((
|
11
|
+
SELECT scope.id, scope.type, ST_AsKML(venn_polygons.geom) AS kml FROM ST_Dump((
|
13
12
|
SELECT ST_Polygonize(the_geom) AS the_geom FROM (
|
14
13
|
|
15
14
|
SELECT ST_Union(the_geom) AS the_geom FROM (
|
@@ -26,13 +25,20 @@ module SpatialFeatures
|
|
26
25
|
)) AS venn_polygons
|
27
26
|
"
|
28
27
|
|
28
|
+
# If we have a target model, throw away all venn_polygons not bounded by the target
|
29
|
+
if options[:target]
|
30
|
+
sql <<
|
31
|
+
"INNER JOIN features
|
32
|
+
ON features.spatial_model_type = '#{options[:target].class}' AND features.spatial_model_id = #{options[:target].id} AND ST_Intersects(features.geom, venn_polygons.geom)"
|
33
|
+
end
|
34
|
+
|
29
35
|
# Join with the original polygons so we can determine which original polygons each venn polygon came from
|
30
36
|
scope = scopes.collect do |scope|
|
31
|
-
scope.klass.from(scope, scope.klass.table_name).joins(:features).where('features.feature_type = ?', 'polygon').select("#{scope.klass.table_name}.id, features.spatial_model_type AS type, features
|
37
|
+
scope.klass.from(scope, scope.klass.table_name).joins(:features).where('features.feature_type = ?', 'polygon').select("#{scope.klass.table_name}.id, features.spatial_model_type AS type, features.geom").to_sql
|
32
38
|
end.join(' UNION ')
|
33
39
|
sql <<
|
34
40
|
"INNER JOIN (#{scope}) AS scope
|
35
|
-
ON ST_Covers(scope
|
41
|
+
ON ST_Covers(scope.geom, ST_PointOnSurface(venn_polygons.geom)) -- Shrink the venn polygons so they don't share edges with the original polygons which could cause varying results due to tiny inaccuracy"
|
36
42
|
|
37
43
|
# Eager load the records for each venn polygon
|
38
44
|
eager_load_hash = Hash.new {|hash, key| hash[key] = []}
|
@@ -53,4 +59,4 @@ module SpatialFeatures
|
|
53
59
|
OpenStruct.new(:kml => kml, :records => records)
|
54
60
|
end
|
55
61
|
end
|
56
|
-
end
|
62
|
+
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.0.
|
4
|
+
version: 1.0.2
|
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:
|
12
|
+
date: 2015-01-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -117,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
117
|
version: '0'
|
118
118
|
requirements: []
|
119
119
|
rubyforge_project:
|
120
|
-
rubygems_version: 2.
|
120
|
+
rubygems_version: 2.2.2
|
121
121
|
signing_key:
|
122
122
|
specification_version: 4
|
123
123
|
summary: Adds spatial methods to a model.
|