Add bear_correction as response parameter
The paramater bear_correction is now added to the request response. It determines whether the dynamic azimuth correction based on the clients orientation is applied on the device or not. Also a bug for retrieving the correct row was fixed. Debug output removed.
This commit is contained in:
parent
488ad08e38
commit
7547640597
|
|
@ -8,6 +8,8 @@ from datetime import timezone as dttz
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
bear_correction = False
|
||||||
|
|
||||||
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()
|
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()
|
ureg = pint.UnitRegistry()
|
||||||
|
|
@ -44,13 +42,15 @@ def getGpsDistance():
|
||||||
lat = dm(lat) if lat and len(lat) > 1 else 0.0
|
lat = dm(lat) if lat and len(lat) > 1 else 0.0
|
||||||
long = dm(long) if long and len(long) > 1 else 0.0
|
long = dm(long) if long and len(long) > 1 else 0.0
|
||||||
|
|
||||||
|
print(request.args)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
gpsDateTime = datetime.strptime(request.args.get('gpsDateTime')[:11], '%d%m%y%H%M%S')
|
gpsDateTime = datetime.strptime(request.args.get('gpsDateTime')[:11], '%d%m%y%H%M%S')
|
||||||
print(gpsDateTime)
|
print(gpsDateTime)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
print("No gpsDateTime")
|
print("No gpsDateTime")
|
||||||
gpsDateTime = datetime.now()
|
gpsDateTime = datetime.now()
|
||||||
print(request.args)
|
|
||||||
|
|
||||||
|
|
||||||
with sqlite3.connect('location.db', check_same_thread=False) as conn:
|
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)
|
fwd_azimuth, back_azimuth, distance = geodesic.inv(long, lat, req_long, req_lat)
|
||||||
|
|
||||||
distance = distance * ureg.meter
|
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}')
|
print(f'fwd: {fwd_azimuth}, bwd: {back_azimuth}, dist: {prettyDistance}')
|
||||||
tf = timezonefinder.TimezoneFinder()
|
tf = timezonefinder.TimezoneFinder()
|
||||||
timezone_str = tf.certain_timezone_at(lat=lat, lng=long)
|
timezone_str = tf.certain_timezone_at(lat=lat, lng=long)
|
||||||
|
|
@ -103,11 +103,7 @@ def getGpsDistance():
|
||||||
fwd_azimuth = 0.0
|
fwd_azimuth = 0.0
|
||||||
rTime = datetime.utcnow()
|
rTime = datetime.utcnow()
|
||||||
|
|
||||||
|
return jsonify({'distance': prettyDistance, 'azimuth': fwd_azimuth, 'lastUpdateTZ': rTime.strftime("%m/%d %H:%M:%S"), 'bear_correction': bear_correction})
|
||||||
|
|
||||||
|
|
||||||
return jsonify({'distance': prettyDistance, 'azimuth': fwd_azimuth, 'lastUpdateTZ': rTime.strftime("%H:%M:%S")})
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def dm(ddmm: str):
|
def dm(ddmm: str):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user