Initial commit of files
This commit is contained in:
0
Templates/Project/README.txt
Normal file
0
Templates/Project/README.txt
Normal file
0
Templates/Project/docs/conf.py
Normal file
0
Templates/Project/docs/conf.py
Normal file
0
Templates/Project/docs/index.rst
Normal file
0
Templates/Project/docs/index.rst
Normal file
0
Templates/Project/docs/quickstart.rst
Normal file
0
Templates/Project/docs/quickstart.rst
Normal file
0
Templates/Project/foobar/__init__.py
Normal file
0
Templates/Project/foobar/__init__.py
Normal file
0
Templates/Project/foobar/cli.py
Normal file
0
Templates/Project/foobar/cli.py
Normal file
0
Templates/Project/foobar/storage.py
Normal file
0
Templates/Project/foobar/storage.py
Normal file
0
Templates/Project/foobar/tests/__init__.py
Normal file
0
Templates/Project/foobar/tests/__init__.py
Normal file
0
Templates/Project/foobar/tests/test_cli.py
Normal file
0
Templates/Project/foobar/tests/test_cli.py
Normal file
0
Templates/Project/foobar/tests/test_storage.py
Normal file
0
Templates/Project/foobar/tests/test_storage.py
Normal file
0
Templates/Project/setup.cfg
Normal file
0
Templates/Project/setup.cfg
Normal file
0
Templates/Project/setup.py
Normal file
0
Templates/Project/setup.py
Normal file
37
classes/gpsmath.py
Normal file
37
classes/gpsmath.py
Normal file
@ -0,0 +1,37 @@
|
||||
from math import sin, cos, asin, sqrt, radians
|
||||
|
||||
earth_flatening = 1.0/298.257223563
|
||||
earth_radius = 6378137.0
|
||||
|
||||
def haversine(lat1, lon1, lat2, lon2):
|
||||
"""
|
||||
Calculate the great circle distance between two points
|
||||
on the earth (specified in decimal degrees)
|
||||
"""
|
||||
# convert decimal degrees to radians
|
||||
lon1, lat1, lon2, lat2 = map(radians, [lon1, lat1, lon2, lat2])
|
||||
|
||||
# haversine formula
|
||||
dlon = lon2 - lon1
|
||||
dlat = lat2 - lat1
|
||||
a = sin(dlat/2)**2 + cos(lat1) * cos(lat2) * sin(dlon/2)**2
|
||||
c = 2 * asin(sqrt(a))
|
||||
|
||||
# 6367 km is the radius of the Earth
|
||||
return earth_radius * c
|
||||
|
||||
def roydistance(lat1, lon1, lat2, lon2):
|
||||
"""
|
||||
Calculate the great circle distance between two points
|
||||
on the earth (specified in decimal degrees)
|
||||
"""
|
||||
# convert decimal degrees to radians
|
||||
lon1, lat1, lon2, lat2 = map(radians, [lon1, lat1, lon2, lat2])
|
||||
|
||||
# Roy's method
|
||||
f1 = (1.0 - earth_flatening)
|
||||
|
||||
top = (pow((lon2-lon1), 2) * pow(cos(lat1), 2)) + pow(lat2-lat1, 2)
|
||||
bot = pow(sin(lat1), 2) + (pow(f1, 2) * pow(cos(lat1), 2))
|
||||
|
||||
return f1 * earth_radius * sqrt(top/bot)
|
||||
22
classes/utils/audio.py
Normal file
22
classes/utils/audio.py
Normal file
@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Created on Fri Jan 8 10:26:56 2021
|
||||
|
||||
@author: neal
|
||||
"""
|
||||
|
||||
import os
|
||||
from sys import platform as _platform
|
||||
|
||||
sound_args = ""
|
||||
|
||||
def play_sound(file):
|
||||
if _platform == "win32" or _platform == "win64" or _platform == "cygwin":
|
||||
cmd = "wmplayer " + '"' + file + '"'
|
||||
else:
|
||||
cmd = "aplay -N " + sound_args + " " + file + " &"
|
||||
# print(cmd)
|
||||
os.system(cmd)
|
||||
|
||||
#play_sound("../misc/boat-horn.wav")
|
||||
81
classes/utils/logging.py
Normal file
81
classes/utils/logging.py
Normal file
@ -0,0 +1,81 @@
|
||||
import sys
|
||||
from time import strftime, time
|
||||
import csv
|
||||
import json
|
||||
|
||||
#
|
||||
# Text logging
|
||||
#
|
||||
class LOGlog():
|
||||
def __init__(self):
|
||||
self.filename = ""
|
||||
self.handle = 0
|
||||
self.lineno = 0
|
||||
|
||||
def genname(dire="logs", basename="log-", ext="log"):
|
||||
return dire + '/' + basename + strftime("%Y%m%d-%H%M.") + ext
|
||||
|
||||
def create(self, dire="logs", basename="log-", ext="log"):
|
||||
self.lineno = 0
|
||||
self.handle = open(dire + "/" + basename + strftime("%Y%m%d-%H%M.") + ext, 'a')
|
||||
|
||||
def open(self, filename):
|
||||
self.filename = filename
|
||||
self.handle = open(filename, 'r')
|
||||
|
||||
def write(self, str):
|
||||
self.lineno = self.lineno + 1
|
||||
self.handle.write(str + "\n")
|
||||
|
||||
def read(self):
|
||||
self.lineno = self.lineno + 1
|
||||
return self.handle.read()
|
||||
|
||||
def close(self):
|
||||
self.handle.close()
|
||||
|
||||
def lines(self):
|
||||
return self.lineno
|
||||
|
||||
#
|
||||
# CSV logging
|
||||
#
|
||||
class CSVlog(LOGlog):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.header = ""
|
||||
|
||||
def create(self, dire="logs", basename="log-"):
|
||||
super().create(dire, basename, "csv")
|
||||
|
||||
def open(self, filename):
|
||||
self.reader = csv.reader(super().filename)
|
||||
super().open(filename)
|
||||
|
||||
def read(self):
|
||||
return self.reader.next(super().handle)
|
||||
|
||||
def readall(self, csvfile):
|
||||
data = csv.reader(csvfile)
|
||||
csv.close()
|
||||
return list(data)
|
||||
|
||||
#
|
||||
# JSON logging
|
||||
#
|
||||
class JSONlog(LOGlog):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
def create(self, dire="logs", basename="log-"):
|
||||
super().create(dire, basename, "json")
|
||||
|
||||
def open(self, filename):
|
||||
super().open(filename)
|
||||
|
||||
def write(self, data):
|
||||
data['timestamp'] = time()
|
||||
super().write(json.dumps(data))
|
||||
|
||||
def read(self, ):
|
||||
return json.loads(super().read())
|
||||
8
packages/PACKAGES.txt
Normal file
8
packages/PACKAGES.txt
Normal file
@ -0,0 +1,8 @@
|
||||
|
||||
Required Python3 packages:
|
||||
==========================
|
||||
subversion
|
||||
python3-all
|
||||
python3-pil.imagetk
|
||||
spyder3
|
||||
|
||||
14
packages/packages.sh
Executable file
14
packages/packages.sh
Executable file
@ -0,0 +1,14 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Python 3
|
||||
echo "Python 3 packages:"
|
||||
sudo apt-get -y --ignore-missing install python3-all python3-dev python3-tk idle3 python3-pip python3-pyqt5 python3-serial python3-can python3-protobuf python3-numpy python3-pil.imagetk python3-gi
|
||||
|
||||
# Python addons
|
||||
sudo -H pip install --upgrade pip
|
||||
sudo -H pip install configparser pyside2 pycrate
|
||||
|
||||
# cleanup
|
||||
sudo apt-get autoremove
|
||||
sudo apt-get clean
|
||||
|
||||
Reference in New Issue
Block a user