Hello Frank,<div><br></div><div><br></div><div>I have made your change and it works, I can open the .shp with my GIS. Many thanks for your help.</div><div><br></div><div>Best Regards,</div><div><br></div><div>Jorge<br><br>
<div class="gmail_quote">2011/1/18 Frank Warmerdam <span dir="ltr"><<a href="mailto:warmerdam@pobox.com">warmerdam@pobox.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On 11-01-18 11:28 AM, Jorge Martin wrote:<br>
</div><div class="im"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
OGRPolygon myPoligon;<br>
<br>
tmp = strtok (Line, ":");<br>
<br>
szName = string (tmp);<br>
<br>
<br>
while (tmp != NULL)<br>
{<br>
<br>
OGRLinearRing MyRing;// = (OGRLinearRing*)<br>
OGRGeometryFactory::createGeometry(wkbLinearRing);<br>
<br>
tmp = strtok (NULL, ",");<br>
<br>
if(tmp)<br>
{<br>
<br>
string Coords = string(tmp);<br>
<br>
size_t pos = Coords.find(" ");<br>
<br>
string CoordX = Coords.substr(0,pos);<br>
string CoordY = Coords.substr(pos);<br>
<br>
x = atof(CoordX.c_str());<br>
y = atof(CoordY.c_str());<br>
<br>
MyRing.addPoint(x,y);<br>
<br>
<br>
}<br>
<br>
myPoligon.addRing(&MyRing);<br>
<br>
}<br>
</blockquote>
<br></div>
Jorge,<br>
<br>
The essence of your problem is that you are creating a new<br>
ring for each point instead of creating one ring for the<br>
polygon and adding all the points to that ring before adding<br>
the ring to the polygon. A slightly altered form of the core<br>
that works looks like:<br>
<br>
OGRPolygon myPoligon;<br>
OGRLinearRing MyRing;// = (OGRLinearRing*)<div class="im"><br>
<br>
tmp = strtok (Line, ":");<br>
szName = string (tmp);<br>
while (tmp != NULL)<br>
{<br></div><div class="im">
OGRGeometryFactory::createGeometry(wkbLinearRing);<br>
<br>
tmp = strtok (NULL, ",");<br>
<br>
if(tmp)<br>
{<br>
string Coords = string(tmp);<br>
<br>
size_t pos = Coords.find(" ");<br>
<br>
string CoordX = Coords.substr(0,pos);<br>
string CoordY = Coords.substr(pos);<br>
<br>
x = atof(CoordX.c_str());<br>
y = atof(CoordY.c_str());<br>
<br>
MyRing.addPoint(x,y);<br>
}<br>
}<br>
<br>
myPoligon.addRing(&MyRing);<br>
<br></div><div class="im">
Best regards,<br>
-- <br>
---------------------------------------+--------------------------------------<br>
I set the clouds in motion - turn up | Frank Warmerdam, <a href="mailto:warmerdam@pobox.com" target="_blank">warmerdam@pobox.com</a><br>
light and sound - activate the windows | <a href="http://pobox.com/~warmerdam" target="_blank">http://pobox.com/~warmerdam</a><br>
and watch the world go round - Rush | Geospatial Programmer for Rent<br>
<br></div>
_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br>
</blockquote></div><br></div>