A distance calculator
Project description
Functions
get_coordinates(address: str) -> tuple
Given an address, returns a tuple with the latitude and longitude of the address, obtained from the OpenStreetMap Nominatim API.
Parameters
address (str): The address to get the coordinates of.
Returns
tuple: A tuple with two floats representing the latitude and longitude of the address, respectively.
get_address(lat: float, lon: float) -> str
Given a latitude and longitude, returns the corresponding address, obtained from the OpenStreetMap Nominatim API.
Parameters
lat (float): The latitude of the location.
lon (float): The longitude of the location.
Returns
str: A string representing the address of the location.
haversine_distance(lat1, lon1, lat2, lon2) -> float
Calculates the distance in kilometers between two points on Earth using the Haversine formula.
Parameters
lat1 (float): The latitude of the first point.
lon1 (float): The longitude of the first point.
lat2 (float): The latitude of the second point.
lon2 (float): The longitude of the second point.
Returns
float: A float representing the distance in kilometers between the two points.
spherical_law_of_cosines_distance(lat1, lon1, lat2, lon2) -> float
Calculates the distance in kilometers between two points on Earth using the Spherical Law of Cosines formula.
Parameters
lat1 (float): The latitude of the first point.
lon1 (float): The longitude of the first point.
lat2 (float): The latitude of the second point.
lon2 (float): The longitude of the second point.
Returns
float: A float representing the distance in kilometers between the two points.
equirectangular_approximation(lat1, lon1, lat2, lon2) -> float
Calculates the distance in kilometers between two points on Earth using the Equirectangular Approximation formula.
Parameters
lat1 (float): The latitude of the first point.
lon1 (float): The longitude of the first point.
lat2 (float): The latitude of the second point.
lon2 (float): The longitude of the second point.
Returns
float: A float representing the distance in kilometers between the two points.
***HOW TO USE***
1. Install library
pip install simple-distance-calculator
2. import functions
from simple_distance_calculator.distance import haversine_distance, get_coordinates, spherical_law_of_cosines_distance, get_address, equirectangular_approximation
examples for caculating distances
haversine_distance(54.9037, 23.9578, 54.9057, 23.9562)
returns - 0.24478592390463977
spherical_law_of_cosines_distance(54.9037, 23.9578, 54.9057, 23.9562)
returns - 0.24478591164572538
equirectangular_approximation(54.9037, 23.9578, 54.9057, 23.9562)
returns - 0.24478592392092405
get_coordinates("Gedimino pilis")
returns - (54.686758350000005, 25.29068448063221)
get_address(54.686758350000005, 25.29068448063221)
returns - Gedimino pilis, 5, Arsenalo g., Senamiestis, Senamiesčio seniūnija, Vilnius, Vilniaus miesto savivaldybė, Vilniaus apskritis, 01143, Lietuva
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file simple_distance_calculator-0.0.4.tar.gz.
File metadata
- Download URL: simple_distance_calculator-0.0.4.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f08ad408bff73003038be1e12ba9addaebd533be5570068aa4143b4b75825b0
|
|
| MD5 |
c43d993227753c19d48c3ed218302092
|
|
| BLAKE2b-256 |
13cffb9d0205c119397885c932ae72fa18a7169ae7d13a54d781844b2bd3b9b1
|