Method: MapKit::ZoomLevel::ClassMethods#latitude_to_pixel_space_y

Defined in:
lib/map-kit-wrapper/zoom_level.rb

#latitude_to_pixel_space_y(latitude) ⇒ Object

Convert latitude to pixel space y

  • Args :

    • latitude -> Int or Float

  • Returns :

    • Pixel space y as Int



49
50
51
52
53
54
55
56
57
# File 'lib/map-kit-wrapper/zoom_level.rb', line 49

def latitude_to_pixel_space_y(latitude)
  if latitude == 90.0
    0
  elsif latitude == -90.0
    MERCATOR_OFFSET * 2
  else
    (MERCATOR_OFFSET - MERCATOR_RADIUS * log((1 + sin(latitude * PI / 180.0)) / (1 - sin(latitude * PI / 180.0))) / 2.0).round
  end
end