[postgis-users] How can I detect that geom != st_reverse(geom) for linestrings?

Stephen Woodbridge woodbri at swoodbridge.com
Wed Sep 2 13:23:30 PDT 2015


Hi all,

I just noticed that it is not obvious how to determine that
geom and st_reverse(geom) are different!

It seems that by definition st_equals(geom, st_reverse(geom)) is true as 
is geom = st_reverse(geom). So this seems to be by definition, but it 
brings up the question how to quickly and efficiently determine that 
they are also different, even if they are "equal".

I'm doing st_astext(geom) != st_astext(st_reverse(geom)) but I worry 
about precision issues doing this. I suppose I could also check if the 
st_startpoint() of the two are the same, but that seems problematic also.

Thoughts,
   -Steve


More information about the postgis-users mailing list