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

Paragon Corporation lr at pcorp.us
Wed Sep 2 14:40:28 PDT 2015


Have you tried 

ST_OrderingEquals  ?

-----Original Message-----
From: postgis-users-bounces at lists.osgeo.org [mailto:postgis-users-bounces at lists.osgeo.org] On Behalf Of Stephen Woodbridge
Sent: Wednesday, September 02, 2015 5:05 PM
To: postgis-users at lists.osgeo.org
Subject: Re: [postgis-users] How can I detect that geom != st_reverse(geom) for linestrings?

Hi Bob,

Yes, for now I'm just taking a pgrouting path and reversing some of the edges so the coordinates flow correctly from end to end of the path. But it just dawned on me that I can change the test to geom::text = st_reverse(geom)::text and this will avoid the precision issue I was worded about.

It just seems like we should have a function that allows us to check for
sameness:

create or replace st_isSameGeometry(a geometry, b geometry) returns boolean language sql as $_$ select a::text=b::text; $_$;

-Steve

On 9/2/2015 4:37 PM, Basques, Bob (CI-StPaul) wrote:
> Hi Steve,
>
> I think you almost need to check every point from at least one 
> linestring against the other linestring.
>
> You could check just one end, but they could still be the same but the 
> other end different.  Also you could have line strings with the same 
> end points, but different intermediate points.
>
> Your st_astext approach seems to be the most full proof, if it s just 
> the direction that you are looking for, then you may need to do a 
> double (or triple condition) pass if the line strings are congruent.
> You would need to check the ends against each other after finding out 
> that they match up in physical space in order to get direction.
>
> bobb
>
>
>
>
>> On Sep 2, 2015, at 3:23 PM, Stephen Woodbridge 
>> <woodbri at swoodbridge.com> wrote:
>>
>> 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 _______________________________________________
>> postgis-users mailing list postgis-users at lists.osgeo.org 
>> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
>
> _______________________________________________ postgis-users mailing 
> list postgis-users at lists.osgeo.org 
> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
>

_______________________________________________
postgis-users mailing list
postgis-users at lists.osgeo.org
http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users




More information about the postgis-users mailing list