# [postgis-users] Use of Azimuth Function

cgnicholas at alamedanet.net cgnicholas at alamedanet.net
Wed Feb 13 12:10:20 PST 2008

```we seem to be working on the same problem :-)

I'm draping over a TIN (triangulated irregular network), with an external
Java/JTS/JAMA program, in a relatively brute-force manner, but seems to be
reasonable for batch-mode crunching ...

Basically, iterate through all segments, and for every segment,  find the
intersection of the segment with the triangles it Overlaps(), or if one of
the endpoints falls inside, solve for the intersection between the plane
of the triangle and a vertical ray.

kinda brute force; I'm open to creative alternatives!

Chris

> Hi,
>
>
>
> I need to find the angle of elevation from one point to the previous
> point
> in a route.
>
>
>
> I have come up with this query :
>
>
>
> select azimuth (
>
>
>
> (select endpoint((geometryn ( the_geom,1))) from streets_3d where
> gid=45305),
>
> (select startpoint((geometryn(the_geom,1)))  from streets_3d where
> gid=3800)
>
> )
>
>
>
> And the result I got is : 2.26067325611865
>
>
>
> However when I tried to work it normally, using the TANGENT rule I got
> this
>
>
>
> Can someone please point out what I did wrong?
>
>
>
> This is the endpoint of gid 45305 : "POINT(637677.049535278
> 239825.913222565
> 138.439494012 0)"
>
> This is the startpoint of gid 3800 : "POINT(655579.694091448
> 225053.918041725 88.700036976 0)"
>
>
>
> Both geometries are MULTILINESTRING and have 1 INESTRING according to
> numgeometries(the_geom)
>
>
>
> Does the z affect the angle? I tried it on the same table without the 3D
> aspect and I got the same results as I got from table streets_3d.
>
>
>
> Any help is much appreciated
>
>
>
> Thanks and regards
>
>
>
> Matthew Pulis
>
>
>
>
>
>   _____
>
> I am using the free version of SPAMfighter for private users.
> It has removed 22959 spam emails to date.
> Paying users do not have this message in their emails.