diff --git a/fgs/views.py b/fgs/views.py index ffbdd66..25ee3b2 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,10 +49,11 @@ def collars_distance(): distance_kilometers = 0 coords_pairs = list(map(lambda e : (e.longitude, e.latitude), coords)) + 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(