Skip to content

Faster distance calculation between multigeometries - #15

Merged
patrickbr merged 28 commits into
masterfrom
dist-experiments
Jul 27, 2026
Merged

Faster distance calculation between multigeometries#15
patrickbr merged 28 commits into
masterfrom
dist-experiments

Conversation

@patrickbr

@patrickbr patrickbr commented Dec 22, 2025

Copy link
Copy Markdown
Member

This so fare includes several successful experiments I did over the last week, with the overall goal of speeding up the distance calculation between very large multi-geometries (MULTI* and COLLECTION).

1.) Store the current upper distance bound across multi geometry parts, which causes many candidates being already discarded via a simple bounding box distance calculation

2.) Improve the initial upper bound by storing, for each multigeometry, the rightmost point during parsing

3.) Make the padding for the meter distance distortion on the web mercator projected plane more tight by only considering the local distortion (e.g. if we know that both geometries are on the same "band" around the globe, it is necessary to consider the global distortion factor initially for computing the euclidean distance upper bound, but for the further sweep padding it is then enough to only consider the relative distortion between the geometries (which is nearly 1 if latitudes are close)

4.) Update libspatialjoin to a new experimental version which computes tighter initial upper distance bounds on start (by doing a simple probing of 4 points) and which also updates the sweeping padding dynamically during the sweep.

5.) On the side, fix a very subtle bug in which the distortion for the candidate sweep padding was computed based on the original geometry, but it must be computed based on the padded geometry. This caused some lost candidates on very large distances.

…distance calculation between multigeometries: store the current upper distance bound across multi geometry parts, which causes many candidates being already discarded via a simple bounding box distance calculation, improve the initial upper bound by storing, for each multigeometry, the rightmost point during parsing, make the padding for the meter distance distortion on the web mercator projected plane more tight by only considering the local distortion (e.g. if we know that both geometries are on the same "band" around the globe, it is enough to consider the global distortion factor initially for computing the euclidean distance upper bound, but for the padding it is then enough to only consider the relative distortion between the geometries (which is then nearly 1), fix a very subtle bug in which the distortion for the candidate sweep padding was computed based on the *original* geometry, but it must be computed based on the *padded* geometry
@patrickbr
patrickbr merged commit 215c8a6 into master Jul 27, 2026
4 checks passed
@patrickbr
patrickbr deleted the dist-experiments branch July 27, 2026 09:30
@hannahbast hannahbast changed the title Faster distance clalculation between multigeometries Faster distance calculation between multigeometries Aug 5, 2026
hannahbast pushed a commit to ad-freiburg/qlever that referenced this pull request Aug 10, 2026
…ons, and CRS IRIs (#3184)

This PR updates the `libspatialjoin` library so that follow-up PRs (including #3183) can make use of new features:

- DE-9IM filters in spatial joins (ad-freiburg/spatialjoin#13)
- Improved distance computations (ad-freiburg/spatialjoin#15)
- CRS IRI support (ad-freiburg/spatialjoin#21)

The improved distance computation slightly changes the results of `geof:distance` and of spatial joins with a maximum distance. The distances are now accurate for the WGS84 ellipsoid. For example, the 421.7 km between the Eiffel Tower and the Freiburg Cathedral change by around 10 m. Two unit tests are adapted accordingly.
hannahbast pushed a commit to ad-freiburg/qlever that referenced this pull request Aug 10, 2026
…ons, and CRS IRIs (#3184)

This PR updates the `libspatialjoin` library so that follow-up PRs (including #3183) can make use of new features:

- DE-9IM filters in spatial joins (ad-freiburg/spatialjoin#13)
- Improved distance computations (ad-freiburg/spatialjoin#15)
- CRS IRI support (ad-freiburg/spatialjoin#21)

The updated library slightly changes the results of `geof:distance` and of spatial joins with a maximum distance (for example, the 421.7 km between the Eiffel Tower and the Freiburg Cathedral change by around 10 m). Two unit tests are adapted accordingly. Note that `geof:distance` itself still uses the previous approximate computation in projected coordinates, switching it to the improved distance computation is part of the planned follow-ups.
yarox-1 pushed a commit to yarox-1/qlever that referenced this pull request Aug 11, 2026
…ons, and CRS IRIs (ad-freiburg#3184)

This PR updates the `libspatialjoin` library so that follow-up PRs (including ad-freiburg#3183) can make use of new features:

- DE-9IM filters in spatial joins (ad-freiburg/spatialjoin#13)
- Improved distance computations (ad-freiburg/spatialjoin#15)
- CRS IRI support (ad-freiburg/spatialjoin#21)

The updated library slightly changes the results of `geof:distance` and of spatial joins with a maximum distance (for example, the 421.7 km between the Eiffel Tower and the Freiburg Cathedral change by around 10 m). Two unit tests are adapted accordingly. Note that `geof:distance` itself still uses the previous approximate computation in projected coordinates, switching it to the improved distance computation is part of the planned follow-ups.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant