[gdal-dev] A question of eficiency
Abel Pau
a.pau at creaf.uab.cat
Fri Jul 7 03:43:57 PDT 2023
Hi again,
I can totally give this number in GetFeatureCount(). No problem from my driver to other.
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?
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...
Thanks for your kind anwser!
De: Even Rouault <even.rouault at spatialys.com>
Enviado el: divendres, 7 de juliol de 2023 12:32
Para: Abel Pau <a.pau at creaf.uab.cat>; gdal-dev at lists.osgeo.org
Asunto: Re: [gdal-dev] A question of eficiency
Abel,
At the minimum for the reading side of a vector driver, you need to implement GetNextFeature().
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.
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
Even
Le 07/07/2023 à 11:33, Abel Pau a écrit :
Hi,
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?
I need that to write my format (I don’t explain the details cause I don’t get you bored :) )
If anyone know that I’d appreciate an answer. Thanks in advance.
Abel.
_______________________________________________
gdal-dev mailing list
gdal-dev at lists.osgeo.org<mailto:gdal-dev at lists.osgeo.org>
https://lists.osgeo.org/mailman/listinfo/gdal-dev
--
http://www.spatialys.com
My software is free, but my time generally not.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20230707/44ac99ed/attachment-0001.htm>
More information about the gdal-dev
mailing list