void addAscii(final int keyID, final String value) { // +1 for the '|' character to be appended final int lenght = value.length() + 1; final KeyDirectoryEntry entry = new KeyDirectoryEntry( keyID, getGeoAsciiParamsTag().getNumber(), lenght, asciiValues.length()); entries.add(entry); asciiValues.append(value); asciiValues.append('|'); }
/** Write all stored informations in the tiff metadata tree. */ void flush() { // write GeoKeyDirectory // first line (4 int) contain the version and number of keys // Header={KeyDirectoryVersion, KeyRevision, MinorRevision, NumberOfKeys} final int[] values = new int[4 + 4 * entries.size()]; values[0] = GEOTIFF_VERSION; values[1] = REVISION_MAJOR; values[2] = REVISION_MINOR; values[3] = entries.size(); for (int i = 0, l = 4, n = entries.size(); i < n; i++, l += 4) { final KeyDirectoryEntry entry = entries.get(i); values[l] = entry.valueKey; values[l + 1] = entry.valuelocation; values[l + 2] = entry.valueNb; values[l + 3] = entry.valueOffset; } final Node nGeoKeyDir = createTiffField(getGeoKeyDirectoryTag()); nGeoKeyDir.appendChild(createTiffShorts(values)); ifd.appendChild(nGeoKeyDir); // write tagsets ifd.setAttribute( ATT_TAGSETS, BaselineTIFFTagSet.class.getName() + "," + GeoTIFFTagSet.class.getName()); if (nPixelScale != null) { ifd.appendChild(nPixelScale); } if (!tiePoints.isEmpty()) { ifd.appendChild(createModelTiePointsElement(tiePoints)); } else if (nTransform != null) { ifd.appendChild(nTransform); } if (!doubleValues.isEmpty()) { final Node nDoubles = createTiffField(getGeoDoubleParamsTag()); final Node nValues = createTiffDoubles(doubleValues); nDoubles.appendChild(nValues); ifd.appendChild(nDoubles); } if (asciiValues.length() > 0) { final Node nAsciis = createTiffField(getGeoAsciiParamsTag()); final Node nValues = createTiffAsciis(asciiValues.toString()); nAsciis.appendChild(nValues); ifd.appendChild(nAsciis); } }