lutraconsulting / MDAL

Mesh Data Abstraction Library
http://www.mdal.xyz/
MIT License
160 stars 50 forks source link

Problem to open slf file #126

Closed MatthewSen closed 5 years ago

MatthewSen commented 5 years ago

Hello,

I can't open selafin file with mdal/crayfish plugin on Qgis 3.6.3.

If I use the Data Source Manager; I get a critical error : "Invalid Data Source". Even if I select .slf as extension in the file manager.

If I use a crayfish function in the toolbox I get a Python error : 2019-06-18T23:41:35 WARNING Traceback (most recent call last): File "XXXX/QGIS/QGIS3\profiles\default/python/plugins\crayfish\processing\parameters.py", line 122, in on_change for i in range(dp.datasetGroupCount()): AttributeError: 'QgsVectorDataProvider' object has no attribute 'datasetGroupCount'

Is it possible to fix this problem?

Thank you

PeterPetrik commented 5 years ago

Hi, please share the conflicting file with us to be able to reproduce the problem. If the file is too big, or contains sensitive data or you want to inform options how to resolve the issue, please contact info@lutraconsulting.co.uk . Thanks

MatthewSen commented 5 years ago

I tried with the Telemac 2D test case geometry file of Malapasset.

geo_malpasset-large.zip

I tried also with your selafin file example (MDAL/tests/data/slf/example.slf) and it doesn't work either. Maybe I have a problem with my installation? I just added the plugin Crayfish (and another plugin named Mascaret). I am on Windows 10 64 bits.

PeterPetrik commented 5 years ago

Do you open it as mesh layer, because the error suggests you trying to open it as vector layer..

saberraz commented 5 years ago

To add a mesh layer (example.slf), in QGIS main menu > Layer > Add Layer ... > Add Mesh Layer ... and then point it to your slf file.

Btw, your uploaded file is empty. I found the file here: https://github.com/ogoe/OpenTelemac/blob/master/examples/telemac3d/malpasset/geo_malpasset-large.slf

But could not open it as a mesh. It can be opened as a vector layer though.

ccoulet commented 5 years ago

I think I know the reason of this bug... By the past, selafin file was only of one type (single precision) and there was no indicator in the first record of the file. The title was 80 character long. Some old program sometimes write in the 8 latest character the origin of the file. With the extension of capabilities of selafin file to double precision, it was decided to use those 8 latest characters as a kind of identifier... "SELAFIN " means single precision and "SELAFIND" means double precision. But in fact if those 8 characters are different from "SELAFIND" we should consider it's a single precision and then proceed in the same way... geo_malpasset-large.slf is a old file without "SELAFIN " at the end of the first record.

Hope this help to understand the problem

PeterPetrik commented 5 years ago

if that is the case, we need to remove this assert https://github.com/lutraconsulting/MDAL/blob/master/mdal/frmts/mdal_selafin.cpp#L64

ccoulet commented 5 years ago

Yes this is a solution for old selafin file. The other solution is maybe to indicate it's maybe an old file... On the other side, I will try to have an action on the Telemac side to update at least all the file which are in the example directory of Telemac...

MatthewSen commented 5 years ago

Thank you for your answers ! Sorry for the empty uploaded .zip, I was not totally awoken...

I found what was wrong : the example.slf file I downloaded was corrupted. I downloaded it again properly and it works perfectly. I tested also on another test case ("culm") and it works too.

Thank you again