matryoshka_view 0.2.3 → 0.2.4

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: f9abe733adeec7a0d632b300437a8c83682915b6
4
- data.tar.gz: 4d8cd1d651217606ac0530d673053eae7ec0ab70
3
+ metadata.gz: f44d84344c60d4c94323907e63d5ddeac87651ce
4
+ data.tar.gz: 8cf78233e816dd675d63f640d0391d3dd93220d5
5
5
  SHA512:
6
- metadata.gz: fb4f27953d68e3d8017889afa92ea2bb1c8865b0fdfcce5b084b5d70477ea975bf522b532c450446020efc41c45f705c6e534ad0870213478d7bc0197cf25d46
7
- data.tar.gz: 05fbc48cbeeb69736d5fdb8f7ef1554b495e144c9b3d9bca7cac3d50ea8716c7055b57ccbea787a7f0988ffb7d6cd290965c1487b4091feb712c507d88d531db
6
+ metadata.gz: 1687c25e01224c0faad72ef30aa7fc0a4d40c0225a0a07c3e31081899dee9aa7024c691538871932b111f316cde4ba8e99680e45821994156e2784166c3c0770
7
+ data.tar.gz: 779939e738edc87c4539f8656ea32a84acb968e1f1c6bf0668c3e8d054326768073510e76c92db4b1b2ec8645a586283c50ea35354f10104d9eddca2bd402cd0
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ 2014-10-19 / 0.2.4
2
+
3
+ * Enhancements
4
+
5
+ * Faster - no need for ST_Expand with &&
6
+
1
7
  2014-10-12 / 0.2.3
2
8
 
3
9
  * Enhancements
@@ -1,3 +1,3 @@
1
1
  class MatryoshkaView
2
- VERSION = '0.2.3'
2
+ VERSION = '0.2.4'
3
3
  end
@@ -47,9 +47,9 @@ 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("ST_Expand(the_geom, 0.00001) && (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
+ 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
51
51
  elsif the_geom_geojson
52
- Record.where("ST_Expand(the_geom, 0.00001) && 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
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
53
53
  else
54
54
  raise "expecting geom_source or the_geom_geojson"
55
55
  end
@@ -28,5 +28,5 @@ Gem::Specification.new do |spec|
28
28
  spec.add_development_dependency "pry"
29
29
  spec.add_development_dependency "rake", "~> 10.0"
30
30
  spec.add_development_dependency "rspec"
31
- spec.add_development_dependency "the_geom_geojson"
31
+ spec.add_development_dependency "the_geom_geojson", '>=0.0.5'
32
32
  end
@@ -22,7 +22,7 @@ describe MatryoshkaView do
22
22
 
23
23
  it "doesn't auto-create anything" do
24
24
  expect(world.lookup(the_geom_geojson: geojson(:burlington_point))).to eq(world)
25
- expect(world.lookup(the_geom_geojson: geojson(:barre_point))).to eq(world)
25
+ expect(world.lookup(the_geom_geojson: geojson(:montpelier_point))).to eq(world)
26
26
  end
27
27
 
28
28
  it "helps you spawn inner views given geojson" do
@@ -46,7 +46,7 @@ describe MatryoshkaView do
46
46
  end
47
47
 
48
48
  it "falls back to original table outside boundaries" do
49
- expect(world.lookup(the_geom_geojson: geojson(:montreal))).to eq(world)
49
+ expect(world.lookup(the_geom_geojson: geojson(:montreal_canada))).to eq(world)
50
50
  end
51
51
 
52
52
  xit "doesn't confuse bases" do
@@ -57,16 +57,16 @@ describe MatryoshkaView do
57
57
  describe "non-overlapping matryoshka views" do
58
58
  before do
59
59
  south_burlington
60
- downtown_burlington
60
+ burlington_downtown
61
61
  end
62
62
 
63
63
  it "chooses the right view" do
64
64
  expect(world.lookup(the_geom_geojson: geojson(:south_burlington_point))).to eq(south_burlington)
65
- expect(world.lookup(the_geom_geojson: geojson(:downtown_burlington_point))).to eq(downtown_burlington)
65
+ expect(world.lookup(the_geom_geojson: geojson(:burlington_downtown_point))).to eq(burlington_downtown)
66
66
  end
67
67
 
68
68
  it "falls back to original table outside boundaries" do
69
- expect(world.lookup(the_geom_geojson: geojson(:montreal))).to eq(world)
69
+ expect(world.lookup(the_geom_geojson: geojson(:montreal_canada))).to eq(world)
70
70
  end
71
71
  end
72
72
 
@@ -95,7 +95,7 @@ describe MatryoshkaView do
95
95
  describe 'with the_geom_geojson' do
96
96
  let(:burlington) { world.spawn the_geom_geojson: geojson(:burlington) }
97
97
  let(:south_burlington) { world.spawn the_geom_geojson: geojson(:south_burlington) }
98
- let(:downtown_burlington) { world.spawn the_geom_geojson: geojson(:downtown_burlington) }
98
+ let(:burlington_downtown) { world.spawn the_geom_geojson: geojson(:burlington_downtown) }
99
99
 
100
100
  it_behaves_like 'OK'
101
101
  end
@@ -103,7 +103,7 @@ describe MatryoshkaView do
103
103
  describe 'with geom_source' do
104
104
  let(:burlington) { world.spawn geom_source: place(:burlington) }
105
105
  let(:south_burlington) { world.spawn geom_source: place(:south_burlington) }
106
- let(:downtown_burlington) { world.spawn geom_source: place(:downtown_burlington) }
106
+ let(:burlington_downtown) { world.spawn geom_source: place(:burlington_downtown) }
107
107
 
108
108
  it_behaves_like 'OK'
109
109
  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.3
4
+ version: 0.2.4
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-12 00:00:00.000000000 Z
11
+ date: 2014-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -142,14 +142,14 @@ dependencies:
142
142
  requirements:
143
143
  - - ">="
144
144
  - !ruby/object:Gem::Version
145
- version: '0'
145
+ version: 0.0.5
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - ">="
151
151
  - !ruby/object:Gem::Version
152
- version: '0'
152
+ version: 0.0.5
153
153
  description: Helps you spawn new inner views and lookup the right one.
154
154
  email:
155
155
  - seamus@abshere.net
@@ -199,3 +199,4 @@ summary: Maintains a list of inner (subset/nested) views and their geometic boun
199
199
  test_files:
200
200
  - spec/matryoshka_view_spec.rb
201
201
  - spec/spec_helper.rb
202
+ has_rdoc: