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

Find nearest neighbors even if no bbox intersection is found #3

Closed
zimmicz opened this Issue Nov 21, 2017 · 1 comment

Comments

Projects
None yet
1 participant
@zimmicz
Owner

zimmicz commented Nov 21, 2017

Probably via growing bbox of target feature until it intersects with at least one source feature bbox.

@zimmicz zimmicz self-assigned this Nov 21, 2017

@zimmicz zimmicz added this to the 1.0 milestone Nov 21, 2017

@zimmicz

This comment has been minimized.

Show comment
Hide comment
@zimmicz

zimmicz Nov 22, 2017

Owner

Be careful about this one! Even though you may find a bbox intersection, it doesn't necessarily have to be the closest feature. See lines 4 and 7 in the picture below.

The correct steps to be taken:

  1. try using QgsSpatialIndex.intersects to find any intersection
  2. if any is found, get the distance between the two features
  3. use this distance as the new bbox for the target feature to test whether there are any features closer to it
  4. if none is found, grow target feature bbox step by step until the intersection is found

qgis

Owner

zimmicz commented Nov 22, 2017

Be careful about this one! Even though you may find a bbox intersection, it doesn't necessarily have to be the closest feature. See lines 4 and 7 in the picture below.

The correct steps to be taken:

  1. try using QgsSpatialIndex.intersects to find any intersection
  2. if any is found, get the distance between the two features
  3. use this distance as the new bbox for the target feature to test whether there are any features closer to it
  4. if none is found, grow target feature bbox step by step until the intersection is found

qgis

@zimmicz zimmicz closed this Nov 26, 2017

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