cuspatial icon indicating copy to clipboard operation
cuspatial copied to clipboard

[QST] How to do point on line check?

Open jweisbaum opened this issue 4 years ago • 6 comments

What is your question? I could be crazy but I didn't see an obvious way to check if a point is on a line from the docs. Is the expected way to find the distance and if it's 0 it's assumed to be on the line? How about line intersection checks or self intersection checks, or line simplification? Thanks.

jweisbaum avatar Apr 24 '21 18:04 jweisbaum

Hi @jweisbaum ! That's correct, there's no point-on-line API at this time, but you could use the polyline distance API cuspatial.quadtree_point_to_nearest_polyline. We don't have intersection checks or line simplification - can you point out a specific API that I could copy? :)

thomcom avatar Apr 29 '21 20:04 thomcom

In general I'm looking to replace turf.js: https://turfjs.org/ My use case is as follows: we do real-time scoring and routing of sailboat races. A sailing race course can consist of points, lines and polygons. A big race may have 1000 boats but we may be running hundreds of races at a time, so we have a need to check every second (or many times a second) if thousands of boats crossed thousands of start/finish lines. We're also interested in checking if a boat's track crosses over itself (did it do a 360?) and line simplification will be useful to reduce the amount of data downloaded by people viewing the race tracks. Not sure if Douglas-Peuker can be parallelized or not.

https://turfjs.org/docs/#pointOnFeature https://turfjs.org/docs/#lineIntersect https://turfjs.org/docs/#simplify

Buffer would also be useful for us since we often need to check if someone is near the coast and the global coast datasets are large and buffering takes forever.

https://turfjs.org/docs/#buffer

jweisbaum avatar May 05 '21 15:05 jweisbaum

Is turfjs implemented in Javascript? For your small-ish data size (O(100K) boats) you may not even need a GPU, just a better CPU implementation (e.g. in C++)

harrism avatar May 06 '21 02:05 harrism

I believe turf is implemented in js. It's true the number of boats isn't likely to be huge but it's important for our end users that we have incredibly low latency. Also, we want to do privacy checks and filtering for data - for instance having high resolution polygons of the land or Open Street Map data, and if someone is on a highway, or on land, we can throw out those data points for privacy reasons because they obviously aren't part of the race. If we end up doing these checks a few times a second for hundreds of races at a time, I think the parallelization would help us with latency. We're also interested in offline stuff with much larger data sets. For instance when we open our data set up to Olympic race teams sailing in a new area, they pull in tens of millions of positions for that region from archived races to answer questions like which side of the bay is more advantageous. The real time component of the system is mission critical - for instance being able to umpire races and react in real time as the boats cross lines or enter areas. The subscribers on the other end can't wait around too long for events. It's true I haven't benchmarked turf.js yet, I was just hoping we could get a POC running with parallelization from the get-go.

jweisbaum avatar May 06 '21 17:05 jweisbaum

This issue has been labeled inactive-90d due to no recent activity in the past 90 days. Please close this issue if no further response or action is needed. Otherwise, please respond with a comment indicating any updates or changes to the original issue and/or confirm this issue still needs to be addressed.

github-actions[bot] avatar Nov 23 '21 20:11 github-actions[bot]

This issue has been labeled inactive-30d due to no recent activity in the past 30 days. Please close this issue if no further response or action is needed. Otherwise, please respond with a comment indicating any updates or changes to the original issue and/or confirm this issue still needs to be addressed. This issue will be labeled inactive-90d if there is no activity in the next 60 days.

github-actions[bot] avatar Nov 23 '21 20:11 github-actions[bot]