YoannQDQ / qgis-memory-layer-saver

Makes data in memory provider layers persistent between QGIS sessions. Data saved in .mldata file alongside project file.
Other
7 stars 4 forks source link

Save mldata to qgz project if available #9

Closed haubourg closed 1 year ago

haubourg commented 5 years ago

Hi! It would be nice to save the mldata file inside the qgz zipped file when available. That would avoid users to forget to embbed this data when sharing the project file.

In fact, this use case was one of the rationale for creating qgz format :) I'll keep in touch if we have the possibility to submit a PR.

ccrook commented 5 years ago

Hi Régis. Yes - I did look at trying that when I ported the plugin to QGIS3. At that time the advise I got from mail list was that there wasn't yet an API to support that - but that may have changed. So would be delighted if you submit a PR :-)

klainkaliber commented 5 years ago

Hi, this is something I am deeply missing in QGIS. I frequently have Excel-Sheets (and MS Access databases) containing measurement data and two columns containin x and y coordinates and my procedure in ArcGIS was to load the xlsx, then "Display XY-data" using two columns and the layer was there. Saving the mxd also made the points permanent. It is not the way GIS is meant to be (I am aware of this), but it is super practical and fulfills my need most of fthe times when I just need visualisation of some measured data.

ccrook commented 5 years ago

@klainkaliber I'm not sure quite how this relates to the memory layer saver plugin. However you can certainly load spreadsheets directly in QGIS - create a new vector layer and load the speadsheet in from there. In my work I tend to be creating data from other programs so I often use comma delimited (CSV) files, which you can also load that way, or more conveniently as a delimited text layer.

haubourg commented 5 years ago

@klainkaliber try spreadsheet layer plugin :)

klainkaliber commented 5 years ago

@haubourg this is funny - I installed this very plugin some time ago, after the preferences the layer never showed up (did not find out why). TodayI reinstalled it - and now it does what I expected. Great!

geomenke commented 3 years ago

Has there been any progress in saving a memory layer inside a QGZ zipped file. It looks like no, but this is exacly what I am looking for so wanted to check. Perhaps we can submit a PR.

ccrook commented 3 years ago

@geomenke You are correct - the answer is no as far as the plugin is concerned. I haven't had (and still don't have) time to investigate whether the recent updates to QGIS 3add this API capability (ie to add and retrieve a file from a .qgz file, or better yet to open a python file handle on an embedded file.

baswein commented 2 years ago

I am not technical savvy enough to know for sure but this merge in QGIS looks like it adds the ability to add files to .qgz: https://github.com/qgis/QGIS/pull/43526

ccrook commented 2 years ago

Thanks @baswein - certainly looks promising. I won't have time to look at this myself for a while - other priorities.

jmonticolo commented 1 year ago

This repo is meant to do that : https://github.com/YoannQDQ/qgis_scratch_layer_saver

ccrook commented 1 year ago

Hi @jmonticolo. This looks great at an admittedly casual look. To be honest I don't have much time for working on QGIS these days and certainly haven't been able to give this plugin the attention it deserves (I always felt it should be core functionality rather than a plugin).

I am wondering whether you would be interested in taking over ownership of this plugin and merging your code in to it. To me that seems a better option than having two very similar plugins in the QGIS repository.

What do you think?

YoannQDQ commented 1 year ago

Hi @ccrook,

This repository is an empty shell for now, but I was planning to work on it in the next few weeks. In another project of mine, I embedded the Memory Layer Saver plugin (great work by the way!) which I tweaked quite extensively. Now I want to make those changes available to all, but they seemed a bit much to go through the PR/review process, hence the new repository.

If you're willing, transferring ownership is indeed probably the best solution.

ccrook commented 1 year ago

Hi @YoannQDQ. I very much appreciate the work you've done on this and your offer to take over maintenance of the plugin. I've added you as a collaborator of the plugin in the QGIS plugin repository and offered transfer of the github repository to you. I guess we can request ownership change of the plugin in the plugin repository from the system maintainers?

YoannQDQ commented 1 year ago

Thank you very much! Yes, that would be ideal.

YoannQDQ commented 1 year ago

Fixed in version 5.0.0 (waiting for approval)

ccrook commented 1 year ago

Hi @YoannQDQ. I have pushed the approval button in the QGIS plugins repository (didn't realise it was waiting for me to do that). I haven't seen a place to request transfer of ownership to you or any help about how to do that - do you know the process? Otherwise I guess mailing the QGIS dev list may be the best option?

YoannQDQ commented 1 year ago

Hi @ccrook. Is this not simply that you got approval privileges on plugins.qgis.org (and I don't)? Even for my own plugins, everytime I submit a new version, I have to wait for someone else to approve them before they're published. Thanks for the approval though 👍!

ccrook commented 1 year ago

That must have changed since I last did an update then!

mikedufty commented 1 year ago

I think this is a brilliant update, but we are having some issues with it, with memory layers going missing. I think the issue is in a multi user environment where some have updated the plugin and some haven't. It looks like the plugin will transfer existing external mldata files into the internal quite satisfactorily. If another user comes and edits the project with the old version installed, it will find the external file still there and save edits to that. The next user to open with the current plugin will not see any of the changes to the external file, as the new one appears to find the internal file there and use that.

If I'm correct about what is happening, then the ideal solution of course is for everyone to update at once.
Not sure if there is a good way to deal with it in the plugin. Perhaps a warning might be possible if changes or mismatch between the internal and external mldata file are detected. Maybe the external file should be deleted when creating the internal one? Could be a problem. I was able to recover lost layers by manually overwriting the file in the qgz with the modified external one using 7zip, but this won't work well if they have both been edited.

YoannQDQ commented 1 year ago

Thanks for pointing it out.

Newer versions of the plugin could detect if a legacy file is present, and check if it is more recent that the embedded data. If so, a message could be displayed asking the user if they want to update the embedded data using the legacy file.

mikedufty commented 1 year ago

That would be quite helpful. Though I suspect it is only a short term problem. I'm currently running around the office trying to make sure everyone has updated, so hoping not to have the issue again.