Even,
thanks for the answer.

I saw it recently in the list but I didn’t relate with that!
Thanks. I understand! I think it’s a good idea have al sealed before. And as 
you can remember I would seal the number of features also :p

Thanks :)

De: Even Rouault <even.roua...@spatialys.com>
Enviado el: dimecres, 20 de desembre de 2023 21:06
Para: Abel Pau <a....@creaf.uab.cat>; gdal-dev@lists.osgeo.org
Asunto: Re: [gdal-dev] How to assign a new eType to a feature


Abel,

You should not change the type of field types (or the number of fields) once 
GetLayerDefn() has been called on the layer, after which the layer definition 
must be considered as sealed (cf recent RFC 
https://gdal.org/development/rfc/rfc97_feature_and_fielddefn_sealing.html), 
until potential calls from the user to CreateField()/DeleteField()/etc. which 
might unseal it. Changing field types during feature iteration would break 
expectations from users of the GDAL API (included GDAL tools such as ogr2ogr) 
and could cause nasty crashing bugs.

If you don't have a way to figure out the field type by looking at the header 
of your dataset, then you need to do a first reading pass to establish it (like 
done for example in the GeoJSON driver)

Even
Le 20/12/2023 à 20:58, Abel Pau via gdal-dev a écrit :
HI,
In the GetNewtRawFeature() I am processing all fields and a previusly OFTString 
type field has to be changed into OFTStringList type. After that, It’ll be 
probably a OFTString again.

I try to do that:
poFeature->GetDefnRef()->GetFieldDefn(nIField)->SetType(OFTStringList);

And when the destination driver gets it, the OFTStringList is again OFTString. 
I’ve lost the property by magic.

The line that does that is poDstFeature->SetFDefnUnsafe(poDstFDefn); in 
Translate() line5746 (probably).

So, there is a good way to change the type I’ve assigned in the constructor by 
the same but a “List” instead in the GetNextRawFeature()?

Sorry for asking a question (again) but I’ve been a long time trying to figure 
out what happens!

Thanks!

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
[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.






_______________________________________________

gdal-dev mailing list

gdal-dev@lists.osgeo.org<mailto: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