postgrespro/pgsphere

Missing equality operator for type spoint?

Closed this issue · 5 comments

# select distinct spoint_deg(lon, lat) from sometable;
ERROR:  could not identify an equality operator for type spoint

I think this is a reasonable thing to do?

Should equality operators for the pgsphere types be added?

df7cb commented

spoint = spoint does exist, but what this message means is that we'd need a spoint btree or hash opclass. I'll cook something up.

Would it similarly make sense to add hash opclasses for the other pgsphere types (strans, scircle, spoly)? Probably not as useful as spoint, but for the sake of completeness?

df7cb commented

It's (sort of) easy for the types that have canonical representations. scircle is doable, but spoly would need sorting the nodes, and I hear there's open issues with left- and right-handed spolys.

That said, there's a possible minor problem even with spoints: the dreaded "signed zeros" might cause "equal" spoints to have representations differing in the sign. But that only applies to spoints where one coordinate is exactly zero, no idea how likely that is in practise. We might also force all zeros to be +0 either in spoint_hash32 or in spoint_in.

Which types would you be interested in?

@df7cb asked:

Which types would you be interested in?

Hard to say. I could see using an scircle hash opclass.

I wonder if the error in issue #93 would be helped if there was a hash opclass for strans?

Also, I'm ok with forcing all zeroes to be +0 in the spoint hash function if that "solves" any problems you foresee.