mongoid-geospatial 4.0.1 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/README.md +126 -242
- data/bench/bench +11 -10
- data/lib/mongoid/geospatial.rb +14 -17
- data/lib/mongoid/geospatial/fields/point.rb +42 -10
- data/lib/mongoid/geospatial/geometry_field.rb +25 -2
- data/lib/mongoid/geospatial/helpers/delegate.rb +6 -2
- data/lib/mongoid/geospatial/version.rb +1 -1
- data/lib/mongoid/geospatial/wrappers/georuby.rb +4 -0
- data/lib/mongoid/geospatial/wrappers/rgeo.rb +4 -1
- data/mongoid-geospatial.gemspec +2 -2
- data/spec/models/bar.rb +1 -1
- data/spec/models/farm.rb +1 -1
- data/spec/models/person.rb +2 -1
- data/spec/models/river.rb +7 -7
- data/spec/mongoid/geospatial/fields/line_string_spec.rb +44 -8
- data/spec/mongoid/geospatial/fields/point_spec.rb +30 -28
- data/spec/mongoid/geospatial/fields/polygon_spec.rb +25 -18
- data/spec/mongoid/geospatial/geospatial_spec.rb +65 -49
- data/spec/mongoid/geospatial/helpers/core_spec.rb +8 -3
- data/spec/mongoid/geospatial/helpers/delegate_spec.rb +18 -1
- data/spec/mongoid/geospatial/helpers/spatial_spec.rb +9 -1
- data/spec/mongoid/geospatial/helpers/sphere_spec.rb +10 -1
- data/spec/mongoid/geospatial/wrappers/rgeo_spec.rb +4 -2
- data/spec/spec_helper.rb +7 -3
- metadata +5 -5
@@ -7,7 +7,15 @@ describe Mongoid::Fields do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
it 'should created indexes' do
|
10
|
-
expect(Bar.collection.indexes
|
10
|
+
expect(Bar.collection.indexes.get(location: '2d')).not_to be_nil
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should create correct indexes' do
|
14
|
+
expect(Bar.collection.indexes.get(location: '2d'))
|
15
|
+
.to eq('key' => { 'location' => '2d' },
|
16
|
+
'name' => 'location_2d',
|
17
|
+
'ns' => 'mongoid_geo_test.bars',
|
18
|
+
'v' => 1)
|
11
19
|
end
|
12
20
|
|
13
21
|
it 'should set spatial fields' do
|
@@ -7,7 +7,16 @@ describe Mongoid::Fields do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
it 'should created indexes' do
|
10
|
-
expect(Alarm.collection.indexes
|
10
|
+
expect(Alarm.collection.indexes.get(spot: '2dsphere')).not_to be_nil
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should create correct indexes' do
|
14
|
+
expect(Alarm.collection.indexes.get(spot: '2dsphere'))
|
15
|
+
.to eq('2dsphereIndexVersion' => 2,
|
16
|
+
'key' => { 'spot' => '2dsphere' },
|
17
|
+
'name' => 'spot_2dsphere',
|
18
|
+
'ns' => 'mongoid_geo_test.alarms',
|
19
|
+
'v' => 1)
|
11
20
|
end
|
12
21
|
|
13
22
|
it 'should set spatial fields' do
|
@@ -93,7 +93,8 @@ describe 'RGeo Wrapper' do
|
|
93
93
|
it 'should mongoize array' do
|
94
94
|
geom = Farm.create!(area: [[5, 5], [6, 5], [6, 6], [5, 6]]).area
|
95
95
|
expect(geom.class).to eql(Mongoid::Geospatial::Polygon)
|
96
|
-
expect(geom.to_rgeo.class)
|
96
|
+
expect(geom.to_rgeo.class)
|
97
|
+
.to eql(RGeo::Geographic::SphericalPolygonImpl)
|
97
98
|
expect(geom.to_rgeo.to_s)
|
98
99
|
.to eq 'POLYGON ((5.0 5.0, 6.0 5.0, 6.0 6.0, 5.0 6.0, 5.0 5.0))'
|
99
100
|
end
|
@@ -103,7 +104,8 @@ describe 'RGeo Wrapper' do
|
|
103
104
|
it 'should mongoize array' do
|
104
105
|
geom = River.create!(course: [[5, 5], [6, 5], [6, 6], [5, 6]]).course
|
105
106
|
expect(geom.class).to eql(Mongoid::Geospatial::LineString)
|
106
|
-
expect(geom.to_rgeo.class)
|
107
|
+
expect(geom.to_rgeo.class)
|
108
|
+
.to eql(RGeo::Geographic::SphericalLineStringImpl)
|
107
109
|
expect(geom.to_rgeo.to_s)
|
108
110
|
.to eq 'LINESTRING (5.0 5.0, 6.0 5.0, 6.0 6.0, 5.0 6.0)'
|
109
111
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -17,16 +17,14 @@ if ENV['CI']
|
|
17
17
|
# end
|
18
18
|
end
|
19
19
|
|
20
|
+
require 'pry'
|
20
21
|
require 'rspec'
|
21
|
-
|
22
22
|
require 'mongoid'
|
23
23
|
# require "mocha"
|
24
24
|
require 'mongoid/geospatial'
|
25
25
|
|
26
26
|
LOGGER = Logger.new($stdout)
|
27
27
|
|
28
|
-
puts "Running with Mongoid v#{Mongoid::VERSION}"
|
29
|
-
|
30
28
|
Mongoid.configure do |config|
|
31
29
|
config.connect_to('mongoid_geo_test')
|
32
30
|
end
|
@@ -46,3 +44,9 @@ RSpec.configure do |config|
|
|
46
44
|
Mongoid.purge!
|
47
45
|
end
|
48
46
|
end
|
47
|
+
|
48
|
+
Mongo::Logger.logger.level = Logger::INFO if Mongoid::VERSION >= '5'
|
49
|
+
|
50
|
+
# Mongoid.load!(File.expand_path('../support/mongoid.yml', __FILE__), :test)
|
51
|
+
|
52
|
+
puts "Running with Mongoid v#{Mongoid::VERSION}"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid-geospatial
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Ong
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-07-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mongoid
|
@@ -17,14 +17,14 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version:
|
20
|
+
version: 5.0.0.beta
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version:
|
27
|
+
version: 5.0.0.beta
|
28
28
|
description: Mongoid Extension that simplifies MongoDB casting and operations on spatial
|
29
29
|
Ruby objects.
|
30
30
|
email:
|
@@ -105,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
105
|
version: '0'
|
106
106
|
requirements: []
|
107
107
|
rubyforge_project:
|
108
|
-
rubygems_version: 2.4.
|
108
|
+
rubygems_version: 2.4.8
|
109
109
|
signing_key:
|
110
110
|
specification_version: 4
|
111
111
|
summary: Mongoid Extension that simplifies MongoDB Geospatial Operations.
|