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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d33a23d2731d7f0e30c137531229374426ed23db
4
- data.tar.gz: 865d5642e89137fd3c8f429c49c22fe0470e07ef
3
+ metadata.gz: 0c855976ac7d5e8ef52a01986ce5a4343b086999
4
+ data.tar.gz: 0cff6196dca2f1358aed93334b8f8c2bdbc0103f
5
5
  SHA512:
6
- metadata.gz: 742c33963dc21a4f1352f988bef0b64f314944c30bcead9547ca300c7435786127f3c6234481f6e85744ed1003171c9e7ed1d4ba89c4df4ca5f82b95536bcaaf
7
- data.tar.gz: 6b1195721ad3cb1e16cbd5e8dd1c0de008058a680644cd080aea4513d3010d080e10246c2adcf298ba0d63374a61f21934e3cfe3a45a16b10ec4c086f763db31
6
+ metadata.gz: 6d1ee2c273696afbe48bbcbfc0ade125fc54fc5d0b9288b652cb860e7b2861c9de73756b274f950e300c8d149545a804ff7d76940bba66a57c2f1a0c47148064
7
+ data.tar.gz: c92678c5b41bb728f2df3b4248f3925ce17411e7d9a637736db15217925fb239e3c40e37f8d649a505e840fee90ad098e946ac80f6c78918e7005080f28c92a1
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ 2015-06-08 / 0.2.6
2
+
3
+ * Bug fixes
4
+
5
+ * Restrict lookup to the same base
6
+
1
7
  2015-05-12 / 0.2.5
2
8
 
3
9
  * Enhancements
@@ -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 = if geom_source
50
- with_connection do |c|
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
@@ -1,3 +1,3 @@
1
1
  class MatryoshkaView
2
- VERSION = '0.2.5'
2
+ VERSION = '0.2.6'
3
3
  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.5
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-05-12 00:00:00.000000000 Z
11
+ date: 2015-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord