tidwall / tile38

Real-time Geospatial and Geofencing
https://tile38.com
MIT License
9.09k stars 569 forks source link

Web Hook Not Firing #311

Open gmonk63 opened 6 years ago

gmonk63 commented 6 years ago

SETHOOK NB_6500 redis://localhost:6379/local INTERSECTS FD WHERE Bearing 340 +inf WHERE Bearing -inf 20 FENCE DETECT enter OBJECT { "type": "Feature", "properties": { "IntID": 6500, "Longitude": -111.840065942233, "Latitude": 33.400579713564497 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -111.840065942232997, 33.400579713564497 ], [ -111.83949460992865, 33.393726108276795 ], [ -111.840065942232997, 33.393709373780418 ], [ -111.840637274537343, 33.393726108276795 ], [ -111.840065942232997, 33.400579713564497 ] ] ] } }

Trying to create FENCE that will trigger webhook based on direction of travel using the bearing provided by GPS. All others work except Northbound. ex. Eastbound 70 +inf -inf 110 Westbound 250 +inf -inf 290 Southbound 160 +inf -inf 190 However it will work if i exclude WHERE Bearing -inf 20 but this will only cover someone traveling NNW to N where Im trying to cover NNW to NNE

gmonk63 commented 6 years ago

After looking closer at the docs I see why its not working. I was assuming mutiple WHERE statements provided an OR like function but i was wrong. Is it possible to add a statement that provides this or do I need to use the WHEREIN and list 340,341,342,343,344,345...0,1,2,3,4,5,6,7...20 and does providing a large list like this take away from performance.

tidwall commented 6 years ago

The WHEREIN with a list of options is one way, though I might be concerned with performance. Also try out the WHEREEVAL option. It utilizes the builtin Lua interpreter.

INTERSECTS FD WHEREEVAL "return FIELDS.Bearing >= 340 or FIELDS.Bearing <= 20" 0 ...

I recommend experimenting with both.

abhit011 commented 6 years ago

I have a hook set like this {"ok":true,"hooks":[{"name":"geoId_0","key":"fleet","endpoints":["kafka://127.0.0.1:9092/geofishing","kafka://127.0.0.1:9093/geofishing","kafka://127.0.0.1:9094/geofishing","kafka://127.0.0.1:9095/geofishing","kafka://127.0.0.1:9096/geofishing","kafka://127.0.0.1:9097/geofishing","kafka://127.0.0.1:9098/geofishing"],"command":["INTERSECTS","fleet","FENCE","DETECT","enter","OBJECT","{\"type\":\"Feature\",\"properties\": {\"site\":\"Airport\",\"siteid\":\"10\", \"cid\": \"153\"},\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[80.877656,26.761911],[80.877656,26.763941],[80.881754,26.763941],[80.881754,26.761911],[80.877656,26.761911]]]}}"]}],"elapsed":"0s"} and when i do

set fleet 123123 POINT 80.881754 26.763941

No hooks getting fired

abhit011 commented 6 years ago

am i doing something wrong ?

tidwall commented 6 years ago

The SET ... POINT command is in lat/lon order, not lon/lat

try

SET fleet 123123 POINT 26.763941 80.881754
abhit011 commented 6 years ago

Oh my bad... I will correct it...

if i have to detect "enter,exit" on object e.g below ``

r1.execute_command('SETHOOK', savetile, 'kafka://127.0.0.1:9092/geofishing,kafka://127.0.0.1:9093/geofishing,kafka://127.0.0.1:9094/geofishing,kafka://127.0.0.1:9095/geofishing,kafka://127.0.0.1:9096/geofishing,kafka://127.0.0.1:9097/geofishing,kafka://127.0.0.1:9098/geofishing', 'INTERSECTS','fleet','FENCE','DETECT','enter','exit','OBJECT',hookline)

its giving me error..

redis.exceptions.ResponseError: invalid argument 'exit'

abhit011 commented 6 years ago

''enter,exit',' this sovled it...

tidwall commented 6 years ago

@abhit011 Good to hear. 👍