<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Message</TITLE>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<STYLE>.hmmessage P {
PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px
}
BODY.hmmessage {
FONT-SIZE: 10pt; FONT-FAMILY: Tahoma
}
</STYLE>
<META content="MSHTML 6.00.6000.16705" name=GENERATOR></HEAD>
<BODY class=hmmessage>
<DIV><SPAN class=817333516-15082008><FONT face=Arial
color=#0000ff>Correction:</FONT></SPAN></DIV>
<DIV><SPAN class=817333516-15082008><FONT face=Arial
color=#0000ff></FONT></SPAN> </DIV>
<DIV><SPAN class=817333516-15082008><FONT face=Arial
color=#0000ff> /* Buffer the point
*/<BR> px := px + (dx *
buffer);<BR> py := py + (dy *
buffer);<BR> pz := pz + (dz *
buffer);</FONT>
<DIV><FONT face=Arial color=#0000ff></FONT> </DIV>
<DIV><SPAN class=579000815-15082008><FONT face=Arial
color=#0000ff> retWKT :=
retWKT <SPAN class=817333516-15082008>|| </SPAN>' ( ' || px::text || ' ' ||
py::text || ' ' || pz::text || '
)';<BR> <BR></FONT></SPAN></SPAN>
<DIV></DIV><FONT face=Tahoma>-----Original Message-----<BR><B>From:</B>
postgis-users-bounces@postgis.refractions.net
[mailto:postgis-users-bounces@postgis.refractions.net] <B>On Behalf Of
</B>Sufficool, Stanley<BR><B>Sent:</B> Friday, August 15, 2008 8:34
AM<BR><B>To:</B> PostGIS Users Discussion<BR><B>Subject:</B> RE: [postgis-users]
3d buffer<BR><BR></FONT></DIV></DIV>
<BLOCKQUOTE dir=ltr
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px">
<DIV><SPAN class=579000815-15082008><FONT face=Arial color=#0000ff>Step 1: Get
center of cube by averaging all points (x,y,z) on the cube</FONT></SPAN></DIV>
<DIV><SPAN class=579000815-15082008><FONT face=Arial color=#0000ff>Step 2: Get
the delta of each points (x,y,z) from the center point and divide by
distance from the center and then add/subtract that delta from the points
(x,y,z) multiplied by the buffer number</FONT></SPAN></DIV>
<DIV><SPAN class=579000815-15082008><FONT face=Arial
color=#0000ff></FONT></SPAN> </DIV>
<DIV><SPAN class=579000815-15082008><FONT face=Arial
color=#0000ff>This would expand the CUBE from the center by the given
amount.</FONT></SPAN></DIV>
<DIV><SPAN class=579000815-15082008><FONT face=Arial
color=#0000ff></FONT></SPAN> </DIV>
<DIV><SPAN class=579000815-15082008><FONT face=Arial color=#0000ff>Someone
correct this if needed since I have absolutely no practical application or
data to drive this code.</FONT></SPAN></DIV>
<DIV><SPAN class=579000815-15082008></SPAN><SPAN
class=579000815-15082008><FONT face=Arial
color=#0000ff></FONT></SPAN> </DIV>
<DIV><SPAN class=579000815-15082008><FONT face=Arial
color=#0000ff><STRONG>VERY PSEUDO CODE (since there is no cube geometry
type?):</STRONG></FONT></SPAN></DIV>
<DIV><SPAN class=579000815-15082008><FONT face=Arial
color=#0000ff></FONT></SPAN> </DIV>
<DIV><SPAN class=579000815-15082008><FONT face=Arial color=#0000ff>CREATE
FUNCTION st_buffercube(theCube geometry, buffer double precision) <BR>returns
geometry AS $BODY$</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=579000815-15082008><FONT face=Arial color=#0000ff>declare i
int;</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=579000815-15082008><FONT face=Arial color=#0000ff>/* Centroid
of cube */<BR>declare cx double precision; <BR>declare cy double precision;
<BR>declare cz double precision;</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff></FONT> </DIV>
<DIV><SPAN class=579000815-15082008><FONT face=Arial color=#0000ff>/* Cube
point */<BR>declare px double precision; <BR>declare py double precision;
<BR>declare pz double precision;</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=579000815-15082008><FONT face=Arial color=#0000ff>/* Cube
point delta */<BR>declare segLength double precision;<BR>declare dx double
precision; <BR>declare dy double precision; <BR>declare dz double
precision;</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=579000815-15082008><FONT face=Arial color=#0000ff>/* Output
?CUBE? */<BR>declare retWKT character varying(4096);</FONT></SPAN></DIV>
<DIV><SPAN class=579000815-15082008><FONT face=Arial
color=#0000ff></FONT></SPAN> </DIV>
<DIV><SPAN class=579000815-15082008><FONT face=Arial
color=#0000ff>BEGIN</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=579000815-15082008><FONT face=Arial
color=#0000ff> cx := 0;<BR> cy :=
0;<BR> cz := 0;<BR> for i IN
1..st_npoints(theCube) LOOP<BR> cx
:= cx + st_x(pointn(theCube,i));<BR>
cy := cy +
st_y(pointn(theCube,i));<BR> cz :=
cz + st_z(pointn(theCube,i));<BR> END
LOOP;</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=579000815-15082008><FONT face=Arial
color=#0000ff> /* Compute centroid of cube
*/<BR> cx := cx / st_npoints(theCube);<BR>
cy := cy / st_npoints(theCube);<BR> cz := cz /
st_npoints(theCube);</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=579000815-15082008><FONT face=Arial
color=#0000ff> /* WHAT WOULD THE APPROPRIATE STORAGE TYPE
FOR THIS BE ??? */<BR> retWKT := 'POLYGON(
';<BR> for i in 1..st_npoints(theCube)
loop<BR> px :=
st_x(pointn(theCube,i)); <BR> py :=
st_y(pointn(theCube,i)); <BR> pz :=
st_z(pointn(theCube,i));</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=579000815-15082008><FONT face=Arial
color=#0000ff> dx :=
st_x(pointn(theCube,i)) - cx; <BR>
dy := st_y(pointn(theCube,i)) - cy;
<BR> dz := st_z(pointn(theCube,i)) -
cz;<BR> /* Divide by distance from
center point */<BR> segLength :=
sqrt( (cx -px) ^ 2 + (cy - py) ^ 2 + (cz - pz) ^
2);<BR> dx := dx /
segLength;<BR> dy := dy /
segLength;<BR> dz := dz
/segLength;<BR>
<BR> /* Buffer the point
*/<BR> px := px +
dx;<BR> py := py +
dy;<BR> pz := pz +
dz;</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=579000815-15082008><FONT face=Arial
color=#0000ff> retWKT := ' ( ' ||
px::text || ' ' || py::text || ' ' || pz::text || '
)';<BR> <BR> end
loop;</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=579000815-15082008><FONT face=Arial
color=#0000ff> retWKT := ' )';<BR>
<BR> return setsrid(retWKT::geometry,
st_srid(theCube));<BR>END;<BR>$BODY$<BR> LANGUAGE
'plpgsql'</FONT></SPAN></DIV>
<DIV><SPAN class=579000815-15082008><FONT face=Arial
color=#0000ff></FONT></SPAN> </DIV>
<BLOCKQUOTE
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left><FONT
face=Tahoma>-----Original Message-----<BR><B>From:</B>
postgis-users-bounces@postgis.refractions.net
[mailto:postgis-users-bounces@postgis.refractions.net] <B>On Behalf Of
</B>eehab hamzeh<BR><B>Sent:</B> Friday, August 15, 2008 1:51
AM<BR><B>To:</B> postgis-users@postgis.refractions.net<BR><B>Subject:</B>
[postgis-users] 3d buffer<BR><BR></FONT></DIV>
<DIV style="TEXT-ALIGN: left">What i mean by 3d buffer are i have a room
which is like a box and i need to find all the areas that this room Box that
will intersect if the room are extended and get
larger....<BR><BR><BR></DIV><P:COLORSCHEME
colors="#ffffff,#000000,#808080,#000000,#00cc99,#3333cc,#ccccff,#b2b2b2"></P:COLORSCHEME>
<DIV class=O v:shape="_x0000_s1026"><SPAN style="FONT-SIZE: 16pt">buffer
FROM (SELECT gid,buffer(r.the_geom,10) as buffer FROM room r WHERE
r.roomname='guest room') AS foo USING UNIQUE gid USING SRID=31467"<BR><BR>i
need such query to take the 3d dimension in consideration and make it not
just only in 2d
<BR></SPAN></DIV><BR><BR><BR>Thanks<BR><BR>ihab<BR><BR><BR><BR>
<HR>
Get news, entertainment and everything you care about at Live.com. <A
href="http://www.live.com/getstarted.aspx " target=_new>Check it out!</A>
</BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>