Closed bsimmo closed 4 years ago
Fixed! Now I just need to deploy it.
The fix should be deployed to the beta version, @bsimmo. Perhaps you could test it and confirm that it's fixed?
The /beta URL is 404 not found for me (in browser and code)
On Fri, 6 Mar 2020, 12:04 pm Starbeamrainbowlabs, notifications@github.com wrote:
The fix should be deployed to the beta version https://sensors.connectedhumber.org/beta/, @bsimmo https://github.com/bsimmo. Perhaps you could test it and confirm that it's fixed?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ConnectedHumber/Air-Quality-Web/issues/59?email_source=notifications&email_token=ACYAXNYEZNJS2L4RCDJKXVTRGDRELA5CNFSM4LCOTU6KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEOBEDEQ#issuecomment-595739026, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACYAXN33KPJIKBJ7S2R3MWLRGDRELANCNFSM4LCOTU6A .
And me - live map is still there
Ack! It shouldn't have done that. It should be fixed now @BNNorman @bsimmo
Beta and live maps work for me
Site is working, but the API list-devices-near is not quite working.
If I asked for 3 locations, I would get three before (as intended) Now I just get the same one (nearest) three times.
Example Python3 code
import json
from urllib import request, parse
api_url = "http://sensors.connectedhumber.org/beta/api.php?action="
no_of_locations = 3
my_location = ( 53.750, -0.395 )
def get_nearest_sensors( my_location, no_of_locations ):
url = str( api_url ) + "list-devices-near&count=" + str( no_of_locations )
data = parse.urlencode( {'latitude': my_location[0], 'longitude': my_location[1]} ).encode()
req = request.Request( url, data=data )
response = request.urlopen( req )
return response
# ------- #
nearest_sensors = json.loads( get_nearest_sensors( my_location, no_of_locations ).read().decode('utf-8') )
print( nearest_sensors )
for line in nearest_sensors:
print( line['id'], line['name'], "is", round( line['distance_actual']*0.000621, 1), "miles away" )
print("----------")
Currently returns
[{'id': 36, 'name': 'CHASW-24AD43-1', 'latitude': 53.75642593, 'longitude': -0.36844245, 'distance_calc': 1886.588853560329, 'last_seen': '2020-03-08 21:32:06', 'distance_actual': 1892.19}, {'id': 36, 'name': 'CHASW-24AD43-1', 'latitude': 53.75642593, 'longitude': -0.36844245, 'distance_calc': 1886.588853560329, 'last_seen': '2020-03-08 21:32:06', 'distance_actual': 1892.19}, {'id': 36, 'name': 'CHASW-24AD43-1', 'latitude': 53.75642593, 'longitude': -0.36844245, 'distance_calc': 1886.588853560329, 'last_seen': '2020-03-08 21:32:06', 'distance_actual': 1892.19}]
36 CHASW-24AD43-1 is 1.2 miles away
36 CHASW-24AD43-1 is 1.2 miles away
36 CHASW-24AD43-1 is 1.2 miles away
Also as an aside, I thought 'distance_calc': 1886.588853560329 field was being removed as 'distance_actual' is the correct geodesic distance.
This started failing some time back, I mentioned it then but forgot all about it.
Can you check if the POST method for list-devices-near works For me it is failing still and the code has not changed
This abbreviated Python3 code should raise the 500 Server Error and had previously worked.