Class: Location

Inherits:
Data
  • Object
show all
Defined in:
lib/inat-channel/data_types.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#latObject (readonly)

Returns the value of attribute lat

Returns:

  • (Object)

    the current value of lat



163
164
165
# File 'lib/inat-channel/data_types.rb', line 163

def lat
  @lat
end

#lngObject (readonly)

Returns the value of attribute lng

Returns:

  • (Object)

    the current value of lng



163
164
165
# File 'lib/inat-channel/data_types.rb', line 163

def lng
  @lng
end

Instance Method Details

#decimalObject



180
181
182
183
184
185
186
# File 'lib/inat-channel/data_types.rb', line 180

def decimal
  lat_dir = lat >= 0 ? "N" : "S"
  lng_dir = lng >= 0 ? "E" : "W"
  lat_abs = lat.abs
  lng_abs = lng.abs
  "%.4f°%s, %.4f°%s" % [lat_abs, lat_dir, lng_abs, lng_dir]
end

#dmsObject



167
168
169
170
171
172
173
174
175
176
177
178
179
# File 'lib/inat-channel/data_types.rb', line 167

def dms
  lat_dir = lat >= 0 ? "N" : "S"
  lng_dir = lng >= 0 ? "E" : "W"
  lat_abs = lat.abs
  lng_abs = lng.abs
  lat_d = lat_abs.floor
  lat_m = ((lat_abs - lat_d) * 60).floor
  lat_s = ((lat_abs - lat_d - lat_m / 60.0) * 3600).round
  lng_d = lng_abs.floor
  lng_m = ((lng_abs - lng_d) * 60).floor
  lng_s = ((lng_abs - lng_d - lng_m / 60.0) * 3600).round
  "%d°%02d'%02d\"%s %d°%02d'%02d\"%s" % [lat_d, lat_m, lat_s, lat_dir, lng_d, lng_m, lng_s, lng_dir]
end

#googleObject



187
188
189
190
# File 'lib/inat-channel/data_types.rb', line 187

def google
  # "https://www.google.com/maps/search/?api=1&query=#{lat},#{lng}&z=#{FORMATS[:zoom]}&ll=#{lat},#{lng}"
  "https://www.google.com/maps/place/#{lat},#{lng}/@#{lat},#{lng},#{IC::CONFIG.dig(:tg_bot, :link_zoom)}z/"
end

#iconObject



164
165
166
# File 'lib/inat-channel/data_types.rb', line 164

def icon
  IC::ICONS[:location]
end

#osmObject



194
195
196
# File 'lib/inat-channel/data_types.rb', line 194

def osm
   "https://www.openstreetmap.org/?mlat=#{lat}&mlon=#{lng}#map=#{IC::CONFIG.dig(:tg_bot, :link_zoom)}/#{lat}/#{lng}"
end

#urlObject



197
198
199
# File 'lib/inat-channel/data_types.rb', line 197

def url
  osm
end

#yandexObject



191
192
193
# File 'lib/inat-channel/data_types.rb', line 191

def yandex
  "https://yandex.ru/maps/?ll=#{lng},#{lat}&z=#{IC::CONFIG.dig(:tg_bot, :link_zoom)}&pt=#{lng},#{lat},pm2rdm1"
end