[postgis-devel] Testing on Windows PostGIS 1RC1

Nicklas Avén nicklas.aven at jordogskog.no
Thu Sep 23 04:07:38 PDT 2010


If it is valid or not I don't know anything about. But the gain of
returning an empty geometry instead would be that it would fit to the
logic in ST_Shortestline

This is not a question for 1.5 but eventually for trun.k

I had some thought about the logic when I wrote ST_Shortestline and I
think I discussed it on the list.

The idea is that ST_Shortestline shall return the line between the two
closest points in two geometries. That makes two more things quite
natural. If we have geometry A and geometry B
Then ST_Shortestline(A, B) shall satisfy:

1) ST_Length(ST_Shortestline(A, B)) = ST_Distance(A, B)
2) The first point in the result from ST_Shortestline(A, B) shall be a
point in geometry A and the second point in the resulting line shall be
a point in geometry B

I also mean that the geometry type returned shall be consistent, in
other words always a line.

If not mixed with ST_SnapToGrid, this works as expected.
ST_Length(ST_Shortestline(A, B)) is alwas the same as ST_Distance(A, B)
in all cases. Also when the two geometries intersect.
If the geometries intersects the first and the last point in the
returned line is the same and is an intersecting point between the two
geometries.

If ST_SnapToGrid returned an empty geometry it would almost work the
same way. 

The result from 
SELECT  st_length('GEOMETRYCOLLECTION EMPTY'::geometry);
is 0 so it wouldn't violate so then we would get


ST_Length(ST_SnapToGrid(ST_Shortestline(A, B)) ~ ST_Distance(A, B)

of course the rounding of ST_SnaptoGrid will make the results little
different, but intersecting geometries would always give a length=0 on
the resulting line.


If Martin and Kevin are right that a zero-length line is valid, then, is
there any reason to handle them as invalid in PostGIS?
Or is things just not clarified as Kevin mentions? 

If it is invalid I guess we have to find some other answer to
ST_Shortestline on intersecting geometries. We can not have functions
giving invalid answers, by design, can we?


/Nicklas




On Thu, 2010-09-23 at 01:24 +0200, strk wrote:
> On Thu, Sep 23, 2010 at 12:18:37AM +0200, Nicklas Avén wrote:
> 
> > select st_snaptogrid('LINESTRING(1 2, 1 2)'::geometry, 0.1)
> > 
> > So we don't get a parse error or an empty geometry, but... nothing
> > 
> > Maybe empty geometry would be better?
> 
> FWIW, that's an invalid geometry.
> ST_MakeValid would make it a POINT.
> 
> But yes, SnapToGrid turns collapsed geomeries into NULLs,
> intentionally, as it was designed as a vector reduction tool.
> 
> Dunno what would an empty give you more than the current NULL.
> Possibly a POINT would help you more.
> 
> --strk;
> 
>   ()   Free GIS & Flash consultant/developer
>   /\   http://strk.keybit.net/services.html
> _______________________________________________
> postgis-devel mailing list
> postgis-devel at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-devel
> 





More information about the postgis-devel mailing list