tidwall / tile38

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

Filtering #292

Open gmonk opened 6 years ago

gmonk commented 6 years ago

Is it possible to filter points based on direction? If my direction of travel is East bound and I have several points along this path but only want to know x number of upcoming locations is this possible. Ive tried Geofences but because the close proximity of points to the north and south and the radius I need which 762m everything seems to overlap.

tidwall commented 6 years ago

I can't think of a way to currently derive direction from Tile38. The only thing that comes to mind is; prior to setting a point, get the previous point and calculate the bearing from the two. But this might not be very accurate (airplanes would be fine, but cars, bike, or walkers not so much).

You'll probably need a sample set of points to calculate from to get a decent result, sort like a history of points. Tile38 doesn't currently keep this information, but I could see it as a candidate for a future feature.

Sometimes GPS devices come with bearing details, like the iPhone and Android phones. I believe Garmin and many chip providers do the sampling at the hardware level and often provide directions with each point update.

If it's possible to get it from the hardware, then perhaps you could set a custom field in for the point:

SET fleet truck1 FIELD direction 54 POINT 33.0 -115.0

Then you could filter on the "direction" field with queries and geofencing.

gmonk63 commented 6 years ago

what about using shapes. I created a polygon for each leg of the intersection N,E,S,W and Im trying to create geofence out of each that would trigger on enter,exit only but im not having any luck im running the following NEARBY EB_Preempt FENCE OBJECT { "type": "Feature", "properties": { "IntID": 3750, "Location": "Main & Dobson", "Type": "D4", "Ip": "x.x.x.x", "Longitude": -111.874472384987, "Latitude": 33.414853417361101 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -111.87447, 33.41485 ], [ -111.88264, 33.41437 ], [ -111.88266, 33.41485 ], [ -111.88264, 33.41533 ], [ -111.87447, 33.41485 ] ] ] } } I get (error) invalid argument 'OBJECT' The docs say geojson format is supported but am i missing somthing? I checked it on geojson.io and it displays no problem. I only really need to know which direction the Truck came from so if it is heading East on Dobson and Just entered the EB fence and Exited the WB Fence I know the next intersection coming up is Alma School

tidwall commented 6 years ago

The NEARBY is only for points. You'll need to use INTERSECTS or WITHIN

gmonk63 commented 6 years ago

Ah ha ... I knew I was doing something wrong. That worked thank you. On a side note I know you have the Patreon page but have you thought about offering commercial support?

tidwall commented 6 years ago

I recently added the Patreon page so that I can provide priority support to backers and sponsors, but I've done commercial support specifically for Tile38. Shoot me an email if you want to discuss further.