rhoneyager/libicedb

Shape-file in-line comments

Closed this issue · 5 comments

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..

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?

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

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

There were three problems:

  • The shape was being mistakenly identified as a DDSCAT file.
  • When comments were detected, the code was searching for the wrong end-of-line character ('n' instead of '\n'
  • The parser from a much older version of the code did work; looks like subsequent changes subtly broke the parsing code.

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.

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

Thanks Ryan.

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