Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#3844 closed enhancement (fixed)

b-tree support for strict equality test and spatially adjacent ordering

Reported by: pramsey Owned by: pramsey
Priority: critical Milestone: PostGIS 2.4.0
Component: postgis Version: master
Keywords: Cc:

Description

Change the = operator to test the binary geometry representations directly, to allow more "rational" GROUP BY behavior on geometry. Also enhance the ≠ operators to sort based on a rough morton key to put rows ordered by geometry columns into a rough "things near in the list are near in space" ordering.

Change History (13)

comment:1 by pramsey, 7 years ago

Done at r15700, waiting for the CI machines to all crash

comment:2 by strk, 7 years ago

Topology relies on OPERATOR < to be usable to find leftmost geometry. Isn't this a bit too big of a change to be done after feature freeze ?

comment:3 by robe, 7 years ago

it was a bug fix not a feature added :)

comment:4 by strk, 7 years ago

Is it still safe to use OPERATOR< to find leftmost edge ?

comment:5 by robe, 7 years ago

strk you should never have been using an undocumented operator use << instead

comment:6 by robe, 7 years ago

Resolution: fixed
Status: newclosed

ci machines all seem happy with this and Komzzpa likes it too. I'm happy he's happy.

18:34] <Komzzpa> I like the patch :)

comment:7 by strk, 7 years ago

OPERATOR << returns false on overlap:

select 'LINESTRING(0 0, 10 0)'::geometry << 'LINESTRING(2 0, 12 0)'::geometry;
 ?column?
----------
 f
(1 row)

So it cannot be used to find the left-most edge of a topology.

comment:8 by pramsey, 7 years ago

Well, we found a user who depended on the old logic, and surprise, he's one of us!

No, < won't be good for edges anymore, (a) because it uses box centroids and (b) sorting is on morton key (somewhat), so the sorted set won't line up in a neat line but will zigzag around the plane.

comment:9 by pramsey, 7 years ago

Could replacing "ORDER BY geom" with "ORDER BY ST_XMin(geom)" be sufficient? Where does this "find the left edge" logic happen?

comment:10 by strk, 7 years ago

For the record: as of r15708 I've changed the code to ORDER BY ST_XMin(geom) instead.

With this change the expected result gets back to its original, which is good.

comment:11 by strk, 7 years ago

Logic happens on line 167 topology/sql/export/TopoJSON.sql.in but I've been thinking about using it also for other cases (polygonization)

comment:12 by pramsey, 7 years ago

Updated = docs at r15712

comment:13 by robe, 7 years ago

In 15721:

update docs to reflect = operator changed in 2.4.0. correct the examples to exhibit new behavior. Put a note in ~= which means what = used to mean
References #3844 for PostGIS 2.4.0

Note: See TracTickets for help on using tickets.