[Qgis-developer] Memory data provider persistence

Chris Crook ccrook at linz.govt.nz
Thu Jul 26 12:41:57 PDT 2012


Hi Even

Thanks for the suggestion and code examples - very helpful. I haven't followed up on this yet partly because this has prompted me to look at other storage formats for the data (something I'd been putting off).

If I understand the GML driver documentation properly then I would have to manage the possibility of the user having a field called FID, as after I've saved the data, then reloaded with GMS_EXPOSE_FID set to NO, that field will be lost? As you suggest, renaming the fields before saving and then after reloading would fix handle this.

Cheers
Chris

-----Original Message-----
From: Even Rouault [mailto:even.rouault at mines-paris.org] 
Sent: Thursday, 26 July 2012 6:47 a.m.
To: qgis-developer at lists.osgeo.org
Cc: Chris Crook; haubourg
Subject: Re: [Qgis-developer] Memory data provider persistence

Le mercredi 25 juillet 2012 20:03:16, Chris Crook a écrit :
> Hi .. yes I don't like masking the FID field and I'm not thinking this 
> is a long term solution, even before the problem in my implementation 
> with the field index issue (which I think I will be able to fix).  I'm 
> looking at a couple of options over the next few days .. and open to 
> any contributions, suggestions, code, etc :-)

Chris,

did you try setting GML_EXPOSE_FID to NO before opening the GML as we discussed on the GDAL trac system ? This should fix your issue without much code, basically calling CPLSetConfigOption("GML_EXPOSE_FID", "NO") (or gdal.SetConfigOption("GML_EXPOSE_FID", "NO") if you're coding in Python) before doing the OGROpen() call with the GML file.

Actually, to avoid "polluting" other portions of code, you should save the original value and restore it afterwards, so :

in C/C++ :

char* pszOldVal = CPLGetConfigOption("GML_EXPOSE_FID") ? 
strdup(CPLGetConfigOption("GML_EXPOSE_FID")) : NULL; CPLSetConfigOption("GML_EXPOSE_FID", "NO"); OGRDataSource hDS  = OGROpen(....); CPLSetConfigOption("GML_EXPOSE_FID", pszOldVal); free(pszOldVal);

in Python :

old_val = gdal.GetConfigOption("GML_EXPOSE_FID")
gdal.SetConfigOption("GML_EXPOSE_FID", "NO") ds = ogr.Open(....)
gdal.SetConfigOption("GML_EXPOSE_FID",old_val)

And to avoid confusion, yes, you should also avoid that a user creates a 'FID' 
field.

> 
> Cheers
> Chris
> ________________________________________
> From: haubourg [regis.haubourg at eau-adour-garonne.fr]
> Sent: 23 July 2012 20:58
> To: qgis-developer at lists.osgeo.org
> Subject: Re: [Qgis-developer] Memory data provider persistence
> 
> Hi Chris, thanks for your feedback. I start thinking using a 
> spatialite is a great idea. I prefer this than having rules to mask 
> FID field. This can generate very hard-to-find bugs..
> 
> Having a complex Qgs zipfile containing either a spatialite DB or xml 
> + data would be great but is a big evolution. IMHO, such a break 
> should be kept for a major version change in QGIS (2.0?).
> 
> Is that a work you are on ? Need contributors?
> 
> 
> 
> 
> 
> 
> --
> View this message in context:
> http://osgeo-org.1560.n6.nabble.com/Memory-data-provider-persistence-t
> p410 8012p4989995.html Sent from the Quantum GIS - Developer mailing 
> list archive at Nabble.com.
> 
> This message contains information, which is confidential and may be 
> subject to legal privilege. If you are not the intended recipient, you 
> must not peruse, use, disseminate, distribute or copy this message. If 
> you have received this message in error, please notify us immediately 
> (Phone 0800
> 665 463 or info at linz.govt.nz) and destroy the original message. LINZ 
> accepts no responsibility for changes to this email, or for any 
> attachments, after its transmission from LINZ. Thank You.
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
This message contains information, which is confidential and may be subject to legal privilege. If you are not the intended recipient, you must not peruse, use, disseminate, distribute or copy this message. If you have received this message in error, please notify us immediately (Phone 0800 665 463 or info at linz.govt.nz) and destroy the original message. LINZ accepts no responsibility for changes to this email, or for any attachments, after its transmission from LINZ. Thank You.


More information about the Qgis-developer mailing list