geoprojection 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b21a5ce188fe4283f22a8ffeae14392942981c101d010f5ae9e9d0f0a67d410e
4
- data.tar.gz: 76ac0d07a358785a9505cbcfe4830181b6fe4d7a3b3d923ccf512b13ea906dae
3
+ metadata.gz: 8560b474f5efac958d7e5296dae0fc6c122d9fc6ea605a8ae406101717a46d06
4
+ data.tar.gz: 66c955de7126b71538d6d019ad43d767cbed22719929b631bbd0987420070d96
5
5
  SHA512:
6
- metadata.gz: 9979de234b5ac3661a96561a5e9b836b11351e82d60dd1aece15726a06a1235537324f9baaca026412d7c03712bae235b0ff50951bb0565897e45b717d55f6e1
7
- data.tar.gz: 3f572c2025e219ceddb69f6b41e5a87ea84b71ed1ea8a23b3f7c4ab5848a812338af1ee2a34bf3e4b89402bbc3541a6db4461da28002d570bb1b6a44a4e3aea4
6
+ metadata.gz: efee6e93050df75436a04773199c6721fcfd8b39f979ecbc8092df3717ba5b88086e0351ebf5a8def6b21e0adbaf991002a33748f473134cb7e95361ffea4809
7
+ data.tar.gz: 720fa6125c7ac803473e0c604c37ca6829ba68ca89bcb539821d5b660e7c81828c72f01726e1c21307b63552bb36e05477c4fc973999583e2e19629fd086631e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- geoprojection (0.1.0)
4
+ geoprojection (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/doc/example.rb ADDED
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'gnuplot'
4
+ require 'geoprojection'
5
+
6
+ ellipse = Geoprojection::Ellipse.new(latitude: 50.8169, longitude: 0.1367, distance: 10)
7
+
8
+ Gnuplot.open do |gp|
9
+ Gnuplot::Plot.new(gp) do |plot|
10
+ plot.title 'Ellipsis'
11
+ plot.xlabel 'x'
12
+ plot.ylabel 'y'
13
+ plot.data << Gnuplot::DataSet.new(ellipse.points.transpose) do |ds|
14
+ ds.with = 'points'
15
+ ds.linewidth = 4
16
+ end
17
+ end
18
+ end
@@ -3,9 +3,9 @@
3
3
  module Geoprojection
4
4
  # Elliptical projection of a center point (lat, long) with a provided distance from the center.
5
5
  class Ellipse
6
- EQUATOR_KM_PER_LATITUDE_DEGREE = 110.567
7
- EQUATOR_KM_PER_LONGITUDE_DEGREE = 111.321
8
6
  DEGREES_PER_RADIAN = Math::PI / 180
7
+ EQUATOR_KM_PER_LATITUDE_RADIAN = 110.567 * DEGREES_PER_RADIAN
8
+ EQUATOR_KM_PER_LONGITUDE_RADIAN = 111.321 * DEGREES_PER_RADIAN
9
9
 
10
10
  def initialize(latitude:, longitude:, distance:, points: 36)
11
11
  @latitude = latitude
@@ -33,7 +33,7 @@ module Geoprojection
33
33
  end
34
34
 
35
35
  def derived_y(theta)
36
- @latitude + (DEGREES_PER_RADIAN * @distance * latitude_distortion * Math.sin(DEGREES_PER_RADIAN * theta))
36
+ @latitude + (DEGREES_PER_RADIAN * @distance * Math.sin(DEGREES_PER_RADIAN * theta))
37
37
  end
38
38
 
39
39
  def step
@@ -41,11 +41,7 @@ module Geoprojection
41
41
  end
42
42
 
43
43
  def longitude_distortion
44
- @longitude_distortion ||= 1 / (EQUATOR_KM_PER_LONGITUDE_DEGREE * Math.cos(DEGREES_PER_RADIAN * @latitude))
45
- end
46
-
47
- def latitude_distortion
48
- @latitude_distortion ||= 1 / (EQUATOR_KM_PER_LATITUDE_DEGREE / @latitude)
44
+ @longitude_distortion ||= 1 / (EQUATOR_KM_PER_LONGITUDE_RADIAN * Math.cos(DEGREES_PER_RADIAN * @latitude))
49
45
  end
50
46
  end
51
47
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Geoprojection
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
5
5
  end
data/test.rb ADDED
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'gnuplot'
4
+ require 'geoprojection'
5
+
6
+ ellipse = Geoprojection::Ellipse.new(latitude: 50.8169, longitude: 0.1367, distance: 10)
7
+
8
+ Gnuplot.open do |gp|
9
+ Gnuplot::Plot.new(gp) do |plot|
10
+ plot.title 'Ellipse'
11
+ plot.xlabel 'x'
12
+ plot.ylabel 'y'
13
+ plot.data << Gnuplot::DataSet.new(ellipse.points.transpose) do |ds|
14
+ ds.with = 'points'
15
+ ds.linewidth = 4
16
+ end
17
+ end
18
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geoprojection
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bob Farrell
@@ -25,10 +25,12 @@ files:
25
25
  - Makefile
26
26
  - README.md
27
27
  - Rakefile
28
+ - doc/example.rb
28
29
  - lib/geoprojection.rb
29
30
  - lib/geoprojection/ellipse.rb
30
31
  - lib/geoprojection/version.rb
31
32
  - sig/geoprojection.rbs
33
+ - test.rb
32
34
  homepage: https://github.com/bobf/geoprojection
33
35
  licenses: []
34
36
  metadata: