matryoshka_view 0.2.4 → 0.2.5

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: f44d84344c60d4c94323907e63d5ddeac87651ce
4
- data.tar.gz: 8cf78233e816dd675d63f640d0391d3dd93220d5
3
+ metadata.gz: d33a23d2731d7f0e30c137531229374426ed23db
4
+ data.tar.gz: 865d5642e89137fd3c8f429c49c22fe0470e07ef
5
5
  SHA512:
6
- metadata.gz: 1687c25e01224c0faad72ef30aa7fc0a4d40c0225a0a07c3e31081899dee9aa7024c691538871932b111f316cde4ba8e99680e45821994156e2784166c3c0770
7
- data.tar.gz: 779939e738edc87c4539f8656ea32a84acb968e1f1c6bf0668c3e8d054326768073510e76c92db4b1b2ec8645a586283c50ea35354f10104d9eddca2bd402cd0
6
+ metadata.gz: 742c33963dc21a4f1352f988bef0b64f314944c30bcead9547ca300c7435786127f3c6234481f6e85744ed1003171c9e7ed1d4ba89c4df4ca5f82b95536bcaaf
7
+ data.tar.gz: 6b1195721ad3cb1e16cbd5e8dd1c0de008058a680644cd080aea4513d3010d080e10246c2adcf298ba0d63374a61f21934e3cfe3a45a16b10ec4c086f763db31
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ 2015-05-12 / 0.2.5
2
+
3
+ * Enhancements
4
+
5
+ * Use geom_source.the_geom if geom_source has changed
6
+
1
7
  2014-10-19 / 0.2.4
2
8
 
3
9
  * Enhancements
@@ -47,9 +47,17 @@ class MatryoshkaView
47
47
  def lookup(geom_source: nil, the_geom_geojson: nil)
48
48
  # FIXME move to Record class method
49
49
  hit = if geom_source
50
- Record.where("the_geom && (SELECT the_geom FROM #{geom_source.class.quoted_table_name} WHERE id = #{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 = #{quote(geom_source.id)}))").order("ST_Area(the_geom, false) ASC").first
50
+ with_connection do |c|
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
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
55
+ end
56
+ end
51
57
  elsif the_geom_geojson
52
- Record.where("the_geom && ST_SetSRID(ST_GeomFromGeoJSON(#{quote(the_geom_geojson)}), 4326) AND ST_Contains(ST_Buffer(the_geom, 0.00001), ST_SetSRID(ST_GeomFromGeoJSON(#{quote(the_geom_geojson)}), 4326))").order("ST_Area(the_geom, false) ASC").first
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
53
61
  else
54
62
  raise "expecting geom_source or the_geom_geojson"
55
63
  end
@@ -1,3 +1,3 @@
1
1
  class MatryoshkaView
2
- VERSION = '0.2.4'
2
+ VERSION = '0.2.5'
3
3
  end
@@ -108,5 +108,17 @@ describe MatryoshkaView do
108
108
  it_behaves_like 'OK'
109
109
  end
110
110
 
111
+ describe 'with the_geom' do
112
+ let(:burlington) { world.spawn geom_source: place(:burlington) }
113
+ it "tells you what view to use inside boundaries (inclusive)" do
114
+ burlington
115
+ expect(world.lookup(geom_source: place(:burlington_point))).to eq(burlington)
116
+ end
117
+
118
+ it "falls back to original table outside boundaries" do
119
+ burlington
120
+ expect(world.lookup(geom_source: place(:montreal_canada))).to eq(world)
121
+ end
122
+ end
111
123
 
112
124
  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
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seamus Abshere
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-19 00:00:00.000000000 Z
11
+ date: 2015-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord