private void readTiePointGrids(Document jDomDocument) throws IOException {
   final String[] tiePointGridNames = product.getTiePointGridNames();
   for (String tiePointGridName : tiePointGridNames) {
     final TiePointGrid tiePointGrid = product.getTiePointGrid(tiePointGridName);
     String dataFile =
         DimapProductHelpers.getTiePointDataFile(jDomDocument, tiePointGrid.getName());
     final int dataType =
         DimapProductHelpers.getTiePointDataType(
             jDomDocument.getRootElement(), tiePointGrid.getName());
     dataFile = FileUtils.exchangeExtension(dataFile, DimapProductConstants.IMAGE_FILE_EXTENSION);
     FileImageInputStream inputStream = null;
     try {
       inputStream = new FileImageInputStream(new File(inputDir, dataFile));
       final float[] data = ((float[]) tiePointGrid.getData().getElems());
       inputStream.seek(0);
       if (dataType == ProductData.TYPE_FLOAT32) {
         inputStream.readFully(data, 0, data.length);
       } else {
         final double[] doubles = new double[data.length];
         inputStream.readFully(doubles, 0, doubles.length);
         int i = 0;
         for (double d : doubles) {
           data[i++] = (float) d;
         }
       }
       inputStream.close();
       inputStream = null;
       // See if we have a -180...+180 or a 0...360 degree discontinuity
       if (tiePointGrid.getDiscontinuity() != TiePointGrid.DISCONT_NONE) {
         tiePointGrid.setDiscontinuity(TiePointGrid.getDiscontinuity(data));
       }
     } catch (Exception e) {
       throw new IOException(
           MessageFormat.format(
               "I/O error while reading tie-point grid ''{0}''.", tiePointGridName),
           e);
     } finally {
       if (inputStream != null) {
         inputStream.close();
       }
     }
   }
 }