sql statements for angles on multilinestrings

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

sql statements for angles on multilinestrings

Thomas Preuth
-----------------------------------------------------------------------------------------------------------------
Hello,

I have two questions concerning postgis.
The issue is:

The column the_geom includes lines (multilinestring) as geometries, which
define their position by two coordinates. A symbol  should be placed at
first coordinate. The base of the symbol should be perpendicular to the
line. Therefore I need the tilt angle of the multilinestring.
So my questions:
1.)How can I extract the first coordinate of the multilinestring with  a
sql statement?
2.)How can I get the tilt angle of the multilinestring (to the horizontal)
with a sql statement?

Thanks!



Reply | Threaded
Open this post in threaded view
|

Re: sql statements for angles on multilinestrings

David Blasby-3
Thomas Preuth wrote:

> -----------------------------------------------------------------------------------------------------------------
> Hello,
>
> I have two questions concerning postgis.
> The issue is:
>
> The column the_geom includes lines (multilinestring) as geometries, which
> define their position by two coordinates. A symbol  should be placed at
> first coordinate. The base of the symbol should be perpendicular to the
> line. Therefore I need the tilt angle of the multilinestring.
> So my questions:
> 1.)How can I extract the first coordinate of the multilinestring with  a
> sql statement?
> 2.)How can I get the tilt angle of the multilinestring (to the horizontal)
> with a sql statement?

1.
     SELECT startpoint(geometryN(the_geom,1)) FROM <table>

2.
     I'm not sure what you exactly you mean by "tilt angle", but you
     can extract the (x,y) coordinates from a linestring like this:

         x(  pointN(  geometryN( the_geom,1), 1))
         y(  pointN(  geometryN( the_geom,1), 1))

         x(  pointN(  geometryN( the_geom,1), 2))
         y(  pointN(  geometryN( the_geom,1), 2))

     Postgresql supports all the trigonometry functions, so it should be
      easy to compute the "tilt angle".

dave