


from math import atan, cos, radians, sin, tan

from .haversine_distance import haversine_distance

_A		       =						6_378_137.0
_A		       =						6_356_752.314_245
_A		       =						637_8137

def 						_UpperCAmelCase				(			SCREAMING_SNAKE_CASE__			:					float			,     SCREAMING_SNAKE_CASE__			:					float			,     SCREAMING_SNAKE_CASE__			:					float			,     SCREAMING_SNAKE_CASE__			:					float				):
     __UpperCamelCase    							=(AXIS_A - AXIS_B) / AXIS_A
     # Parametric latitudes
     # https://en.wikipedia.org/wiki/Latitude#Parametric_(or_reduced)_latitude
     __UpperCamelCase    							=atan((1 - flattening) * tan(radians(SCREAMING_SNAKE_CASE__				)				)				)
     __UpperCamelCase    							=atan((1 - flattening) * tan(radians(SCREAMING_SNAKE_CASE__				)				)				)

     # Compute central angle between two points
     # using haversine theta. sigma =  haversine_distance / equatorial radius
     __UpperCamelCase    							=haversine_distance(SCREAMING_SNAKE_CASE__			,     SCREAMING_SNAKE_CASE__			,     SCREAMING_SNAKE_CASE__			,     SCREAMING_SNAKE_CASE__				) / EQUATORIAL_RADIUS

     # Intermediate P and Q values
     __UpperCamelCase    							=(b_lata + b_lata) / 2
     __UpperCamelCase    							=(b_lata - b_lata) / 2

     # Intermediate X value
     # X = (sigma - sin(sigma)) * sin^2Pcos^2Q / cos^2(sigma/2)
     __UpperCamelCase    							=(sin(SCREAMING_SNAKE_CASE__				) ** 2) * (cos(SCREAMING_SNAKE_CASE__				) ** 2)
     __UpperCamelCase    							=cos(sigma / 2				) ** 2
     __UpperCamelCase    							=(sigma - sin(SCREAMING_SNAKE_CASE__				)) * (x_numerator / x_demonimator)

     # Intermediate Y value
     # Y = (sigma + sin(sigma)) * cos^2Psin^2Q / sin^2(sigma/2)
     __UpperCamelCase    							=(cos(SCREAMING_SNAKE_CASE__				) ** 2) * (sin(SCREAMING_SNAKE_CASE__				) ** 2)
     __UpperCamelCase    							=sin(sigma / 2				) ** 2
     __UpperCamelCase    							=(sigma + sin(SCREAMING_SNAKE_CASE__				)) * (y_numerator / y_denominator)

     return EQUATORIAL_RADIUS * (sigma - ((flattening / 2) * (x_value + y_value)))


if __name__ == "__main__":
   import doctest

   doctest.testmod()









from __future__ import annotations

import csv

import requests
from bsa import BeautifulSoup

def 						_UpperCAmelCase				(			SCREAMING_SNAKE_CASE__			:					str = ""				):
     __UpperCamelCase    							=url or 'https://www.imdb.com/chart/top/?ref_=nv_mv_250'
     __UpperCamelCase    							=BeautifulSoup(requests.get(SCREAMING_SNAKE_CASE__				).text			,     'html.parser'				)
     __UpperCamelCase    							=soup.find_all('td'			,     attrs='titleColumn'				)
     __UpperCamelCase    							=soup.find_all('td'			,     class_='ratingColumn imdbRating'				)
     return {
         title.a.text: float(rating.strong.text				)
         for title, rating in zip(SCREAMING_SNAKE_CASE__			,     SCREAMING_SNAKE_CASE__				)
     }

def 						_UpperCAmelCase				(			SCREAMING_SNAKE_CASE__			:					str = "IMDb_Top_250_Movies.csv"				):
     __UpperCamelCase    							=get_imdb_top_aaa_movies()
     with open(SCREAMING_SNAKE_CASE__			,     'w'			,     newline=''				) as out_file:
          __UpperCamelCase    							=csv.writer(SCREAMING_SNAKE_CASE__				)
          writer.writerow(['Movie title', 'IMDb rating']				)
          for title, rating in movies.items():
               writer.writerow([title, rating]				)


if __name__ == "__main__":
   write_movies()





