Skip to content

Instantly share code, notes, and snippets.

@shyampurk
Created June 29, 2018 09:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shyampurk/5ffd9a62cc53070a6e06c75dc5a895ad to your computer and use it in GitHub Desktop.
Save shyampurk/5ffd9a62cc53070a6e06c75dc5a895ad to your computer and use it in GitHub Desktop.
def handleEmergencyMessage(client, userdata, msg):
print(msg.topic + ' ' + str(msg.payload))
dataReceived = json.loads(msg.payload)
gpsLocation[0] = dataReceived["lat"]
gpsLocation[1] = dataReceived["lon"]
gps_tuple = tuple(gpsLocation)
distanceCalculated = int(vincenty(TRAFFIC_SIGNAL, gps_tuple).meters)
print ("Emergency Vehicle Location: ", distanceCalculated)
if distanceCalculated >= 150:
emergencyVehicleState["state"] = 0
trafficLightNormalCurrState = LIGHT_RED
else:
emergencyVehicleState["state"] = 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment