add boundaries to model and view

This commit is contained in:
sessionm21 2020-05-13 06:58:49 +01:00
commit 48fb5d0d9b

View File

@ -3,7 +3,7 @@ from .jwt import jwt_required
from .model import * from .model import *
from flask import g, jsonify, request, abort from flask import g, jsonify, request, abort
from sqlalchemy import func from sqlalchemy import func
import geopy.distance from geopy.distance import geodesic
from datetime import datetime, timedelta from datetime import datetime, timedelta
@app.route('/') @app.route('/')
@ -49,10 +49,11 @@ def collars_distance():
distance_kilometers = 0 distance_kilometers = 0
coords_pairs = list(map(lambda e : (e.longitude, e.latitude), coords)) coords_pairs = list(map(lambda e : (e.longitude, e.latitude), coords))
if len(coords_pairs) < 1: continue
coord_last = coords_pairs.pop(0) coord_last = coords_pairs.pop(0)
for coord in coords_pairs: for coord in coords_pairs:
distance_kilometers += geopy.distance.VincentyDistance(coord_last,coord).km distance_kilometers += geodesic(coord_last,coord).km
coord_last = coord coord_last = coord
active_collars.append( active_collars.append(