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>  RETURNS geometry AS<br>$BODY$<br>declare<br>    cx alias for $1;<br>    cy alias for $2;<br>    a alias for $3;<br>    b alias for $4;<br>    slices alias for $5;<br>    i float;<br>    geom geometry;<br>begin<br>    i := 
0.0;<br>    execute 'create table tempo(ii float,the_geom geometry) with oids;';<br>    WHILE i < 2.0*pi() LOOP<br>    execute 'insert into tempo select '||i||'::float,makepoint('||cx+a*cos(i)||','||cy+b*sin(i)||');';
<br>    i := i+2.0*pi()/slices;<br>    END LOOP;<br>    execute 'select setsrid(makepolygon(makeline(the_geom)),4170) from tempo;' into geom;<br>    execute 'drop table tempo;';<br>    return geom;<br>end;
<br>$BODY$<br>  LANGUAGE 'plpgsql' 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 <<a href="mailto:pcreso@pcreso.com">pcreso@pcreso.com</a>>:</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'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'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'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>  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>