[postgis-users] Establish versus of a line

Nicolas Ribot nicolas.ribot at gmail.com
Fri Apr 30 03:37:39 PDT 2010


> Hi Nicolas,
>
> many thx for the hints (now I'm study better the ST_ForceRHR function), but
> I think
> my need is a bit more complex (Unfortunately).
>
> Because I don't need to know if the polygon is clockwise or
> counter-clockwise.
>
> I can surely assume all polygons are clockwise (for example).
>
> But I need to know if the linestrings are same versus of the polygon
> boundary or are reverse versus of the polygon boundary.
>
> Regards,
>
> Andrea.

Ok, so maybe you could rebuild polygons from the linestrings and test
these polygons ?

select st_orderingEquals(
	st_makepolygon(geom),
	st_forceRHR(st_makepolygon(geom))) from

(select geometryFromText('LINESTRING (0 0, 1 0, 1 1, 0 1, 0 0)', -1) as geom
union
select geometryFromText('LINESTRING (2 2, 2 3, 3 3, 3 2, 2 2)', -1) as
geom) as foo
;

Nico



More information about the postgis-users mailing list