Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

better stationxml vs seed detection #137

Open
crotwell opened this issue Jul 28, 2021 · 0 comments
Open

better stationxml vs seed detection #137

crotwell opened this issue Jul 28, 2021 · 0 comments

Comments

@crotwell
Copy link
Contributor

See #95

I think the input file detection still does not work the way it should. This is a StationXML validator, and so the default case should be to parse a StationXML file, not to parse a SEED file.

Currently the file reading looks like:

if(isStationXml(file)) {
...read station xml file
} else {
...read as SEED file
}

But, the else has no checking is done to see if the file is a SEED file. An xml file that has a mistake in the root xml element will be processed as if it is a SEED volume giving hard to understand errors.

For example if the root element is:

<TypoFDSNStationXML xmlns="http://www.fdsn.org/xml/station/1" schemaVersion="1.1">

then the error generated by the validator looks like:

[2021-07-28 09:36:13] [SEVERE] edu.iris.dmc.Application exitWithError: java.io.IOException: Error calculation record length!edu.iris.dmc.seed.blockette.util.BlocketteItrator.hasNext(BlocketteItrator.java:58)
edu.iris.dmc.IrisUtil.readSeed(IrisUtil.java:62)
edu.iris.dmc.IrisUtil.readSeed(IrisUtil.java:54)
edu.iris.dmc.Application.read(Application.java:214)
edu.iris.dmc.Application.run(Application.java:178)
edu.iris.dmc.Application.run(Application.java:168)
edu.iris.dmc.Application.run(Application.java:147)
edu.iris.dmc.Application.main(Application.java:118)

which tells you nothing about why the file is not valid.

Would be better if the code looked like:


if(isXml(file)) {
    if(isStationXml(file)) {
       ...read station xml file
    } else {
        "warning, file looks like XML but is not StationXML: "+reason
    }
} else if (isSEED(file)) {
   ...read as SEED file
} else {
   warning "input file doesn't look like StationXML or SEED: "+reason
}

Where isXml() and isSeed() did basic checking.

Even better IMHO would be if the command line args were -x <xmlfile> and -s <seedfile> instead of a blanket -input arg. The person running the code usually knows what type of file they want processed and you might as well give them a way to tell the program.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant