geomodel 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,65 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Geomodel::Types' do
4
+ include Geomodel::Types
5
+
6
+ describe 'Point' do
7
+ it "can't be created with invalid latitude or longitude" do
8
+ expect { Geomodel::Types::Point.new(95, 0) }.to raise_error
9
+ expect { Geomodel::Types::Point.new(0, 185) }.to raise_error
10
+ end
11
+
12
+ it "can be created with valid latitude or longitude" do
13
+ point = Geomodel::Types::Point.new(37, -122)
14
+
15
+ expect(point.latitude).to eq(37)
16
+ expect(point.longitude).to eq(-122)
17
+ end
18
+
19
+ it "can be compared to another point" do
20
+ point_a = Geomodel::Types::Point.new(37, -122)
21
+ point_b = Geomodel::Types::Point.new(37, -122)
22
+ point_c = Geomodel::Types::Point.new(0, 0)
23
+
24
+ expect(point_a).to eq(point_b)
25
+ expect(point_a).to_not eq(point_c)
26
+ end
27
+
28
+ it "returns a suitable string representation" do
29
+ point = Geomodel::Types::Point.new(37, -122)
30
+
31
+ expect(point.to_s).to eq('(37, -122)')
32
+ end
33
+ end
34
+
35
+ describe 'Box' do
36
+
37
+ it "can't be created with invalid values" do
38
+ expect { Geomodel::Types::Box.new(95, 0, 0, 0) }.to raise_error
39
+ end
40
+
41
+ it "can be created with valid values" do
42
+ box = Geomodel::Types::Box.new(37, -122, 34, -125)
43
+
44
+ expect(box.north).to eq(37)
45
+ expect(box.south).to eq(34)
46
+ expect(box.east).to eq(-122)
47
+ expect(box.west).to eq(-125)
48
+ end
49
+
50
+ it "can be compared to another box" do
51
+ box_a = Geomodel::Types::Box.new(37, -122, 34, -125)
52
+ box_b = Geomodel::Types::Box.new(37, -122, 34, -125)
53
+
54
+ expect(box_a).to eq(box_b)
55
+ end
56
+
57
+ it "can be created with north below south" do
58
+ box = Geomodel::Types::Box.new(37, -122, 34, -125)
59
+
60
+ expect { box.north = 32 }.to raise_error
61
+ expect { box.south = 39 }.to raise_error
62
+ end
63
+
64
+ end
65
+ end
@@ -0,0 +1,24 @@
1
+ require 'simplecov'
2
+ require 'coveralls'
3
+ Coveralls.wear!
4
+
5
+ SimpleCov.command_name 'Unit Tests'
6
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
7
+ SimpleCov::Formatter::HTMLFormatter,
8
+ Coveralls::SimpleCov::Formatter
9
+ ]
10
+ SimpleCov.start
11
+
12
+ require 'rubygems'
13
+ require 'pry'
14
+
15
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
16
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
17
+
18
+ require 'geomodel'
19
+ require 'rspec'
20
+ require 'rspec/autorun'
21
+
22
+ RSpec.configure do |config|
23
+
24
+ end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Geomodel::Util' do
4
+
5
+ it 'can merge and sort one or many arrays into a target array' do
6
+ list1 = [0, 1, 5, 6, 8, 9, 15]
7
+ list2 = [0, 2, 3, 5, 8, 10, 11, 17]
8
+ list3 = [1, 4, 6, 8, 10, 15, 16]
9
+ list4 = [-1, 19]
10
+ list5 = [20]
11
+ list6 = []
12
+
13
+
14
+ Geomodel::Util.merge_in_place(list1, [list2, list3,
15
+ list4, list5, list6], lambda { |x| x })
16
+
17
+ expect(list1).to eq([-1, 0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 15, 16, 17, 19, 20])
18
+ end
19
+ end
metadata ADDED
@@ -0,0 +1,229 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: geomodel
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Brian Sam-Bodden
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-01-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: geocoder
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 1.1.9
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 1.1.9
27
+ - !ruby/object:Gem::Dependency
28
+ name: hashie
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 2.0.5
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 2.0.5
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: hashie
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: debugger
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: launchy
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: pry
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '>='
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '>='
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: coveralls
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - '>='
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - '>='
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ description: A Ruby implementation of the Geomodel concept
168
+ email:
169
+ - bsbodden@integrallis.com
170
+ executables: []
171
+ extensions: []
172
+ extra_rdoc_files: []
173
+ files:
174
+ - .gitignore
175
+ - .rspec
176
+ - .ruby-gemset
177
+ - .ruby-version
178
+ - .travis.yml
179
+ - CHANGELOG.md
180
+ - Gemfile
181
+ - LICENSE.txt
182
+ - README.md
183
+ - Rakefile
184
+ - geomodel.gemspec
185
+ - lib/geomodel.rb
186
+ - lib/geomodel/geocell.rb
187
+ - lib/geomodel/geomath.rb
188
+ - lib/geomodel/geotypes.rb
189
+ - lib/geomodel/util.rb
190
+ - lib/geomodel/version.rb
191
+ - spec/geocell_spec.rb
192
+ - spec/geomath_spec.rb
193
+ - spec/geomodel_spec.rb
194
+ - spec/geotypes_spec.rb
195
+ - spec/spec_helper.rb
196
+ - spec/util_spec.rb
197
+ homepage: https://github.com/integrallis/geomodel
198
+ licenses:
199
+ - MIT
200
+ metadata: {}
201
+ post_install_message:
202
+ rdoc_options: []
203
+ require_paths:
204
+ - lib
205
+ required_ruby_version: !ruby/object:Gem::Requirement
206
+ requirements:
207
+ - - '>='
208
+ - !ruby/object:Gem::Version
209
+ version: '0'
210
+ required_rubygems_version: !ruby/object:Gem::Requirement
211
+ requirements:
212
+ - - '>='
213
+ - !ruby/object:Gem::Version
214
+ version: '0'
215
+ requirements: []
216
+ rubyforge_project:
217
+ rubygems_version: 2.1.11
218
+ signing_key:
219
+ specification_version: 4
220
+ summary: Geomodel aims to provide a generalized solution for performing basic indexing and
221
+ querying of geospatial data in non-relation environments. At the core, this solution
222
+ utilizes geohash-like objects called geocells.
223
+ test_files:
224
+ - spec/geocell_spec.rb
225
+ - spec/geomath_spec.rb
226
+ - spec/geomodel_spec.rb
227
+ - spec/geotypes_spec.rb
228
+ - spec/spec_helper.rb
229
+ - spec/util_spec.rb