tidwall / tile38

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

Decreasing/increasing a polygon is not reflected in detect events #589

Open iwpnd opened 3 years ago

iwpnd commented 3 years ago

Hi! 👋

Describe the bug (?) I create a setchan on a warehouse, and set a point into it I receive an enter,inside event. If I now shrink the polygon of that warehouse and set the point with the same coordinates again, I receive an outside event, where I would expect an exit event. On the other hand, if I change the polygon to it's original size, I receive an inside event, while I would expect an enter event. If at this state I create the point outside, I receive an exit

To Reproduce create a warehouse

setchan warehouse within fleet object '{"type": "Polygon","coordinates":[[[13.3978271484375,52.47241630049245],[13.40055227279663,52.47241630049245],[13.40055227279663,52.47397169787183],[13.3978271484375,52.47397169787183],[13.3978271484375,52.47241630049245]]]}'

set point inside

set fleet scooter point 52.47391941649986 13.39930772781372

shrink warehouse

setchan warehouse within fleet object '{"type": "Polygon","coordinates":[[[13.398149013519287,52.47265157421311],[13.400230407714844,52.47265157421311],[13.400230407714844,52.47374950161198],[13.398149013519287,52.47374950161198],[13.398149013519287,52.47265157421311]]]}'

set point inside again

set fleet scooter point 52.47391941649986 13.39930772781372

Expected behavior On shrinking a hook/chan I would expect an exit event for vehicles that were previously inside the bigger version of it. Vice versa: If I start with a smaller polygon and set a point outside, I get an outside event. On expanding the hook/chan I would expect an enter event for vehicles that were previously outside the smaller version of it, but I receive an inside event.

What do you think about that?

tidwall commented 3 years ago

Hi, I can certainly see a value in having geofence updates trigger the detection system. But right now, only changes to objects will send notifications, not the other way around.

iwpnd commented 3 years ago

thank you for getting back to me on this.

I'm not entirely sure if we talk about the same thing, so when in doubt that might be my fault. I picturing like the following:

In this scenario geofences are subject to change on a regular basis. I set them up to with DETECT enter,exit because because inside,outside would be causing to much traffic. A vehicle enters a geofence and the fence triggers enter correctly. Now while the vehicle is in the geofence, constantly sending updates, the geofence shrinks but the vehicle does not change position, just sends the same one over and over. Would you not expect this to trigger an exit event, when the underlying fence shrinks in this scenario?