Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding tolerance to @turf/boolean-point-on-line #906

Open
rowanwins opened this issue Aug 16, 2017 · 7 comments
Open

Adding tolerance to @turf/boolean-point-on-line #906

rowanwins opened this issue Aug 16, 2017 · 7 comments

Comments

@rowanwins
Copy link
Member

rowanwins commented Aug 16, 2017

A couple of days ago @DenisCarriere raised the possibility of adding a tolerance threshold to @turf/boolean-point-on-line. Currently the point has to be exactly on the line, there is 0 margin for error.

A few finds from my investigations

  • As far as I can work out the current algorithm doesn't really support adding in a tolerance check
  • I did find a pretty neat algorithm for finding the distance between a point and a line here
    • we don't really have a module for this currently, is this something we'd like to package up @DenisCarriere ?
    • this is quite a bit slower than the current algorithm (eg half the number of ops per sec) but if it only got called when the tolerance threshold was set that might be acceptable...
  • there are a couple of other potential options that I'd like to explore still that would be an entire replacement

I knew I should've paid more attention in maths!

@rowanwins
Copy link
Member Author

Both my other options are a no go, they were more about using an epsilon value to round float point precision which isn't really what we're wanting from this tolerance type setting.

So I'm thinking the distance measurement is the best bet at the moment...

Will keep mulling it over

@DenisCarriere
Copy link
Member

👍 @rowanwins great findings, I wouldn't sweat it if we don't get this implemented, the pointOnLine does seem to do the job at the moment.

Very interesting links you provided, I also should of paid more attention to math 😄

@stebogit
Copy link
Collaborator

we don't really have a module for this ['finding the distance between a point and a line'] currently

@rowanwins @turf/point-on-line does actually calculate that distance (probably not in the fastest way) and returns the point on the line at the closest distance (from the input point).
It might be useful to create a module for that calculation, and maybe make sure we use the fastest algorithm in there.

BTW, in this issue we are talking about @turf/boolean-point-on-line right?
Quite confusing that we have two different modules almost with the same name 😅

@DenisCarriere
Copy link
Member

maybe make sure we use the fastest algorithm in there.

👍 That would be handy!

Quite confusing that we have two different modules almost with the same name

Agreed, it can get confusing at times 😢

@DenisCarriere DenisCarriere changed the title Adding tolerance to point-on-line Adding tolerance to @turf/boolean-point-on-line Aug 19, 2017
@rowanwins
Copy link
Member Author

Adding another reference to this jsfiddle which looks pretty close to what we want. Had a brief go at getting it going with no joy so needs a bit more thought

@DenisCarriere
Copy link
Member

That JSFiddle is really cool! 😄 so fun!

@chris-gaona
Copy link

This ticket is pretty old, but has anymore progress been made for this issue?

We have a use case where we're using the nearestPointOnLine method in our UI to keep a point on a line string & then using the booleanPointOnLine method in our api to validate the point from the UI is actually on the line string, but because it's expecting such an exact number, the validation pretty much always returns false.

We're looking into the jsfiddle above as maybe a potential solution. Thanks for sharing that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants