<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML amb format previ Car";
        margin:0cm;
        font-size:10.0pt;
        font-family:"Courier New";}
span.HTMLambformatpreviCar
        {mso-style-name:"HTML amb format previ Car";
        mso-style-priority:99;
        mso-style-link:"HTML amb format previ";
        font-family:"Courier New";}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 3.0cm 70.85pt 3.0cm;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body lang="CA" link="blue" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal">Ok,</p>
<p class="MsoNormal">It’s just what happened when I programmed the read-from-Spatial-Oracle and write-in-our-format.
</p>
<p class="MsoNormal">Our format have a main header, one header for every feature (so, as many as features in the layer) and after that have the geometric information.
</p>
<p class="MsoNormal">In other files have the other information that comes from Fields. No prblem in that one.</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I can use a not efficient but simple strategy: write every part in separate files and put all together on the correct place after finishing.</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks a lot for answering!</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<table class="MsoNormalTable" border="0" cellspacing="0" cellpadding="0" width="500" style="width:375.0pt">
<tbody>
<tr>
<td width="310" style="width:232.5pt;padding:0cm 0cm 0cm 0cm">
<p class="MsoNormal"><strong><span style="font-size:11.5pt;font-family:"Arial",sans-serif;color:#003300">Abel Pau Garcia</span></strong>
<o:p></o:p></p>
<div>
<p class="MsoNormal"><strong><span style="font-size:9.0pt;font-family:"Arial",sans-serif;color:#669900">Tècnic en SIG</span></strong><span style="font-size:9.0pt;font-family:"Arial",sans-serif;color:#669900"><o:p></o:p></span></p>
</div>
</td>
<td width="190" valign="top" style="width:142.5pt;padding:0cm 0cm 0cm 0cm">
<p class="MsoNormal" align="right" style="text-align:right"><img width="134" height="50" style="width:1.3958in;height:.5208in" id="Imatge_x0020_9" src="cid:image010.png@01D740ED.86C01100"><o:p></o:p></p>
</td>
</tr>
<tr>
<td style="padding:0cm 0cm 0cm 0cm">
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#003300"><a href="mailto:a.pau@creaf.uab.cat"><strong><span style="font-family:"Arial",sans-serif">a.pau@creaf.uab.cat</span></strong></a><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><strong><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#003300">Tel. +34 935814277</span></strong><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#003300"><o:p></o:p></span></p>
</div>
</td>
<td width="142" valign="top" style="width:106.5pt;padding:0cm 0cm 0cm 0cm">
<p class="MsoNormal" align="right" style="text-align:right"><img border="0" width="105" height="50" style="width:1.0937in;height:.5208in" id="Imatge_x0020_8" src="cid:image011.png@01D740ED.86C01100"><o:p></o:p></p>
</td>
</tr>
<tr>
<td style="padding:0cm 0cm 0cm 0cm">
<p style="margin:0cm"><a href="https://www.facebook.com/CREAFecologia/" target="_blank"><span style="text-decoration:none"><img border="0" width="19" height="18" style="width:.1979in;height:.1875in" id="Imatge_x0020_7" src="cid:image012.png@01D740ED.86C01100"></span></a><a href="https://twitter.com/CREAF_ecologia" target="_blank"><span style="text-decoration:none"><img border="0" width="19" height="18" style="width:.1979in;height:.1875in" id="Imatge_x0020_6" src="cid:image013.png@01D740ED.86C01100"></span></a><a href="https://www.linkedin.com/company/1363052?trk=tyah&trkInfo=clickedVertical:company,clickedEntityId:1363052,idx:2-1-2,tarId:1465807877789,tas:creaf" target="_blank"><span style="text-decoration:none"><img border="0" width="18" height="17" style="width:.1875in;height:.177in" id="Imatge_x0020_5" src="cid:image014.png@01D740ED.86C01100"></span></a><a href="https://www.youtube.com/c/creafecologia" target="_blank"><span style="text-decoration:none"><img border="0" width="18" height="17" style="width:.1875in;height:.177in" id="Imatge_x0020_4" src="cid:image015.png@01D740ED.86C01100"></span></a><a href="https://www.instagram.com/CREAF_ecologia/" target="_blank"><span style="text-decoration:none"><img border="0" width="19" height="18" style="width:.1979in;height:.1875in" id="Imatge_x0020_3" src="cid:image016.png@01D740ED.86C01100"></span></a></p>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#003300"><a href="http://www.creaf.cat" target="_blank"><strong><span style="font-family:"Arial",sans-serif;color:#003300;text-decoration:none">www.creaf.cat</span></strong></a><strong><span style="font-family:"Arial",sans-serif">
 | </span></strong><a href="http://blog.creaf.cat" target="_blank"><strong><span style="font-family:"Arial",sans-serif;color:#003300;text-decoration:none">http://blog.creaf.cat</span></strong></a><o:p></o:p></span></p>
</div>
</td>
<td valign="top" style="padding:0cm 0cm 0cm 0cm">
<p class="MsoNormal" align="right" style="text-align:right"><img border="0" width="105" height="50" style="width:1.0937in;height:.5208in" id="Imatge_x0020_2" src="cid:image017.png@01D740ED.86C01100"><o:p></o:p></p>
</td>
</tr>
<tr>
<td colspan="2" style="padding:0cm 0cm 0cm 0cm">
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#003300">CREAF. Campus UAB. Edifici C. 08193 Bellaterra (Barcelona)<o:p></o:p></span></p>
</td>
</tr>
<tr>
<td colspan="2" style="padding:0cm 0cm 0cm 0cm">
<div>
<p class="MsoNormal"><span style="font-size:8.5pt;font-family:"Arial",sans-serif;color:#999999"><br>
Abans d'imprimir aquest missatge electrònic penseu en el medi ambient.<o:p></o:p></span></p>
</div>
</td>
</tr>
<tr>
<td colspan="2" style="padding:0cm 0cm 0cm 0cm">
<p class="MsoNormal"><img border="0" width="500" height="6" style="width:5.2083in;height:.0625in" id="Imatge_x0020_1" src="cid:image018.gif@01D740ED.86C01100"><o:p></o:p></p>
</td>
</tr>
</tbody>
</table>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="mso-element:para-border-div;border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal" style="border:none;padding:0cm"><b>De: </b><a href="mailto:even.rouault@spatialys.com">Even Rouault</a><br>
<b>Enviat: </b>divendres, 21 de juliol de 2023 19:32<br>
<b>Per a: </b><a href="mailto:a.pau@creaf.uab.cat">Abel Pau</a>; <a href="mailto:gdal-dev@lists.osgeo.org">
gdal-dev@lists.osgeo.org</a><br>
<b>Tema: </b>Re: [gdal-dev] A question of eficiency</p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p><span style="mso-fareast-language:EN-US">Abel,<o:p></o:p></span></p>
<p><span style="mso-fareast-language:EN-US">OK, I now better understand what you meant. Well, no, there's no way for the writing part of a driver to know how many features there are in the source layer, because in the general case, there is no source layer...
 Users could potentially call CreateFeature() without any source layer and without knowing in advance how many features they are going to write. Ideally your driver wouldn't need to know that, but I don't know the specificities of your format. If you really
 need to know the number of features before being able to write the file, the strategy would be that the ICreateFeature() method of your driver actually delegates writing those features to another GDAL driver (e.g GeoPackage) in a temporary file, and upon layer
 closing, you read back that temporary file to actually write your own file.<o:p></o:p></span></p>
<p><span style="mso-fareast-language:EN-US">In some cases, ogr2ogr could potentially know in advance the number of features to be written and pass them to the output driver(as well as the extent typically), but:<o:p></o:p></span></p>
<p><span style="mso-fareast-language:EN-US">- knowing the number of features can be a pretty slow operation for some input drivers , or when using a SQL statement<o:p></o:p></span></p>
<p><span style="mso-fareast-language:EN-US">- and there's no such infrastructure currently<o:p></o:p></span></p>
<p><span style="mso-fareast-language:EN-US">Even<o:p></o:p></span></p>
<div>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">Le 21/07/2023 à 19:23, Abel Pau a écrit :<o:p></o:p></span></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span lang="ES" style="color:#1F497D;mso-fareast-language:EN-US">Hello!</span><span style="mso-fareast-language:EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="ES" style="color:#1F497D;mso-fareast-language:EN-US"> </span><span style="mso-fareast-language:EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D;mso-fareast-language:EN-US">I’ve been trying to use the
</span><span style="mso-fareast-language:EN-US">OGRLayer::GetFeatureCount() </span>
<span lang="EN-US" style="color:#1F497D;mso-fareast-language:EN-US">when I am reading another format inside the
</span><span style="font-size:9.5pt;font-family:Consolas;color:black">ICreateFeature()
</span><span lang="EN-US" style="color:#1F497D;mso-fareast-language:EN-US">but I think it’s impossible. At this point I don’t have access to the layer info, so to the GetFeatureCount().</span><span style="mso-fareast-language:EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D;mso-fareast-language:EN-US">In fact I don’t mind where to call this function but I need to call it in order to write our format efficiently (at least in most of cases).</span><span style="mso-fareast-language:EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D;mso-fareast-language:EN-US"> </span><span style="mso-fareast-language:EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D;mso-fareast-language:EN-US">So the question is, in my driver, when I read a format I get some information about the layer but I can’t acces to the count of the features of the layer. I am right? If
 not, how I do that?</span><span style="mso-fareast-language:EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D;mso-fareast-language:EN-US"> </span><span style="mso-fareast-language:EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D;mso-fareast-language:EN-US">Thanks but before sending this mail I’ve been like hours trying to find it out debbuging and consulting the call stack from all points and nothing seems to indicate I can
 do that. But perhaps I am wrong.</span><span style="mso-fareast-language:EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D;mso-fareast-language:EN-US"> </span><span style="mso-fareast-language:EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D;mso-fareast-language:EN-US">It would be very helpful knowing that information. I not my writting strategy with change radically. Thankssssss!</span><span style="mso-fareast-language:EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D;mso-fareast-language:EN-US"> </span><span style="mso-fareast-language:EN-US"><o:p></o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="ES">De:</span></b><span lang="ES"> gdal-dev <a href="mailto:gdal-dev-bounces@lists.osgeo.org">
<span style="color:#0563C1"><gdal-dev-bounces@lists.osgeo.org></span></a> <b>En nombre de
</b>Abel Pau<br>
<b>Enviado el:</b> divendres, 7 de juliol de 2023 12:44<br>
<b>Para:</b> Even Rouault <a href="mailto:even.rouault@spatialys.com"><span style="color:#0563C1"><even.rouault@spatialys.com></span></a>;
<a href="mailto:gdal-dev@lists.osgeo.org"><span style="color:#0563C1">gdal-dev@lists.osgeo.org</span></a><br>
<b>Asunto:</b> Re: [gdal-dev] A question of eficiency</span><span style="mso-fareast-language:EN-US"><o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"> <o:p></o:p></span></p>
<p class="MsoNormal"><span lang="ES" style="color:#1F497D;mso-fareast-language:EN-US">Hi again,</span><span style="mso-fareast-language:EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="ES" style="color:#1F497D;mso-fareast-language:EN-US"> </span><span style="mso-fareast-language:EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D;mso-fareast-language:EN-US">I can totally give this number in
</span><span style="mso-fareast-language:EN-US">GetFeatureCount()</span><span lang="EN-US" style="color:#1F497D;mso-fareast-language:EN-US">. No problem from my driver to other.</span><span style="mso-fareast-language:EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D;mso-fareast-language:EN-US">Then I understand that in one way (efficient) or in another (no efficient) I can always get the number of features with the GetFeatureCount(). True?</span><span style="mso-fareast-language:EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D;mso-fareast-language:EN-US"> </span><span style="mso-fareast-language:EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D;mso-fareast-language:EN-US">About the other question imagine a multiline shape with two lines of two parts every line. I need to know the total count of individual lines (cause my driver doesn’t have
 multiline and I have to convert every multiline to N lines). It is 4 (2+2). Can I get this number without asking every feature how many parts it have? I doubt that, but...
</span><span style="mso-fareast-language:EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D;mso-fareast-language:EN-US"> </span><span style="mso-fareast-language:EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D;mso-fareast-language:EN-US">Thanks for your kind anwser!</span><span style="mso-fareast-language:EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D;mso-fareast-language:EN-US"> </span><span style="mso-fareast-language:EN-US"><o:p></o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US">De:</span></b><span lang="EN-US"> Even Rouault <<a href="mailto:even.rouault@spatialys.com"><span style="color:#0563C1">even.rouault@spatialys.com</span></a>>
<br>
<b>Enviado el:</b> divendres, 7 de juliol de 2023 </span><span lang="ES">12:32<br>
<b>Para:</b> Abel Pau <<a href="mailto:a.pau@creaf.uab.cat"><span style="color:#0563C1">a.pau@creaf.uab.cat</span></a>>;
<a href="mailto:gdal-dev@lists.osgeo.org"><span style="color:#0563C1">gdal-dev@lists.osgeo.org</span></a><br>
<b>Asunto:</b> Re: [gdal-dev] A question of eficiency</span><span style="mso-fareast-language:EN-US"><o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"> <o:p></o:p></span></p>
<p><span style="mso-fareast-language:EN-US">Abel,<o:p></o:p></span></p>
<p><span style="mso-fareast-language:EN-US">At the minimum for the reading side of a vector driver, you need to implement GetNextFeature().<o:p></o:p></span></p>
<p><span style="mso-fareast-language:EN-US">If there is an efficient way of knowing the number of features without iterating over the whole file (typically a field in a header giving that number), you may implement GetFeatureCount(). If you don't implement
 it, and code using your driver needs the feature count, the generic implementation of OGRLayer::GetFeatureCount() will call GetNextFeature() repeatdly until it returns NULL.<o:p></o:p></span></p>
<p><span style="mso-fareast-language:EN-US">Not totally sure to understand your question about multielements. If you have an instance of OGRGeometryCollection or any deriving class, there's a getNumGeometries() method to get the number of parts<o:p></o:p></span></p>
<p><span style="mso-fareast-language:EN-US">Even<o:p></o:p></span></p>
<div>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">Le 07/07/2023 à 11:33, Abel Pau a écrit :<o:p></o:p></span></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">Hi,</span><span style="mso-fareast-language:EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">I would like to know if when we use the code of GDAL to program a driver (or whatever) in vectors (so, ogr) we can assume that we can know the number of elements we are going to import
 in any way or it would be possible not knowing that until NextFeature is empty (or something like that). So, there is any way to obtain this number of elements without doing a while? And in case of multielements its possible to know how many parts are there
 in total?</span><span style="mso-fareast-language:EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">I need that to write my format (I don’t explain the details cause I don’t get you bored :) )</span><span style="mso-fareast-language:EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"> </span><span style="mso-fareast-language:EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">If anyone know that I’d appreciate an answer. Thanks in advance.</span><span style="mso-fareast-language:EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"> </span><span style="mso-fareast-language:EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">Abel.</span><span style="mso-fareast-language:EN-US"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:12.0pt;mso-fareast-language:EN-US"> </span><span style="mso-fareast-language:EN-US"><o:p></o:p></span></p>
<pre>_______________________________________________</pre>
<pre>gdal-dev mailing list</pre>
<pre><a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a></pre>
<pre><a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a></pre>
</blockquote>
<pre>-- </pre>
<pre><a href="http://www.spatialys.com">http://www.spatialys.com</a></pre>
<pre>My software is free, but my time generally not.</pre>
</blockquote>
<pre>-- </pre>
<pre><a href="http://www.spatialys.com">http://www.spatialys.com</a></pre>
<pre>My software is free, but my time generally not.</pre>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New""><o:p> </o:p></span></p>
</div>
</body>
</html>