[postgis-devel] ORDER BY semantic on geometries

Paul Ramsey pramsey at cleverelephant.ca
Wed Sep 13 05:04:51 PDT 2017


On Wed, Sep 13, 2017 at 12:32 AM, Sandro Santilli <strk at kbt.io> wrote:
>
>
> Is the new operator working as expected ? A test should be added.
> I tried this:
>
>   with inp(g) as ( VALUES
>     ( 'LINESTRING(0 0, 10 0)'::geometry ),
>     ( 'LINESTRING(2 0, 12 0)'::geometry ),
>     ( 'LINESTRING(10 0, 0 0)'::geometry ),
>     ( 'LINESTRING(2 1, 12 -1)'::geometry )
>   )
>   select 'order1', ST_AsText(g)
>   FROM inp ORDER BY g;
>
> And obtained this:
>
>   order1|LINESTRING(0 0,10 0)
>   order1|LINESTRING(10 0,0 0)
>   order1|LINESTRING(2 1,12 -1)
>   order1|LINESTRING(2 0,12 0)
>

>> and << are not b-tree ops, they are gist ops

There's not going to be a great eyeball test of order by, it's a "sort of"
morton curve, due to the fact that negative numbers are in their own domain
well above the positive numbers. Also note the spatial ordering is on the
bbox centers, so each of your elements is quite similar, and in fact the
"near close to near" principal has been carried out in the ordering.



>
> --strk;
> _______________________________________________
> postgis-devel mailing list
> postgis-devel at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/postgis-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-devel/attachments/20170913/fef140ed/attachment.html>


More information about the postgis-devel mailing list