code: private IIOMetadata insertGPSCoords( IIOMetadata exif ) {
  
          IIOMetadata outExif = null;
          try {
              TIFFDirectory ifd = TIFFDirectory.createFromMetadata(exif);
              TIFFField gpsInfoPointer = null;
  
              // first get the pointer from the directory if it's not there create a new one
              if (ifd.containsTIFFField(EXIFParentTIFFTagSet.TAG_GPS_INFO_IFD_POINTER)) {
                  gpsInfoPointer = ifd.getTIFFField(EXIFParentTIFFTagSet.TAG_GPS_INFO_IFD_POINTER);
                  System.out.println("Already has GPS Metadata");
                  return exif;
              } else {
                  // this assumes that the EXIFParentTIFFTagSet is allowed on the tiff image reader
  
                  // first construct the directory to hold the GPS data
                  TIFFDirectory gpsData = createDirectory();
  
                  // Create the pointer with the data
                  EXIFParentTIFFTagSet parentSet = EXIFParentTIFFTagSet.getInstance();
                  gpsInfoPointer = new TIFFField(parentSet.getTag(EXIFParentTIFFTagSet.TAG_GPS_INFO_IFD_POINTER),
                          TIFFTag.TIFF_LONG, 1, gpsData);
                  System.out.println("is pointer =" + gpsInfoPointer.getTag().isIFDPointer() + " data type is ok="
                          + gpsInfoPointer.getTag().isDataTypeOK(TIFFTag.TIFF_LONG));
              }
              ifd.addTIFFField(gpsInfoPointer);
              outExif = ifd.getAsMetadata();
  
          } catch (IIOInvalidTreeException e) {
              e.printStackTrace();
          }
  
          return outExif;
  
      }
docs: Private method - adds gps information to the exif data
  @param pos a GPSPosition object containing the information to encode
  @param exif the exif metadata to add the position to