def get_vehicle_info(vin): response = app.response_class( response=json.dumps(myp.get_vehicle_info(vin).to_dict(), default=str), status=200, mimetype='application/json' ) return response
def get_position(vin): res = myp.get_vehicle_info(vin) coordinates = res.last_position.geometry.coordinates if len(coordinates) == 3: # altitude is not always availlable longitude, latitude, altitude = coordinates return jsonify({ "longitude": longitude, "latitude": latitude, "altitude": altitude, "url": f"http://maps.google.com/maps?q={latitude},{longitude}" }) else: longitude, latitude = coordinates return jsonify({ "longitude": longitude, "latitude": latitude, "url": f"http://maps.google.com/maps?q={latitude},{longitude}" })
def get_vehicle_info(vin): from_cache = int(request.args.get('from_cache', 0)) == 1 response = app.response_class(response=json.dumps(myp.get_vehicle_info( vin, from_cache).to_dict(), default=str), status=200, mimetype='application/json') return response
def get_position(vin): res = myp.get_vehicle_info(vin) longitude, latitude = res.last_position.geometry.coordinates return jsonify({ "longitude": longitude, "latitude": latitude, "url": f"http://maps.google.com/maps?q={latitude},{longitude}" })
def get_position(vin): res = myp.get_vehicle_info(vin) try: coordinates = res.last_position.geometry.coordinates except AttributeError: return jsonify({'error': 'last_position not available from api'}) longitude, latitude, altitude = coordinates[:2] if len(coordinates) == 3: # altitude is not always available altitude = coordinates[2] else: altitude = None return jsonify( {"longitude": longitude, "latitude": latitude, "altitude": altitude, "url": f"https://maps.google.com/maps?q={latitude},{longitude}"})