sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1771368 [2/2] - in /sis/branches/JDK8: ide-project/NetBeans/ storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/
Date Fri, 25 Nov 2016 18:45:51 GMT
Modified: sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoKeys.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoKeys.java?rev=1771368&r1=1771367&r2=1771368&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoKeys.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoKeys.java
[UTF-8] Fri Nov 25 18:45:51 2016
@@ -41,407 +41,198 @@ final class GeoKeys {
     // KEYS, values are taken from :
     // http://www.remotesensing.org/geotiff/spec/geotiff6.html#6
     ////////////////////////////////////////////////////////////////////////////
-    static class Configuration {
 
-        //6.2.1 GeoTIFF Configuration Keys
-        static final int GTModelTypeGeoKey           = 1024; /* Section 6.3.1.1 Codes */
-        static final int GTRasterTypeGeoKey          = 1025; /* Section 6.3.1.2 Codes */
-        static final int GTCitationGeoKey            = 1026; /* documentation */
-
-        /*
-         * 6.3.1.1 Model Type Codes
-         *
-         * Ranges:
-         *   0              = undefined
-         *   [   1,  32766] = GeoTIFF Reserved Codes
-         *   32767          = user-defined
-         *   [32768, 65535] = Private User Implementations
-         *
-         * Notes:
-         *   1. ModelTypeGeographic and ModelTypeProjected
-         *   correspond to the FGDC metadata Geographic and
-         *   Planar-Projected coordinate system types.
-         */
-        //GeoTIFF defined CS Model Type Codes:
-        static final int ModelTypeProjected   = 1;   /* Projection Coordinate System    
    */
-        static final int ModelTypeGeographic  = 2;   /* Geographic latitude-longitude System
*/
-        static final int ModelTypeGeocentric  = 3;   /* Geocentric (X,Y,Z) Coordinate System
*/
-        ////////////////////////////////////////////////////////////////////////////
-        // Codes
-        ////////////////////////////////////////////////////////////////////////////
-
-        static final short GTUserDefinedGeoKey         = 32767;
-        static final String GTUserDefinedGeoKey_String = "32767";
-
-        /**
-         * Returns key Name from {@link Configuration} class if exist.
-         * If key name doesn't exist return {@code null}.
-         *
-         * @param key
-         * @return tag Name from {@link Configuration} class.
-         */
-        static String getName(final int key) {
-            try {
-                for (final Field field : Configuration.class.getDeclaredFields()) {
-                    if (field.getType() == Integer.TYPE) {
-                        if (field.getInt(null) == key) {
-                            return field.getName();
-                        }
-                    }
-                }
-            } catch (ReflectiveOperationException ex) {
-                throw new AssertionError(ex); // Should never happen.
-            }
-            return Integer.toHexString(key);
-        }
-
-        /**
-         * Returns {@code true} if {@link Configuration} class contain given key
-         * else return {@code false}.
-         *
-         * @param key
-         * @return {@code true} if {@link configuration} contain key else {@code false}.
-         */
-        static boolean contain(int key) {
-            try {
-                for (final Field field : Configuration.class.getDeclaredFields()) {
-                    if (field.getType() == Integer.TYPE) {
-                        if (field.getInt(null) == key) {
-                            return true;
-                        }
-                    }
-                }
-            } catch (ReflectiveOperationException ex) {
-                throw new AssertionError(ex); // Should never happen.
-            }
-            return false;
-        }
-    }
-
-    static class Operation_Method {
-        /*
-         * 6.3.3.3 Coordinate Transformation Codes
-         * Ranges:
-         * 0 = undefined
-         * [    1, 16383] = GeoTIFF Coordinate Transformation codes
-         * [16384, 32766] = Reserved by GeoTIFF
-         * 32767          = user-defined
-         * [32768, 65535] = Private User Implementations
-         */
-        static final int CT_TransverseMercator =             1;
-        static final int CT_TransvMercator_Modified_Alaska = 2;
-        static final int CT_ObliqueMercator =                3;
-        static final int CT_ObliqueMercator_Laborde =        4;
-        static final int CT_ObliqueMercator_Rosenmund =      5;
-        static final int CT_ObliqueMercator_Spherical =      6;
-        static final int CT_Mercator =                       7;
-        static final int CT_LambertConfConic_2SP =           8;
-        static final int CT_LambertConfConic_1SP =           9;
-        static final int CT_LambertAzimEqualArea =           10;
-        static final int CT_AlbersEqualArea =                11;
-        static final int CT_AzimuthalEquidistant =           12;
-        static final int CT_EquidistantConic =               13;
-        static final int CT_Stereographic =                  14;
-        static final int CT_PolarStereographic =             15;
-        static final int CT_ObliqueStereographic =           16;
-        static final int CT_Equirectangular =                17;
-        static final int CT_CassiniSoldner =                 18;
-        static final int CT_Gnomonic =                       19;
-        static final int CT_MillerCylindrical =              20;
-        static final int CT_Orthographic =                   21;
-        static final int CT_Polyconic =                      22;
-        static final int CT_Robinson =                       23;
-        static final int CT_Sinusoidal =                     24;
-        static final int CT_VanDerGrinten =                  25;
-        static final int CT_NewZealandMapGrid =              26;
-        static final int CT_TransvMercator_SouthOriented=    27;
-        //Aliases:
-        static final int CT_AlaskaConformal =                CT_TransvMercator_Modified_Alaska;
-        static final int CT_TransvEquidistCylindrical =      CT_CassiniSoldner;
-        static final int CT_ObliqueMercator_Hotine =         CT_ObliqueMercator;
-        static final int CT_SwissObliqueCylindrical =        CT_ObliqueMercator_Rosenmund;
-        static final int CT_GaussBoaga =                     CT_TransverseMercator;
-        static final int CT_GaussKruger =                    CT_TransverseMercator;
-        static final int CT_LambertConfConic =               CT_LambertConfConic_2SP ;
-        static final int CT_LambertConfConic_Helmert =       CT_LambertConfConic_1SP;
-        static final int CT_SouthOrientedGaussConformal =    CT_TransvMercator_SouthOriented;
-
-        /**
-         * Returns key Name from {@link Operation_Method} class if exist.
-         * If key name doesn't exist return {@code null}.
-         *
-         * @param key
-         * @return tag Name from {@link Operation_Method} class.
-         */
-        static String getName(final int tag) {
-            try {
-                for (final Field field : Operation_Method.class.getDeclaredFields()) {
-                    if (field.getType() == Integer.TYPE) {
-                        if (field.getInt(null) == tag) {
-                            return field.getName();
-                        }
-                    }
-                }
-            } catch (ReflectiveOperationException ex) {
-                throw new AssertionError(ex); // Should never happen.
-            }
-            return Integer.toHexString(tag);
-        }
-
-        /**
-         * Returns {@code true} if {@link Configuration} class contain given key
-         * else return {@code false}.
-         *
-         * @param key
-         * @return {@code true} if {@link configuration} contain key else {@code false}.
-         */
-        static boolean contain(int key) {
-            try {
-                for (final Field field : Operation_Method.class.getDeclaredFields()) {
-                    if (field.getType() == Integer.TYPE) {
-                        if (field.getInt(null) == key) {
-                            return true;
-                        }
-                    }
-                }
-            } catch (ReflectiveOperationException ex) {
-                throw new AssertionError(ex); // Should never happen.
-            }
-            return false;
-        }
-    }
-
-    static class Units {
-        /*
-         * 6.3.1.3 Linear Units Codes
-         *
-         *  There are several different kinds of units that may be used in geographically
related raster data: linear units, angular units, units of time (e.g. for radar-return), CCD-voltages,
etc. For this reason there will be a single, unique range for each kind of unit, broken down
into the following currently defined ranges:
-         *  Ranges:
-         *     0             = undefined
-         *     [   1,  2000] = Obsolete GeoTIFF codes
-         *     [2001,  8999] = Reserved by GeoTIFF
-         *     [9000,  9099] = EPSG Linear Units.
-         *     [9100,  9199] = EPSG Angular Units.
-         *     32767         = user-defined unit
-         *     [32768, 65535]= Private User Implementations
-         *  Linear Unit Values (See the ESPG/POSC tables for definition):
-         */
-        static final int Linear_Meter                       = 9001;
-        static final int Linear_Foot                        = 9002;
-        static final int Linear_Foot_US_Survey              = 9003;
-        static final int Linear_Foot_Modified_American      = 9004;
-        static final int Linear_Foot_Clarke                 = 9005;
-        static final int Linear_Foot_Indian                 = 9006;
-        static final int Linear_Link                        = 9007;
-        static final int Linear_Link_Benoit                 = 9008;
-        static final int Linear_Link_Sears                  = 9009;
-        static final int Linear_Chain_Benoit                = 9010;
-        static final int Linear_Chain_Sears                 = 9011;
-        static final int Linear_Yard_Sears                  = 9012;
-        static final int Linear_Yard_Indian                 = 9013;
-        static final int Linear_Fathom                      = 9014;
-        static final int Linear_Mile_International_Nautical = 9015;
-
-        /*
-         * 6.3.1.4 Angular Units Codes
-         * These codes shall be used for any key that requires specification of an angular
unit of measurement.
-         */
-        static final int Angular_Radian         = 9101;
-        static final int Angular_Degree         = 9102;
-        static final int Angular_Arc_Minute     = 9103;
-        static final int Angular_Arc_Second     = 9104;
-        static final int Angular_Grad           = 9105;
-        static final int Angular_Gon            = 9106;
-        static final int Angular_DMS            = 9107;
-        static final int Angular_DMS_Hemisphere = 9108;
-
-        /**
-         * Returns key Name from {@link Units} class if exist.
-         * If key name doesn't exist return {@code null}.
-         *
-         * @param key
-         * @return tag Name from {@link Units} class.
-         */
-        static String getName(final int tag) {
-            try {
-                for (final Field field : Units.class.getDeclaredFields()) {
-                    if (field.getType() == Integer.TYPE) {
-                        if (field.getInt(null) == tag) {
-                            return field.getName();
-                        }
-                    }
-                }
-            } catch (ReflectiveOperationException ex) {
-                throw new AssertionError(ex); // Should never happen.
-            }
-            return Integer.toHexString(tag);
-        }
-
-        /**
-         * Returns {@code true} if {@link Units} class contain given key
-         * else return {@code false}.
-         *
-         * @param key
-         * @return {@code true} if {@link Units} contain key else {@code false}.
-         */
-        static boolean contain(int key) {
-            try {
-                for (final Field field : Units.class.getDeclaredFields()) {
-                    if (field.getType() == Integer.TYPE) {
-                        if (field.getInt(null) == key) {
-                            return true;
-                        }
-                    }
-                }
-            } catch (ReflectiveOperationException ex) {
-                throw new AssertionError(ex); // Should never happen.
-            }
-            return false;
-        }
-    }
+    //6.2.1 GeoTIFF Configuration Keys
+    public static final short GTModelTypeGeoKey           = 1024; /* Section 6.3.1.1 Codes
*/
+    public static final short GTRasterTypeGeoKey          = 1025; /* Section 6.3.1.2 Codes
*/
+    public static final short GTCitationGeoKey            = 1026; /* documentation */
 
-
-    static class CRS {
-
-        //6.2.2 Geographic CS Parameter Keys
-        static final int GeographicTypeGeoKey        = 2048; /* Section 6.3.2.1 Codes */
-        static final int GeogCitationGeoKey          = 2049; /* documentation */
-        static final int GeogGeodeticDatumGeoKey     = 2050; /* Section 6.3.2.2 Codes */
-        static final int GeogPrimeMeridianGeoKey     = 2051; /* Section 6.3.2.4 codes */
-        static final int GeogLinearUnitsGeoKey       = 2052; /* Section 6.3.1.3 Codes */
-        static final int GeogLinearUnitSizeGeoKey    = 2053; /* meters */
-        static final int GeogAngularUnitsGeoKey      = 2054; /* Section 6.3.1.4 Codes */
-        static final int GeogAngularUnitSizeGeoKey   = 2055; /* radians */
-        static final int GeogEllipsoidGeoKey         = 2056; /* Section 6.3.2.3 Codes */
-        static final int GeogSemiMajorAxisGeoKey     = 2057; /* GeogLinearUnits */
-        static final int GeogSemiMinorAxisGeoKey     = 2058; /* GeogLinearUnits */
-        static final int GeogInvFlatteningGeoKey     = 2059; /* ratio */
-        static final int GeogAzimuthUnitsGeoKey      = 2060; /* Section 6.3.1.4 Codes */
-        static final int GeogPrimeMeridianLongGeoKey = 2061; /* GeogAngularUnit */
-
-        //6.2.3 Projected CS Parameter Keys
-        static final int ProjectedCSTypeGeoKey          = 3072;  /* Section 6.3.3.1 codes
*/
-        static final int PCSCitationGeoKey              = 3073;  /* documentation */
-        static final int ProjectionGeoKey               = 3074;  /* Section 6.3.3.2 codes
*/
-        static final int ProjCoordTransGeoKey           = 3075;  /* Section 6.3.3.3 codes
*/
-        static final int ProjLinearUnitsGeoKey          = 3076;  /* Section 6.3.1.3 codes
*/
-        static final int ProjLinearUnitSizeGeoKey       = 3077;  /* meters */
-        static final int ProjStdParallel1GeoKey         = 3078;  /* GeogAngularUnit */
-        static final int ProjStdParallel2GeoKey         = 3079;  /* GeogAngularUnit */
-        static final int ProjNatOriginLongGeoKey        = 3080;  /* GeogAngularUnit */
-        static final int ProjNatOriginLatGeoKey         = 3081;  /* GeogAngularUnit */
-        static final int ProjFalseEastingGeoKey         = 3082;  /* ProjLinearUnits */
-        static final int ProjFalseNorthingGeoKey        = 3083;  /* ProjLinearUnits */
-        static final int ProjFalseOriginLongGeoKey      = 3084;  /* GeogAngularUnit */
-        static final int ProjFalseOriginLatGeoKey       = 3085;  /* GeogAngularUnit */
-        static final int ProjFalseOriginEastingGeoKey   = 3086;  /* ProjLinearUnits */
-        static final int ProjFalseOriginNorthingGeoKey  = 3087;  /* ProjLinearUnits */
-        static final int ProjCenterLongGeoKey           = 3088;  /* GeogAngularUnit */
-        static final int ProjCenterLatGeoKey            = 3089;  /* GeogAngularUnit */
-        static final int ProjCenterEastingGeoKey        = 3090;  /* ProjLinearUnits */
-        static final int ProjCenterNorthingGeoKey       = 3091;  /* ProjLinearUnits */
-        static final int ProjScaleAtNatOriginGeoKey     = 3092;  /* ratio */
-        static final int ProjScaleAtCenterGeoKey        = 3093;  /* ratio */
-        static final int ProjAzimuthAngleGeoKey         = 3094;  /* GeogAzimuthUnit */
-        static final int ProjStraightVertPoleLongGeoKey = 3095;  /* GeogAngularUnit */
-        //Aliases:
-        static final int ProjStdParallelGeoKey       = ProjStdParallel1GeoKey;
-        static final int ProjOriginLongGeoKey        = ProjNatOriginLongGeoKey;
-        static final int ProjOriginLatGeoKey         = ProjNatOriginLatGeoKey;
-        static final int ProjScaleAtOriginGeoKey     = ProjScaleAtNatOriginGeoKey;
-
-        //6.2.4 Vertical CS Keys
-        static final int VerticalCSTypeGeoKey    = 4096;   /* Section 6.3.4.1 codes */
-        static final int VerticalCitationGeoKey  = 4097;   /* documentation */
-        static final int VerticalDatumGeoKey     = 4098;   /* Section 6.3.4.2 codes */
-        static final int VerticalUnitsGeoKey     = 4099;   /* Section 6.3.1.3 codes */
-
-        /**
-         * Returns key Name from {@link CRS} class if exist.
-         * If key name doesn't exist return {@code null}.
-         *
-         * @param key
-         * @return tag Name from {@link CRS} class.
-         */
-        static String getName(final int tag) {
-            try {
-                for (final Field field : CRS.class.getDeclaredFields()) {
-                    if (field.getType() == Integer.TYPE) {
-                        if (field.getInt(null) == tag) {
-                            return field.getName();
-                        }
-                    }
-                }
-            } catch (ReflectiveOperationException ex) {
-                throw new AssertionError(ex); // Should never happen.
-            }
-            return Integer.toHexString(tag);
-        }
-
-        /**
-         * Returns {@code true} if {@link CRS} class contain given key
-         * else return {@code false}.
-         *
-         * @param key
-         * @return {@code true} if {@link CRS} contain key else {@code false}.
-         */
-        static boolean contain(int key) {
-            try {
-                for (final Field field : CRS.class.getDeclaredFields()) {
-                    if (field.getType() == Integer.TYPE) {
-                        if (field.getInt(null) == key) {
-                            return true;
-                        }
-                    }
-                }
-            } catch (ReflectiveOperationException ex) {
-                throw new AssertionError(ex); // Should never happen.
-            }
-            return false;
-        }
-    }
-
-    static class GridToCrs {
-
-    }
-
-
-    //--------------------------- To String ------------------------------------
-    /**
-     * Returns key Name from one of {@link Configuration}, {@link Operation_Method},
-     * {@link Units} or {@link CRS} class if exist. If key name doesn't
-     * exist return {@code null}.
+    /*
+     * 6.3.1.1 Model Type Codes
      *
-     * @param key
-     * @return tag Name from one of internal sub-class if exist.
+     * Ranges:
+     *   0              = undefined
+     *   [   1,  32766] = GeoTIFF Reserved Codes
+     *   32767          = user-defined
+     *   [32768, 65535] = Private User Implementations
+     *
+     * Notes:
+     *   1. ModelTypeGeographic and ModelTypeProjected
+     *   correspond to the FGDC metadata Geographic and
+     *   Planar-Projected coordinate system types.
      */
-    static String getName(final int tag) {
-        if (Configuration.contain(tag))
-            return Configuration.getName(tag);
-
-        if (Operation_Method.contain(tag))
-            return Operation_Method.getName(tag);
+    //GeoTIFF defined CS Model Type Codes:
+    public static final short ModelTypeProjected   = 1;   /* Projection Coordinate System
        */
+    public static final short ModelTypeGeographic  = 2;   /* Geographic latitude-longitude
System */
+    public static final short ModelTypeGeocentric  = 3;   /* Geocentric (X,Y,Z) Coordinate
System */
+    ////////////////////////////////////////////////////////////////////////////
+    // Codes
+    ////////////////////////////////////////////////////////////////////////////
 
-        if (Units.contain(tag))
-            return Units.getName(tag);
+    public static final short GTUserDefinedGeoKey         = 32767;
+    static final String GTUserDefinedGeoKey_String = "32767";
 
-        if (CRS.contain(tag))
-            return CRS.getName(tag);
+    /*
+     * 6.3.3.3 Coordinate Transformation Codes
+     * Ranges:
+     * 0 = undefined
+     * [    1, 16383] = GeoTIFF Coordinate Transformation codes
+     * [16384, 32766] = Reserved by GeoTIFF
+     * 32767          = user-defined
+     * [32768, 65535] = Private User Implementations
+     */
+    public static final short CT_TransverseMercator =             1;
+    public static final short CT_TransvMercator_Modified_Alaska = 2;
+    public static final short CT_ObliqueMercator =                3;
+    public static final short CT_ObliqueMercator_Laborde =        4;
+    public static final short CT_ObliqueMercator_Rosenmund =      5;
+    public static final short CT_ObliqueMercator_Spherical =      6;
+    public static final short CT_Mercator =                       7;
+    public static final short CT_LambertConfConic_2SP =           8;
+    public static final short CT_LambertConfConic_1SP =           9;
+    public static final short CT_LambertAzimEqualArea =           10;
+    public static final short CT_AlbersEqualArea =                11;
+    public static final short CT_AzimuthalEquidistant =           12;
+    public static final short CT_EquidistantConic =               13;
+    public static final short CT_Stereographic =                  14;
+    public static final short CT_PolarStereographic =             15;
+    public static final short CT_ObliqueStereographic =           16;
+    public static final short CT_Equirectangular =                17;
+    public static final short CT_CassiniSoldner =                 18;
+    public static final short CT_Gnomonic =                       19;
+    public static final short CT_MillerCylindrical =              20;
+    public static final short CT_Orthographic =                   21;
+    public static final short CT_Polyconic =                      22;
+    public static final short CT_Robinson =                       23;
+    public static final short CT_Sinusoidal =                     24;
+    public static final short CT_VanDerGrinten =                  25;
+    public static final short CT_NewZealandMapGrid =              26;
+    public static final short CT_TransvMercator_SouthOriented=    27;
+    //Aliases:
+    public static final short CT_AlaskaConformal =                CT_TransvMercator_Modified_Alaska;
+    public static final short CT_TransvEquidistCylindrical =      CT_CassiniSoldner;
+    public static final short CT_ObliqueMercator_Hotine =         CT_ObliqueMercator;
+    public static final short CT_SwissObliqueCylindrical =        CT_ObliqueMercator_Rosenmund;
+    public static final short CT_GaussBoaga =                     CT_TransverseMercator;
+    public static final short CT_GaussKruger =                    CT_TransverseMercator;
+    public static final short CT_LambertConfConic =               CT_LambertConfConic_2SP
;
+    public static final short CT_LambertConfConic_Helmert =       CT_LambertConfConic_1SP;
+    public static final short CT_SouthOrientedGaussConformal =    CT_TransvMercator_SouthOriented;
 
-        return null;
-    }
+    /*
+     * 6.3.1.3 Linear Units Codes
+     *
+     *  There are several different kinds of units that may be used in geographically related
raster data: linear units, angular units, units of time (e.g. for radar-return), CCD-voltages,
etc. For this reason there will be a single, unique range for each kind of unit, broken down
into the following currently defined ranges:
+     *  Ranges:
+     *     0             = undefined
+     *     [   1,  2000] = Obsolete GeoTIFF codes
+     *     [2001,  8999] = Reserved by GeoTIFF
+     *     [9000,  9099] = EPSG Linear Units.
+     *     [9100,  9199] = EPSG Angular Units.
+     *     32767         = user-defined unit
+     *     [32768, 65535]= Private User Implementations
+     *  Linear Unit Values (See the ESPG/POSC tables for definition):
+     */
+    public static final short Linear_Meter                       = 9001;
+    public static final short Linear_Foot                        = 9002;
+    public static final short Linear_Foot_US_Survey              = 9003;
+    public static final short Linear_Foot_Modified_American      = 9004;
+    public static final short Linear_Foot_Clarke                 = 9005;
+    public static final short Linear_Foot_Indian                 = 9006;
+    public static final short Linear_Link                        = 9007;
+    public static final short Linear_Link_Benoit                 = 9008;
+    public static final short Linear_Link_Sears                  = 9009;
+    public static final short Linear_Chain_Benoit                = 9010;
+    public static final short Linear_Chain_Sears                 = 9011;
+    public static final short Linear_Yard_Sears                  = 9012;
+    public static final short Linear_Yard_Indian                 = 9013;
+    public static final short Linear_Fathom                      = 9014;
+    public static final short Linear_Mile_International_Nautical = 9015;
+
+    /*
+     * 6.3.1.4 Angular Units Codes
+     * These codes shall be used for any key that requires specification of an angular unit
of measurement.
+     */
+    public static final short Angular_Radian         = 9101;
+    public static final short Angular_Degree         = 9102;
+    public static final short Angular_Arc_Minute     = 9103;
+    public static final short Angular_Arc_Second     = 9104;
+    public static final short Angular_Grad           = 9105;
+    public static final short Angular_Gon            = 9106;
+    public static final short Angular_DMS            = 9107;
+    public static final short Angular_DMS_Hemisphere = 9108;
+
+
+    //6.2.2 Geographic CS Parameter Keys
+    public static final short GeographicTypeGeoKey        = 2048; /* Section 6.3.2.1 Codes
*/
+    public static final short GeogCitationGeoKey          = 2049; /* documentation */
+    public static final short GeogGeodeticDatumGeoKey     = 2050; /* Section 6.3.2.2 Codes
*/
+    public static final short GeogPrimeMeridianGeoKey     = 2051; /* Section 6.3.2.4 codes
*/
+    public static final short GeogLinearUnitsGeoKey       = 2052; /* Section 6.3.1.3 Codes
*/
+    public static final short GeogLinearUnitSizeGeoKey    = 2053; /* meters */
+    public static final short GeogAngularUnitsGeoKey      = 2054; /* Section 6.3.1.4 Codes
*/
+    public static final short GeogAngularUnitSizeGeoKey   = 2055; /* radians */
+    public static final short GeogEllipsoidGeoKey         = 2056; /* Section 6.3.2.3 Codes
*/
+    public static final short GeogSemiMajorAxisGeoKey     = 2057; /* GeogLinearUnits */
+    public static final short GeogSemiMinorAxisGeoKey     = 2058; /* GeogLinearUnits */
+    public static final short GeogInvFlatteningGeoKey     = 2059; /* ratio */
+    public static final short GeogAzimuthUnitsGeoKey      = 2060; /* Section 6.3.1.4 Codes
*/
+    public static final short GeogPrimeMeridianLongGeoKey = 2061; /* GeogAngularUnit */
+
+    //6.2.3 Projected CS Parameter Keys
+    public static final short ProjectedCSTypeGeoKey          = 3072;  /* Section 6.3.3.1
codes */
+    public static final short PCSCitationGeoKey              = 3073;  /* documentation */
+    public static final short ProjectionGeoKey               = 3074;  /* Section 6.3.3.2
codes */
+    public static final short ProjCoordTransGeoKey           = 3075;  /* Section 6.3.3.3
codes */
+    public static final short ProjLinearUnitsGeoKey          = 3076;  /* Section 6.3.1.3
codes */
+    public static final short ProjLinearUnitSizeGeoKey       = 3077;  /* meters */
+    public static final short ProjStdParallel1GeoKey         = 3078;  /* GeogAngularUnit
*/
+    public static final short ProjStdParallel2GeoKey         = 3079;  /* GeogAngularUnit
*/
+    public static final short ProjNatOriginLongGeoKey        = 3080;  /* GeogAngularUnit
*/
+    public static final short ProjNatOriginLatGeoKey         = 3081;  /* GeogAngularUnit
*/
+    public static final short ProjFalseEastingGeoKey         = 3082;  /* ProjLinearUnits
*/
+    public static final short ProjFalseNorthingGeoKey        = 3083;  /* ProjLinearUnits
*/
+    public static final short ProjFalseOriginLongGeoKey      = 3084;  /* GeogAngularUnit
*/
+    public static final short ProjFalseOriginLatGeoKey       = 3085;  /* GeogAngularUnit
*/
+    public static final short ProjFalseOriginEastingGeoKey   = 3086;  /* ProjLinearUnits
*/
+    public static final short ProjFalseOriginNorthingGeoKey  = 3087;  /* ProjLinearUnits
*/
+    public static final short ProjCenterLongGeoKey           = 3088;  /* GeogAngularUnit
*/
+    public static final short ProjCenterLatGeoKey            = 3089;  /* GeogAngularUnit
*/
+    public static final short ProjCenterEastingGeoKey        = 3090;  /* ProjLinearUnits
*/
+    public static final short ProjCenterNorthingGeoKey       = 3091;  /* ProjLinearUnits
*/
+    public static final short ProjScaleAtNatOriginGeoKey     = 3092;  /* ratio */
+    public static final short ProjScaleAtCenterGeoKey        = 3093;  /* ratio */
+    public static final short ProjAzimuthAngleGeoKey         = 3094;  /* GeogAzimuthUnit
*/
+    public static final short ProjStraightVertPoleLongGeoKey = 3095;  /* GeogAngularUnit
*/
+    //Aliases:
+    public static final short ProjStdParallelGeoKey       = ProjStdParallel1GeoKey;
+    public static final short ProjOriginLongGeoKey        = ProjNatOriginLongGeoKey;
+    public static final short ProjOriginLatGeoKey         = ProjNatOriginLatGeoKey;
+    public static final short ProjScaleAtOriginGeoKey     = ProjScaleAtNatOriginGeoKey;
+
+    //6.2.4 Vertical CS Keys
+    public static final short VerticalCSTypeGeoKey    = 4096;   /* Section 6.3.4.1 codes
*/
+    public static final short VerticalCitationGeoKey  = 4097;   /* documentation */
+    public static final short VerticalDatumGeoKey     = 4098;   /* Section 6.3.4.2 codes
*/
+    public static final short VerticalUnitsGeoKey     = 4099;   /* Section 6.3.1.3 codes
*/
 
     /**
-     * Returns {@code true} if given key is within one of {@link Configuration}, {@link Operation_Method},
-     * {@link Units} or {@link CRS} internal sub class else return {@code false}.
+     * Returns key name if exist.
      *
-     * @param key
-     * @return {@code true} if one of internal sub class contain key else {@code false}.
+     * @return tag  name from one of the constants.
      */
-    static boolean contain(int key) {
-        return Configuration.contain(key)
-            || Operation_Method.contain(key)
-            || Units.contain(key)
-            || CRS.contain(key);
+    static String getName(final short tag) {
+        try {
+            for (final Field field : GeoKeys.class.getDeclaredFields()) {
+                if (field.getType() == Short.TYPE) {
+                    if (field.getShort(null) == tag) {
+                        return field.getName();
+                    }
+                }
+            }
+        } catch (ReflectiveOperationException ex) {
+            throw new AssertionError(ex); // Should never happen.
+        }
+        return Integer.toHexString(Short.toUnsignedInt(tag));
     }
 }

Modified: sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTiffStore.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTiffStore.java?rev=1771368&r1=1771367&r2=1771368&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTiffStore.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTiffStore.java
[UTF-8] Fri Nov 25 18:45:51 2016
@@ -116,12 +116,6 @@ public class GeoTiffStore extends DataSt
                 while ((dir = reader.getImageFileDirectory(n++)) != null) {
                     dir.completeMetadata(builder, locale);
                 }
-                /*
-                 * Add Coordinate Reference System built from GeoTIFF tags.  Note that the
CRS may not exist,
-                 * in which case the CRS builder returns null. This is safe since all MetadataBuilder
methods
-                 * ignore null values (a design choice because this pattern come very often).
-                 */
-                builder.add(reader.crsBuilder.build());
                 metadata = builder.build(true);
             } catch (IOException e) {
                 throw new DataStoreException(reader.errors().getString(Errors.Keys.CanNotRead_1,
reader.input.filename), e);

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=1771368&r1=1771367&r2=1771368&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 18:45:51 2016
@@ -26,6 +26,7 @@ import java.nio.charset.Charset;
 import javax.measure.Unit;
 import javax.measure.quantity.Length;
 import org.opengis.metadata.citation.DateType;
+import org.opengis.util.FactoryException;
 import org.apache.sis.internal.geotiff.Resources;
 import org.apache.sis.internal.storage.ChannelDataInput;
 import org.apache.sis.storage.DataStoreException;
@@ -283,6 +284,27 @@ final class ImageFileDirectory {
     private Compression compression;
 
     /**
+     * References the {@link GeoKeys} needed for building the Coordinate Reference System.
+     * This is a GeoTIFF extension to the TIFF specification.
+     * Content will be parsed by {@link CRSBuilder}.
+     */
+    private Vector geoKeyDirectory;
+
+    /**
+     * The numeric values referenced by the {@link #geoKeyDirectory}.
+     * This is a GeoTIFF extension to the TIFF specification.
+     * Content will be parsed by {@link CRSBuilder}.
+     */
+    private Vector numericGeoParameters;
+
+    /**
+     * The characters referenced by the {@link #geoKeyDirectory}.
+     * This is a GeoTIFF extension to the TIFF specification.
+     * Content will be parsed by {@link CRSBuilder}.
+     */
+    private String asciiGeoParameters;
+
+    /**
      * Creates a new image file directory.
      *
      * @param reader  information about the input stream to read, the metadata and the character
encoding.
@@ -587,23 +609,29 @@ final class ImageFileDirectory {
              * An array of unsigned SHORT values, which are primarily grouped into blocks
of 4.
              * The first 4 values are special, and contain GeoKey directory header information.
              */
-            case Tags.GeoKeyDirectory : {
-                reader.crsBuilder.setGeoKeyDirectoryTag(type.readVector(input(), count));
+            case Tags.GeoKeyDirectory: {
+                geoKeyDirectory = type.readVector(input(), count);
                 break;
             }
             /*
-             * This tag is used to store all of the DOUBLE valued GeoKeys, referenced by
the GeoKeyDirectory.
+             * Stores all of the 'double' valued GeoKeys, referenced by the GeoKeyDirectory.
              */
-            case Tags.GeoDoubleParams : {
-                reader.crsBuilder.setGeoDoubleParamsTag(type.readVector(input(), count));
+            case Tags.GeoDoubleParams: {
+                numericGeoParameters = type.readVector(input(), count);
                 break;
             }
             /*
-             * This tag is used to store all of the ASCII valued GeoKeys, referenced by the
GeoKeyDirectory.
+             * Stores all the characters referenced by the GeoKeyDirectory. Should contains
exactly one string
+             * which will be splitted by CRSBuilder, but we allow an arbitrary amount as
a paranoiac check.
+             * Note that TIFF files use 0 as the end delimiter in strings (C/C++ convention).
              */
-            case Tags.GeoAsciiParams : {
+            case Tags.GeoAsciiParams: {
                 final String[] values = type.readString(input(), count, encoding());
-                reader.crsBuilder.setGeoAsciiParamsTag(values[0]);      // TODO: should pass
the full array.
+                switch (values.length) {
+                    case 0:  break;
+                    case 1:  asciiGeoParameters = values[0]; break;
+                    default: asciiGeoParameters = String.join("\u0000", values).concat("\u0000");
break;
+                }
                 break;
             }
             /*
@@ -952,7 +980,9 @@ final class ImageFileDirectory {
      * @param metadata  where to write metadata information. Caller should have already invoked
      *        {@link MetadataBuilder#setFormat(String)} before {@code completeMetadata(…)}
calls.
      */
-    final void completeMetadata(final MetadataBuilder metadata, final Locale locale) {
+    final void completeMetadata(final MetadataBuilder metadata, final Locale locale)
+            throws DataStoreContentException, FactoryException
+    {
         metadata.newCoverage(false);
         if (compression != null) {
             metadata.addCompression(compression.name().toLowerCase(locale));
@@ -991,6 +1021,14 @@ final class ImageFileDirectory {
                 break;
             }
         }
+        /*
+         * Add Coordinate Reference System built from GeoTIFF tags.  Note that the CRS may
not exist,
+         * in which case the CRS builder returns null. This is safe since all MetadataBuilder
methods
+         * ignore null values (a design choice because this pattern come very often).
+         */
+        if (geoKeyDirectory != null) {
+            metadata.add(new CRSBuilder(reader).build(geoKeyDirectory, numericGeoParameters,
asciiGeoParameters));
+        }
     }
 
     /**

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=1771368&r1=1771367&r2=1771368&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 18:45:51 2016
@@ -110,14 +110,6 @@ final class Reader extends GeoTIFF {
     final MetadataBuilder metadata;
 
     /**
-     * Builder for the Coordinate Reference System.
-     *
-     * @todo should not be here since we can have a CRS for each image and we don't want
to merge them
-     *       like we do for metadata.
-     */
-    final CRSBuilder crsBuilder;
-
-    /**
      * Creates a new GeoTIFF reader which will read data from the given input.
      * The input must be at the beginning of the GeoTIFF file.
      *
@@ -126,10 +118,9 @@ final class Reader extends GeoTIFF {
      */
     Reader(final GeoTiffStore owner, final ChannelDataInput input) throws IOException, DataStoreException
{
         super(owner);
-        this.input      = input;
-        this.origin     = input.getStreamPosition();
-        this.metadata   = new MetadataBuilder();
-        this.crsBuilder = new CRSBuilder(this);
+        this.input    = input;
+        this.origin   = input.getStreamPosition();
+        this.metadata = new MetadataBuilder();
         /*
          * A TIFF file begins with either "II" (0x4949) or "MM" (0x4D4D) characters.
          * Those characters identify the byte order. Note that we do not need to care

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=1771368&r1=1771367&r2=1771368&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 18:45:51 2016
@@ -142,7 +142,7 @@ final class Tags {
     /**
      * References all "GeoKeys" needed for building the Coordinate Reference System.
      * GeoTIFF keys are stored in a kind of directory inside the TIFF directory, with
-     * the keys enumerated in the {@link GeoTIFF} class.
+     * the keys enumerated in the {@link CRSBuilder} class.
      *
      * @see GeoKeys
      */
@@ -173,7 +173,7 @@ final class Tags {
     static String name(final short tag) {
         try {
             for (final Field field : Tags.class.getFields()) {
-                if (field.getType() == Integer.TYPE) {
+                if (field.getType() == Short.TYPE) {
                     if (field.getShort(null) == tag) {
                         return field.getName();
                     }




Mime
View raw message