sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1771491 [2/2] - in /sis/branches/JDK8/storage/sis-geotiff/src: main/java/org/apache/sis/internal/geotiff/ main/java/org/apache/sis/storage/geotiff/ test/java/org/apache/sis/storage/geotiff/
Date Sat, 26 Nov 2016 15:41:55 GMT
Copied: sis/branches/JDK8/storage/sis-geotiff/src/test/java/org/apache/sis/storage/geotiff/GeoIdentifiers.java
(from r1771400, 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/test/java/org/apache/sis/storage/geotiff/GeoIdentifiers.java?p2=sis/branches/JDK8/storage/sis-geotiff/src/test/java/org/apache/sis/storage/geotiff/GeoIdentifiers.java&p1=sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoKeys.java&r1=1771400&r2=1771491&rev=1771491&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/test/java/org/apache/sis/storage/geotiff/GeoIdentifiers.java
[UTF-8] Sat Nov 26 15:41:55 2016
@@ -17,69 +17,36 @@
 package org.apache.sis.storage.geotiff;
 
 import java.lang.reflect.Field;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.referencing.operation.MathTransform;
 
 
 /**
- * All Geographic Keys needed for building {@link CoordinateReferenceSystem} instances
- * and {@link MathTransform} "grid to CRS" from TIFF tags values.
+ * Identifiers (usually EPSG codes) associated to {@link GeoKeys}.
+ * Those identifiers do not need to be declared in the main {@code sis-geotiff} module
+ * because the GeoTIFF reader uses the EPSG database instead or declare those identifiers
+ * in the {@link org.apache.sis.internal.referencing.provider} package instead.
+ * However those identifiers are useful for verification purposes during tests.
  *
  * @author  Rémi Maréchal (Geomatys)
  * @since   0.8
  * @version 0.8
  * @module
  */
-final class GeoKeys {
+final class GeoIdentifiers {
     /**
      * Do not allow instantiation of this class.
      */
-    private GeoKeys() {
+    private GeoIdentifiers() {
     }
 
-    ////////////////////////////////////////////////////////////////////////////
-    // KEYS, values are taken from :
-    // http://www.remotesensing.org/geotiff/spec/geotiff6.html#6
-    ////////////////////////////////////////////////////////////////////////////
-
-    //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 */
-
-    /*
-     * 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:
-    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
-    ////////////////////////////////////////////////////////////////////////////
-
-    public static final short GTUserDefinedGeoKey         = 32767;
-    static final String GTUserDefinedGeoKey_String = "32767";
-
     /*
      * 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
+     *   [    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;
@@ -108,7 +75,8 @@ final class GeoKeys {
     public static final short CT_VanDerGrinten =                  25;
     public static final short CT_NewZealandMapGrid =              26;
     public static final short CT_TransvMercator_SouthOriented=    27;
-    //Aliases:
+
+    // 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;
@@ -122,15 +90,20 @@ final class GeoKeys {
     /*
      * 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:
+     *  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
+     *     [    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;
@@ -162,76 +135,21 @@ final class GeoKeys {
     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 key name if exist.
-     *
-     * @return tag  name from one of the constants.
+     * Returns the name of the given code. Implementation of this method is inefficient,
+     * but it should rarely be invoked (mostly for formatting error messages).
      */
-    static String getName(final short tag) {
+    static String name(final short tag) {
         try {
-            for (final Field field : GeoKeys.class.getDeclaredFields()) {
+            for (final Field field : GeoIdentifiers.class.getFields()) {
                 if (field.getType() == Short.TYPE) {
                     if (field.getShort(null) == tag) {
                         return field.getName();
                     }
                 }
             }
-        } catch (ReflectiveOperationException ex) {
-            throw new AssertionError(ex); // Should never happen.
+        } catch (IllegalAccessException e) {
+            throw new AssertionError(e);        // Should never happen because we asked only
for public fields.
         }
         return Integer.toHexString(Short.toUnsignedInt(tag));
     }



Mime
View raw message