<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Howdy list...<br>
<blockquote
 cite="mid:e8e7199c0901220749k7d5dbeaexfd30b1c5d88632b5@mail.gmail.com"
 type="cite">
  <blockquote type="cite">
    <blockquote type="cite">
      <pre wrap="">1. implement support for geometry collections: probably a partial
implementation allowing to retrieve parts of geometry collection from
GEOS would suffice for the begin.

      </pre>
    </blockquote>
    <pre wrap="">If I did implement this (as a partial implementation) would you recommend
simply returning the geometry  collection as a list of geometries, or
retrieving parts of the collection based on some input parameter (i.e.
retrieve polygons only). From an initial glance at the GOES api, this first
implementation looks possible, but I'm not a strong c++ programmer, so I'll
likely have to run it by others once I'm done...
    </pre>
  </blockquote>
  <pre wrap=""><!---->
The approach with returning a list of geometry parts looks like a more
flexible approach to me.
  </pre>
</blockquote>
Ok, so I really don't know what I'm doing here, maybe someone can tell
me why I can't quite get this to return a filled list:<br>
<br>
QList&lt;QgsGeometry*&gt; QgsGeometry::asGeometryCollection()<br>
{<br>
&nbsp; if ( mGeos == NULL )<br>
&nbsp; {<br>
&nbsp;&nbsp;&nbsp; exportWkbToGeos();<br>
&nbsp; }<br>
&nbsp; <br>
&nbsp; int type = GEOSGeomTypeId(( GEOSGeometry * ) mGeos );<br>
&nbsp; printf ("%d \n", type);<br>
&nbsp; // The above works ok, and returns that the GEOSGeometry is a
geometry collection (7)<br>
<br>
&nbsp; QVector&lt;GEOSGeometry *&gt; geoms;<br>
<br>
&nbsp; for ( int i = 0; i &lt; GEOSGetNumGeometries(( GEOSGeometry * ) mGeos
); ++i )<br>
&nbsp;&nbsp;&nbsp; // The above returns 0 for GEOSGetNumGeometries(( GEOSGeometry * )
mGeos ) which means the following never really runs...<br>
&nbsp;&nbsp;&nbsp; geoms.append( ( GEOSGeometry * ) GEOSGetGeometryN(( GEOSGeometry *
) mGeos, i ) );<br>
<br>
&nbsp; QList&lt;QgsGeometry*&gt; geomCollection;<br>
<br>
&nbsp; for ( int i = 0; i &lt; geoms.size(); ++i )<br>
&nbsp;&nbsp;&nbsp; geomCollection.append( fromGeosGeom( geoms[ i ] ) );<br>
&nbsp; <br>
&nbsp; return geomCollection;<br>
}<br>
<br>
I've removed all error checking etc to improve readability... and run
the above as two separate 'for loops' so it's obvious what I'm trying
to do... which is essentially grab each GEOSGeometry in the geometry
collection, and return a list of QgsGeometries from that...<br>
<br>
I'm missing a crucial step, but I don't know what it is... any ideas?<br>
<br>
Cheers,<br>
<br>
Carson
</body>
</html>