Class: CfSim::CordinationSystem

Inherits:
Object
  • Object
show all
Defined in:
lib/cf_sim/cordination_system.rb

Overview

本来なら都道府県によって座標系が決定されるべきだが、とりあえず簡易的に最も近いものを対象とする

Constant Summary collapse

ORIGIN_MAP =
{ 1  => [33.00000,129.30000],
2  => [33.00000,131.00000],
3  => [36.00000,132.10000],
4  => [33.00000,133.30000],
5  => [36.00000,134.20000],
6  => [36.00000,136.00000],
7  => [36.00000,137.10000],
8  => [36.00000,138.30000],
9  => [36.00000,139.50000],
10 => [40.00000,140.50000],
11 => [44.00000,140.15000],
12 => [44.00000,142.15000],
13 => [44.00000,144.15000],
14 => [26.00000,142.00000],
15 => [26.00000,127.30000],
16 => [26.00000,124.00000],
17 => [26.00000,131.00000],
18 => [20.00000,136.00000],
19 => [26.00000,154.00000] }

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(latitude, longitude) ⇒ CordinationSystem

Returns a new instance of CordinationSystem.



25
26
27
28
# File 'lib/cf_sim/cordination_system.rb', line 25

def initialize(latitude, longitude)
  @latitude = latitude
  @longitude = longitude
end

Instance Attribute Details

#latitudeObject (readonly)

Returns the value of attribute latitude.



3
4
5
# File 'lib/cf_sim/cordination_system.rb', line 3

def latitude
  @latitude
end

#longitudeObject (readonly)

Returns the value of attribute longitude.



3
4
5
# File 'lib/cf_sim/cordination_system.rb', line 3

def longitude
  @longitude
end

Instance Method Details

#nearest_originObject



34
35
36
# File 'lib/cf_sim/cordination_system.rb', line 34

def nearest_origin
  @nearest_origin ||= ORIGIN_MAP[nearest_system_number]
end

#nearest_system_numberObject



30
31
32
# File 'lib/cf_sim/cordination_system.rb', line 30

def nearest_system_number
  @nearest_system_number ||= ORIGIN_MAP.min_by { |_, origin| distance(origin) }.first
end