rhoneyager / libicedb

A toolbox for snow particle modeling!
https://rhoneyager.github.io/libicedb
Other
0 stars 1 forks source link

Shape-file in-line comments #25

Closed RobinEke closed 6 years ago

RobinEke commented 6 years ago

I tend to include headers into my shape-files. ADDA uses # for single-line comments. However, this seems to create some issue when importing the given shape-file. I've tried some other common characters but there seems to be no support for single-line comments at all.

For the heck of it, I tried importing a DDASCAT file as well, and that seemed to work well.

I believe some type of line-commenting should be allowed for the shape-files, though I'm not sure exactly what characters should be supported. Multiple characters should be possible without conflicts, i.e. #, %, etc..

rhoneyager commented 6 years ago

Comment-handling code is at apps/3d_structures_singlethreaded/shapeIOtextParsers2.cpp, around line 540.

while ((pNumStart[0] == '#' || pNumStart[0] == 'N' || pNumStart[0] == 'n') && pNumStart < pb) {
                    const char* lineEnd = strchr(pNumStart + 1, 'n');
                    pNumStart = lineEnd + 1;
                }

Do your comments start at the beginning of the line, or is there space before the "#" symbol?

RobinEke commented 6 years ago

I use spacing after #, but I've tried files where no spacing was used as well and they fail as well.

One test case I've tried, that fails, literally only contains these lines:

# test
7 5 0

I've attached the file in question: test.shape.tar.gz

rhoneyager commented 6 years ago

Okay, I've committed changes to the master branch to handle these cases. This shape now parses properly.

There were three problems:

Parsing text is always rather awkward. Would you mind sending me a few small shape files (also @DaveOri)? These can be used as inputs for a verification program to ensure that the code is working correctly, and to ensure that we do not accidentally break the code in the future.

DaveOri commented 6 years ago

I have created a folder "samplefiles" in the master branch with some files within already. It might address @rhoneyager needs and serve as a repository for future automated testing

RobinEke commented 6 years ago

Thanks Ryan.

Importing seems to work for my shape-files now. I've put some example files into the ftp.