Add traffic light range to entity
This commit is contained in:
parent
2514ba60e8
commit
c76bbdc42f
@ -40,19 +40,27 @@ def get_traffic_lights_geo():
|
|||||||
|
|
||||||
lat = float(query_parameters.get('lat'))
|
lat = float(query_parameters.get('lat'))
|
||||||
lon = float(query_parameters.get('lon'))
|
lon = float(query_parameters.get('lon'))
|
||||||
distance = float(query_parameters.get('distance'))
|
|
||||||
|
|
||||||
traffic_lights = [
|
traffic_lights = [
|
||||||
traffic_light for traffic_light in
|
traffic_light for traffic_light in
|
||||||
mongo.db.trafficLights.find({'location': {
|
mongo.db.trafficLights.aggregate([
|
||||||
'$near': {
|
{"$geoNear": {
|
||||||
'$geometry': {
|
"near": {
|
||||||
'type': "Point",
|
"type": "Point",
|
||||||
'coordinates': [lon, lat]
|
"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})
|
return json_util.dumps({'cursor': traffic_lights})
|
||||||
|
|||||||
@ -1,10 +1,17 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"id": "1",
|
"id": "1",
|
||||||
"location": [16.315283, 48.190331]
|
"location": [16.0, 48.0],
|
||||||
|
"range": 2000
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "2",
|
"id": "2",
|
||||||
"location": [16.316331, 48.192382]
|
"location": [16.0, 48.1],
|
||||||
|
"range": 800
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "3",
|
||||||
|
"location": [16.0, 48.2],
|
||||||
|
"range": 1000
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
Loading…
x
Reference in New Issue
Block a user