[Qgis-developer] Memory data provider persistence

Martin Dobias wonder.sk at gmail.com
Mon Dec 6 04:57:41 EST 2010


On Mon, Dec 6, 2010 at 10:45 AM, Barry Rowlingson
<b.rowlingson at lancaster.ac.uk> wrote:
> 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?".

I completely agree with Barry - to me it looks like a waste of time to
invent a new data format - exclusively readable just by QGIS - and
intended just to load/store some data from/to memory provider.
Additionally, memory provider was thought to represent just temporary
(nonpersistent) data - so asking the user to convert it to some other
format when exiting seems reasonable to me.

Regards
Martin


More information about the Qgis-developer mailing list