-
Notifications
You must be signed in to change notification settings - Fork 366
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
ST_Distance doesn't return the minimum distance. #979
Comments
Distance in PostGIS is not delegated to GEOS, so this issue should properly be ticketed there. That said, I will add a test case here before closing, just in case it's also an issue in GEOS. |
Well, your particular example crashes GEOS, and in general the question of "what is the distance to EMPTY" seems a little fraught. Distance between https://trac.osgeo.org/postgis/wiki/DevWikiEmptyGeometry The case of distance between geometry A, a collection with an empty component and a non-empty component and geometry B, a non-empty geometry, seems generally unclear. Probably the "least bad" answer is to ignore the empty components? Meanwhile, over in PostGIS land, distance between EMPTY and EMPTY is NULL. |
Agreed. And this should be very simple to implement - it's always easy to ignore things. |
It's just a little odd that distance of |
Agreed this is an inconsistency. One way to resolve it is to return |
Yeah, ordinarily A.Distance(A) would be expected to return 0 by definition... but not for empty? It's a very pick your poison situation. |
Hi, I just wanted to write what I said in matrix to clarify. There some distance operations that are not still well defined, I think we all agree what a distance is two geometries exists, but the story changes in edge cases like this. I think the best is first check conceptually what represent an empty geometry, well we know it is the absence of geometries, but to get a better the behavior of distance lets get some thoughts. Here some examples of empty geometries:
A geometry is basically a set of rules, the point where is something, a space that follow that rules, an empty geometry represents that exists no geometry that accomplish all the rules. Here the question, which is the distance from a object that does not exists to anything? I think the right answer is... "does not exists", not infinite. Lets check the difference, if the distance is infinite at least represents that exists a path between two points, you will travel infinite space but the travel/route exists. For example the travel from -pi/2 (positive side) to pi/2 (negative side) is a existent path that is infinite large. The distance between an Empty Geom to something should be "does not exists" because should be clear that that path also does not exists. Lets keep this concepts different from NA and NULL, where NA usually means "you don't know", and NULL has several meanings... like in join sql where means don't exists, as pointer is used like "pointer value that can be defined", and this ones are pretty different from the Empty Geometry case. From my point of view, I think numerically there should be some particular values to represent, NA/nan (don't know), Infinite indeterminate, and "Not exists". Maybe there is some cases that we can need new special values to represent correctly them? Just because I like to write this table: Real Value + Real Value = Real Value Is like... the priority adding things is like Not Exists > Indeterminate > Infinity > Real Value |
Well, we aren't going to be able to add another value to the FP zoo, we're just a little geometry project. |
Hi, Actually all this values on math like Not Exists and Indeterminate exists for a good reason, the lack of one of them causes problems and broken relations, as you said, if you choose Infinity there will be some relations broken, if you choose 0 others will be broken..... This happens because "Not Exists" has different properties than any value you want to use to replace it, and that properties will break the geometry relations. There exists a middle point if there is no intention to include this values: Nan: Not known value Using that definitions can do at some extent some match and handle some properties, still some will be broken but is the best I think to keep all the most coherent possible. While the right values don't exists there will be no right answer here, is like choose your poison, I recommend the one not most intuitive, choose the one more close to the right answers. With that said, I think in only have Nan and Zoo the best would be the distance to bee Zoo, I know is weird, some geometry collections has empty geometries, and the result will be Zoo if any geometry is Empty, but that would be the most correct answer, seems wrong probs because we are not used to work with Empty Geometries, until know I didn't put too much thoughts in how to interpret an Empty Geometry, we should learn what we are using, to know how to use them, then we will understand why the result of the distance is "Not Exists" and for that for example, be Zoo in the end. I still think create the right values would simplify all this relations and help to improve in the future :) |
Consider this statement:
According to the following definition, ST_Distance returns the minimum distance between two geometries :
The minimum distance between a1 and a2 is 2 instead of 3. But the result of ST_Distance(a2, a1) is 3, which is not the minimum distance.
Meanwhile, the result of ST_Distance(a2, a1) is not same as ST_Distance( a1, a2).
So I believe it is a functional issue that the current test suites haven't explored.
According to the crash #977, the function related to the GEOMETRYCOLLECTION with EMPTY seems not to be explored by before test suites?
The version is the newest in GitHub:
POSTGIS="3.5.0dev 3.4.0rc1-705-g5c3ec8392" [EXTENSION] PGSQL="170" GEOS="3.13.0dev-CAPI-1.18.0" PROJ="8.2.1 NETWORK_ENABLED=OFF URL_ENDPOINT=https://cdn.proj.org/ USER_WRITABLE_DIRECTORY=/tmp/proj DATABASE_PATH=/usr/share/proj/proj.db" LIBXML="2.9.13"
The text was updated successfully, but these errors were encountered: