Why doesn't ST_contains and ST_within doesn't support geography overload?

Both postgis and cockroach just support geometry version of ST_contains and ST_within, I don’t know why.
Sql server supports geography overload of these functions.

ST_DWithin has geography overloads in both Postgis and Cockroach. Will that work for your use case?

There is also ST_Covers and ST_CoveredBy which have similar semantics and have both geometry and geography overloads.

Hi @mgartner , I am reading the source code of cockroach. I just wonder why they are not supported.

Our goal was to be compatible with PostGIS as much as possible. PostGIS only supports geometry arguments for ST_Contains and ST_Within, which explains why CockroachDB does the same.

I tried to find an answer for why PostGIS does not support geography arguments for ST_Contains and ST_Within, but did not find anything conclusive. I did however find an interesting post about some unexpected “quirks” of these two functions. It’s possible these functions were not extended for geographies because of the confusion caused by these quirks.

2 Likes