From f79748c113192c254ef8b6b9591d7e3707d74e9b Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Tue, 12 May 2020 17:37:48 -0700 Subject: [PATCH 1/3] Touch up distance API --- fgs/views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fgs/views.py b/fgs/views.py index 162ad26..42f6049 100644 --- a/fgs/views.py +++ b/fgs/views.py @@ -48,8 +48,9 @@ def collars_distance(): distance_kilometers = 0 coords_pairs = list(map(lambda e : (e.longitude, e.latitude), coords)) + if len(coord_pairs) < 1: continue - coord_last = coords_pairs.pop() + coord_last = coords_pairs.pop(0) for coord in coords_pairs: distance_kilometers += geopy.distance.VincentyDistance(coord_last,coord).km coord_last = coord From 7d3138c48fac8b322bf5c71d42a6d734b0a87b3c Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Tue, 12 May 2020 18:42:59 -0700 Subject: [PATCH 2/3] Fix typo --- fgs/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fgs/views.py b/fgs/views.py index 99ce8a6..2302358 100644 --- a/fgs/views.py +++ b/fgs/views.py @@ -89,4 +89,4 @@ def collar_detail(id): order_by(StimulusActivation.datetime.desc()) n_stimulus = stimulus_points.count() - return jsonify({'id': collar.id, 'name': collar.name, 'stimilus': n_stimulus }) + return jsonify({'id': collar.id, 'name': collar.name, 'stimulus': n_stimulus }) From 630ef001cc8af4f2253a6a625a7879052d35a1ca Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Tue, 12 May 2020 22:07:59 -0700 Subject: [PATCH 3/3] Update to latest GPS version. --- fgs/views.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fgs/views.py b/fgs/views.py index 2302358..6025f61 100644 --- a/fgs/views.py +++ b/fgs/views.py @@ -3,7 +3,7 @@ from .jwt import jwt_required from .model import * from flask import g, jsonify, request, abort from sqlalchemy import func -import geopy.distance +from geopy.distance import geodesic from datetime import datetime, timedelta @app.route('/') @@ -49,11 +49,11 @@ def collars_distance(): distance_kilometers = 0 coords_pairs = list(map(lambda e : (e.longitude, e.latitude), coords)) - if len(coord_pairs) < 1: continue + if len(coords_pairs) < 1: continue coord_last = coords_pairs.pop(0) for coord in coords_pairs: - distance_kilometers += geopy.distance.VincentyDistance(coord_last,coord).km + distance_kilometers += geodesic(coord_last,coord).km coord_last = coord active_collars.append(