Jean,<br><br>You might want to test with <font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB">AddGeometryDirectly instead of </span></font><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB">
AddGeometry so as to avoid the extra geometry creations.<br><br>When you have a large number of points in the rings you might want to use the CreateFromWkb method to avoid the number of invocations between the C#/C interface. You can create a byte array containing the wkb of the polygon in the C# side and call the static CreateFromWkb of the Geometry class with that array.
<br><br>Currently we have no such function you have mentioned, and I'm not sure about the proper signature to use (depending on the type of the geometry) if needed.<br> <br></span></font><br>Best regards,<br><br>Tamas
<br><br><br><div><span class="gmail_quote">2007/7/24, Jean Michel PIERRET <<a href="mailto:jmp@geosys.com">jmp@geosys.com</a>>:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div link="blue" vlink="purple" lang="FR">
<div>
<p style=""><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB">Hi,</span></font></p>
<p style=""><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB"> </span></font></p>
<p style=""><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB"> I
would like transform a geometry structure in a OGR.Geometry.</span></font></p>
<p style=""><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB"> </span></font></p>
<p style="margin-left: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB">Struct
MyGeometry</span></font></p>
<p style="margin-left: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB">{</span></font></p>
<p style="margin-left: 35.4pt; text-indent: 35.4pt;"><font color="blue" face="Courier New" size="2"><span style="font-size: 10pt; color: blue;" lang="EN-GB">bool</span></font><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB">
[] exterior = <font color="blue"><span style="color: blue;">null</span></font>;</span></font></p>
<p style="margin-left: 35.4pt; text-indent: 35.4pt;"><font color="blue" face="Courier New" size="2"><span style="font-size: 10pt; color: blue;" lang="EN-GB">int</span></font><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB">
[] partStarts = <font color="blue"><span style="color: blue;">null</span></font>;</span></font></p>
<p style="margin-left: 35.4pt; text-indent: 35.4pt;"><font color="blue" face="Courier New" size="2"><span style="font-size: 10pt; color: blue;">int</span></font><font face="Courier New" size="2"><span style="font-size: 10pt;">
[]
partEnds = <font color="blue"><span style="color: blue;">null</span></font>;</span></font></p>
<p style="margin-left: 35.4pt; text-indent: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;"> </span></font></p>
<p style="margin-left: 35.4pt; text-indent: 35.4pt;"><font color="blue" face="Courier New" size="2"><span style="font-size: 10pt; color: blue;">double</span></font><font face="Courier New" size="2"><span style="font-size: 10pt;">
[]
padfX = <font color="blue"><span style="color: blue;">null</span></font>;</span></font></p>
<p style="margin-left: 35.4pt; text-indent: 35.4pt;"><font color="blue" face="Courier New" size="2"><span style="font-size: 10pt; color: blue;" lang="EN-GB">double</span></font><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB">
[] padfY = <font color="blue"><span style="color: blue;">null</span></font>;</span></font></p>
<p style="margin-left: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB">}</span></font></p>
<p style="margin-left: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB"> </span></font></p>
<p style="margin-left: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB">When
I use the method ExportToWkt and CreateFromWkt it's very slow.</span></font></p>
<p style="text-indent: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB">Now
I have this method for the transformation :</span></font></p>
<p style="margin-left: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB"> </span></font></p>
<p style="margin-left: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB">Geometry
gm = <font color="blue"><span style="color: blue;">null</span></font>;</span></font></p>
<p style="margin-left: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB">Geometry
g = <font color="blue"><span style="color: blue;">null</span></font>;</span></font></p>
<p style="margin-left: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB">Geometry
lr = <font color="blue"><span style="color: blue;">null</span></font>;</span></font></p>
<p style="margin-left: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB"> </span></font></p>
<p style="margin-left: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB">g
= <font color="blue"><span style="color: blue;">new</span></font> Geometry(wkbGeometryType.wkbPolygon);</span></font></p>
<p style="margin-left: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB"> </span></font></p>
<p style="margin-left: 35.4pt;"><font color="blue" face="Courier New" size="2"><span style="font-size: 10pt; color: blue;" lang="EN-GB">for</span></font><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB">
(<font color="blue"><span style="color: blue;">int</span></font> i = 0; i < partStarts.Length;
i++)</span></font></p>
<p style="margin-left: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB">{</span></font></p>
<p style="margin-left: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB"> <font color="blue"><span style="color: blue;">if</span></font> (exterior[i])</span></font></p>
<p style="margin-left: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB"> {</span></font></p>
<p style="margin-left: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB"> <font color="blue"><span style="color: blue;">if</span></font> (i > 0)</span></font></p>
<p style="margin-left: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB"> {</span></font></p>
<p style="margin-left: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB"> <font color="blue"><span style="color: blue;">if</span></font> (gm == <font color="blue"><span style="color: blue;">
null</span></font>)</span></font></p>
<p style="margin-left: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB"> gm
= <font color="blue"><span style="color: blue;">new</span></font> Geometry(wkbGeometryType.wkbMultiPolygon);</span></font></p>
<p style="margin-left: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB">
gm.AddGeometry(g);</span></font></p>
<p style="margin-left: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB"> g.Dispose();</span></font></p>
<p style="margin-left: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB"> g
= <font color="blue"><span style="color: blue;">null</span></font>;</span></font></p>
<p style="margin-left: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB"> }</span></font></p>
<p style="margin-left: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB"> </span></font></p>
<p style="margin-left: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB"> <font color="blue"><span style="color: blue;">if</span></font> (g == <font color="blue"><span style="color: blue;">
null</span></font>)</span></font></p>
<p style="margin-left: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB"> g
= <font color="blue"><span style="color: blue;">new</span></font> Geometry(wkbGeometryType.wkbPolygon);</span></font></p>
<p style="margin-left: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB"> }</span></font></p>
<p style="margin-left: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB"> </span></font></p>
<p style="margin-left: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB"> lr
= <font color="blue"><span style="color: blue;">new</span></font> Geometry(wkbGeometryType.wkbLinearRing);</span></font></p>
<p style="margin-left: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB"> <font color="blue"><span style="color: blue;">for</span></font> (<font color="blue"><span style="color: blue;">
int</span></font> j = partStarts[i]; j < partEnds[i];
j++)</span></font></p>
<p style="margin-left: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB"> lr.AddPoint(padfX[j],
padfY[j], 0);</span></font></p>
<p style="margin-left: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB"> </span></font></p>
<p style="margin-left: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB"> g.AddGeometry(lr);</span></font></p>
<p style="margin-left: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB"> lr.Dispose();</span></font></p>
<p style="margin-left: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB"> lr
= <font color="blue"><span style="color: blue;">null</span></font>;</span></font></p>
<p style="margin-left: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB">}</span></font></p>
<p style="margin-left: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB"> </span></font></p>
<p style="margin-left: 35.4pt;"><font color="blue" face="Courier New" size="2"><span style="font-size: 10pt; color: blue;" lang="EN-GB">if</span></font><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB">
(gm != <font color="blue"><span style="color: blue;">null</span></font>)</span></font></p>
<p style="margin-left: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB">{</span></font></p>
<p style="margin-left: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB"> <font color="blue"><span style="color: blue;">if</span></font> (g != <font color="blue"><span style="color: blue;">
null</span></font>)</span></font></p>
<p style="margin-left: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB"> {</span></font></p>
<p style="margin-left: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB"> gm.AddGeometry(g);</span></font></p>
<p style="margin-left: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB"> g.Dispose();</span></font></p>
<p style="margin-left: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB"> g
= <font color="blue"><span style="color: blue;">null</span></font>;</span></font></p>
<p style="margin-left: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB"> }</span></font></p>
<p style="margin-left: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB"> </span></font></p>
<p style="margin-left: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB"> <font color="blue"><span style="color: blue;">return</span></font> gm;</span></font></p>
<p style="margin-left: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;">}</span></font></p>
<p style="margin-left: 35.4pt;"><font color="blue" face="Courier New" size="2"><span style="font-size: 10pt; color: blue;">else</span></font></p>
<p style="margin-left: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;"> <font color="blue"><span style="color: blue;">return</span></font> g;</span></font></p>
<p style="margin-left: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;"> </span></font></p>
<p style="margin-left: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB">It
works but it is not very quick, It's possible to have a function like in
the shapelib</span></font></p>
<p style="margin-left: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB"> </span></font></p>
<p style="text-indent: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB">SHPObject
SHPCreateObject(ShapeType shpType, <font color="blue"><span style="color: blue;">int</span></font>
nShapeId, <font color="blue"><span style="color: blue;">int</span></font> nParts, <font color="blue"><span style="color: blue;">int</span></font>[] panPartStart, PartType[]
paPartType, <font color="blue"><span style="color: blue;">int</span></font> nVertices,
<font color="blue"><span style="color: blue;">double</span></font>[] adfX, <font color="blue"><span style="color: blue;">double</span></font>[] adfY, <font color="blue"><span style="color: blue;">double</span></font>[] adfZ,
<font color="blue"><span style="color: blue;">double</span></font>[] adfM);</span></font></p>
<p style="text-indent: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB"> </span></font></p>
<p style=""><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB">Thanks for your
support.</span></font></p>
<p style="text-indent: 35.4pt;"><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB"> </span></font></p>
<p style=""><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB">Best Regards.</span></font></p>
<p><font face="Courier New" size="2"><span style="font-size: 10pt;" lang="EN-GB"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;" lang="EN-GB"> </span></font></p>
<table style="width: 184.5pt;" border="0" cellpadding="0" width="246">
<tbody><tr>
<td style="padding: 0.75pt; width: 147.75pt;" width="197">
<p><b><font color="#eebb22" face="Arial" size="1"><span style="font-size: 9pt; font-family: Arial; color: rgb(238, 187, 34); font-weight: bold;"><a href="mailto:jmp@geosys.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
<font color="#eebb22"><span style="color: rgb(238, 187, 34);">Jean-michel
PIERRET</span></font></a> - Poste 376</span></font></b></p>
</td>
</tr>
<tr>
<td style="padding: 0.75pt; width: 147.75pt;" width="197">
<p><b><font color="#999999" face="Arial" size="1"><span style="font-size: 9pt; font-family: Arial; color: rgb(153, 153, 153); font-weight: bold;">Tel
: +33 (0)5 62 47 80 76</span></font></b><font color="#999999" face="Arial" size="1"><span style="font-size: 9pt; font-family: Arial; color: rgb(153, 153, 153);"><br>
<b><span style="font-weight: bold;">Mail</span></b> : <a href="mailto:jmp@geosys.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)"><font color="#336699"><span style="color: rgb(51, 102, 153);">
jmp@geosys.com</span></font></a><br>
</span></font><b><font color="#336699" face="Arial" size="1"><span style="font-size: 9pt; font-family: Arial; color: rgb(51, 102, 153); font-weight: bold;">GEOSYS
SA</span></font></b></p>
</td>
</tr>
</tbody></table>
<p><font face="Times New Roman" size="3"><span style="font-size: 12pt;"> </span></font></p>
<p><font face="Times New Roman" size="3"><span style="font-size: 12pt;"> </span></font></p>
</div>
</div>
<br>_______________________________________________<br>Gdal-dev mailing list<br><a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:Gdal-dev@lists.maptools.org">Gdal-dev@lists.maptools.org</a><br><a onclick="return top.js.OpenExtLink(window,event,this)" href="http://lists.maptools.org/mailman/listinfo/gdal-dev" target="_blank">
http://lists.maptools.org/mailman/listinfo/gdal-dev</a><br></blockquote></div><br>