On 15th of December, Heikki Linnakangas committed patch:
Add point <-> polygon distance operator. Alexander Korotkov, reviewed by Emre Hasegeli.
I'm not actually using geometric types at all. Or geography. Of course I am aware of PostGIS, and what's built into PostgreSQL itself, but it just so happened, that, so far, I had only one time usecase for them.
But in any way – there are people that use it, and for them it will be much bigger news than it is for me.
We got distance operator for point and polygon.
Let's start with some sanity check. Let's use a triangle, that will have all it's points far from the point that we'll be measuring distance to.
$ SELECT '(1.3,0)'::point <-> '((-100,-50),(0,-50),(0,50))'::polygon; ?COLUMN? ---------- 1.3 (1 ROW)
Works. In my short test (creating 100000 random polygons in a table, and doing:
EXPLAIN analyze SELECT * FROM test ORDER BY '(0,0)'::point <-> poly LIMIT 2;
, with gist index on poly, it doesn't look like we can use index. Most likely – as of now, and it will probably be added in future.
In any case – finding distance works now and is definitely usefull. Thanks.