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 +4 -4
- data/Gemfile.lock +1 -1
- data/doc/example.rb +18 -0
- data/lib/geoprojection/ellipse.rb +4 -8
- data/lib/geoprojection/version.rb +1 -1
- data/test.rb +18 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8560b474f5efac958d7e5296dae0fc6c122d9fc6ea605a8ae406101717a46d06
|
4
|
+
data.tar.gz: 66c955de7126b71538d6d019ad43d767cbed22719929b631bbd0987420070d96
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efee6e93050df75436a04773199c6721fcfd8b39f979ecbc8092df3717ba5b88086e0351ebf5a8def6b21e0adbaf991002a33748f473134cb7e95361ffea4809
|
7
|
+
data.tar.gz: 720fa6125c7ac803473e0c604c37ca6829ba68ca89bcb539821d5b660e7c81828c72f01726e1c21307b63552bb36e05477c4fc973999583e2e19629fd086631e
|
data/Gemfile.lock
CHANGED
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 *
|
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 / (
|
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
|
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.
|
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:
|