[postgis-users] Calculate accumulative bearing given a zig-zagging line
Sandro Santilli
strk at kbt.io
Thu Feb 17 03:33:49 PST 2022
On Thu, Feb 17, 2022 at 08:21:24AM +0000, Shaozhong SHI wrote:
> Is there a function for calculating accumulative bearing given a
> zig-zagging line?
>
> If we set a segment to travel towards north and its bearing is 0. Next
> segment may zig-zag towards 10 degrees. The following one may zig-zag
> towards -5 degree.
>
> Calculating accumulative bearing may assist us to check whether a line does
> a U-turn. If accumulative bearing is greater than 180, it is a U-turn.
>
> Is there such function available?
You can use ST_Azimuth, some normalization routine to turn the radians
into a signed value and the sum aggregate to "accumulate" it.
--strk;
More information about the postgis-users
mailing list