Ok, I've discovered that myPolygon has geometryType <em style="font-family:'Lucida Grande',Verdana,Geneva,Arial,sans-serif;font-size:12px;background-color:rgb(251,252,253)">wkbGeometryCollection.</em><div><font face="Lucida Grande, Verdana, Geneva, Arial, sans-serif"><span style="font-size:12px">When I try to:</span></font></div>
<div> newDataSource->CreateLayer("test",NULL, <em style="font-family:'Lucida Grande',Verdana,Geneva,Arial,sans-serif;font-size:12px;background-color:rgb(251,252,253)">wkbGeometryCollection</em>, NULL);</div>
<div>it fails and returns NULL.</div><div><br></div><div>So my question now is: How do I create a wkbGeometryCollection layer (if possible) or how do I correctly change the geometry type of my geometry (from <em style="font-family:'Lucida Grande',Verdana,Geneva,Arial,sans-serif;font-size:12px;background-color:rgb(251,252,253)">wkbGeometryCollection </em><span style="font-family:'Lucida Grande',Verdana,Geneva,Arial,sans-serif;font-size:12px;background-color:rgb(251,252,253)">to </span><em style="font-family:'Lucida Grande',Verdana,Geneva,Arial,sans-serif;font-size:12px;background-color:rgb(251,252,253)">wkbPolygon</em><span style="font-family:'Lucida Grande',Verdana,Geneva,Arial,sans-serif;font-size:12px;background-color:rgb(251,252,253)">)?</span></div>
<div><font face="Lucida Grande, Verdana, Geneva, Arial, sans-serif"><span style="font-size:12px"><i><br></i></span></font></div><div><font face="Lucida Grande, Verdana, Geneva, Arial, sans-serif"><span style="font-size:12px">Thanks in advance,</span></font></div>
<div><font face="Lucida Grande, Verdana, Geneva, Arial, sans-serif"><span style="font-size:12px">Hugo Benício.<br><br></span></font><div><font face="Lucida Grande, Verdana, Geneva, Arial, sans-serif"><span style="font-size:12px"><i><br>
</i></span></font><br><div class="gmail_quote">On Mon, Oct 22, 2012 at 11:24 AM, Hugo Benicio <span dir="ltr"><<a href="mailto:hbobenicio@gmail.com" target="_blank">hbobenicio@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi guys!<div><br></div><div>I'm trying to create a shapefile containing a single polygon, but unfortunately I'm facing an error that I have no clue how to solve.</div><div>I'm successfuly creating a datasource and a layer with:</div>
<div><br></div><div>OGRLayer* testLayer = newDataSource->CreateLayer("test",NULL, wkbPolygon, NULL);</div><div><br></div><div>Then when I try to create a feature containing a <b>previously calculated*</b> polygon like this:</div>
<div><br></div><div>OGRFeature* feature = OGRFeature::CreateFeature(testLayer->GetLayerDefn());</div><div>feature->SetGeometry(myPolygon);</div><div>OGRErr errorCode = testLayer->CreateFeature(feature);</div><div>
<br></div><div>The line 'testLayer->CreateFeature(feature)' fails returning the error code:</div><div>OGRERR_UNSUPPORTED_GEOMETRY_TYPE 3</div><div><br></div><div>What am I missing here? How can I "make my geometry type supported"? Any clues?</div>
<div>Maybe I have to set the geometry type somehow somewhere else (on the layer or the geometry definition)... I don't know...</div><div><br></div><div><b>(*) </b>FYI, 'myPolygon' is generated with the Intersection of other 2 Polygons</div>
<div>OGRGeometry *myPolygon = basinPolygon->Intersection(landscapePolygon);</div><div><br></div><div>Thanks in Advance,</div><div>Best Regards,</div><div>Hugo Benício.</div>
</blockquote></div><br></div></div>