I wrote this function to draw ellipses (or circles) in PG.<br>Feel free to make changes and send to the list.<br><br>Parameters:<br>cx,cy: Center of ellipse<br>a: major semi-axis<br>b: minor semi-axis<br>slices: number of vertices of polygon that define the ellipse. As big as this value smoothed is the curve.
<br><br>-- Function: make_ellipse(cx float8, cy float8, a float8, b float8, slices float8)<br><br>-- DROP FUNCTION make_ellipse(cx float8, cy float8, a float8, b float8, slices float8);<br><br>CREATE OR REPLACE FUNCTION make_ellipse(cx float8, cy float8, a float8, b float8, slices float8)
<br>&nbsp; RETURNS geometry AS<br>$BODY$<br>declare<br>&nbsp;&nbsp;&nbsp; cx alias for $1;<br>&nbsp;&nbsp;&nbsp; cy alias for $2;<br>&nbsp;&nbsp;&nbsp; a alias for $3;<br>&nbsp;&nbsp;&nbsp; b alias for $4;<br>&nbsp;&nbsp;&nbsp; slices alias for $5;<br>&nbsp;&nbsp;&nbsp; i float;<br>&nbsp;&nbsp;&nbsp; geom geometry;<br>begin<br>&nbsp;&nbsp;&nbsp; i := 
0.0;<br>&nbsp;&nbsp;&nbsp; execute &#39;create table tempo(ii float,the_geom geometry) with oids;&#39;;<br>&nbsp;&nbsp;&nbsp; WHILE i &lt; 2.0*pi() LOOP<br>&nbsp;&nbsp;&nbsp; execute &#39;insert into tempo select &#39;||i||&#39;::float,makepoint(&#39;||cx+a*cos(i)||&#39;,&#39;||cy+b*sin(i)||&#39;);&#39;;
<br>&nbsp;&nbsp;&nbsp; i := i+2.0*pi()/slices;<br>&nbsp;&nbsp;&nbsp; END LOOP;<br>&nbsp;&nbsp;&nbsp; execute &#39;select setsrid(makepolygon(makeline(the_geom)),4170) from tempo;&#39; into geom;<br>&nbsp;&nbsp;&nbsp; execute &#39;drop table tempo;&#39;;<br>&nbsp;&nbsp;&nbsp; return geom;<br>end;
<br>$BODY$<br>&nbsp; LANGUAGE &#39;plpgsql&#39; VOLATILE;<br>ALTER FUNCTION make_ellipse(cx float8, cy float8, a float8, b float8, slices float8) OWNER TO marco;<br>GRANT EXECUTE ON FUNCTION make_ellipse(cx float8, cy float8, a float8, b float8, slices float8) TO public;
<br><br><br><br><div><span class="gmail_quote">2007/3/7, Brent Wood &lt;<a href="mailto:pcreso@pcreso.com">pcreso@pcreso.com</a>&gt;:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br><br><br>OK, I&#39;ve trimmed all the other content, but my request is slightly off the main<br>subject.<br><br>Does anyone have any comments/advice on what I am doing in this subject area?<br>The discusison so far suggests I could usefully learm something here :-)
<br><br><br>So far I&#39;ve used a local custom equal area projection (Albers EA from memory) I<br>created for my purposes.<br><br>I was looking at the recorded start positions for fishing trawls along with the<br>distance towed and gear width to derive an estimated swept area held as a
<br>circle centred on the start point. As I want the circles to represent a<br>comparable area whether they at lat 20S or 60S, I used an equal area projection<br>to create them.<br><br>Mu limited understanding was that despite the circles being defined by a
<br>radius, an equal area was better than equidistant for this.<br><br>I&#39;m storing them as lat/long (EPSG:4326 projection with longs 0-360 as they<br>cross the 180 meridian... sigh...). In this projection the circles display as
<br>ellipses, exactly as they should, but this does confuse some around here :-)<br><br><br>Is there a better way to achieve this?<br><br>Thanks,<br><br>&nbsp;&nbsp;Brent<br>_______________________________________________<br>postgis-users mailing list
<br><a href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br><a href="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users
</a><br></blockquote></div><br><br clear="all"><br>-- <br>Marco Vieira<br>+55 21 9499-6800<br>e-mail: <a href="mailto:maovieira@gmail.com">maovieira@gmail.com</a>