[pdal] Thinking out loud about stream usage
Michael P. Gerlek
mpg at flaxen.com
Fri Mar 30 21:13:32 EDT 2012
In implementing the NITF writer which derives from the LAS writer, I'm wrestling with an issue that we've had for some time: what are the semantics of a stage with respect to the file it uses? We've never written this down anywhere, and I suspect some stages do it differently.
For example, the LAS writer, if passed a filename, will open the file in initialize() and close() it in the dtor. [Because of this, we have had to explicitly scope Writer objects on occasion, e.g. in the test cases where we want to read the file immediately after writing it.] In practice, though, the LAS writer only actually writes to the stream during the write() sequence (writeBegin to writeEnd). Should this be a "rule" that clients can assume?
On the reader side, I suspect we only do reads during initialize() and during the read() sequence. If the caller has access to the stream the reader is using, is it allowed to move the stream position after initialize() or between read() sequences?
And I think a lot of this is tied up with the fact that readers and writers can take either a stream/stream-factory or just an Option-filename.
Just some stuff to think about over spring break...
More information about the pdal