<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
p
{mso-style-priority:99;
mso-margin-top-alt:auto;
margin-right:0in;
mso-margin-bottom-alt:auto;
margin-left:0in;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
span.EmailStyle17
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:windowtext;}
span.EmailStyle19
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=EN-US link=blue vlink=purple>
<div class=WordSection1>
<p class=MsoNormal><span style='color:#1F497D'>Thanks for the reply.<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'>I tried to use the st_buildarea
with st_collect as you suggested by modifying my wedgefunc function that I
posted earlier. However, now I don’t get anything out of the
function. I believe the collect is returning a MULTILINESTRING with the
three elements to my wedge in it, but for some reason the st_buildarea function
is returning nothing. Any ideas?<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'>Here is my modified wedgefunc
function:<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'>CREATE OR REPLACE FUNCTION
wedgefunc(outerradius float, startangle float, openingangle float)<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'> RETURNS text AS<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'>$BODY$<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'> DECLARE<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'> startchord
geometry;<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'> midchord
geometry;<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'> endchord
geometry;<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'> revstartchord
geometry;<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'> outerarc
text;<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'> outerarcline
geometry;<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'> polyborder
geometry;<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'> poly
geometry;<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'> BEGIN<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'> -- Rotate a horizontal
line to form chords - the 'mid' chord is to help form the CIRCULARLINESTRING<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'> startchord
:= st_rotate(st_makeline(st_point(0,0),st_point(outerradius,0)),startangle);<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'> midchord
:= st_rotate(st_makeline(st_point(0,0),st_point(outerradius,0)),startangle +
(.5 * openingangle));<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'> endchord
:= st_rotate(st_makeline(st_point(0,0),st_point(outerradius,0)),startangle
+ openingangle);<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'> <o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'> --Make a reversal of the
start chord - not sure if this is needed, just incase the points need to be in
order when putting together the poly<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'> revstartchord
:= st_reverse(startchord); <o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'> <o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'> --Create an arc line by
passing the endpoints of the endchord, midchord, and startchord<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'> outerarc
:= 'CIRCULARSTRING('||st_x(st_endpoint(endchord))||'
'||st_y(st_endpoint(endchord))||','||st_x(st_endpoint(midchord))||'
'||st_y(st_endpoint(midchord))||','||st_x(st_endpoint(startchord))||'
'||st_y(st_endpoint(startchord))||')';<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'> outerarcline
:= st_curvetoline(outerarc);<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'> --TRYING ST_BUILDAREA
WITH ST_COLLECT AFTER UNIONING THE 3 LINESTRINGS<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'> poly
:= st_buildarea(st_collect(geom))<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'> FROM
(select revstartchord as geom<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'> union
select endchord as geom<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'> union
select outerarcline as geom<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'> )
as u;<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'> return
st_astext(poly);<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'> END;<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'> $BODY$<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'> LANGUAGE 'plpgsql'
IMMUTABLE;<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p>
<div>
<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'>
<p class=MsoNormal style='margin-left:.5in'><b><span style='font-size:10.0pt;
font-family:"Tahoma","sans-serif"'>From:</span></b><span style='font-size:10.0pt;
font-family:"Tahoma","sans-serif"'>
postgis-users-bounces@postgis.refractions.net
[mailto:postgis-users-bounces@postgis.refractions.net] <b>On Behalf Of </b>Randall,
Eric<br>
<b>Sent:</b> Tuesday, June 22, 2010 2:26 PM<br>
<b>To:</b> PostGIS Users Discussion<br>
<b>Subject:</b> Re: [postgis-users] Create POLYGON from Several LINESTRINGs<o:p></o:p></span></p>
</div>
</div>
<p class=MsoNormal style='margin-left:.5in'><o:p> </o:p></p>
<div>
<p class=MsoNormal style='margin-left:.5in'><span style='font-size:12.0pt;
font-family:"Times New Roman","serif"'> <o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt;
font-family:"Arial","sans-serif";color:blue'>I think perhaps st_buildarea and
st_collect might be what you want. Below is what I used to create a
hexagon out of points->lines which was then translated (using
generate_series) across X and Y to create a hexagonal grid for the
County. There's probably a simpler way to make a hexagon but it
illustrates the st_buildarea. Maybe that helps.</span><span
style='font-size:12.0pt;font-family:"Times New Roman","serif"'><o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal style='margin-left:.5in'><span style='font-size:12.0pt;
font-family:"Times New Roman","serif"'> <o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt;
font-family:"Arial","sans-serif";color:blue'>-Eric </span><span
style='font-size:12.0pt;font-family:"Times New Roman","serif"'><o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal style='margin-left:.5in'><span style='font-size:12.0pt;
font-family:"Times New Roman","serif"'> <o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal style='margin-left:.5in'><span style='font-size:12.0pt;
font-family:"Times New Roman","serif"'> <o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal style='margin-left:.5in'><span style='font-size:12.0pt;
font-family:"Times New Roman","serif"'> <o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal style='margin-left:.5in'><span style='font-size:12.0pt;
font-family:"Times New Roman","serif"'> <o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt;
font-family:"Arial","sans-serif";color:blue'>--let's make a hexagon with 1000
foot sides and position it with it's <br>
--center at 1210000, 610000 (the lower left of the pamap tile extent for Erie
County)<br>
--and create a table </span><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'><o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal style='margin-left:.5in'><span style='font-size:12.0pt;
font-family:"Times New Roman","serif"'> <o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt;
font-family:"Arial","sans-serif";color:blue'>drop table if exists hex1000;<br>
create table hex1000 as<br>
select translate(st_buildarea(st_collect(geom)),1210000, 610000) as geom
from <br>
(select makeline(st_endpoint(makeline(makepoint(0, 0),makepoint(0, -
1000))),st_endpoint(rotate(makeline(makepoint(0, 0),makepoint(0, -1000)),
radians(300)))) as geom <br>
union select makeline(st_endpoint(rotate(makeline(makepoint(0, 0),makepoint(0,
-1000)), radians(300))),st_endpoint(rotate(makeline(makepoint(0,
0),makepoint(0, -1000)), radians(240)))) as geom <br>
union select makeline(st_endpoint(rotate(makeline(makepoint(0, 0),makepoint(0,
-1000)), radians(240))),st_endpoint(rotate(makeline(makepoint(0,
0),makepoint(0, -1000)), radians(180)))) as geom <br>
union select makeline(st_endpoint(rotate(makeline(makepoint(0, 0),makepoint(0,
-1000)), radians(180))),st_endpoint(rotate(makeline(makepoint(0,
0),makepoint(0, -1000)), radians(120)))) as geom <br>
union select makeline(st_endpoint(rotate(makeline(makepoint(0, 0),makepoint(0,
-1000)), radians(120))),st_endpoint(rotate(makeline(makepoint(0,
0),makepoint(0, -1000)), radians(60)))) as geom <br>
union select makeline(st_endpoint(rotate(makeline(makepoint(0, 0),makepoint(0,
-1000)), radians(60))),st_endpoint(rotate(makeline(makepoint(0, 0),makepoint(0,
-1000)), radians(0)))) as geom <br>
) as t1;</span><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'><o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal style='margin-left:.5in'><span style='font-size:12.0pt;
font-family:"Times New Roman","serif"'> <o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal style='margin-left:.5in'><span style='font-size:12.0pt;
font-family:"Times New Roman","serif"'> <o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal style='margin-left:.5in'><span style='font-size:12.0pt;
font-family:"Times New Roman","serif"'> <o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal style='margin-left:.5in'><span style='font-size:12.0pt;
font-family:"Times New Roman","serif"'> <o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal style='margin-left:.5in'><span style='font-size:12.0pt;
font-family:"Times New Roman","serif"'> <o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal style='mso-margin-top-alt:0in;margin-right:0in;margin-bottom:
12.0pt;margin-left:.5in'><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>-----Original
Message-----<br>
<b>From:</b> postgis-users-bounces@postgis.refractions.net
[mailto:postgis-users-bounces@postgis.refractions.net]<b>On Behalf Of </b>Avery
Penniston<br>
<b>Sent:</b> Tuesday, June 22, 2010 2:38 PM<br>
<b>To:</b> postgis-users@postgis.refractions.net<br>
<b>Subject:</b> Re: [postgis-users] Create POLYGON from Several LINESTRINGs</span><span
style='font-size:12.0pt;font-family:"Times New Roman","serif"'><o:p></o:p></span></p>
</div>
<blockquote style='margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt'>
<p class=MsoNormal style='margin-left:.5in'>I’m trying to create
‘pie wedge’ shaped polygons by building them in a Postgres
function. I am able to create the 2 straight chords and the arc as
separate LINESTRINGs, and I have verified that each LINESTRING shares its
endpoints with the other two LINESTRINGs. However, I am having trouble
putting the individual parts together to form a POLYGON.<o:p></o:p></p>
<p class=MsoNormal style='margin-left:.5in'><o:p> </o:p></p>
<p class=MsoNormal style='margin-left:.5in'>I tried to ST_UNION the 3
LINESTRINGs together, and the result is a MULTILINESTRING. I then call
ST_LINEMERGE to convert the MULTILINESTRING to a single LINESTRING so I can
pass it to the ST_POLYGON function, but the result of the ST_LINEMERGE is a MULTILINESTRING.
<o:p></o:p></p>
<p class=MsoNormal style='margin-left:.5in'><o:p> </o:p></p>
<p class=MsoNormal style='margin-left:.5in'>I tried using ST_COLLECT instead of
ST_UNION, but then I got a GEOMETRYCOLLECTION containing a MULTILINESTRING and
a LINESTRING.<o:p></o:p></p>
<p class=MsoNormal style='margin-left:.5in'><o:p> </o:p></p>
<p class=MsoNormal style='margin-left:.5in'>Does anybody have some advice for
creating a POLYGON from 3 or more separate LINESTRINGs?<o:p></o:p></p>
</blockquote>
</div>
</body>
</html>