Conversation
The distance is converted to meters, which is only what ST_DWithin measures in for projected SRIDs or geography columns; on a geographic-SRID geometry column it is interpreted in degrees. Refs geopython#164
Author
|
Closing this. Not something I'm going to keep current. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The SQLAlchemy backend converts
DWITHINandBEYONDdistances the wrong way. Inpygeofilter/backends/sqlalchemy/filters.py, kilometers are divided by 1000 and miles by 1609, whereboth should multiply to reach meters. A 5 kilometer query therefore searches 0.005 meters, so it
matches nothing, and the failure is silent: an empty result set rather than an error.
This multiplies instead, and uses 1609.34 for miles rather than 1609, which is the statute mile to
three decimal places rather than truncated.
The docstring gains a note that the value is converted to meters, and that meters is what
ST_DWithinmeasures in only for projected SRIDs or
geographycolumns. On a geographic SRID with ageometrycolumn it measures in degrees, so the conversion is right for the cases this backend supports and
worth stating rather than leaving for someone to rediscover.
Tests cover both units against the compiled SQL.
Fixes #164