<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=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<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;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML con formato previo Car";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";
        mso-fareast-language:CA;}
span.HTMLconformatoprevioCar
        {mso-style-name:"HTML con formato previo Car";
        mso-style-priority:99;
        mso-style-link:"HTML con formato previo";
        font-family:Consolas;
        mso-fareast-language:EN-US;}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;
        mso-fareast-language:CA;}
span.EstiloCorreo21
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
span.EstiloCorreo22
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
span.EstiloCorreo23
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 3.0cm 70.85pt 3.0cm;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="CA" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><span lang="ES" style="color:#1F497D">Hello!<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="ES" style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D">I’ve been trying to use the
</span>OGRLayer::GetFeatureCount() <span lang="EN-US" style="color:#1F497D">when I am reading another format inside the
</span><span style="font-size:9.5pt;font-family:Consolas;color:black;mso-fareast-language:CA">ICreateFeature()
</span><span lang="EN-US" style="color:#1F497D">but I think it’s impossible. At this point I don’t have access to the layer info, so to the GetFeatureCount().<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D">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).<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D">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?<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D">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.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D">It would be very helpful knowing that information. I not my writting strategy with change radically. Thankssssss!<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D"><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" style="mso-fareast-language:CA">De:</span></b><span lang="ES" style="mso-fareast-language:CA"> gdal-dev <gdal-dev-bounces@lists.osgeo.org>
<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 <even.rouault@spatialys.com>; gdal-dev@lists.osgeo.org<br>
<b>Asunto:</b> Re: [gdal-dev] A question of eficiency<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span lang="ES" style="color:#1F497D">Hi again,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="ES" style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D">I can totally give this number in
</span>GetFeatureCount()<span lang="EN-US" style="color:#1F497D">. No problem from my driver to other.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D">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?<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D">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...
<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D">Thanks for your kind anwser!<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D"><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" style="mso-fareast-language:CA">De:</span></b><span lang="EN-US" style="mso-fareast-language:CA"> Even Rouault <<a href="mailto:even.rouault@spatialys.com">even.rouault@spatialys.com</a>>
<br>
<b>Enviado el:</b> divendres, 7 de juliol de 2023 </span><span lang="ES" style="mso-fareast-language:CA">12:32<br>
<b>Para:</b> Abel Pau <<a href="mailto:a.pau@creaf.uab.cat">a.pau@creaf.uab.cat</a>>;
<a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a><br>
<b>Asunto:</b> Re: [gdal-dev] A question of eficiency<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p>Abel,<span style="font-size:12.0pt;mso-fareast-language:CA"><o:p></o:p></span></p>
<p>At the minimum for the reading side of a vector driver, you need to implement GetNextFeature().<o:p></o:p></p>
<p>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></p>
<p>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></p>
<p>Even<o:p></o:p></p>
<div>
<p class="MsoNormal">Le 07/07/2023 à 11:33, Abel Pau a écrit :<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span lang="EN-US">Hi,</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="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><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US">I need that to write my format (I don’t explain the details cause I don’t get you bored :) )</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US">If anyone know that I’d appreciate an answer. Thanks in advance.</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US">Abel.</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:12.0pt;font-family:"Times New Roman",serif;mso-fareast-language:CA"><o:p> </o:p></span></p>
<pre>_______________________________________________<o:p></o:p></pre>
<pre>gdal-dev mailing list<o:p></o:p></pre>
<pre><a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a><o:p></o:p></pre>
<pre><a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a><o:p></o:p></pre>
</blockquote>
<pre>-- <o:p></o:p></pre>
<pre><a href="http://www.spatialys.com">http://www.spatialys.com</a><o:p></o:p></pre>
<pre>My software is free, but my time generally not.<o:p></o:p></pre>
</div>
</body>
</html>