[Mapbender-users] problems with the postgis functions ST_BuildArea(), St_Collect() and ST_Union()

Daniel Grum daniel.grum at unibw.de
Wed Dec 9 08:48:55 EST 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_war


      SET the_geom = (SELECT
      ST_BuildArea(St_Collect(grenze_by.the_geom,ST_Union(
                                     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))))),
                                     ST_Union(            
      ST_Union(ST_Expand(wachturm.the_geom, 3000)),  
                                                                    
      ST_Union(ST_Expand(lager.the_geom,2000))))))
      FROM     public.grenze_by grenze_by,public.holzfaeller holzfaeller,
                      public.steinbruch steinbruch,public.erzmine
      erzmine,public.kaserne kaserne,                                 
      public.wohnhaus wohnhaus, public.saegewerk saegewerk,
      public.strassen strassen,                           
      public.haupthaus haupthaus, public.lager lager,public.wachturm
      wachturm
      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?

Are there other PostGIS functions that can solve this problem better 
than the function st_union?

Thanks,
--daniel


More information about the Mapbender_users mailing list