goGPS-Project / goGPS_Java

goGPS Java is a GNSS observation processing library.
http://www.gogps-project.org
59 stars 43 forks source link

Handle .z rinex files that are compressed in Gzip format #31

Closed ZiglioUK closed 7 years ago

ZiglioUK commented 7 years ago

I've run into a strange exception

org.gogpsproject.parser.rinex.RinexNavigation getRNPByTimestamp: Input not in compress format (read magic number 0x1f8b) java.io.IOException: Input not in compress format (read magic number 0x1f8b) at org.gogpsproject.util.UncompressInputStream.parse_header(UncompressInputStream.java:373) at org.gogpsproject.util.UncompressInputStream.(UncompressInputStream.java:62) at org.gogpsproject.parser.rinex.RinexNavigation.getFromHTTP(RinexNavigation.java:316) at org.gogpsproject.parser.rinex.RinexNavigation.getRNPByTimestamp(RinexNavigation.java:214)

It turns out this rinex file (ending with .z), looks like it's been compressed in gzip, not z, format: http://garner.ucsd.edu/pub/rinex/2017/071/auto0710.17n.Z

I've verified it using 7zip:

image

This change in RinexNavigation seems to work for me. I'll integrate it when I get around to doing it, hopefully soon...

        if(remoteFile.endsWith(".Z")){
          try{
            InputStream is = new ByteArrayInputStream(res.getContent());
            InputStream uis = new UncompressInputStream(is);
            rnp = new RinexNavigationParser(uis,rnf);
            rnp.init();
            uis.close();
          }
          catch( IOException e ){
            InputStream is = new ByteArrayInputStream(res.getContent());
            InputStream uis = new GZIPInputStream(is);
            rnp = new RinexNavigationParser(uis,rnf);
            rnp.init();
            uis.close();
          }
        }
        else {
          InputStream is = new ByteArrayInputStream(res.getContent());
          rnp = new RinexNavigationParser(is,rnf);
          rnp.init();
          is.close();
        }
ZiglioUK commented 7 years ago

See https://github.com/goGPS-Project/goGPS_Java/blob/master/src/main/java/org/gogpsproject/parser/rinex/RinexNavigation.java