Sha256: d19f2b933f3e6f324b82f36e5972fc6231f32727a3c75dcf1bf053adf25d35a1

Contents?: true

Size: 1.04 KB

Versions: 30

Compression:

Stored size: 1.04 KB

Contents

#!/usr/bin/env ruby -w
# encoding: UTF-8
#
# = FitFile_spec.rb -- Fit4Ruby - FIT file processing library for Ruby
#
# Copyright (c) 2014, 2015 by Chris Schlaeger <cs@taskjuggler.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of version 2 of the GNU General Public License as
# published by the Free Software Foundation.
#

$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))

require 'fit4ruby/GeoMath'

describe Fit4Ruby::GeoMath do

  it 'should compute a distance between 2 points' do
    p0_lat = 48.180506536737084
    p0_lon = 11.611978523433208
    points = [
      # latitude, longitude, distance to p0 in meters
      [ 48.180506536737084, 11.611978523433208, 0.0 ],
      [ 48.18047543987632, 11.61195664666593, 3.821 ],
      [ 48.18034409545362, 11.611852794885635, 20.339 ],
      [ 48.17970883101225, 11.611351054161787, 100.225 ]
    ]
    points.each do |p|
      expect(Fit4Ruby::GeoMath.distance(
        p0_lat, p0_lon, p[0], p[1])).to be_within(0.001).of(p[2])
    end
  end

end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
fit4ruby-3.13.0 spec/GeoMath_spec.rb
fit4ruby-3.12.0 spec/GeoMath_spec.rb
fit4ruby-3.11.0 spec/GeoMath_spec.rb
fit4ruby-3.10.0 spec/GeoMath_spec.rb
fit4ruby-3.9.0 spec/GeoMath_spec.rb
fit4ruby-3.8.0 spec/GeoMath_spec.rb
fit4ruby-3.7.0 spec/GeoMath_spec.rb
fit4ruby-3.6.0 spec/GeoMath_spec.rb
fit4ruby-3.5.0 spec/GeoMath_spec.rb
fit4ruby-3.4.0 spec/GeoMath_spec.rb
fit4ruby-3.3.0 spec/GeoMath_spec.rb
fit4ruby-3.2.0 spec/GeoMath_spec.rb
fit4ruby-3.1.0 spec/GeoMath_spec.rb
fit4ruby-3.0.0 spec/GeoMath_spec.rb
fit4ruby-2.0.0 spec/GeoMath_spec.rb
fit4ruby-1.7.0 spec/GeoMath_spec.rb
fit4ruby-1.6.2 spec/GeoMath_spec.rb
fit4ruby-1.6.1 spec/GeoMath_spec.rb
fit4ruby-1.6.0 spec/GeoMath_spec.rb
fit4ruby-1.5.1 spec/GeoMath_spec.rb