[postgis-users] Build a fog of war with ST_BuildArea(), St_Collect() and ST_Union()

Daniel Grum daniel.grum at unibw.de
Mon Nov 30 06:29:52 PST 2009


Hi,

I want to create an fog of war. I use a start-polygon and in this should 
be the area screened transparent where the user has build some buildings.

Here is the SQL-script that works if the user has a building of every 
building-type but if he only has an "haupthaus" no geom will be 
created???!!!

But at the beginning the user only has the building: haupthaus-->and for 
this starting situation a fog of war has to be created.

UPDATE fog_of_war2
SET the_geom = (SELECT ST_BuildArea(
            St_Collect(grenze_by.the_geom,
                ST_Union(        ST_Union(    
ST_Union(ST_Union(ST_Expand(holzfaeller.the_geom, 
2000)),ST_Union(ST_Expand(steinbruch.the_geom,2000))),
                                    
ST_Union(ST_Union(ST_Expand(erzmine.the_geom, 
2000)),ST_Union(ST_Expand(kaserne.the_geom,2000)))),
                            ST_Union(    
ST_Union(ST_Union(ST_Expand(wohnhaus.the_geom, 
2000)),ST_Union(ST_Expand(saegewerk.the_geom,2000))),
                                    
ST_Union(ST_Union(ST_Expand(strassen.the_geom, 
1000)),ST_Union(ST_Expand(haupthaus.the_geom,6000)))))))
        FROM     public.grenze_by grenze_by,
            public.holzfaeller2 holzfaeller,
            public.steinbruch2 steinbruch,
            public.erzmine2 erzmine,
            public.kaserne2 kaserne,
            public.wohnhaus2 wohnhaus,
            public.saegewerk2 saegewerk,
            public.strassen2 strassen,
            public.haupthaus2 haupthaus
        GROUP BY grenze_by.the_geom);

I know that the functions are very convoluted, but for me there is no 
other way to union/collect the different areas of the buildings.

Please give me some tips how I can solve the problem.

--daniel



More information about the postgis-users mailing list