sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1771295 - in /sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff: DeferredEntry.java GeoTIFF.java ImageFileDirectory.java Reader.java Tags.java
Date Fri, 25 Nov 2016 11:41:09 GMT
Author: desruisseaux
Date: Fri Nov 25 11:41:08 2016
New Revision: 1771295

URL: http://svn.apache.org/viewvc?rev=1771295&view=rev
Log:
GeoTIFF keys are unsigned short values.

Modified:
    sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/DeferredEntry.java
    sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTIFF.java
    sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/ImageFileDirectory.java
    sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/Reader.java
    sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/Tags.java

Modified: sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/DeferredEntry.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/DeferredEntry.java?rev=1771295&r1=1771294&r2=1771295&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/DeferredEntry.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/DeferredEntry.java
[UTF-8] Fri Nov 25 11:41:08 2016
@@ -32,9 +32,9 @@ final class DeferredEntry implements Com
     final ImageFileDirectory owner;
 
     /**
-     * The GeoTIFF tag to decode.
+     * The GeoTIFF tag to decode, as an <strong>unsigned</strong> short.
      */
-    final int tag;
+    final short tag;
 
     /**
      * The GeoTIFF type of the value to read.
@@ -54,7 +54,7 @@ final class DeferredEntry implements Com
     /**
      * Creates a new deferred entry.
      */
-    DeferredEntry(final ImageFileDirectory owner, final int tag, final Type type, final long
count, final long offset) {
+    DeferredEntry(final ImageFileDirectory owner, final short tag, final Type type, final
long count, final long offset) {
         this.owner  = owner;
         this.tag    = tag;
         this.type   = type;

Modified: sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTIFF.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTIFF.java?rev=1771295&r1=1771294&r2=1771295&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTIFF.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTIFF.java
[UTF-8] Fri Nov 25 11:41:08 2016
@@ -81,7 +81,7 @@ abstract class GeoTIFF implements Closea
      */
     final DateFormat getDateFormat() {
         if (dateFormat == null) {
-            dateFormat = new SimpleDateFormat("yyy:MM:dd HH:mm:ss", Locale.US);
+            dateFormat = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss", Locale.US);
             if (TIMEZONE != null) {
                 dateFormat.setTimeZone(TIMEZONE);
             }

Modified: sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/ImageFileDirectory.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/ImageFileDirectory.java?rev=1771295&r1=1771294&r2=1771295&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/ImageFileDirectory.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/ImageFileDirectory.java
[UTF-8] Fri Nov 25 11:41:08 2016
@@ -323,7 +323,7 @@ final class ImageFileDirectory {
      * @throws UnsupportedOperationException if the given type is {@link Type#UNDEFINED}.
      * @throws DataStoreException if a logical error is found or an unsupported TIFF feature
is used.
      */
-    Object addEntry(final int tag, final Type type, final long count)
+    Object addEntry(final short tag, final Type type, final long count)
             throws IOException, ParseException, DataStoreException
     {
         switch (tag) {
@@ -847,7 +847,7 @@ final class ImageFileDirectory {
     final void validateMandatoryTags() throws DataStoreContentException {
         if (imageWidth  < 0) throw missingTag(Tags.ImageWidth);
         if (imageHeight < 0) throw missingTag(Tags.ImageLength);
-        final int offsetsTag, byteCountsTag;
+        final short offsetsTag, byteCountsTag;
         switch (tileTagFamily) {
             case STRIP: {
                 if (tileWidth  < 0) tileWidth  = Math.toIntExact(imageWidth);
@@ -914,7 +914,7 @@ final class ImageFileDirectory {
                 break;
             }
             default: {
-                final int tag;
+                final short tag;
                 switch (Integer.lowestOneBit(missing)) {
                     case 0b0001: tag = Tags.TileWidth;  break;
                     case 0b0010: tag = Tags.TileLength; break;
@@ -1008,7 +1008,7 @@ final class ImageFileDirectory {
     /**
      * Verifies that the given tags have the same length and reports a warning if they do
not.
      */
-    private void ensureSameLength(final int tag1, final int tag2, final int length1, final
int length2) {
+    private void ensureSameLength(final short tag1, final short tag2, final int length1,
final int length2) {
         if (length1 != length2) {
             warning(Level.WARNING, Resources.Keys.MismatchedLength_4, Tags.name(tag1), Tags.name(tag2),
length1, length2);
         }
@@ -1021,7 +1021,7 @@ final class ImageFileDirectory {
      * @param  value     the default value or the computed value.
      * @param  computed  whether the default value has been computed.
      */
-    private void missingTag(final int missing, final long value, final boolean computed)
{
+    private void missingTag(final short missing, final long value, final boolean computed)
{
         warning(computed ? Level.WARNING : Level.FINE,
                 computed ? Resources.Keys.ComputedValueForAttribute_2 : Resources.Keys.DefaultValueForAttribute_2,
                 Tags.name(missing), value);
@@ -1032,7 +1032,7 @@ final class ImageFileDirectory {
      *
      * @param  missing  the numerical value of the missing tag.
      */
-    private DataStoreContentException missingTag(final int missing) {
+    private DataStoreContentException missingTag(final short missing) {
         return new DataStoreContentException(reader.resources().getString(
                 Resources.Keys.MissingValue_2, input().filename, Tags.name(missing)));
     }

Modified: sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/Reader.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/Reader.java?rev=1771295&r1=1771294&r2=1771295&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/Reader.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/Reader.java
[UTF-8] Fri Nov 25 11:41:08 2016
@@ -250,7 +250,7 @@ final class Reader extends GeoTIFF {
                  *   - The number of values of the indicated type.
                  *   - The value, or the file offset to the value elswhere in the file.
                  */
-                final int  tag   = input.readUnsignedShort();
+                final short tag  = (short) input.readUnsignedShort();
                 final Type type  = Type.valueOf(input.readShort());        // May be null.
                 final long count = readUnsignedInt();
                 final long size  = (type != null) ? Math.multiplyExact(type.size, count)
: 0;
@@ -354,7 +354,7 @@ final class Reader extends GeoTIFF {
      * @param tag    the tag than can not be read.
      * @param error  the value than can not be understand, or the exception that we got while
trying to parse it.
      */
-    private void warning(final int tag, final Object error) {
+    private void warning(final short tag, final Object error) {
         final short key;
         final Object[] args;
         final Exception exception;

Modified: sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/Tags.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/Tags.java?rev=1771295&r1=1771294&r2=1771295&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/Tags.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/Tags.java
[UTF-8] Fri Nov 25 11:41:08 2016
@@ -37,90 +37,101 @@ final class Tags {
     //                  BASELINE TIFF TAGS                  //
     //////////////////////////////////////////////////////////
 
-    public static final int NewSubfileType              = 0x00FE;
-    public static final int SubfileType                 = 0x00FF;
-    public static final int ImageWidth                  = 0x0100;
-    public static final int ImageLength                 = 0x0101;
-    public static final int BitsPerSample               = 0x0102;
-    public static final int Compression                 = 0x0103;
-    public static final int PhotometricInterpretation   = 0x0106;
-    public static final int Threshholding               = 0x0107;
-    public static final int CellWidth                   = 0x0108;
-    public static final int CellLength                  = 0x0109;
-    public static final int FillOrder                   = 0x010A;
-    public static final int DocumentName                = 0x010D;
-    public static final int ImageDescription            = 0x010E;
-    public static final int Make                        = 0x010F;
-    public static final int Model                       = 0x0110;
-    public static final int StripOffsets                = 0x0111;
-    public static final int Orientation                 = 0x0112;
-    public static final int SamplesPerPixel             = 0x0115;
-    public static final int RowsPerStrip                = 0x0116;
-    public static final int StripByteCounts             = 0x0117;
-    public static final int MinSampleValue              = 0x0118;
-    public static final int MaxSampleValue              = 0x0119;
-    public static final int XResolution                 = 0x011A;
-    public static final int YResolution                 = 0x011B;
-    public static final int PlanarConfiguration         = 0x011C;
-    public static final int PageName                    = 0x011D;
-    public static final int XPosition                   = 0x011E;
-    public static final int YPosition                   = 0x011F;
-    public static final int FreeOffsets                 = 0x0120;
-    public static final int FreeByteCounts              = 0x0121;
-    public static final int GrayResponseUnit            = 0x0122;
-    public static final int GrayResponseCurve           = 0x0123;
-    public static final int T4Options                   = 0x0124;
-    public static final int T6Options                   = 0x0125;
-    public static final int ResolutionUnit              = 0x0128;
-    public static final int PageNumber                  = 0x0129;
-    public static final int TransferFunction            = 0x012D;
-    public static final int Software                    = 0x0131;
-    public static final int DateTime                    = 0x0132;
-    public static final int DateTimeOriginal            = 0x9003;
-    public static final int DateTimeDigitized           = 0x9004;
-    public static final int Artist                      = 0x013B;
-    public static final int HostComputer                = 0x013C;
-    public static final int Predictor                   = 0x013D;
-    public static final int WhitePoint                  = 0x013E;
-    public static final int PrimaryChromaticities       = 0x013F;
-    public static final int ColorMap                    = 0x0140;
-    public static final int HalftoneHints               = 0x0141;
-    public static final int TileWidth                   = 0x0142;
-    public static final int TileLength                  = 0x0143;
-    public static final int TileOffsets                 = 0x0144;
-    public static final int TileByteCounts              = 0x0145;
-    public static final int InkSet                      = 0x014C;
-    public static final int InkNames                    = 0x014D;
-    public static final int NumberOfInks                = 0x014E;
-    public static final int DotRange                    = 0x0150;
-    public static final int TargetPrinter               = 0x0151;
-    public static final int ExtraSamples                = 0x0152;
-    public static final int SampleFormat                = 0x0153;
-    public static final int SMinSampleValue             = 0x0154;
-    public static final int SMaxSampleValue             = 0x0155;
-    public static final int TransferRange               = 0x0156;
-    public static final int JPEGProc                    = 0x0200;
-    public static final int JPEGInterchangeFormat       = 0x0201;
-    public static final int JPEGInterchangeFormatLength = 0x0202;
-    public static final int JPEGRestartInterval         = 0x0203;
-    public static final int JPEGLosslessPredictors      = 0x0205;
-    public static final int JPEGPointTransforms         = 0x0206;
-    public static final int JPEGQTables                 = 0x0207;
-    public static final int JPEGDCTables                = 0x0208;
-    public static final int JPEGACTables                = 0x0209;
-    public static final int YCbCrCoefficients           = 0x0211;
-    public static final int YCbCrSubSampling            = 0x0212;
-    public static final int YCbCrPositioning            = 0x0213;
-    public static final int ReferenceBlackWhite         = 0x0214;
-    public static final int Copyright                   = 0x8298;
+    public static final short NewSubfileType              = 0x00FE;
+    public static final short SubfileType                 = 0x00FF;
+    public static final short ImageWidth                  = 0x0100;
+    public static final short ImageLength                 = 0x0101;
+    public static final short BitsPerSample               = 0x0102;
+    public static final short Compression                 = 0x0103;
+    public static final short PhotometricInterpretation   = 0x0106;
+    public static final short Threshholding               = 0x0107;
+    public static final short CellWidth                   = 0x0108;
+    public static final short CellLength                  = 0x0109;
+    public static final short FillOrder                   = 0x010A;
+    public static final short DocumentName                = 0x010D;
+    public static final short ImageDescription            = 0x010E;
+    public static final short Make                        = 0x010F;
+    public static final short Model                       = 0x0110;
+    public static final short StripOffsets                = 0x0111;
+    public static final short Orientation                 = 0x0112;
+    public static final short SamplesPerPixel             = 0x0115;
+    public static final short RowsPerStrip                = 0x0116;
+    public static final short StripByteCounts             = 0x0117;
+    public static final short MinSampleValue              = 0x0118;
+    public static final short MaxSampleValue              = 0x0119;
+    public static final short XResolution                 = 0x011A;
+    public static final short YResolution                 = 0x011B;
+    public static final short PlanarConfiguration         = 0x011C;
+    public static final short PageName                    = 0x011D;
+    public static final short XPosition                   = 0x011E;
+    public static final short YPosition                   = 0x011F;
+    public static final short FreeOffsets                 = 0x0120;
+    public static final short FreeByteCounts              = 0x0121;
+    public static final short GrayResponseUnit            = 0x0122;
+    public static final short GrayResponseCurve           = 0x0123;
+    public static final short T4Options                   = 0x0124;
+    public static final short T6Options                   = 0x0125;
+    public static final short ResolutionUnit              = 0x0128;
+    public static final short PageNumber                  = 0x0129;
+    public static final short TransferFunction            = 0x012D;
+    public static final short Software                    = 0x0131;
+    public static final short DateTime                    = 0x0132;
+    public static final short DateTimeOriginal    = (short) 0x9003;
+    public static final short DateTimeDigitized   = (short) 0x9004;
+    public static final short Artist                      = 0x013B;
+    public static final short HostComputer                = 0x013C;
+    public static final short Predictor                   = 0x013D;
+    public static final short WhitePoint                  = 0x013E;
+    public static final short PrimaryChromaticities       = 0x013F;
+    public static final short ColorMap                    = 0x0140;
+    public static final short HalftoneHints               = 0x0141;
+    public static final short TileWidth                   = 0x0142;
+    public static final short TileLength                  = 0x0143;
+    public static final short TileOffsets                 = 0x0144;
+    public static final short TileByteCounts              = 0x0145;
+    public static final short InkSet                      = 0x014C;
+    public static final short InkNames                    = 0x014D;
+    public static final short NumberOfInks                = 0x014E;
+    public static final short DotRange                    = 0x0150;
+    public static final short TargetPrinter               = 0x0151;
+    public static final short ExtraSamples                = 0x0152;
+    public static final short SampleFormat                = 0x0153;
+    public static final short SMinSampleValue             = 0x0154;
+    public static final short SMaxSampleValue             = 0x0155;
+    public static final short TransferRange               = 0x0156;
+    public static final short JPEGProc                    = 0x0200;
+    public static final short JPEGInterchangeFormat       = 0x0201;
+    public static final short JPEGInterchangeFormatLength = 0x0202;
+    public static final short JPEGRestartInterval         = 0x0203;
+    public static final short JPEGLosslessPredictors      = 0x0205;
+    public static final short JPEGPointTransforms         = 0x0206;
+    public static final short JPEGQTables                 = 0x0207;
+    public static final short JPEGDCTables                = 0x0208;
+    public static final short JPEGACTables                = 0x0209;
+    public static final short YCbCrCoefficients           = 0x0211;
+    public static final short YCbCrSubSampling            = 0x0212;
+    public static final short YCbCrPositioning            = 0x0213;
+    public static final short ReferenceBlackWhite         = 0x0214;
+    public static final short Copyright           = (short) 0x8298;
 
 
     /////////////////////////////////////////////////////////
     //                 GDAL EXTENSION TAGS                 //
     /////////////////////////////////////////////////////////
 
-    public static final int GDAL_METADATA = 42112;  // http://www.awaresystems.be/imaging/tiff/tifftags/gdal_metadata.html
-    public static final int GDAL_NODATA   = 42113;  // http://www.awaresystems.be/imaging/tiff/tifftags/gdal_nodata.html
+    /**
+     * holds an XML list of name=value 'metadata' values about the image as a whole, and
about specific samples.
+     *
+     * @see <a href="http://www.awaresystems.be/imaging/tiff/tifftags/gdal_metadata.html">TIFF
Tag GDAL_METADATA</a>
+     */
+    public static final short GDAL_METADATA = (short) 0xA480;             // 42112
+
+    /**
+     * Contains an ASCII encoded nodata or background pixel value.
+     *
+     * @see <a href="http://www.awaresystems.be/imaging/tiff/tifftags/gdal_nodata.html">TIFF
Tag GDAL_NODATA</a>
+     */
+    public static final short GDAL_NODATA = (short) 0xA481;               // 42113
 
 
     /////////////////////////////////////////////////////////
@@ -134,19 +145,19 @@ final class Tags {
      *
      * @todo omit the "Tag" suffix since this class is all about tags.
      */
-    public static final int GeoKeyDirectoryTag = 0x87AF;        // 34735
+    public static final short GeoKeyDirectoryTag = (short) 0x87AF;        // 34735
 
     /**
      * References all {@code double} values referenced by the {@link GeoKeys}.
      * The keys are stored in the entry referenced by {@link #GeoKeyDirectoryTag}.
      */
-    public static final int GeoDoubleParamsTag = 0x87B0;        // 34736
+    public static final short GeoDoubleParamsTag = (short) 0x87B0;        // 34736
 
     /**
      * References all {@link String} values referenced by the {@link GeoKeys}.
      * The keys are stored in the entry referenced by {@link #GeoKeyDirectoryTag}.
      */
-    public static final int GeoAsciiParamsTag = 0x87B1;         // 34737
+    public static final short GeoAsciiParamsTag = (short) 0x87B1;         // 34737
 
     /**
      * Do not allow instantiation of this class.
@@ -158,11 +169,11 @@ final class Tags {
      * Returns the name of the given tag. Implementation of this method is inefficient,
      * but it should rarely be invoked (mostly for formatting error messages).
      */
-    static String name(final int tag) {
+    static String name(final short tag) {
         try {
             for (final Field field : Tags.class.getFields()) {
                 if (field.getType() == Integer.TYPE) {
-                    if (field.getInt(null) == tag) {
+                    if (field.getShort(null) == tag) {
                         return field.getName();
                     }
                 }
@@ -170,6 +181,6 @@ final class Tags {
         } catch (IllegalAccessException e) {
             throw new AssertionError(e);        // Should never happen because we asked only
for public fields.
         }
-        return Integer.toHexString(tag);
+        return Integer.toHexString(Short.toUnsignedInt(tag));
     }
 }



Mime
View raw message