roam-qgis / Roam

Simple data collection built using QGIS.
http://roam-docs.readthedocs.org/en/latest/
GNU General Public License v2.0
171 stars 61 forks source link

[Question/Bug] Field type Photo don't store in the attribute field the custom directory #374

Closed jonnyforestGIS closed 6 years ago

jonnyforestGIS commented 7 years ago

I create a folder inside of _images:

When i define a field as type Photo in Roam, i check the save to file option and try to use absolute paths and relative paths: Attempt 1 Relative path: _images\fecho Attempt 2 Absolute path: C:\IntraMaps Roam\projects\ProjectGIS_images\fecho

In both cases, Roam save in _images folder outside of the custom folder that i create. Another thing, when i open the attribute table of spatiallite in QGIS we only store the name of the file in the field of the photo.

How can i add the directory with the name of the file in the field?

Regards, João

bwragg commented 7 years ago

I was having the same problem. Seems to be caused in featureform.py around line 862. Passes in a folder which seems to be the projects default location (_image). This seems to overwrite the location you set for that field.

folder = self.form.project.image_folder saved = wrapper.save(folder, filename)

jonnyforestGIS commented 7 years ago

Hi @bwragg can you suggest any workaround for this situation?

bwragg commented 7 years ago

Sorry for the delay into getting back to you. In my project every time I save every image field I have a custom location to save it. The following hack only works if this is the case.

I'm new to all this and not setup properly on github or with compilers on my desktop so as a quick work around I just copied the imagewidget.py from the source into the libs/roam/editorwidgets directory, renamed the existing imagewidget.pyc to something like imagewidget.pyc.old.

Then I edited the imagewidget.py and at line 364 in the save function I changed this: saved, name = save_image(self.widget.getImage(), folder, filename)

to this saved, name = save_image(self.widget.getImage(), self.defaultlocation, filename)

notice I changed folder to self.defaultlocation. So this forces it to use the value from the default location you can specify in the config manager rather than the value that the previous function passes in.

Hope that helps.

jonnyforestGIS commented 7 years ago

@bwragg i'm sorry for my delay answer i will check your workaround. Thanks for your tip. Cheers, João Gaspar

bwragg commented 7 years ago

just further on this I found this creates a problem after capturing the initial feature. When I select a feature the info section on the right shows a broken link and when I edit the feature the images are missing. There is a way to fix it on the edit feature page by changing the following in featureform.py around line 508:

value = os.path.join(self.form.project.image_folder, value)

needs to become:

value = os.path.join(wrapper.defaultlocation, value)

but this still doesn't fix it on the info section.

NathanW2 commented 7 years ago

@jonnyforestGIS sorry this is a case of bad UI. The location you set in the config isn't for the save location it's for the default open location. I have changed the UI to make that clearer.

jonnyforestGIS commented 6 years ago

Ok thanks. I will close this. Sorry for my late answer... Cheers