




from heapq import heappop, heappush

import numpy as np




def 		lowerCAmelCase_   (	lowerCamelCase	,     lowerCamelCase	,     lowerCamelCase	,     lowerCamelCase	,     ):
				__magic_name__				, __magic_name__	:	Tuple								=grid.shape
				__magic_name__	:	List[str]								=[-1, 1, 0, 0]
				__magic_name__	:	Dict								=[0, 0, -1, 1]
				if allow_diagonal:
								dx += [-1, -1, 1, 1]
								dy += [-1, 1, -1, 1]

				__magic_name__				, __magic_name__	:	Any								=[(0, source)], set()
				__magic_name__	:	str								=np.full((rows, cols)	,     np.inf   )
				__magic_name__	:	Optional[int]								=0
				__magic_name__	:	Dict								=np.empty((rows, cols)	,     dtype=lowerCamelCase   )
				__magic_name__	:	str								=None

				while queue:
								((__magic_name__)				, (__magic_name__))	:	Dict								=heappop(lowerCamelCase   )
								if (x, y) in visited:
												continue
								visited.add((x, y)   )

								if (x, y) == destination:
												__magic_name__	:	str								=[]
												while (x, y) != source:
																path.append((x, y)   )
																__magic_name__				, __magic_name__	:	Optional[Any]								=predecessors[x, y]
												path.append(lowerCamelCase   )  # add the source manually
												path.reverse()
												return matrix[destination], path

								for i in range(len(lowerCamelCase   )   ):
												__magic_name__				, __magic_name__	:	Union[str, Any]								=x + dx[i], y + dy[i]
												if 0 <= nx < rows and 0 <= ny < cols:
																__magic_name__	:	Union[str, Any]								=grid[nx][ny]
																if next_node == 1 and matrix[nx, ny] > dist + 1:
																				heappush(lowerCamelCase	,     (dist + 1, (nx, ny))   )
																				__magic_name__	:	Dict								=dist + 1
																				__magic_name__	:	Tuple								=(x, y)

				return np.inf, []


if __name__ == "__main__":
							import doctest

							doctest.testmod()










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

from .haversine_distance import haversine_distance

UpperCAmelCase_		:				Dict									=     637_8137.0
UpperCAmelCase_		:				List[Any]									=     635_6752.31_4245
UpperCAmelCase_		:				List[str]									=     6378137




def 		lowerCAmelCase_   (	lowerCamelCase	,     lowerCamelCase	,     lowerCamelCase	,     lowerCamelCase   ):
				__magic_name__	:	str								=(AXIS_A - AXIS_B) / AXIS_A
				# Parametric latitudes
				# https://en.wikipedia.org/wiki/Latitude#Parametric_(or_reduced)_latitude
				__magic_name__	:	str								=atan((1 - flattening) * tan(radians(lowerCamelCase   )   )   )
				__magic_name__	:	List[Any]								=atan((1 - flattening) * tan(radians(lowerCamelCase   )   )   )

				# Compute central angle between two points
				# using haversine theta. sigma =  haversine_distance / equatorial radius
				__magic_name__	:	List[Any]								=haversine_distance(lowerCamelCase	,     lowerCamelCase	,     lowerCamelCase	,     lowerCamelCase   ) / EQUATORIAL_RADIUS

				# Intermediate P and Q values
				__magic_name__	:	Tuple								=(b_lata + b_lata) / 2
				__magic_name__	:	int								=(b_lata - b_lata) / 2

				# Intermediate X value
				# X = (sigma - sin(sigma)) * sin^2Pcos^2Q / cos^2(sigma/2)
				__magic_name__	:	Optional[int]								=(sin(lowerCamelCase   ) ** 2) * (cos(lowerCamelCase   ) ** 2)
				__magic_name__	:	Any								=cos(sigma / 2   ) ** 2
				__magic_name__	:	List[Any]								=(sigma - sin(lowerCamelCase   )) * (x_numerator / x_demonimator)

				# Intermediate Y value
				# Y = (sigma + sin(sigma)) * cos^2Psin^2Q / sin^2(sigma/2)
				__magic_name__	:	Any								=(cos(lowerCamelCase   ) ** 2) * (sin(lowerCamelCase   ) ** 2)
				__magic_name__	:	Optional[Any]								=sin(sigma / 2   ) ** 2
				__magic_name__	:	str								=(sigma + sin(lowerCamelCase   )) * (y_numerator / y_denominator)

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


if __name__ == "__main__":
							import doctest

							doctest.testmod()




