Add traffic light range to entity
This commit is contained in:
@@ -40,19 +40,27 @@ def get_traffic_lights_geo():
|
||||
|
||||
lat = float(query_parameters.get('lat'))
|
||||
lon = float(query_parameters.get('lon'))
|
||||
distance = float(query_parameters.get('distance'))
|
||||
|
||||
traffic_lights = [
|
||||
traffic_light for traffic_light in
|
||||
mongo.db.trafficLights.find({'location': {
|
||||
'$near': {
|
||||
'$geometry': {
|
||||
'type': "Point",
|
||||
'coordinates': [lon, lat]
|
||||
mongo.db.trafficLights.aggregate([
|
||||
{"$geoNear": {
|
||||
"near": {
|
||||
"type": "Point",
|
||||
"coordinates": [lon, lat]
|
||||
},
|
||||
'$maxDistance': distance
|
||||
}
|
||||
}})
|
||||
"spherical": True,
|
||||
"distanceField": "calculatedRange"
|
||||
}},
|
||||
{"$redact": {
|
||||
"$cond": {
|
||||
"if": {"$lte": ["$calculatedRange", "$range"]},
|
||||
"then": "$$KEEP",
|
||||
"else": "$$PRUNE"
|
||||
}
|
||||
}}
|
||||
]
|
||||
)
|
||||
]
|
||||
|
||||
return json_util.dumps({'cursor': traffic_lights})
|
||||
|
||||
Reference in New Issue
Block a user