goGPS-Project/goGPS_Java

Handle .z rinex files that are compressed in Gzip format

Closed this issue · 1 comments

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();
        }