tidwall / tile38

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

Determining if on route #182

Open deathg0d opened 7 years ago

deathg0d commented 7 years ago

I was trying to calculate if a vehicle is on a predefined route. For this I used several circular geofences on the route and checked if the course is as expected. Is there a better method to do this? Or would it be useful to somehow introduce linestring? So far I haven't seen any documentation regarding this, also it looks resource consuming and would require optimizations. Regardless, don't you think ability to check if a vehicle is in its route would be a good feature for tile38? Or would this be outside the scope of tile38?

Lars-Meijer commented 7 years ago

I think what you are looking for is #79, there is however no functionality that currently supports this.

What you could do is make a polygon of a linestring yourself (maybe use the operation described in #79), and use this to check if your point is inside this polygon.

deathg0d commented 7 years ago

@Lars-Meijer Yes that is what I am looking for. For now I will use the polygon method. Thanks. However, it would be great to have feature as described in #79 as many open data have streets depicted as linestrings.

Lars-Meijer commented 7 years ago

However, it would be great to have feature as described in #79 as many open data have streets depicted as linestrings.

I agree, it would be a useful feature.

I did some digging and found a similar feature in the Java Topology Suite (JTS), it's called buffer and its documentation can be found here: https://locationtech.github.io/jts/javadoc/org/locationtech/jts/geom/Geometry.html#buffer(double)

It mentions the Minkowski sum: "Computes a buffer area around this geometry having the given width. The buffer of a Geometry is the Minkowski sum or difference of the geometry with a disc of radius abs(distance)."

Maybe this can be ported to go (or maybe it already has been ported), or maybe you can create a java program that converts linestrings to polygons with this.

tidwall commented 7 years ago

@deathg0d I'm sorry that the buffering feature is not a part of Tile38 yet. This will be an incredible addition. Both for geofencing and performing NEARBY/KNN queries on polygons. For now there's only workarounds.

Adding circles is one way, or ever a series of circles and/or polygons that simulate a buffer around the line. These geometries could then be added to one FeatureCollection that the geofence uses. There may be other ways too, and I know it's not ideal. :\

@Lars-Meijer Thanks for sharing the link. The JTS library looks very interesting. A potential target for porting to Go.

Right now I'm knee-deep in getting the alpha branch for 2.0 together, but this feature is on my short list for "absolute next additions".

deathg0d commented 7 years ago

@Lars-Meijer Thanks a lot for the link. I will check it out too. @tidwall No pressure :) We understand that you are trying to do a lot. Take your time. Your responsiveness to our queries already mean a lot to us.

abhit011 commented 6 years ago

Isn't perpendicular distance is best approach to determine if its on route or not ? The length of the perpendicular is what determines your range ... Abhi !wq