<html>
<head>
</head>
<body>Yes, I guess it is what you call layer union layer case I am talking about. 
        <div><br />
                </div>
        <div>But the point is that it is not unly the intersection between layers that needs to be calculated but also between the polygons in the same layer.
                <div>
                        <div><br />
                                </div>
                        <div>To solve that in PostGIS today is quite dirty:</div>
                        <div>http://trac.osgeo.org/postgis/wiki/UsersWikiExamplesOverlayTables2</div>
                        <div><br />
                                </div>
                        <div>and more discussions :</div>
                        <div>http://trac.osgeo.org/postgis/wiki/UsersWikiExamplesOverlayTables</div>
                        <div><br />
                                </div>
                        <div>What I target is not the unioning between the layers but inside the same layer. The problem is the same -> to do something with more than two geometries involved.</div>
                        <div><br />
                                </div>
                        <div>Yes, I guess you are right that it would be possible to write a function that does the job from a collection</div>
                        <div><br />
                                </div>
                        <div>But the function will have to do the same thing. To calculate a result from 2 polygons, then use the resulting polygon for calculation against the third polygon and so on. Just like an aggregate function works.</div>
                        <div>
                                <div>
                                        <div>
                                                <div>
                                                        <div>
                                                                <div>
                                                                        <div>
                                                                                <div><br />
                                                                                        Adding aggregates is really less a priority than adding support for <br />
                                                                                        ></div>ARRAY[geom1,geom2,geom3...] for the relevant functions.<br />
                                                                                ></div>
                                                                        <div>Ok ?</div>
                                                                        <div><br />
                                                                                </div>
                                                                        <div>Why not just use:</div>
                                                                        <div><code class="funcdef" style="color: rgb(46, 46, 46); font-size: 13px; background-color: rgb(255, 255, 255);">geometry <span style="font-weight: bold;">ST_Collect</span>(</code><span style="color: rgb(46, 46, 46); font-family: 'Lucida Grande', Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);">geometry[] </span><var class="pdparam" style="color: rgb(153, 0, 0); font-family: 'Lucida Grande', Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);">g1_array</var><code style="color: rgb(46, 46, 46); font-size: 13px; background-color: rgb(255, 255, 255);">)</code><span style="color: rgb(46, 46, 46); font-family: 'Lucida Grande', Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);">;</span></div>
                                                                        <div><span style="color: rgb(46, 46, 46); font-family: 'Lucida Grande', Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);"><br />
                                                                                        </span></div>
                                                                        <div><span style="color: rgb(46, 46, 46); font-family: 'Lucida Grande', Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);">What would an array of geometries be that a collection isn't?</span></div>
                                                                        <div><span style="color: rgb(46, 46, 46); font-family: 'Lucida Grande', Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);"><br />
                                                                                        </span></div>
                                                                        <div><span style="color: rgb(46, 46, 46); font-family: 'Lucida Grande', Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);"><br />
                                                                                        </span></div>
                                                                        <div><span style="color: rgb(46, 46, 46); font-family: 'Lucida Grande', Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);">I think that aggregates is very interesting. It opens a lot of possibilities to to do something with a bunch of geoemtries, and combinate them in different ways.</span></div>
                                                                        <div><span style="color: rgb(46, 46, 46); font-family: 'Lucida Grande', Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);">Like the ST_AsTWKBagg function. There I pack the geoemtries as twkb in an aggregate function. But instead of using ST_Collect I wrote a new aggregate. In that way I could pack also the individual id:s of the geometris in the twkb. Another thing that I gained from that was that I could continue the delta encoding over many rows. </span></div>
                                                                        <div><span style="color: rgb(46, 46, 46); font-family: 'Lucida Grande', Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);">When aggregating points that can make a huge difference. </span><span style="color: rgb(46, 46, 46); font-family: 'Lucida Grande', Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);">ST_AsTWKBagg</span><span style="color: rgb(46, 46, 46); font-family: 'Lucida Grande', Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);"> can make interesting vector tiles for instance.</span></div>
                                                                        <div> <br />
                                                                                ></div>The essential difference that is often blocking is that aggregates can't be used in a lot of places<br />
                                                                        ></div>(FROM, WHERE, in ordering, in windows ...), and you can't stake theim (aggregate(aggregate()) is forbiden).<br />
                                                                ></div><br />
                                                        ></div>So often going the array way is the only short solution(you have always the possibility ot use lot's of CTE but with big data this has a cost).<br />
                                                ></div>
                                        <div><br />
                                                </div>
                                        <div>Well, this is the way I find my self go a lot. Using aggregates in sub queries or CTE.</div>
                                        <div><br />
                                                </div>
                                        <div>Are you sure that the planner and indexes will manage arrays better?</div>
                                        <div><br />
                                                </div>
                                        <div>/Nicklas</div>
                                        <div><br />
                                                ></div>Cheers,<br />
                                        >Rémi-C<br />
                                        >>
                                        <div>>
                                                <div>>
                                                        <div>>
                                                                <div>>
                                                                        <div>
>
                                                                                <div>>
                                                                                        <div>>
                                                                                                <div>>
                                                                                                        <div><br />
                                                                                                                ></div></div></div></div></div></div></div></div></div></div>>
                                <div><br />
                                        ><br />
                                        >>
                                        <div>2014-09-01 10:37 GMT+02:00 Nicklas Avén <<a target="_blank">nicklas.aven@jordogskog.no</a>>:<br />
                                                >


>
                                                <div>In general I think we could do a lot of cool things with aggregates.
        >
                                                        <div>I have had a thought in my head for a very long time that I haven't had time to investigate.</div>
        >
                                                        <div><br />
                                                                ></div>
        >
                                                        <div>Quite often people is asking for a function like union in the esri world.</div>
        >
                                                        <div><a target="_blank" href="http://resources.arcgis.com/en/help/main/10.1/index.html#//000800000010000000">resources.arcgis.com/en/help/main/10.1/index.html#//000800000010000000</a></div>
        >
                                                        <div><br />
                                                                ></div>
        >
                                                        <div>In PostGIS we have a problem to do calculations that involves more than 2 geoemtries.</div>
        >
                                                        <div>But as an aggregate function it vould be possible to do.</div><span style="color: rgb(136, 136, 136);">
        </span>>
                                                        <div><br />
                                                                ></div>
        >
                                                        <div>/Nicklas</div>
        >
                                                        <div>>
                                                                <div><br />
                                                                        >
                 2014-09-01 Paul Ramsey  wrote:<br />
                                                                        ><br />
                                                                        >
                Only reason is nobody ever asked for it, it's hard to figure great use<br />
                                                                        >
                
>cases for it.<br />
                                                                        >
                
><br />
                                                                        >
                
>P<br />
                                                                        >
                
><br />
                                                                        ></div>>
                                                                <div>
                
>On Sun, Aug 31, 2014 at 6:16 PM, Paragon Corporation 
                 wrote:<br />
                                                                        >
                        
>> I wasn't sure if we just thought there wasn't much utility in it or if there<br />
                                                                        >
                        
>> was a technical obstacle.<br />
                                                                        >
                        
>><br />
                                                                        >
                        
>> I would think that would be easier to build than the other aggregates since<br />
                                                                        >
                        
>> as you add more geometries it shrinks and the current aggregate state is<br />
                                                                        >
                        
>> always the result of the previous state plus new geometry (so no need for an<br />
                                                                        >
                        
>> accumulation function or a final state function) and if you ever end up with<br />
                                                                        >
                        
>> a  geometry collection, you short-circuit out.<br />
                                                                        >
                        
>><br />
                                                                        >
                        
>> Thanks,<br />
                                                                        >
                        
>> Regina<br />
                                                                        >
                        
>><br />
                                                                        >
                        
>><br />
                                                                        >
                        
>> _______________________________________________<br />
                                                                        >
                        
>> postgis-devel mailing list<br />
                                                                        >
                        
>> <a target="_blank">postgis-devel@lists.osgeo.org</a><br />
                                                                        >
                        
>> <a target="_blank" href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-devel">lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-devel</a><br />
                                                                        >
                        
>_______________________________________________<br />
                                                                        >
                        
>postgis-devel mailing list<br />
                                                                        >
                        
><a target="_blank">postgis-devel@lists.osgeo.org</a><br />
                                                                        >
                        
><a target="_blank" href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-devel">lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-devel</a><br />
                                                                        >
                        
><br />
                                                                        >
                        
>
 </div></div>
</div>

<br />
                                                >_______________________________________________<br />
                                                >
postgis-devel mailing list<br />
                                                ><a>postgis-devel@lists.osgeo.org</a><br />
                                                ><a target="_blank" href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-devel">lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-devel</a><br />
                                                ></div><br />
                                        ></div>


 </div></div></div>
</body>
</html>