geospatial 1.4.1 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/geospatial/filter.rb +39 -1
- data/lib/geospatial/map.rb +3 -1
- data/lib/geospatial/version.rb +1 -1
- data/spec/geospatial/filter_spec.rb +9 -5
- data/spec/geospatial/polygon_spec.rb +7 -7
- metadata +2 -3
- data/.rspec_status +0 -57
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8fca3653194c4ff68cb7744f9a12e0744979555
|
4
|
+
data.tar.gz: 4f6c45c0aa46ef88e09277c5ff718dae23782de8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c8b33b7fd6e99e81bc3347b05b00eb01b553439ab8065a19e76caa28c1ed1eee753b7c926065f3f5df9f8ac9b55be03e70fc20d6182324c71570904ed5fc68b
|
7
|
+
data.tar.gz: e451c93b27e41bd5acbb8fc9e08d633ee6674694626d54f965b98b9b90f780efaeb1be89d12bca2b384a0c74a443e1f5a46eddc8970e461d6182cf18a93a022d
|
data/lib/geospatial/filter.rb
CHANGED
@@ -52,8 +52,9 @@ module Geospatial
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
-
def initialize
|
55
|
+
def initialize(curve)
|
56
56
|
@ranges = []
|
57
|
+
@curve = curve
|
57
58
|
end
|
58
59
|
|
59
60
|
attr :ranges
|
@@ -78,5 +79,42 @@ module Geospatial
|
|
78
79
|
def include?(point)
|
79
80
|
@ranges.any?{|range| range.include?(point.hash)}
|
80
81
|
end
|
82
|
+
|
83
|
+
def each(depth: 0)
|
84
|
+
# TODO using a range tree might allow a significantly improved implementation.
|
85
|
+
@curve.traverse do |child_origin, child_size, prefix, order|
|
86
|
+
child = Box.new(Vector.elements(child_origin), Vector.elements(child_size))
|
87
|
+
|
88
|
+
# puts "Considering (order=#{order}) #{child.inspect}..."
|
89
|
+
|
90
|
+
min = prefix
|
91
|
+
max = prefix | ((1 << (order*2)) - 1)
|
92
|
+
|
93
|
+
if min_range = find(min)
|
94
|
+
if order == depth # at bottom
|
95
|
+
yield(child, prefix, order); :skip
|
96
|
+
elsif min_range.include?(max)
|
97
|
+
# This range completely contains the current prefix/order
|
98
|
+
yield(child, prefix, order); :skip
|
99
|
+
else
|
100
|
+
# go deeper
|
101
|
+
end
|
102
|
+
elsif max_range = find(max)
|
103
|
+
if order == depth # at bottom
|
104
|
+
yield(child, prefix, order); :skip
|
105
|
+
else
|
106
|
+
# go deeper
|
107
|
+
end
|
108
|
+
elsif sub_range = @ranges.find{|range| range.min >= min && range.max <= max}
|
109
|
+
# go deeper
|
110
|
+
else
|
111
|
+
:skip # out of bounds
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
def find(hash)
|
117
|
+
@ranges.find{|range| range.include?(hash)}
|
118
|
+
end
|
81
119
|
end
|
82
120
|
end
|
data/lib/geospatial/map.rb
CHANGED
@@ -67,6 +67,8 @@ module Geospatial
|
|
67
67
|
@bounds = nil
|
68
68
|
end
|
69
69
|
|
70
|
+
attr :curve
|
71
|
+
|
70
72
|
def order
|
71
73
|
@curve.order
|
72
74
|
end
|
@@ -144,7 +146,7 @@ module Geospatial
|
|
144
146
|
end
|
145
147
|
|
146
148
|
def filter_for(region, **options)
|
147
|
-
filter = Filter.new
|
149
|
+
filter = Filter.new(@curve)
|
148
150
|
|
149
151
|
# The filter will coalesce sequential segments of the curve into a single range.
|
150
152
|
traverse(region, **options) do |child, prefix, order|
|
data/lib/geospatial/version.rb
CHANGED
@@ -8,13 +8,17 @@ RSpec.describe Geospatial::Map.for_earth(30) do
|
|
8
8
|
let(:ranges) {[[888899773526966272, 888899773560520703], [888899773912842240, 888899775322128383], [888899775355682816, 888899775389237247], [888899775422791680, 888899775573786623], [888899775708004352, 888899776311984127], [888899776932741120, 888899776966295551], [888899776999849984, 888899777050181631], [888899781680693248, 888899782217564159], [888899782754435072, 888899783291305983], [888899787317837824, 888899788123144191], [888899788660015104, 888899816141094911], [888899816157872128, 888899816191426559], [888899816224980992, 888899816392753151], [888899816426307584, 888899816443084799], [888899816510193664, 888899817181282303], [888899817349054464, 888899817416163327], [888899817617489920, 888899817634267135], [888899817651044352, 888899821224591359], [888899821342031872, 888899821509804031], [888899822516436992, 888899822717763583], [888899822751318016, 888899823019753471], [888900520767389696, 888900520800944127], [888900520834498560, 888900520868052991], [888900521572696064, 888900521690136575], [888900521824354304, 888900521992126463], [888900525599227904, 888900525632782335], [888900525666336768, 888900525699891199], [888900525917995008, 888900526874296319], [888900527411167232, 888900527444721663], [888900527461498880, 888900580964040703], [888900581031149568, 888900581064703999], [888900581098258432, 888900581349916671], [888900582843088896, 888900582876643327], [888900583044415488, 888900583077969919], [888900583111524352, 888900583161855999], [888900584051048448, 888900584084602879], [888900584134934528, 888900584369815551], [888900584504033280, 888900587154833407], [888900587171610624, 888900587255496703], [888900587624595456, 888900587641372671], [888900587674927104, 888900587708481535], [888900587876253696, 888900587909808127], [888900587926585344, 888900587993694207], [888900588161466368, 888900588178243583], [888900588195020800, 888900591718236159], [888900591768567808, 888900591802122239], [888900591818899456, 888900593093967871], [888900593110745088, 888900593127522303], [888900593244962816, 888900593261740031], [888900593983160320, 888900594016714751], [888900594100600832, 888900594117378047], [888900594134155264, 888900594503254015], [888900594520031232, 888900594536808447], [888900594704580608, 888900594721357823], [888900594738135040, 888900594855575551], [888900594872352768, 888900623544614911], [888900623678832640, 888900633426395135], [888900633795493888, 888900633812271103], [888900633845825536, 888900633879379967], [888900634214924288, 888900634483359743], [888900634567245824, 888900634634354687], [888900634651131904, 888900634667909119], [888900636110749696, 888900636161081343], [888900636244967424, 888900636261744639], [888900636278521856, 888900636882501631], [888900636999942144, 888900637016719359], [888900637520035840, 888900637570367487], [888900644365139968, 888900644381917183], [888900644415471616, 888900644499357695], [888900644549689344, 888900645757648895], [888900645791203328, 888900645807980543], [888900645942198272, 888900646328074239], [888900646344851456, 888900646512623615], [888900649347973120, 888900649364750335], [888900677651136512, 888900677667913727], [888900677701468160, 888900677751799807], [888900677953126400, 888900677969903615], [888912854286073856, 888912854420291583], [888912854621618176, 888912858111279103], [888912858195165184, 888912858228719615], [888912858279051264, 888912858480377855], [888912858530709504, 888912858564263935], [888912858614595584, 888912859487010815], [888912859537342464, 888912859570896895], [888912859621228544, 888912859822555135], [888912859856109568, 888912877103087615], [888912877237305344, 888912877371523071], [888912877505740800, 888912878143275007], [888912878344601600, 888912878411710463], [888912878713700352, 888912878881472511], [888912878931804160, 888912878965358591], [888912879015690240, 888912879888105471], [888912879904882688, 888912879988768767], [888912885978234880, 888912886011789311], [888912886045343744, 888912886078898175], [888912886783541248, 888912886817095679], [888912886850650112, 888912886900981759], [888912887035199488, 888912887169417215], [888912891162394624, 888912891179171839], [888912891263057920, 888912891967700991], [888912892018032640, 888912892051587071], [888912892638789632, 888912892655566847], [888912892705898496, 888912901815926783], [888912901849481216, 888912901883035647], [888912901916590080, 888912902067585023], [888912902201802752, 888912903090995199], [888912903124549632, 888912903174881279], [888912903426539520, 888912903460093951], [888912903476871168, 888912903543980031], [888912906849091584, 888912906882646015], [888912906916200448, 888912909013352447], [888912909214679040, 888912909265010687], [888912909298565120, 888912909315342335], [888912910405861376, 888912910523301887], [888912910657519616, 888912910791737343], [888912911680929792, 888912911714484223], [888912911731261440, 888912912016474111], [888912912050028544, 888912912083582975], [888912912117137408, 888913026034434047], [888913026051211264, 888913026151874559], [888913026168651776, 888913026185428991], [888913026789408768, 888913026906849279], [888913026923626496, 888913027913482239], [888913027930259456, 888913028098031615], [888913028114808832, 888913028131586047], [888913028433575936, 888913028450353151], [888913028483907584, 888913028567793663], [888913028584570880, 888913028601348095], [888913037912702976, 888913037929480191], [888913038550237184, 888913038718009343], [888913038734786560, 888913039993077759], [888913040009854976, 888913040177627135], [888913040446062592, 888913040462839807], [888913040496394240, 888913040597057535], [888913040613834752, 888913056082427903], [888913056115982336, 888913056266977279], [888913056602521600, 888913056686407679], [888913056719962112, 888913059202990079], [888913059622420480, 888913059689529343], [888913713212424192, 888913713413750783], [888913713430528000, 888913713447305215], [888913713682186240, 888913713698963455], [888913713715740672, 888913716366540799], [888913716383318016, 888913716416872447], [888913716685307904, 888913716718862335], [888913716735639552, 888913716836302847], [888913716853080064, 888913716869857279], [888913720711839744, 888913720745394175], [888913720762171392, 888913720896389119], [888913721282265088, 888913721299042303], [888913721466814464, 888913721483591679], [888913721500368896, 888913723110981631], [888913723329085440, 888913756464087039], [888913756665413632, 888913756732522495], [888913756933849088, 888913757772709887], [888913761698578432, 888913761748910079], [888913761782464512, 888913762352889855], [888913762386444288, 888913762436775935], [888913762772320256, 888913762822651903], [888913762856206336, 888913763393077247], [888913763460186112, 888913763510517759], [888913769013444608, 888913769231548415], [888913769265102848, 888913769281880063], [888913769583869952, 888913769617424383], [888913769785196544, 888913771177705471], [888913771446140928, 888913771647467519]]}
|
9
9
|
|
10
10
|
it "can generate visualisation" do
|
11
|
+
filter = Geospatial::Filter.new(subject.curve)
|
12
|
+
|
13
|
+
ranges.each do |min, max|
|
14
|
+
filter.ranges << (min..max)
|
15
|
+
end
|
16
|
+
|
11
17
|
Geospatial::Visualization.for_map(subject) do |pdf, origin|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
size = (b - a).collect(&:abs)
|
18
|
+
filter.each do |child, prefix, order|
|
19
|
+
size = child.size
|
20
|
+
top_left = origin + child.origin + Vector[0, size[1]]
|
16
21
|
|
17
|
-
top_left = origin + a + Vector[0, size[1]]
|
18
22
|
pdf.rectangle(top_left.to_a, *size.to_a)
|
19
23
|
end
|
20
24
|
|
@@ -25,13 +25,13 @@ require_relative 'visualization'
|
|
25
25
|
RSpec.shared_context "kaikoura region" do
|
26
26
|
let(:region) do
|
27
27
|
Geospatial::Polygon[
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
28
|
+
Vector[173.7218528654108, -42.32817252073923],
|
29
|
+
Vector[173.6307775307161, -42.32729039137249],
|
30
|
+
Vector[173.5400659958715, -42.39758413896335],
|
31
|
+
Vector[173.5446498680837, -42.43847509799515],
|
32
|
+
Vector[173.6833471779081, -42.44870319335309],
|
33
|
+
Vector[173.7608096128163, -42.42144813099029],
|
34
|
+
Vector[173.7218528654108, -42.32817252073923],
|
35
35
|
]
|
36
36
|
end
|
37
37
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geospatial
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -61,7 +61,6 @@ extra_rdoc_files: []
|
|
61
61
|
files:
|
62
62
|
- ".gitignore"
|
63
63
|
- ".rspec"
|
64
|
-
- ".rspec_status"
|
65
64
|
- ".simplecov"
|
66
65
|
- ".travis.yml"
|
67
66
|
- Gemfile
|
data/.rspec_status
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
example_id | status | run_time |
|
2
|
-
----------------------------------------------- | ------ | --------------- |
|
3
|
-
./spec/geospatial/box_spec.rb[1:1] | passed | 0.00096 seconds |
|
4
|
-
./spec/geospatial/circle_spec.rb[1:1] | passed | 0.00011 seconds |
|
5
|
-
./spec/geospatial/circle_spec.rb[1:2] | passed | 0.0001 seconds |
|
6
|
-
./spec/geospatial/circle_spec.rb[1:3] | passed | 0.00009 seconds |
|
7
|
-
./spec/geospatial/circle_spec.rb[1:4] | passed | 0.00008 seconds |
|
8
|
-
./spec/geospatial/circle_spec.rb[1:5] | passed | 0.40939 seconds |
|
9
|
-
./spec/geospatial/dimensions_spec.rb[1:1] | passed | 0.0001 seconds |
|
10
|
-
./spec/geospatial/dimensions_spec.rb[1:2] | passed | 0.00006 seconds |
|
11
|
-
./spec/geospatial/distance_spec.rb[1:1] | passed | 0.00005 seconds |
|
12
|
-
./spec/geospatial/distance_spec.rb[1:2] | passed | 0.00005 seconds |
|
13
|
-
./spec/geospatial/distance_spec.rb[1:3] | passed | 0.00005 seconds |
|
14
|
-
./spec/geospatial/distance_spec.rb[1:4] | passed | 0.00005 seconds |
|
15
|
-
./spec/geospatial/distance_spec.rb[1:5] | passed | 0.00004 seconds |
|
16
|
-
./spec/geospatial/distance_spec.rb[1:6] | passed | 0.00006 seconds |
|
17
|
-
./spec/geospatial/distance_spec.rb[1:7] | passed | 0.00007 seconds |
|
18
|
-
./spec/geospatial/filter_spec.rb[1:1] | passed | 0.4025 seconds |
|
19
|
-
./spec/geospatial/filter_spec.rb[1:2] | passed | 0.14153 seconds |
|
20
|
-
./spec/geospatial/hilbert_curve_spec.rb[1:1:1] | passed | 0.00041 seconds |
|
21
|
-
./spec/geospatial/hilbert_curve_spec.rb[1:2:1] | passed | 0.00009 seconds |
|
22
|
-
./spec/geospatial/hilbert_curve_spec.rb[1:3:1] | passed | 0.00007 seconds |
|
23
|
-
./spec/geospatial/hilbert_curve_spec.rb[1:4:1] | passed | 0.00007 seconds |
|
24
|
-
./spec/geospatial/hilbert_curve_spec.rb[2:1:1] | passed | 0.00007 seconds |
|
25
|
-
./spec/geospatial/hilbert_curve_spec.rb[2:2:1] | passed | 0.00007 seconds |
|
26
|
-
./spec/geospatial/hilbert_curve_spec.rb[2:3:1] | passed | 0.00007 seconds |
|
27
|
-
./spec/geospatial/hilbert_curve_spec.rb[2:4:1] | passed | 0.00007 seconds |
|
28
|
-
./spec/geospatial/hilbert_curve_spec.rb[3:1:1] | passed | 0.00009 seconds |
|
29
|
-
./spec/geospatial/hilbert_curve_spec.rb[3:2:1] | passed | 0.00011 seconds |
|
30
|
-
./spec/geospatial/hilbert_curve_spec.rb[3:3:1] | passed | 0.0001 seconds |
|
31
|
-
./spec/geospatial/hilbert_curve_spec.rb[3:4:1] | passed | 0.00011 seconds |
|
32
|
-
./spec/geospatial/hilbert_traverse_spec.rb[1:1] | passed | 0.00025 seconds |
|
33
|
-
./spec/geospatial/hilbert_traverse_spec.rb[2:1] | passed | 0.00384 seconds |
|
34
|
-
./spec/geospatial/index_spec.rb[1:1:1] | passed | 0.00008 seconds |
|
35
|
-
./spec/geospatial/index_spec.rb[1:1:2] | passed | 0.00008 seconds |
|
36
|
-
./spec/geospatial/index_spec.rb[2:1:1] | passed | 0.00012 seconds |
|
37
|
-
./spec/geospatial/index_spec.rb[2:1:2] | passed | 0.00009 seconds |
|
38
|
-
./spec/geospatial/index_spec.rb[3:1:1] | passed | 0.00014 seconds |
|
39
|
-
./spec/geospatial/index_spec.rb[3:1:2] | passed | 0.00014 seconds |
|
40
|
-
./spec/geospatial/location_spec.rb[1:1] | passed | 0.00006 seconds |
|
41
|
-
./spec/geospatial/location_spec.rb[1:2] | passed | 0.00006 seconds |
|
42
|
-
./spec/geospatial/location_spec.rb[2:1] | passed | 0.00006 seconds |
|
43
|
-
./spec/geospatial/map_index_spec.rb[1:1] | passed | 0.00009 seconds |
|
44
|
-
./spec/geospatial/map_index_spec.rb[1:2] | passed | 0.00011 seconds |
|
45
|
-
./spec/geospatial/map_spec.rb[1:1] | passed | 0.45715 seconds |
|
46
|
-
./spec/geospatial/map_spec.rb[1:2] | passed | 0.00018 seconds |
|
47
|
-
./spec/geospatial/map_spec.rb[1:3] | passed | 0.01971 seconds |
|
48
|
-
./spec/geospatial/polygon_spec.rb[1:1] | passed | 0.00007 seconds |
|
49
|
-
./spec/geospatial/polygon_spec.rb[1:2] | passed | 0.00011 seconds |
|
50
|
-
./spec/geospatial/polygon_spec.rb[1:3] | passed | 0.00006 seconds |
|
51
|
-
./spec/geospatial/polygon_spec.rb[1:4] | passed | 0.00007 seconds |
|
52
|
-
./spec/geospatial/polygon_spec.rb[2:1] | passed | 2.09 seconds |
|
53
|
-
./spec/geospatial/polygon_spec.rb[2:2] | passed | 2.09 seconds |
|
54
|
-
./spec/geospatial/polygon_spec.rb[3:1] | passed | 0.14057 seconds |
|
55
|
-
./spec/geospatial/polygon_spec.rb[3:2] | passed | 0.55125 seconds |
|
56
|
-
./spec/geospatial/polygon_spec.rb[4:1] | passed | 0.54482 seconds |
|
57
|
-
./spec/geospatial/polygon_spec.rb[5:1] | passed | 0.48422 seconds |
|