[Qgis-developer] Memory data provider persistence
Barry Rowlingson
b.rowlingson at lancaster.ac.uk
Mon Dec 6 04:45:36 EST 2010
On Mon, Dec 6, 2010 at 2:04 AM, Chris Crook <ccrook at linz.govt.nz> wrote:
> So, for my requirement for memory provider persistance, the only real question is what is the right way to do it. Although Martin had suggested a spatialite database, my leaning is towards a simple QDataStream. A simple implementation could be (in crude pseudo code)
>
> Qstring header("Qgis data file");
> Int version = 1;
> stream << header << version;
>
> Foreach memory_provider
> if provider < persist
> stream << layer_id
> stream << attribute_count
> foreach attribute
> stream << attribute_definition
> stream << feature_count
> foreach feature
> stream << feature
>
> This could readily be reloaded after the XML project file is read.
>
> Because it is processed sequentially it would sit comfortably in a ZIP file and be sequentially read from it without needing to be extracted and then processed (as a spatialite database would need to be). It is portable between OS etc.
>
> If the user actually wants a spatialite database, or any other format, then they can save the layer to that.
>
> How does this sound to people?
It sounds like you're just creating another spatial data format. Why
not, on project exit, just go "You have unsaved memory data layers -
would you like them converted to [gml|shapefile|spatialite|whatever]
and reloaded before saving/qutting or do you want to lose them
forever?".
Barry
More information about the Qgis-developer
mailing list