swedishgrid 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/swedishgrid.rb +4 -2
  2. metadata +2 -2
data/lib/swedishgrid.rb CHANGED
@@ -25,7 +25,7 @@ class SwedishGrid
25
25
  end
26
26
 
27
27
  # Conversion from grid coordinates to geodetic coordinates.
28
- def grid_to_geodetic(x, y)
28
+ def grid_to_geodetic(x, y, decimals=nil)
29
29
  # Prepare ellipsoid-based stuff.
30
30
  e2 = @flattening * (2.0 - @flattening)
31
31
  n = @flattening / (2.0 - @flattening)
@@ -63,7 +63,9 @@ class SwedishGrid
63
63
  bstar*(Math.sin(phi_star) ** 2) +
64
64
  cstar*(Math.sin(phi_star) ** 4) +
65
65
  dstar*(Math.sin(phi_star) ** 6))
66
- return [lat_radian * 180.0 / Math::PI, lng_radian * 180.0 / Math::PI]
66
+ res = [lat_radian * 180.0 / Math::PI, lng_radian * 180.0 / Math::PI]
67
+ res.map do |x| (x * 10**decimals).round / 10**decimals end unless decimals.nil?
68
+ return res
67
69
  end
68
70
 
69
71
  # Conversion from geodetic coordinates to grid coordinates.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swedishgrid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -45,7 +45,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
45
45
  version: '0'
46
46
  requirements: []
47
47
  rubyforge_project:
48
- rubygems_version: 1.8.24
48
+ rubygems_version: 1.8.25
49
49
  signing_key:
50
50
  specification_version: 2
51
51
  summary: Convert coordinates between geodetic WGS84 and Swedish grid RT90 and SWEREF99