[postgis-tickets] [PostGIS] #5268: ST_ShortestLine return invalid linestring when distance of geometries is 0

PostGIS trac at osgeo.org
Fri Nov 4 07:01:51 PDT 2022


#5268: ST_ShortestLine return invalid linestring when distance of geometries is 0
----------------------+---------------------------
  Reporter:  latot    |      Owner:  pramsey
      Type:  defect   |     Status:  new
  Priority:  medium   |  Milestone:  PostGIS 3.4.0
 Component:  postgis  |    Version:  3.3.x
Resolution:           |   Keywords:
----------------------+---------------------------
Comment (by latot):

 Hi!

 Sorry for the confusion, I should had used the same nomenclature
 everywhere instead of mix them, zero-vectors, some times are called null
 vectors too, is not a SQL null, is a Math null.

 If Simple Features spec already has a definition for valid/invalid
 features, I think is fine follow it. But (always a but), if things like
 zero-vectors are considers invalid, I really, really really prefer postgis
 to return them, there is analysis where we need that invalid geometries,
 and the type of geoemtry, so return them as null is not great at all.

 The invalid features, are not always useful by it self, but is very useful
 recognize them, usually they need other algorithm to they do what we want
 them to do.

 Maybe, instead go to too deep definitions, we can explore in the
 functions, if there is edge cases write a base catalogue, and how their
 properties can affect the calculations in the function, like a start
 point, the zero-vectors and non-zero-vectors.

 I don't like the idea of send a param to do something with non-valid
 geometries, the reason, the treatment to the invalid geometries depends of
 what we want to achieve, so, is like there will be no standard for it. I
 think the better is a way to just recognize them, and let the ppl do what
 they want to do with them.

 I'll just imagine..., maybe there is a better way, the example is inspired
 in a real work I did some time ago, there is always several ways to do it,
 but the next query is pretty easy to read, and know the type helps to work
 better! (just a illustrative example :)):

 ```

 SELECT
  CASE
   WHEN stl.type = 'zero-vector' THEN
    ST_ShortestLine(ST_OffsetCurve(table.geom1, 1), table.geom2)
   ELSE stl.geometry
 FROM table
 LATERAL (ST_ShortestLine(table.geom1, table.geom2)) stl -- Two columns,
 geometry, type

 ```

 Personally, would be great something like this, maybe a param to trigger
 this return type? Can handle one by one, really simplifies everything,
 yeah more lines, and less errors.

 Thx!.
-- 
Ticket URL: <https://trac.osgeo.org/postgis/ticket/5268#comment:6>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.


More information about the postgis-tickets mailing list