001/*
002 * $RCSfile: GeoTIFFTagSet.java,v $
003 *
004 * 
005 * Copyright (c) 2005 Sun Microsystems, Inc. All  Rights Reserved.
006 * 
007 * Redistribution and use in source and binary forms, with or without
008 * modification, are permitted provided that the following conditions
009 * are met: 
010 * 
011 * - Redistribution of source code must retain the above copyright 
012 *   notice, this  list of conditions and the following disclaimer.
013 * 
014 * - Redistribution in binary form must reproduce the above copyright
015 *   notice, this list of conditions and the following disclaimer in 
016 *   the documentation and/or other materials provided with the
017 *   distribution.
018 * 
019 * Neither the name of Sun Microsystems, Inc. or the names of 
020 * contributors may be used to endorse or promote products derived 
021 * from this software without specific prior written permission.
022 * 
023 * This software is provided "AS IS," without a warranty of any 
024 * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND 
025 * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, 
026 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
027 * EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL 
028 * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF 
029 * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
030 * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR 
031 * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
032 * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
033 * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
034 * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
035 * POSSIBILITY OF SUCH DAMAGES. 
036 * 
037 * You acknowledge that this software is not designed or intended for 
038 * use in the design, construction, operation or maintenance of any 
039 * nuclear facility. 
040 *
041 * $Revision: 1.1 $
042 * $Date: 2005/02/11 05:01:17 $
043 * $State: Exp $
044 */
045package com.github.jaiimageio.plugins.tiff;
046
047import java.util.ArrayList;
048import java.util.List;
049
050/**
051 * A class representing the tags found in a GeoTIFF IFD.  GeoTIFF is a
052 * standard for annotating georeferenced or geocoded raster imagery.
053 * The GeoTIFF specification may be found at <a
054 * href="http://www.remotesensing.org/geotiff/spec/geotiffhome.html">
055 * <code>http://www.remotesensing.org/geotiff/spec/geotiffhome.html</code>
056 * </a>. This class does <i>not</i> handle the <i>GeoKey</i>s referenced
057 * from a <i>GeoKeyDirectoryTag</i> as those are not TIFF tags per se.
058 *
059 * <p>The definitions of the data types referenced by the field
060 * definitions may be found in the {@link TIFFTag
061 * <code>TIFFTag</code>} class.</p>
062 */
063public class GeoTIFFTagSet extends TIFFTagSet {
064
065    private static GeoTIFFTagSet theInstance = null;
066
067    /**
068     * A tag used to specify the size of raster pixel spacing in
069     * model space units.
070     */
071    public static final int TAG_MODEL_PIXEL_SCALE = 33550;
072
073    /**
074     * A tag used to specify the transformation matrix between the raster
075     * space and the model space.
076     */
077    public static final int TAG_MODEL_TRANSFORMATION = 34264;
078
079    /** A tag used to store raster->model tiepoint pairs. */
080    public static final int TAG_MODEL_TIE_POINT = 33922;
081
082    /** A tag used to store the <i>GeoKey</i> directory. */
083    public static final int TAG_GEO_KEY_DIRECTORY = 34735;
084
085    /** A tag used to store all <code>double</code>-values <i>GeoKey</i>s. */
086    public static final int TAG_GEO_DOUBLE_PARAMS = 34736;
087
088    /** A tag used to store all ASCII-values <i>GeoKey</i>s. */
089    public static final int TAG_GEO_ASCII_PARAMS = 34737;
090
091    // GeoTIFF tags
092
093    static class ModelPixelScale extends TIFFTag {
094        public ModelPixelScale() {
095            super("ModelPixelScaleTag",
096                  TAG_MODEL_PIXEL_SCALE,
097                  1 << TIFFTag.TIFF_DOUBLE);
098        }
099    }
100
101    static class ModelTransformation extends TIFFTag {
102        public ModelTransformation() {
103            super("ModelTransformationTag",
104                  TAG_MODEL_TRANSFORMATION,
105                  1 << TIFFTag.TIFF_DOUBLE);
106        }
107    }
108
109    static class ModelTiePoint extends TIFFTag {
110        public ModelTiePoint() {
111            super("ModelTiePointTag",
112                  TAG_MODEL_TIE_POINT,
113                  1 << TIFFTag.TIFF_DOUBLE);
114        }
115    }
116
117    static class GeoKeyDirectory extends TIFFTag {
118        public GeoKeyDirectory() {
119            super("GeoKeyDirectory",
120                  TAG_GEO_KEY_DIRECTORY,
121                  1 << TIFFTag.TIFF_SHORT);
122        }
123    }
124
125    static class GeoDoubleParams extends TIFFTag {
126        public GeoDoubleParams() {
127            super("GeoDoubleParams",
128                  TAG_GEO_DOUBLE_PARAMS,
129                  1 << TIFFTag.TIFF_DOUBLE);
130        }
131    }
132
133    static class GeoAsciiParams extends TIFFTag {
134        public GeoAsciiParams() {
135            super("GeoAsciiParams",
136                  TAG_GEO_ASCII_PARAMS,
137                  1 << TIFFTag.TIFF_ASCII);
138        }
139    }
140
141    private static List tags;
142
143    private static void initTags() {
144        tags = new ArrayList(42);
145
146        tags.add(new GeoTIFFTagSet.ModelPixelScale());
147        tags.add(new GeoTIFFTagSet.ModelTransformation());
148        tags.add(new GeoTIFFTagSet.ModelTiePoint());
149        tags.add(new GeoTIFFTagSet.GeoKeyDirectory());
150        tags.add(new GeoTIFFTagSet.GeoDoubleParams());
151        tags.add(new GeoTIFFTagSet.GeoAsciiParams());
152    }
153
154    private GeoTIFFTagSet() {
155        super(tags);
156    }
157
158    /**
159     * Returns a shared instance of a <code>GeoTIFFTagSet</code>.
160     *
161     * @return a <code>GeoTIFFTagSet</code> instance.
162     */
163    public synchronized static GeoTIFFTagSet getInstance() {
164        if (theInstance == null) {
165            initTags();
166            theInstance = new GeoTIFFTagSet();
167            tags = null;
168        }
169        return theInstance;
170    }
171}