Abel Pau,

no you can't know the number of fields at the moment of creating the layer. A number of drivers only accept the CreateField() method to be called until the first call to ICreateFeature(). Cf the "bFeaturesWritten" variable in ogr/ogrsf_frmts/jml/ogrjmlwriterlayer.cpp

Typically ogr2ogr will never call CreateField() after ICreateFeature()

Even

Le 02/10/2023 à 15:54, Abel Pau via gdal-dev a écrit :

Hi everybody,

do anyone know if a driver can know the number of fields (and it’s names, etc) of a layer BEFORE starting fetch features? So in the moment of create the layer.

I mean, when a driver is creating the own layer it could probably be interested in creating all fields before starting and not in the middle of translation. It could be caused because the output format requires that in terms of efficiency.

For instance, first feature have 3 fields, second feature have four, etc... Until the last feature driver is not sure of all fields are definitive.

And every time a feature is added the driver have to verify in which destination field corresponds to the new one.

So, I accepted that it happens with the number of features (Even can remember my concerns that time) and I am wondering if I have to accept that for the number of fields.

Thanks a lot.

*Abel Pau Garcia*

*GIS developer*

        

https://www.creaf.cat/sites/default/files/creaf-signature.png

*a....@creaf.uab.cat* <mailto:a....@creaf.uab.cat>

*Let's chat on Teams!* <https://teams.microsoft.com/l/chat/0/0?users=a....@creaf.uab.cat>

*Tel. +34 934814277*

        

https://www.creaf.cat/sites/default/files/so-en-signature.png

https://www.creaf.cat/sites/default/files/twitter-icon-signature.png <https://twitter.com/CREAF_ecologia>https://www.creaf.cat/sites/default/files/linkedin-icon-signature.png <https://www.linkedin.com/company/1363052?trk=tyah&trkInfo=clickedVertical:company,clickedEntityId:1363052,idx:2-1-2,tarId:1465807877789,tas:creaf>https://www.creaf.cat/sites/default/files/youtube-icon-signature.png <https://www.youtube.com/c/creafecologia>https://www.creaf.cat/sites/default/files/instagram-icon-signature.png <https://www.instagram.com/CREAF_ecologia/>

*www.creaf.cat* <http://www.creaf.cat>*| **http://blog.creaf.cat* <http://blog.creaf.cat>

        

https://www.creaf.cat/sites/default/files/uab_logo_signatura.png

CREAF. Campus UAB. Edifici C. 08193 Bellaterra (Barcelona)


Before printing this electronic message, think about the environment.

http://www.creaf.uab.cat/_signatura/line.gif


_______________________________________________
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev

--
http://www.spatialys.com
My software is free, but my time generally not.
_______________________________________________
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to