Class: Location
- Inherits:
-
Data
- Object
- Data
- Location
- Defined in:
- lib/inat-channel/data_types.rb
Instance Attribute Summary collapse
-
#lat ⇒ Object
readonly
Returns the value of attribute lat.
-
#lng ⇒ Object
readonly
Returns the value of attribute lng.
Instance Method Summary collapse
- #decimal ⇒ Object
- #dms ⇒ Object
- #google ⇒ Object
- #icon ⇒ Object
- #osm ⇒ Object
- #url ⇒ Object
- #yandex ⇒ Object
Instance Attribute Details
#lat ⇒ Object (readonly)
Returns the value of attribute lat
163 164 165 |
# File 'lib/inat-channel/data_types.rb', line 163 def lat @lat end |
#lng ⇒ Object (readonly)
Returns the value of attribute lng
163 164 165 |
# File 'lib/inat-channel/data_types.rb', line 163 def lng @lng end |
Instance Method Details
#decimal ⇒ Object
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 |
#dms ⇒ Object
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 |
#google ⇒ Object
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 |
#icon ⇒ Object
164 165 166 |
# File 'lib/inat-channel/data_types.rb', line 164 def icon IC::ICONS[:location] end |
#osm ⇒ Object
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 |
#url ⇒ Object
197 198 199 |
# File 'lib/inat-channel/data_types.rb', line 197 def url osm end |
#yandex ⇒ Object
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 |