<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">


<STYLE type=text/css>DIV {
        MARGIN: 0px
}
</STYLE>

<META content="MSHTML 6.00.6001.18498" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=750220114-14092010>Hi 
Henri,</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN 
class=750220114-14092010></SPAN></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=750220114-14092010>In the 
process of changing one of my apps, I have to do something similar, but related 
to placing CAMA sketch vectors onto building footprints.  
Attached is a .jpg</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN 
class=750220114-14092010>showing the components the 
following test query, below which is the sql to 
load bldg117862.  If someone has a more compact (economical) 
equivalent, please post it back, I'll make use of it.</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN 
class=750220114-14092010>Thanks.</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN 
class=750220114-14092010></SPAN></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN 
class=750220114-14092010>Eric</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN 
class=750220114-14092010></SPAN></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN 
class=750220114-14092010>======</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN 
class=750220114-14092010></SPAN></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=750220114-14092010>SELECT 
taxpin, bldg2009gid, line_id, length, 
st_makeline(st_setsrid(st_line_interpolate_point(geom,.5),2271),<BR>st_setsrid(st_makepoint(st_x(st_line_interpolate_point(geom,.5))+ 
(length * (sin(orthoaz))),st_y(st_line_interpolate_point(geom,.5))+ (length * 
(cos(orthoaz)))),2271))<BR>from </SPAN></FONT><FONT><SPAN 
class=750220114-14092010><FONT face=Arial color=#0000ff size=2><BR>(<BR>SELECT 
motherpin as taxpin, bldg2009gid, line_id, 
st_length(st_makeline(startpoint,endpoint))::numeric(10,2) as length, 
<BR>azimuth(startpoint,endpoint),azimuth(startpoint,endpoint) - pi()/2 as 
orthoaz, st_makeline(startpoint,endpoint) as 
geom<BR>from</FONT></SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN 
class=750220114-14092010>(</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=750220114-14092010>SELECT 
generate_series(1, npoints(exteriorring(geometryn(st_forceRHR(geom),1)))-1) as 
line_id,gid as bldg2009gid,motherpin, <BR>  
pointn(exteriorring(geometryn(st_forceRHR(geom),1)) ,generate_series(1, 
npoints(exteriorring(geometryn(st_forceRHR(geom),1)))-1)) as startpoint, 
<BR>  pointn(exteriorring(geometryn(st_forceRHR(geom),1)) 
,generate_series(2, 
npoints(exteriorring(geometryn(st_forceRHR(geom),1)))))   as 
endpoint<BR>from bldg117862 <BR>) as t1<BR>) as t2</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN 
class=750220114-14092010></SPAN></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN 
class=750220114-14092010></SPAN></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN 
class=750220114-14092010>=======</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN 
class=750220114-14092010></SPAN></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=750220114-14092010>SET 
STANDARD_CONFORMING_STRINGS TO ON;<BR>SELECT 
DropGeometryColumn('','bldg117862','geom');<BR>DROP TABLE 
"bldg117862";<BR>BEGIN;<BR>CREATE TABLE "bldg117862" (gid serial PRIMARY 
KEY,<BR>"motherpin" varchar(14),<BR>"taxpin" varchar(14),<BR>"status" 
varchar(15),<BR>"area" numeric,<BR>"prev_area" numeric,<BR>"pct_change" 
numeric,<BR>"picture" varchar(133),<BR>"mappage" varchar(6),<BR>"sref_gid" 
int4,<BR>"e_address" varchar(19),<BR>"a_address" varchar(19),<BR>"perim" 
numeric,<BR>"card" int4,<BR>"a_addnum" int4,<BR>"e_street" 
varchar(50),<BR>"a_street" varchar(50),<BR>"e_hsnum" varchar(10));<BR>SELECT 
AddGeometryColumn('','bldg117862','geom','2271','MULTIPOLYGON',2);<BR>INSERT 
INTO "bldg117862" 
("motherpin","taxpin","status","area","prev_area","pct_change","picture","mappage","sref_gid","e_address","a_address","perim","card","a_addnum","e_street","a_street","e_hsnum",geom) 
VALUES 
('33108480001346',NULL,'Changed','2445.59000000','2139.51000000','14.3100000000','<a 
href="<A 
href="http://www.eriecountygov.org/government/assessment/parcelimages.aspx?parcelid=33108480001346">http://www.eriecountygov.org/government/assessment/parcelimages.aspx?parcelid=33108480001346</A>" 
target="_blank">Image Page</A>','33-108','99040','4622 MCCLELLAND 
AVE','4622 MCCLELLAND AVE','233.37','1','4622','MCCLELLAND 
AVE',NULL,'4622','0106000020DF080000010000000103000020DF080000010000000B0000008C721D6C98AC34415E2C5BB9D3E32541AE56DE17BEAC34410613E5A0A0E325411AB6C794AEAC3441BA392FE372E32541C89C38429DAC3441643857628AE325418C299A9095AC3441F66C29B573E32541983F02087EAC34413080AA9F93E325419BAC3C0A86AC3441AC1F3B3DABE32541803A40B974AC3441E8CF3DB9C2E325413E3758C186AC3441D0AAB0E7F7E325410AAAA5429BAC3441BA971217DCE325418C721D6C98AC34415E2C5BB9D3E32541');<BR>CREATE 
INDEX "bldg117862_geom_gist" ON "bldg117862" using gist ("geom" 
gist_geometry_ops);<BR>END;</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN 
class=750220114-14092010></SPAN></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<P><FONT size=2>Eric Randall<BR>GIS DB Admin/Analyst<BR>County of Erie<BR>140 W 
6th St<BR>Room 111<BR>Erie, PA 16501<BR><BR>ph. 814-451-6063<BR>fx. 
814-451-7000<BR></FONT></P>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
  <DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma 
  size=2>-----Original Message-----<BR><B>From:</B> 
  postgis-users-bounces@postgis.refractions.net 
  [mailto:postgis-users-bounces@postgis.refractions.net]<B>On Behalf Of 
  </B>Henri De Feraudy<BR><B>Sent:</B> Monday, September 13, 2010 4:56 
  AM<BR><B>To:</B> postgis-users@postgis.refractions.net<BR><B>Subject:</B> 
  [postgis-users] sum dot product of outward normal vectors ofpolygon segments 
  to given direction<BR><BR></FONT></DIV>
  <DIV 
  style="FONT-SIZE: 12pt; FONT-FAMILY: 'Courier New', courier, monaco, monospace, sans-serif">
  <DIV>Hello, I'm trying to calculate how much a polygon "points" in a given 
  direction. </DIV>
  <DIV>This is to calculate how much light would come from a given light 
  source.</DIV>
  <DIV>This means that for each segment of its outer ring I want to calculate 
  the </DIV>
  <DIV>scalar (dot) product of</DIV>
  <DIV>outward normal vector (whose magnitude is the segment's length) and 
  the given vector.</DIV>
  <DIV><BR></DIV>
  <DIV>One idea is to rotate the polygon, and the given vector simultaneously so 
  that the given vector is vertical and</DIV>
  <DIV>then calculate the width of the bounding box.</DIV>
  <DIV><BR></DIV>
  <DIV>Any comments?</DIV>
  <DIV style="POSITION: fixed"></DIV></DIV></BLOCKQUOTE></BODY></HTML>