geo-distance 0.1.2 → 0.2.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.
- data/Gemfile +7 -9
- data/Gemfile.lock +30 -13
- data/README.textile +28 -8
- data/VERSION +1 -1
- data/geo-distance.gemspec +40 -32
- data/lib/geo-distance.rb +14 -132
- data/lib/geo-distance/class_methods.rb +71 -0
- data/lib/geo-distance/conversion.rb +67 -0
- data/lib/geo-distance/conversion/meters.rb +29 -0
- data/lib/geo-distance/conversion/radians.rb +36 -0
- data/lib/geo-distance/core_ext.rb +12 -23
- data/lib/geo-distance/distance.rb +24 -0
- data/lib/geo-distance/formula.rb +53 -7
- data/lib/geo-distance/formula/flat.rb +21 -0
- data/lib/geo-distance/{haversine.rb → formula/haversine.rb} +18 -14
- data/lib/geo-distance/formula/n_vector.rb +30 -0
- data/lib/geo-distance/formula/spherical.rb +44 -0
- data/lib/geo-distance/formula/vincenty.rb +80 -0
- data/lib/geo-distance/scale.rb +18 -0
- data/spec/geo_distance/class_methods_spec.rb +70 -0
- data/spec/geo_distance/core_ext_spec.rb +65 -0
- data/spec/geo_distance/distance_spec.rb +74 -0
- data/spec/geo_distance/formula/flat_spec.rb +31 -0
- data/spec/geo_distance/formula/haversine_spec.rb +33 -0
- data/spec/geo_distance/formula/n_vector.rb +33 -0
- data/spec/geo_distance/formula/spherical_spec.rb +33 -0
- data/spec/geo_distance/formula/vincenty_spec.rb +33 -0
- data/spec/spec_helper.rb +0 -10
- metadata +97 -96
- data/lib/geo-distance/spherical.rb +0 -24
- data/lib/geo-distance/vincenty.rb +0 -79
- data/spec/core_ext_spec.rb +0 -9
- data/spec/dist_default_spec.rb +0 -23
- data/spec/dist_haversine_spec.rb +0 -21
- data/spec/dist_spherical_spec.rb +0 -21
- data/spec/dist_vincenty_spec.rb +0 -21
| @@ -0,0 +1,70 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            GeoPoint.coord_mode = :lng_lat
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            describe "GeoDistance class methods" do
         | 
| 6 | 
            +
              describe '#earth_radius' do
         | 
| 7 | 
            +
                it 'should return in kms' do
         | 
| 8 | 
            +
                  GeoDistance.earth_radius(:kms).should be_between(6371, 6380)
         | 
| 9 | 
            +
                end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                it 'should return in meters' do
         | 
| 12 | 
            +
                  GeoDistance.earth_radius(:meters).should be_between(6371000, 6380000)
         | 
| 13 | 
            +
                end
         | 
| 14 | 
            +
              end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
              describe '#radians_ratio unit' do
         | 
| 17 | 
            +
                it 'should return in kms' do
         | 
| 18 | 
            +
                  puts GeoDistance.radians_ratio unit(:kms) #.should be_between(6371, 6380)
         | 
| 19 | 
            +
                end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                it 'should return in meters' do
         | 
| 22 | 
            +
                  puts GeoDistance.radians_ratio unit(:meters) #.should be_between(6371000, 6380000)
         | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
              end
         | 
| 25 | 
            +
              
         | 
| 26 | 
            +
              describe '#default_algorithm' do
         | 
| 27 | 
            +
                let(:from)  { [-104.88544, 39.06546].geo_point }
         | 
| 28 | 
            +
                let(:to)    { [-104.80, 39.06546].geo_point }
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                it "should NOT set it to :haver" do
         | 
| 31 | 
            +
                  lambda { GeoDistance.default_algorithm = :haver}.should raise_error
         | 
| 32 | 
            +
                end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                it "should set it to :haversine" do
         | 
| 35 | 
            +
                  GeoDistance.default_algorithm = :haversine
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                  dist = GeoDistance.geo_distance(from, to)
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                  puts "the distance from #{from} to #{to} is: #{dist.meters} meters"
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                  dist.feet.should == 24193.0
         | 
| 42 | 
            +
                  dist.to_feet.should == 24193.0
         | 
| 43 | 
            +
                  dist.kms.to_s.should match(/7\.376*/)
         | 
| 44 | 
            +
                end
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                it "should set it to :flat" do
         | 
| 47 | 
            +
                  GeoDistance.default_algorithm = :flat
         | 
| 48 | 
            +
             | 
| 49 | 
            +
                  dist = GeoDistance.geo_distance(from, to)
         | 
| 50 | 
            +
                  puts "the distance from #{from} to #{to} is: #{dist.meters} meters"
         | 
| 51 | 
            +
                  dist.feet.should be_between(23500, 25000)
         | 
| 52 | 
            +
                end
         | 
| 53 | 
            +
             | 
| 54 | 
            +
                it "should set it to :sphere" do
         | 
| 55 | 
            +
                  GeoDistance.default_algorithm = :sphere
         | 
| 56 | 
            +
             | 
| 57 | 
            +
                  dist = GeoDistance.geo_distance(from, to)
         | 
| 58 | 
            +
                  puts "the distance from #{from} to #{to} is: #{dist.meters} meters"
         | 
| 59 | 
            +
                  dist.feet.should be_between(23500, 25000)
         | 
| 60 | 
            +
                end
         | 
| 61 | 
            +
             | 
| 62 | 
            +
                it "should set it to :vincenty" do
         | 
| 63 | 
            +
                  GeoDistance.default_algorithm = :vincenty
         | 
| 64 | 
            +
             | 
| 65 | 
            +
                  dist = GeoDistance.geo_distance(from, to)
         | 
| 66 | 
            +
                  puts "the distance from #{from} to #{to} is: #{dist.meters} meters"
         | 
| 67 | 
            +
                  dist.feet.should be_between(23500, 25000)
         | 
| 68 | 
            +
                end
         | 
| 69 | 
            +
              end
         | 
| 70 | 
            +
            end
         | 
| @@ -0,0 +1,65 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe "GeoDistance core extensions" do
         | 
| 4 | 
            +
              
         | 
| 5 | 
            +
              describe 'unit_to(other)' do  
         | 
| 6 | 
            +
                describe '#radians_to' do  
         | 
| 7 | 
            +
                  it 'should convert radians to kms' do
         | 
| 8 | 
            +
                    5.radians_to(:kms).should be_within(2).of 556
         | 
| 9 | 
            +
                  end
         | 
| 10 | 
            +
                end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                describe '#kms_to' do  
         | 
| 13 | 
            +
                  it 'should convert radians to kms' do
         | 
| 14 | 
            +
                    5.kms_to(:feet).should be_within(1000).of 16000
         | 
| 15 | 
            +
                  end
         | 
| 16 | 
            +
                end
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
              describe '#radians' do  
         | 
| 20 | 
            +
                it 'should convert Fixnum to GeoDistance' do
         | 
| 21 | 
            +
                  5.radians.should be_a GeoDistance
         | 
| 22 | 
            +
                  5.radians.distance.should == 5
         | 
| 23 | 
            +
                  5.radians.unit.should == :radians
         | 
| 24 | 
            +
                  5.radians.as_kms.should be_within(2).of 556
         | 
| 25 | 
            +
                end
         | 
| 26 | 
            +
              end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
              describe '#kms' do  
         | 
| 29 | 
            +
                it 'should convert Fixnum to GeoDistance' do
         | 
| 30 | 
            +
                  5.kms.should be_a GeoDistance
         | 
| 31 | 
            +
                  5.kms.distance.should == 5
         | 
| 32 | 
            +
                  5.kms.unit.should == :kms
         | 
| 33 | 
            +
                end
         | 
| 34 | 
            +
              end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
              describe '#kms' do  
         | 
| 37 | 
            +
                it 'should convert Float to GeoDistance' do
         | 
| 38 | 
            +
                  5.2.kms.should be_a GeoDistance
         | 
| 39 | 
            +
                  5.2.kms.distance.should == 5.2
         | 
| 40 | 
            +
                  5.2.kms.unit.should == :kms
         | 
| 41 | 
            +
                end
         | 
| 42 | 
            +
              end
         | 
| 43 | 
            +
             | 
| 44 | 
            +
              describe '#meters' do  
         | 
| 45 | 
            +
                it 'should convert Float to GeoDistance' do
         | 
| 46 | 
            +
                  5.2.meters.should be_a GeoDistance
         | 
| 47 | 
            +
                  5.2.meters.distance.should == 5.2
         | 
| 48 | 
            +
                  5.2.meters.unit.should == :meters
         | 
| 49 | 
            +
                end
         | 
| 50 | 
            +
              end
         | 
| 51 | 
            +
             | 
| 52 | 
            +
              describe '#meter' do  
         | 
| 53 | 
            +
                it 'should convert Float to GeoDistance' do
         | 
| 54 | 
            +
                  2.meter.should be_a GeoDistance
         | 
| 55 | 
            +
                  5.2.meter.distance.should == 5.2
         | 
| 56 | 
            +
                  5.2.meter.unit.should == :meters
         | 
| 57 | 
            +
                end
         | 
| 58 | 
            +
              end
         | 
| 59 | 
            +
             | 
| 60 | 
            +
              describe '#to_radians' do  
         | 
| 61 | 
            +
                it 'should convert degrees to radians' do
         | 
| 62 | 
            +
                  180.to_radians.should be_within(0.1).of 3.14159274
         | 
| 63 | 
            +
                end
         | 
| 64 | 
            +
              end
         | 
| 65 | 
            +
            end
         | 
| @@ -0,0 +1,74 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe GeoDistance do
         | 
| 4 | 
            +
              
         | 
| 5 | 
            +
              describe 'initialize' do
         | 
| 6 | 
            +
                describe 'Numeric macro' do
         | 
| 7 | 
            +
                  it 'should create distance from number' do
         | 
| 8 | 
            +
                    500.kms.should be_a(GeoDistance)
         | 
| 9 | 
            +
                    500.kms.unit.should == :kms
         | 
| 10 | 
            +
                    500.kms.units.should == :kms
         | 
| 11 | 
            +
                    500.kms.distance.should == 500
         | 
| 12 | 
            +
                  end
         | 
| 13 | 
            +
                end
         | 
| 14 | 
            +
              end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
              context '500 kms' do
         | 
| 17 | 
            +
                let(:distance) { 500.kms }
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                describe 'comparable' do  
         | 
| 20 | 
            +
                  it '52 kms is less than 52500 meters' do
         | 
| 21 | 
            +
                    52.kms.should < (52.thousand + 500.hundred).meters
         | 
| 22 | 
            +
                  end
         | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
              
         | 
| 25 | 
            +
                describe '#meters' do  
         | 
| 26 | 
            +
                  it 'should be in meters' do
         | 
| 27 | 
            +
                    distance.meters.should == 500.thousand
         | 
| 28 | 
            +
                  end
         | 
| 29 | 
            +
                end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                describe '#in_meters' do  
         | 
| 32 | 
            +
                  it 'should be in meters' do
         | 
| 33 | 
            +
                    distance.in_meters.should == 500.thousand
         | 
| 34 | 
            +
                  end
         | 
| 35 | 
            +
                end
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                describe '#as_meters' do  
         | 
| 38 | 
            +
                  it 'should be in meters' do
         | 
| 39 | 
            +
                    distance.as_meters.should == 500.thousand
         | 
| 40 | 
            +
                  end
         | 
| 41 | 
            +
                end
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                describe '#as_meters!' do  
         | 
| 44 | 
            +
                  it 'should be in meters' do
         | 
| 45 | 
            +
                    dist = distance.as_meters!
         | 
| 46 | 
            +
                    dist.should == distance
         | 
| 47 | 
            +
                    dist.distance.should == 500.thousand
         | 
| 48 | 
            +
                  end
         | 
| 49 | 
            +
                end
         | 
| 50 | 
            +
             | 
| 51 | 
            +
                describe '#to_meters!' do  
         | 
| 52 | 
            +
                  it 'should be in meters' do
         | 
| 53 | 
            +
                    dist = distance.to_meters!
         | 
| 54 | 
            +
                    dist.should == distance
         | 
| 55 | 
            +
                    dist.distance.should == 500.thousand
         | 
| 56 | 
            +
                  end
         | 
| 57 | 
            +
                end
         | 
| 58 | 
            +
             | 
| 59 | 
            +
                describe '#feet' do
         | 
| 60 | 
            +
                  it 'should be in feet' do
         | 
| 61 | 
            +
                    distance.feet.should be_within(10.thousand).of(500.thousand * 3.3)
         | 
| 62 | 
            +
                  end
         | 
| 63 | 
            +
                end
         | 
| 64 | 
            +
             | 
| 65 | 
            +
                describe '#to_feet' do
         | 
| 66 | 
            +
                  it 'should return new GeoDistance converted to feet' do
         | 
| 67 | 
            +
                    new_dist = distance.to_feet
         | 
| 68 | 
            +
                    new_dist.should_not == distance
         | 
| 69 | 
            +
             | 
| 70 | 
            +
                    new_dist.distance.should be_within(10.thousand).of(500.thousand * 3.3)
         | 
| 71 | 
            +
                  end
         | 
| 72 | 
            +
                end
         | 
| 73 | 
            +
              end
         | 
| 74 | 
            +
            end    
         | 
| @@ -0,0 +1,31 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe GeoDistance::Flat do
         | 
| 4 | 
            +
              let(:from) do 
         | 
| 5 | 
            +
                [45, 10].geo_point
         | 
| 6 | 
            +
              end
         | 
| 7 | 
            +
             | 
| 8 | 
            +
              let(:to) do   
         | 
| 9 | 
            +
                b = [42, 11].geo_point
         | 
| 10 | 
            +
              end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
              describe '#distance' do
         | 
| 13 | 
            +
                it "should calculate flat distance as Float" do
         | 
| 14 | 
            +
                  dist = GeoDistance::Flat.distance(from, to, :units => :kms)
         | 
| 15 | 
            +
                  dist.should be_a(Float)
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                  puts "the distance from #{from} to #{to} is: #{dist.kms_to(:meters)} meters"
         | 
| 18 | 
            +
                  dist.should be_within(10).of 340
         | 
| 19 | 
            +
                end
         | 
| 20 | 
            +
              end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
              describe '#geo_distance' do
         | 
| 23 | 
            +
                it "should calculate haversine distance as GeoDistance" do
         | 
| 24 | 
            +
                  dist = GeoDistance::Flat.geo_distance(from, to)
         | 
| 25 | 
            +
                  dist.should be_a(GeoDistance)
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                  # puts "the distance from #{from} to #{to} is: #{dist.meters} meters"
         | 
| 28 | 
            +
                  dist.kms.should be_within(10).of 340
         | 
| 29 | 
            +
                end
         | 
| 30 | 
            +
              end
         | 
| 31 | 
            +
            end
         | 
| @@ -0,0 +1,33 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe GeoDistance::Haversine do
         | 
| 4 | 
            +
              let(:from) do 
         | 
| 5 | 
            +
                [45, 10].geo_point
         | 
| 6 | 
            +
              end
         | 
| 7 | 
            +
             | 
| 8 | 
            +
              let(:to) do   
         | 
| 9 | 
            +
                b = [42, 11].geo_point
         | 
| 10 | 
            +
              end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
              describe '#distance' do
         | 
| 13 | 
            +
                it "should calculate haversine distance as Float" do
         | 
| 14 | 
            +
                  dist = GeoDistance::Haversine.distance(from, to)
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                  dist.should be_a(Float)
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                  puts "the distance from #{from} to #{to} is: #{dist.kms_to(:meters)} meters"
         | 
| 19 | 
            +
                  dist.should be_within(20).of 340
         | 
| 20 | 
            +
                end
         | 
| 21 | 
            +
              end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
              describe '#geo_distance' do
         | 
| 24 | 
            +
                it "should calculate haversine distance as GeoDistance" do
         | 
| 25 | 
            +
                  dist = GeoDistance::Haversine.geo_distance(from, to)
         | 
| 26 | 
            +
                  dist.should be_a(GeoDistance)
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                  puts "the distance from #{from} to #{to} is: #{dist.meters} meters"
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                  dist.kms.should be_within(20).of 340
         | 
| 31 | 
            +
                end
         | 
| 32 | 
            +
              end
         | 
| 33 | 
            +
            end
         | 
| @@ -0,0 +1,33 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe GeoDistance::NVector do
         | 
| 4 | 
            +
              let(:from) do 
         | 
| 5 | 
            +
                [45, 10].geo_point
         | 
| 6 | 
            +
              end
         | 
| 7 | 
            +
             | 
| 8 | 
            +
              let(:to) do   
         | 
| 9 | 
            +
                b = [42, 11].geo_point
         | 
| 10 | 
            +
              end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
              describe '#distance' do
         | 
| 13 | 
            +
                it "should calculate N-vector distance as Float" do
         | 
| 14 | 
            +
                  dist = GeoDistance::NVector.distance(from, to)
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                  dist.should be_a(Float)
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                  puts "the distance from #{from} to #{to} is: #{dist.kms_to(:meters)} meters"
         | 
| 19 | 
            +
                  dist.should be_within(20).of 340
         | 
| 20 | 
            +
                end
         | 
| 21 | 
            +
              end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
              describe '#geo_distance' do
         | 
| 24 | 
            +
                it "should calculate N-vector distance as GeoDistance" do
         | 
| 25 | 
            +
                  dist = GeoDistance::NVector.geo_distance(from, to)
         | 
| 26 | 
            +
                  dist.should be_a(GeoDistance)
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                  puts "the distance from #{from} to #{to} is: #{dist.meters} meters"
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                  dist.kms.should be_within(20).of 340
         | 
| 31 | 
            +
                end
         | 
| 32 | 
            +
              end
         | 
| 33 | 
            +
            end
         | 
| @@ -0,0 +1,33 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe GeoDistance::Spherical do
         | 
| 4 | 
            +
                let(:from) do 
         | 
| 5 | 
            +
                  [45, 10].geo_point
         | 
| 6 | 
            +
                end
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                let(:to) do   
         | 
| 9 | 
            +
                  b = [42, 11].geo_point
         | 
| 10 | 
            +
                end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                describe '#distance' do
         | 
| 13 | 
            +
                  it "should calculate spherical distance as Float" do
         | 
| 14 | 
            +
                    dist = GeoDistance::Spherical.distance(from, to)
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                    dist.should be_a(Float)
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                    puts "the distance from #{from} to #{to} is: #{dist.kms_to(:meters)} meters"
         | 
| 19 | 
            +
                    dist.should be_within(20).of 340
         | 
| 20 | 
            +
                  end
         | 
| 21 | 
            +
                end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                describe '#geo_distance' do
         | 
| 24 | 
            +
                  it "should calculate spherical distance as GeoDistance" do
         | 
| 25 | 
            +
                    dist = GeoDistance::Spherical.geo_distance(from, to)
         | 
| 26 | 
            +
                    dist.should be_a(GeoDistance)
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                    puts "the distance from #{from} to #{to} is: #{dist.meters} meters"
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                    dist.kms.should be_within(20).of 340
         | 
| 31 | 
            +
                  end
         | 
| 32 | 
            +
                end
         | 
| 33 | 
            +
              end
         | 
| @@ -0,0 +1,33 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe GeoDistance::Vincenty do
         | 
| 4 | 
            +
              let(:from) do 
         | 
| 5 | 
            +
                [45, 10].geo_point
         | 
| 6 | 
            +
              end
         | 
| 7 | 
            +
             | 
| 8 | 
            +
              let(:to) do   
         | 
| 9 | 
            +
                b = [42, 11].geo_point
         | 
| 10 | 
            +
              end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
              describe '#distance' do
         | 
| 13 | 
            +
                it "should calculate vincenty distance as Float" do
         | 
| 14 | 
            +
                  dist = GeoDistance::Vincenty.distance(from, to)
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                  dist.should be_a(Float)
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                  puts "the distance from #{from} to #{to} is: #{dist.kms_to(:meters)} meters"
         | 
| 19 | 
            +
                  dist.should be_within(20).of 340
         | 
| 20 | 
            +
                end
         | 
| 21 | 
            +
              end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
              describe '#geo_distance' do
         | 
| 24 | 
            +
                it "should calculate vincenty distance as GeoDistance" do
         | 
| 25 | 
            +
                  dist = GeoDistance::Vincenty.geo_distance(from, to)
         | 
| 26 | 
            +
                  dist.should be_a(GeoDistance)
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                  puts "the distance from #{from} to #{to} is: #{dist.meters} meters"
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                  dist.kms.should be_within(20).of 340
         | 
| 31 | 
            +
                end
         | 
| 32 | 
            +
              end
         | 
| 33 | 
            +
            end
         | 
    
        data/spec/spec_helper.rb
    CHANGED
    
    | @@ -1,12 +1,2 @@ | |
| 1 | 
            -
            $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
         | 
| 2 | 
            -
            $LOAD_PATH.unshift(File.dirname(__FILE__))
         | 
| 3 1 | 
             
            require 'rspec'
         | 
| 4 2 | 
             
            require 'geo-distance'
         | 
| 5 | 
            -
             | 
| 6 | 
            -
            # Requires supporting files with custom matchers and macros, etc,
         | 
| 7 | 
            -
            # in ./support/ and its subdirectories.
         | 
| 8 | 
            -
            Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
         | 
| 9 | 
            -
             | 
| 10 | 
            -
            RSpec.configure do |config|
         | 
| 11 | 
            -
              
         | 
| 12 | 
            -
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,92 +1,92 @@ | |
| 1 | 
            -
            --- !ruby/object:Gem::Specification | 
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: geo-distance
         | 
| 3 | 
            -
            version: !ruby/object:Gem::Version | 
| 4 | 
            -
               | 
| 5 | 
            -
               | 
| 6 | 
            -
              - 0
         | 
| 7 | 
            -
              - 1
         | 
| 8 | 
            -
              - 2
         | 
| 9 | 
            -
              version: 0.1.2
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.2.0
         | 
| 5 | 
            +
              prerelease: 
         | 
| 10 6 | 
             
            platform: ruby
         | 
| 11 | 
            -
            authors: | 
| 7 | 
            +
            authors:
         | 
| 12 8 | 
             
            - Kristian Mandrup
         | 
| 13 9 | 
             
            autorequire: 
         | 
| 14 10 | 
             
            bindir: bin
         | 
| 15 11 | 
             
            cert_chain: []
         | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 12 | 
            +
            date: 2011-06-23 00:00:00.000000000Z
         | 
| 13 | 
            +
            dependencies:
         | 
| 14 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 15 | 
            +
              name: geo_point
         | 
| 16 | 
            +
              requirement: &2153874980 !ruby/object:Gem::Requirement
         | 
| 17 | 
            +
                none: false
         | 
| 18 | 
            +
                requirements:
         | 
| 19 | 
            +
                - - ~>
         | 
| 20 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 21 | 
            +
                    version: 0.2.5
         | 
| 22 | 
            +
              type: :runtime
         | 
| 23 | 
            +
              prerelease: false
         | 
| 24 | 
            +
              version_requirements: *2153874980
         | 
| 25 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 26 | 
            +
              name: geo_units
         | 
| 27 | 
            +
              requirement: &2153874380 !ruby/object:Gem::Requirement
         | 
| 28 | 
            +
                none: false
         | 
| 29 | 
            +
                requirements:
         | 
| 30 | 
            +
                - - ~>
         | 
| 31 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 32 | 
            +
                    version: 0.2.4.1
         | 
| 33 | 
            +
              type: :runtime
         | 
| 34 | 
            +
              prerelease: false
         | 
| 35 | 
            +
              version_requirements: *2153874380
         | 
| 36 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 21 37 | 
             
              name: rspec
         | 
| 22 | 
            -
              requirement: & | 
| 38 | 
            +
              requirement: &2153873740 !ruby/object:Gem::Requirement
         | 
| 23 39 | 
             
                none: false
         | 
| 24 | 
            -
                requirements: | 
| 25 | 
            -
                - -  | 
| 26 | 
            -
                  - !ruby/object:Gem::Version | 
| 27 | 
            -
                     | 
| 28 | 
            -
                    - 2
         | 
| 29 | 
            -
                    - 3
         | 
| 30 | 
            -
                    - 0
         | 
| 31 | 
            -
                    version: 2.3.0
         | 
| 40 | 
            +
                requirements:
         | 
| 41 | 
            +
                - - ! '>='
         | 
| 42 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 43 | 
            +
                    version: 2.6.0
         | 
| 32 44 | 
             
              type: :development
         | 
| 33 45 | 
             
              prerelease: false
         | 
| 34 | 
            -
              version_requirements: * | 
| 35 | 
            -
            - !ruby/object:Gem::Dependency | 
| 46 | 
            +
              version_requirements: *2153873740
         | 
| 47 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 36 48 | 
             
              name: bundler
         | 
| 37 | 
            -
              requirement: & | 
| 49 | 
            +
              requirement: &2153873060 !ruby/object:Gem::Requirement
         | 
| 38 50 | 
             
                none: false
         | 
| 39 | 
            -
                requirements: | 
| 51 | 
            +
                requirements:
         | 
| 40 52 | 
             
                - - ~>
         | 
| 41 | 
            -
                  - !ruby/object:Gem::Version | 
| 42 | 
            -
                     | 
| 43 | 
            -
                    - 1
         | 
| 44 | 
            -
                    - 0
         | 
| 45 | 
            -
                    - 0
         | 
| 46 | 
            -
                    version: 1.0.0
         | 
| 53 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 54 | 
            +
                    version: 1.0.10
         | 
| 47 55 | 
             
              type: :development
         | 
| 48 56 | 
             
              prerelease: false
         | 
| 49 | 
            -
              version_requirements: * | 
| 50 | 
            -
            - !ruby/object:Gem::Dependency | 
| 57 | 
            +
              version_requirements: *2153873060
         | 
| 58 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 51 59 | 
             
              name: jeweler
         | 
| 52 | 
            -
              requirement: & | 
| 60 | 
            +
              requirement: &2153871480 !ruby/object:Gem::Requirement
         | 
| 53 61 | 
             
                none: false
         | 
| 54 | 
            -
                requirements: | 
| 62 | 
            +
                requirements:
         | 
| 55 63 | 
             
                - - ~>
         | 
| 56 | 
            -
                  - !ruby/object:Gem::Version | 
| 57 | 
            -
                     | 
| 58 | 
            -
                    - 1
         | 
| 59 | 
            -
                    - 5
         | 
| 60 | 
            -
                    - 2
         | 
| 61 | 
            -
                    version: 1.5.2
         | 
| 64 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 65 | 
            +
                    version: 1.6.2
         | 
| 62 66 | 
             
              type: :development
         | 
| 63 67 | 
             
              prerelease: false
         | 
| 64 | 
            -
              version_requirements: * | 
| 65 | 
            -
            - !ruby/object:Gem::Dependency | 
| 68 | 
            +
              version_requirements: *2153871480
         | 
| 69 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 66 70 | 
             
              name: rcov
         | 
| 67 | 
            -
              requirement: & | 
| 71 | 
            +
              requirement: &2153870700 !ruby/object:Gem::Requirement
         | 
| 68 72 | 
             
                none: false
         | 
| 69 | 
            -
                requirements: | 
| 70 | 
            -
                - -  | 
| 71 | 
            -
                  - !ruby/object:Gem::Version | 
| 72 | 
            -
                     | 
| 73 | 
            -
                    - 0
         | 
| 74 | 
            -
                    version: "0"
         | 
| 73 | 
            +
                requirements:
         | 
| 74 | 
            +
                - - ! '>='
         | 
| 75 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 76 | 
            +
                    version: '0'
         | 
| 75 77 | 
             
              type: :development
         | 
| 76 78 | 
             
              prerelease: false
         | 
| 77 | 
            -
              version_requirements: * | 
| 78 | 
            -
            description:  | 
| 79 | 
            -
               | 
| 80 | 
            -
               | 
| 79 | 
            +
              version_requirements: *2153870700
         | 
| 80 | 
            +
            description: ! "Calculates the geo distance between two locations using longitude
         | 
| 81 | 
            +
              and latitude using Haversine, Speherical or Vincenty formula. \nThis is done using
         | 
| 82 | 
            +
              Math formulas without resorting to Active Record or SQL DB functionality"
         | 
| 81 83 | 
             
            email: kmandrup@gmail.com
         | 
| 82 84 | 
             
            executables: []
         | 
| 83 | 
            -
             | 
| 84 85 | 
             
            extensions: []
         | 
| 85 | 
            -
             | 
| 86 | 
            -
            extra_rdoc_files: 
         | 
| 86 | 
            +
            extra_rdoc_files:
         | 
| 87 87 | 
             
            - LICENSE.txt
         | 
| 88 88 | 
             
            - README.textile
         | 
| 89 | 
            -
            files: | 
| 89 | 
            +
            files:
         | 
| 90 90 | 
             
            - .document
         | 
| 91 91 | 
             
            - .rspec
         | 
| 92 92 | 
             
            - Gemfile
         | 
| @@ -97,54 +97,55 @@ files: | |
| 97 97 | 
             
            - VERSION
         | 
| 98 98 | 
             
            - geo-distance.gemspec
         | 
| 99 99 | 
             
            - lib/geo-distance.rb
         | 
| 100 | 
            +
            - lib/geo-distance/class_methods.rb
         | 
| 101 | 
            +
            - lib/geo-distance/conversion.rb
         | 
| 102 | 
            +
            - lib/geo-distance/conversion/meters.rb
         | 
| 103 | 
            +
            - lib/geo-distance/conversion/radians.rb
         | 
| 100 104 | 
             
            - lib/geo-distance/core_ext.rb
         | 
| 105 | 
            +
            - lib/geo-distance/distance.rb
         | 
| 101 106 | 
             
            - lib/geo-distance/formula.rb
         | 
| 102 | 
            -
            - lib/geo-distance/ | 
| 103 | 
            -
            - lib/geo-distance/ | 
| 104 | 
            -
            - lib/geo-distance/ | 
| 105 | 
            -
            -  | 
| 106 | 
            -
            -  | 
| 107 | 
            -
            -  | 
| 108 | 
            -
            - spec/ | 
| 109 | 
            -
            - spec/ | 
| 107 | 
            +
            - lib/geo-distance/formula/flat.rb
         | 
| 108 | 
            +
            - lib/geo-distance/formula/haversine.rb
         | 
| 109 | 
            +
            - lib/geo-distance/formula/n_vector.rb
         | 
| 110 | 
            +
            - lib/geo-distance/formula/spherical.rb
         | 
| 111 | 
            +
            - lib/geo-distance/formula/vincenty.rb
         | 
| 112 | 
            +
            - lib/geo-distance/scale.rb
         | 
| 113 | 
            +
            - spec/geo_distance/class_methods_spec.rb
         | 
| 114 | 
            +
            - spec/geo_distance/core_ext_spec.rb
         | 
| 115 | 
            +
            - spec/geo_distance/distance_spec.rb
         | 
| 116 | 
            +
            - spec/geo_distance/formula/flat_spec.rb
         | 
| 117 | 
            +
            - spec/geo_distance/formula/haversine_spec.rb
         | 
| 118 | 
            +
            - spec/geo_distance/formula/n_vector.rb
         | 
| 119 | 
            +
            - spec/geo_distance/formula/spherical_spec.rb
         | 
| 120 | 
            +
            - spec/geo_distance/formula/vincenty_spec.rb
         | 
| 110 121 | 
             
            - spec/spec_helper.rb
         | 
| 111 | 
            -
            has_rdoc: true
         | 
| 112 122 | 
             
            homepage: http://github.com/kristianmandrup/geo-distance
         | 
| 113 | 
            -
            licenses: | 
| 123 | 
            +
            licenses:
         | 
| 114 124 | 
             
            - MIT
         | 
| 115 125 | 
             
            post_install_message: 
         | 
| 116 126 | 
             
            rdoc_options: []
         | 
| 117 | 
            -
             | 
| 118 | 
            -
            require_paths: 
         | 
| 127 | 
            +
            require_paths:
         | 
| 119 128 | 
             
            - lib
         | 
| 120 | 
            -
            required_ruby_version: !ruby/object:Gem::Requirement | 
| 129 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 121 130 | 
             
              none: false
         | 
| 122 | 
            -
              requirements: | 
| 123 | 
            -
              - -  | 
| 124 | 
            -
                - !ruby/object:Gem::Version | 
| 125 | 
            -
                   | 
| 126 | 
            -
                  segments: | 
| 131 | 
            +
              requirements:
         | 
| 132 | 
            +
              - - ! '>='
         | 
| 133 | 
            +
                - !ruby/object:Gem::Version
         | 
| 134 | 
            +
                  version: '0'
         | 
| 135 | 
            +
                  segments:
         | 
| 127 136 | 
             
                  - 0
         | 
| 128 | 
            -
                   | 
| 129 | 
            -
            required_rubygems_version: !ruby/object:Gem::Requirement | 
| 137 | 
            +
                  hash: -358498389682454250
         | 
| 138 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 130 139 | 
             
              none: false
         | 
| 131 | 
            -
              requirements: | 
| 132 | 
            -
              - -  | 
| 133 | 
            -
                - !ruby/object:Gem::Version | 
| 134 | 
            -
                   | 
| 135 | 
            -
                  - 0
         | 
| 136 | 
            -
                  version: "0"
         | 
| 140 | 
            +
              requirements:
         | 
| 141 | 
            +
              - - ! '>='
         | 
| 142 | 
            +
                - !ruby/object:Gem::Version
         | 
| 143 | 
            +
                  version: '0'
         | 
| 137 144 | 
             
            requirements: []
         | 
| 138 | 
            -
             | 
| 139 145 | 
             
            rubyforge_project: 
         | 
| 140 | 
            -
            rubygems_version: 1. | 
| 146 | 
            +
            rubygems_version: 1.8.5
         | 
| 141 147 | 
             
            signing_key: 
         | 
| 142 148 | 
             
            specification_version: 3
         | 
| 143 | 
            -
            summary: Calculates the geo distance between two locations using longitude and latitude, | 
| 144 | 
            -
             | 
| 145 | 
            -
             | 
| 146 | 
            -
            - spec/dist_default_spec.rb
         | 
| 147 | 
            -
            - spec/dist_haversine_spec.rb
         | 
| 148 | 
            -
            - spec/dist_spherical_spec.rb
         | 
| 149 | 
            -
            - spec/dist_vincenty_spec.rb
         | 
| 150 | 
            -
            - spec/spec_helper.rb
         | 
| 149 | 
            +
            summary: Calculates the geo distance between two locations using longitude and latitude,
         | 
| 150 | 
            +
              using Haversine, Speherical or Vincenty formula
         | 
| 151 | 
            +
            test_files: []
         |