Skip to content
This repository was archived by the owner on Nov 3, 2022. It is now read-only.

Functions Module

Zander edited this page Feb 18, 2021 · 14 revisions

Currently the only module, provides all functions in the library.

How to Import

from zcscommonlib import functions

Haversine (Great Circle Distance) - functions.great_circle()


Purpose

Calculates the great circle distance between two points on the earth (specified in decimal degrees), returns the distance in meters.

Args (In order)

lon1 (float): The longitude of the first point.
lat1: (float): The latitude of the first point.
lon2: (float): The longitude of the second point.
lat2: (float): The latitude of the second point.

Returns

The distance in meters between the two sets of coordinates.

Example

# Imports
from zcscommonlib import functions

# Main program logic
distance = functions.great_circle(52.370216, 4.895168, 52.520008, 13.404954)

print(distance)

# Output: 947546.2822650459

Month - functions.month()


Purpose

Takes an input of an integer and returns a string of the month of that number.

Args

num (int): The number of the month.

Returns

The month's name in string format.

Example

# Imports
from zcscommonlib import functions

# Main program logic
month = functions.month(5)

print(month)

# Output: May

Input Verify - functions.inputverify()


Purpose

Gets the input from a user, persisting until the input of the right type is received with an optional input message and error message.

Args

typein (str): The type of input to require of the user (int, float, str, bool).
inputmsg (str): The message to display to the user when getting input.
errormsg (str): The error to log to console when an input of the wrong type is given.

Returns

The input provided from the user in the desired format.

Clone this wiki locally