[postgis-users] sum dot product of outward normal vectors ofpolygon segments to given direction

Randall, Eric ERandall at eriecountygov.org
Tue Sep 14 08:02:26 PDT 2010


Hi Henri,
 
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
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.
Thanks.
 
Eric
 
======
 
SELECT taxpin, bldg2009gid, line_id, length, st_makeline(st_setsrid(st_line_interpolate_point(geom,.5),2271),
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))
from 
(
SELECT motherpin as taxpin, bldg2009gid, line_id, st_length(st_makeline(startpoint,endpoint))::numeric(10,2) as length, 
azimuth(startpoint,endpoint),azimuth(startpoint,endpoint) - pi()/2 as orthoaz, st_makeline(startpoint,endpoint) as geom
from
(
SELECT generate_series(1, npoints(exteriorring(geometryn(st_forceRHR(geom),1)))-1) as line_id,gid as bldg2009gid,motherpin, 
  pointn(exteriorring(geometryn(st_forceRHR(geom),1)) ,generate_series(1, npoints(exteriorring(geometryn(st_forceRHR(geom),1)))-1)) as startpoint, 
  pointn(exteriorring(geometryn(st_forceRHR(geom),1)) ,generate_series(2, npoints(exteriorring(geometryn(st_forceRHR(geom),1)))))   as endpoint
from bldg117862 
) as t1
) as t2
 
 
=======
 
SET STANDARD_CONFORMING_STRINGS TO ON;
SELECT DropGeometryColumn('','bldg117862','geom');
DROP TABLE "bldg117862";
BEGIN;
CREATE TABLE "bldg117862" (gid serial PRIMARY KEY,
"motherpin" varchar(14),
"taxpin" varchar(14),
"status" varchar(15),
"area" numeric,
"prev_area" numeric,
"pct_change" numeric,
"picture" varchar(133),
"mappage" varchar(6),
"sref_gid" int4,
"e_address" varchar(19),
"a_address" varchar(19),
"perim" numeric,
"card" int4,
"a_addnum" int4,
"e_street" varchar(50),
"a_street" varchar(50),
"e_hsnum" varchar(10));
SELECT AddGeometryColumn('','bldg117862','geom','2271','MULTIPOLYGON',2);
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=" http://www.eriecountygov.org/government/assessment/parcelimages.aspx?parcelid=33108480001346" target="_blank">Image Page</A>','33-108','99040','4622 MCCLELLAND AVE','4622 MCCLELLAND AVE','233.37','1','4622','MCCLELLAND AVE',NULL,'4622','0106000020DF080000010000000103000020DF080000010000000B0000008C721D6C98AC34415E2C5BB9D3E32541AE56DE17BEAC34410613E5A0A0E325411AB6C794AEAC3441BA392FE372E32541C89C38429DAC3441643857628AE325418C299A9095AC3441F66C29B573E32541983F02087EAC34413080AA9F93E325419BAC3C0A86AC3441AC1F3B3DABE32541803A40B974AC3441E8CF3DB9C2E325413E3758C186AC3441D0AAB0E7F7E325410AAAA5429BAC3441BA971217DCE325418C721D6C98AC34415E2C5BB9D3E32541');
CREATE INDEX "bldg117862_geom_gist" ON "bldg117862" using gist ("geom" gist_geometry_ops);
END;
 
 

Eric Randall
GIS DB Admin/Analyst
County of Erie
140 W 6th St
Room 111
Erie, PA 16501

ph. 814-451-6063
fx. 814-451-7000


-----Original Message-----
From: postgis-users-bounces at postgis.refractions.net [mailto:postgis-users-bounces at postgis.refractions.net]On Behalf Of Henri De Feraudy
Sent: Monday, September 13, 2010 4:56 AM
To: postgis-users at postgis.refractions.net
Subject: [postgis-users] sum dot product of outward normal vectors ofpolygon segments to given direction


Hello, I'm trying to calculate how much a polygon "points" in a given direction. 
This is to calculate how much light would come from a given light source.
This means that for each segment of its outer ring I want to calculate the 
scalar (dot) product of
outward normal vector (whose magnitude is the segment's length) and the given vector.

One idea is to rotate the polygon, and the given vector simultaneously so that the given vector is vertical and
then calculate the width of the bounding box.

Any comments?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20100914/fb31f254/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: orthoganals_building_sides.JPG
Type: image/jpeg
Size: 85693 bytes
Desc: orthoganals_building_sides.JPG
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20100914/fb31f254/attachment.jpe>


More information about the postgis-users mailing list