matryoshka_view 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +6 -0
- data/lib/matryoshka_view.rb +8 -10
- data/lib/matryoshka_view/version.rb +1 -1
- data/spec/matryoshka_view_spec.rb +6 -0
- 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: 0c855976ac7d5e8ef52a01986ce5a4343b086999
|
4
|
+
data.tar.gz: 0cff6196dca2f1358aed93334b8f8c2bdbc0103f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d1ee2c273696afbe48bbcbfc0ade125fc54fc5d0b9288b652cb860e7b2861c9de73756b274f950e300c8d149545a804ff7d76940bba66a57c2f1a0c47148064
|
7
|
+
data.tar.gz: c92678c5b41bb728f2df3b4248f3925ce17411e7d9a637736db15217925fb239e3c40e37f8d649a505e840fee90ad098e946ac80f6c78918e7005080f28c92a1
|
data/CHANGELOG
CHANGED
data/lib/matryoshka_view.rb
CHANGED
@@ -46,20 +46,18 @@ class MatryoshkaView
|
|
46
46
|
|
47
47
|
def lookup(geom_source: nil, the_geom_geojson: nil)
|
48
48
|
# FIXME move to Record class method
|
49
|
-
hit =
|
50
|
-
|
49
|
+
hit = with_connection do |c|
|
50
|
+
if geom_source
|
51
51
|
if geom_source.changed?
|
52
|
-
Record.where("(the_geom && #{c.quote geom_source.the_geom}) AND ST_Contains(ST_Buffer(the_geom, 0.00001), #{c.quote geom_source.the_geom})").order("ST_Area(the_geom, false) ASC").first
|
52
|
+
Record.where("(base = #{c.quote base}) AND (the_geom && #{c.quote geom_source.the_geom}) AND ST_Contains(ST_Buffer(the_geom, 0.00001), #{c.quote geom_source.the_geom})").order("ST_Area(the_geom, false) ASC").first
|
53
53
|
else
|
54
|
-
Record.where("(the_geom && (SELECT the_geom FROM #{geom_source.class.quoted_table_name} WHERE id = #{c.quote(geom_source.id)})) AND ST_Contains(ST_Buffer(the_geom, 0.00001), (SELECT the_geom FROM #{geom_source.class.quoted_table_name} WHERE id = #{c.quote(geom_source.id)}))").order("ST_Area(the_geom, false) ASC").first
|
54
|
+
Record.where("(base = #{c.quote base}) AND (the_geom && (SELECT the_geom FROM #{geom_source.class.quoted_table_name} WHERE id = #{c.quote(geom_source.id)})) AND ST_Contains(ST_Buffer(the_geom, 0.00001), (SELECT the_geom FROM #{geom_source.class.quoted_table_name} WHERE id = #{c.quote(geom_source.id)}))").order("ST_Area(the_geom, false) ASC").first
|
55
55
|
end
|
56
|
+
elsif the_geom_geojson
|
57
|
+
Record.where("(base = #{c.quote base}) AND (the_geom && ST_SetSRID(ST_GeomFromGeoJSON(#{c.quote the_geom_geojson}), 4326)) AND ST_Contains(ST_Buffer(the_geom, 0.00001), ST_SetSRID(ST_GeomFromGeoJSON(#{c.quote the_geom_geojson}), 4326))").order("ST_Area(the_geom, false) ASC").first
|
58
|
+
else
|
59
|
+
raise "expecting geom_source or the_geom_geojson"
|
56
60
|
end
|
57
|
-
elsif the_geom_geojson
|
58
|
-
with_connection do |c|
|
59
|
-
Record.where("the_geom && ST_SetSRID(ST_GeomFromGeoJSON(#{c.quote the_geom_geojson}), 4326) AND ST_Contains(ST_Buffer(the_geom, 0.00001), ST_SetSRID(ST_GeomFromGeoJSON(#{c.quote the_geom_geojson}), 4326))").order("ST_Area(the_geom, false) ASC").first
|
60
|
-
end
|
61
|
-
else
|
62
|
-
raise "expecting geom_source or the_geom_geojson"
|
63
61
|
end
|
64
62
|
hit.try(:view) || self
|
65
63
|
end
|
@@ -119,6 +119,12 @@ describe MatryoshkaView do
|
|
119
119
|
burlington
|
120
120
|
expect(world.lookup(geom_source: place(:montreal_canada))).to eq(world)
|
121
121
|
end
|
122
|
+
|
123
|
+
it "doesn't confuse bases" do
|
124
|
+
other_world = MatryoshkaView.new(base: 'gibberish')
|
125
|
+
burlington
|
126
|
+
expect(other_world.lookup(geom_source: place(:burlington_point))).to eq(other_world)
|
127
|
+
end
|
122
128
|
end
|
123
129
|
|
124
130
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: matryoshka_view
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Seamus Abshere
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|