diff --git a/server/python_server.py b/server/python_server.py index 5e45271..62d550c 100644 --- a/server/python_server.py +++ b/server/python_server.py @@ -8,6 +8,8 @@ from datetime import timezone as dttz app = Flask(__name__) +bear_correction = False + with sqlite3.connect('location.db', check_same_thread=False) as conn: cur = conn.cursor() @@ -21,10 +23,6 @@ with sqlite3.connect('location.db', check_same_thread=False) as conn: );""" ) -with sqlite3.connect('location.db', check_same_thread=False) as conn: - cur = conn.cursor() - res = cur.execute("SELECT * FROM location_data;") - print(res.fetchall()) ureg = pint.UnitRegistry() @@ -43,6 +41,8 @@ def getGpsDistance(): lat = dm(lat) if lat and len(lat) > 1 else 0.0 long = dm(long) if long and len(long) > 1 else 0.0 + + print(request.args) try: gpsDateTime = datetime.strptime(request.args.get('gpsDateTime')[:11], '%d%m%y%H%M%S') @@ -50,7 +50,7 @@ def getGpsDistance(): except ValueError: print("No gpsDateTime") gpsDateTime = datetime.now() - print(request.args) + with sqlite3.connect('location.db', check_same_thread=False) as conn: @@ -86,7 +86,7 @@ def getGpsDistance(): fwd_azimuth, back_azimuth, distance = geodesic.inv(long, lat, req_long, req_lat) distance = distance * ureg.meter - prettyDistance = f"{distance:.1f~#P}" + prettyDistance = f"{distance:.1f~#P}" + ' (N)' if not bear_correction else '' print(f'fwd: {fwd_azimuth}, bwd: {back_azimuth}, dist: {prettyDistance}') tf = timezonefinder.TimezoneFinder() timezone_str = tf.certain_timezone_at(lat=lat, lng=long) @@ -103,11 +103,7 @@ def getGpsDistance(): fwd_azimuth = 0.0 rTime = datetime.utcnow() - - - - return jsonify({'distance': prettyDistance, 'azimuth': fwd_azimuth, 'lastUpdateTZ': rTime.strftime("%H:%M:%S")}) - + return jsonify({'distance': prettyDistance, 'azimuth': fwd_azimuth, 'lastUpdateTZ': rTime.strftime("%m/%d %H:%M:%S"), 'bear_correction': bear_correction}) def dm(ddmm: str):