sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1772132 - in /sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff: CRSBuilder.java GeoKeys.java
Date Wed, 30 Nov 2016 23:18:40 GMT
Author: desruisseaux
Date: Wed Nov 30 23:18:40 2016
New Revision: 1772132

URL: http://svn.apache.org/viewvc?rev=1772132&view=rev
Log:
Javadoc and CRSBuilder.toString() implementation.

Modified:
    sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/CRSBuilder.java
    sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoKeys.java

Modified: sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/CRSBuilder.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/CRSBuilder.java?rev=1772132&r1=1772131&r2=1772132&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/CRSBuilder.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/CRSBuilder.java
[UTF-8] Wed Nov 30 23:18:40 2016
@@ -24,6 +24,7 @@ import java.util.logging.Level;
 import java.util.logging.LogRecord;
 import java.util.NoSuchElementException;
 import java.lang.reflect.Array;
+import java.io.IOException;
 import javax.measure.Unit;
 import javax.measure.Quantity;
 import javax.measure.UnitConverter;
@@ -70,8 +71,9 @@ import org.apache.sis.referencing.cs.Coo
 import org.apache.sis.referencing.crs.DefaultGeographicCRS;
 import org.apache.sis.referencing.factory.GeodeticAuthorityFactory;
 import org.apache.sis.referencing.factory.GeodeticObjectFactory;
-import org.apache.sis.storage.DataStoreContentException;
+import org.apache.sis.io.TableAppender;
 import org.apache.sis.util.Characters;
+import org.apache.sis.util.Debug;
 
 import static org.apache.sis.util.Utilities.equalsIgnoreMetadata;
 
@@ -488,7 +490,7 @@ final class CRSBuilder {
      */
     @SuppressWarnings("null")
     final CoordinateReferenceSystem build(final Vector keyDirectory, final Vector numericParameters,
final String asciiParameters)
-            throws DataStoreContentException, FactoryException
+            throws FactoryException
     {
         final int numberOfKeys;
         final int directoryLength = keyDirectory.size();
@@ -1109,6 +1111,7 @@ final class CRSBuilder {
      * @throws FactoryException if an error occurred during objects creation with the factories.
      *
      * @see #createGeographicCRS(boolean)
+     * @see #createConversion(String)
      */
     private CoordinateReferenceSystem createProjectedCRS() throws FactoryException {
         final int epsg = getAsInteger(GeoKeys.ProjectedCSType);
@@ -1122,8 +1125,8 @@ final class CRSBuilder {
                  * and build the projected CRS from them.
                  */
                 final String name = getAsString(GeoKeys.PCSCitation);
-                final GeographicCRS baseCRS = createGeographicCRS(false);
                 final Conversion projection = createConversion(name);
+                final GeographicCRS baseCRS = createGeographicCRS(false);
                 CartesianCS cs = epsgFactory().createCartesianCS(String.valueOf(Constants.EPSG_PROJECTED_CS));
                 final Unit<Length> unit = createUnit(GeoKeys.ProjLinearUnits, GeoKeys.ProjLinearUnitSize,
Length.class, Units.METRE);
                 if (!Units.METRE.equals(unit)) {
@@ -1159,6 +1162,14 @@ final class CRSBuilder {
         verify(baseCRS);
     }
 
+    /**
+     * Creates a defining conversion from an EPSG code or from user-defined parameters.
+     *
+     * @throws NoSuchElementException if a mandatory value is missing.
+     * @throws NumberFormatException if a numeric value was stored as a string and can not
be parsed.
+     * @throws ClassCastException if an object defined by an EPSG code is not of the expected
type.
+     * @throws FactoryException if an error occurred during objects creation with the factories.
+     */
     private Conversion createConversion(final String name) throws FactoryException {
         final int epsg = getAsInteger(GeoKeys.Projection);
         switch (epsg) {
@@ -1166,10 +1177,10 @@ final class CRSBuilder {
                 throw new NoSuchElementException(missingValue(GeoKeys.Projection));
             }
             case GeoCodes.userDefined: {
-                final String coordTrans               = getMandatoryString(GeoKeys.ProjCoordTrans);
-                final OperationMethod operationMethod = operationFactory().getOperationMethod(coordTrans);
-                final ParameterValueGroup parameters  = operationMethod.getParameters().createValue();
-                final Conversion c = operationFactory().createDefiningConversion(properties(name),
operationMethod, parameters);
+                final String              type        = getMandatoryString(GeoKeys.ProjCoordTrans);
+                final OperationMethod     method      = operationFactory().getOperationMethod(type);
+                final ParameterValueGroup parameters  = method.getParameters().createValue();
+                final Conversion c = operationFactory().createDefiningConversion(properties(name),
method, parameters);
                 lastName = c.getName();
                 return c;
             }
@@ -1179,22 +1190,26 @@ final class CRSBuilder {
         }
     }
 
+    /**
+     * Returns a string representation of the keys and associated values in this {@code CRSBuilder}.
+     */
+    @Debug
     @Override
     public final String toString() {
-        final StringBuilder strBuild = new StringBuilder("GeoKeys for CoordinateReferenceSystem")
-                .append('\n')
-                .append('\n')
-                .append("geo keys revision: ").append(majorRevision)
-                .append('\n')
-                .append("minor revision: ").append(minorRevision)
-                .append('\n')
-                .append('\n');
-
+        final StringBuilder buffer = new StringBuilder("GeoTIFF keys ").append(majorRevision).append('.')
+                .append(minorRevision).append(" in ").append(reader.input.filename).append(System.lineSeparator());
+        final TableAppender table = new TableAppender(buffer, " ");
         for (Map.Entry<Short,Object> entry : geoKeys.entrySet()) {
             final short key = entry.getKey();
-            strBuild.append(GeoKeys.name(key)).append(" (").append(key).append(") = ").append(entry.getValue());
-            strBuild.append('\n');
+            table.append(String.valueOf(key)).nextColumn();
+            table.append(GeoKeys.name(key)).nextColumn();
+            table.append(" = ").append(String.valueOf(entry.getValue())).nextLine();
+        }
+        try {
+            table.flush();
+        } catch (IOException e) {
+            throw new AssertionError(e);        // Should never happen since we wrote to
a StringBuffer.
         }
-        return strBuild.toString();
+        return buffer.toString();
     }
 }

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=1772132&r1=1772131&r2=1772132&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] Wed Nov 30 23:18:40 2016
@@ -40,57 +40,57 @@ final class GeoKeys {
     }
 
     // 6.2.1 GeoTIFF Configuration Keys
-    /** Section 6.3.1.1 Codes */ public static final short ModelType  = 1024;
-    /** Section 6.3.1.2 Codes */ public static final short RasterType = 1025;
-    /** Documentation         */ public static final short Citation   = 1026;
+    /** Section 6.3.1.1 Codes. */ public static final short ModelType                = 1024;
+    /** Section 6.3.1.2 Codes. */ public static final short RasterType               = 1025;
+    /** Documentation.         */ public static final short Citation                 = 1026;
 
     // 6.2.2 Geographic CS Parameter Keys
-    public static final short GeographicType        = 2048; /* Section 6.3.2.1 Codes */
-    public static final short GeogCitation          = 2049; /* documentation */
-    public static final short GeogGeodeticDatum     = 2050; /* Section 6.3.2.2 Codes */
-    public static final short GeogPrimeMeridian     = 2051; /* Section 6.3.2.4 codes */
-    public static final short GeogLinearUnits       = 2052; /* Section 6.3.1.3 Codes */
-    public static final short GeogLinearUnitSize    = 2053; /* meters */
-    public static final short GeogAngularUnits      = 2054; /* Section 6.3.1.4 Codes */
-    public static final short GeogAngularUnitSize   = 2055; /* radians */
-    public static final short GeogEllipsoid         = 2056; /* Section 6.3.2.3 Codes */
-    public static final short GeogSemiMajorAxis     = 2057; /* GeogLinearUnits */
-    public static final short GeogSemiMinorAxis     = 2058; /* GeogLinearUnits */
-    public static final short GeogInvFlattening     = 2059; /* ratio */
-    public static final short GeogAzimuthUnits      = 2060; /* Section 6.3.1.4 Codes */
-    public static final short GeogPrimeMeridianLong = 2061; /* GeogAngularUnit */
+    /** Section 6.3.2.1 Codes. */ public static final short GeographicType           = 2048;
+    /** Documentation.         */ public static final short GeogCitation             = 2049;
+    /** Section 6.3.2.2 Codes. */ public static final short GeogGeodeticDatum        = 2050;
+    /** Section 6.3.2.4 codes. */ public static final short GeogPrimeMeridian        = 2051;
+    /** Section 6.3.1.3 Codes. */ public static final short GeogLinearUnits          = 2052;
+    /** Relative to meters.    */ public static final short GeogLinearUnitSize       = 2053;
+    /** Section 6.3.1.4 Codes. */ public static final short GeogAngularUnits         = 2054;
+    /** Relative to radians.   */ public static final short GeogAngularUnitSize      = 2055;
+    /** Section 6.3.2.3 Codes. */ public static final short GeogEllipsoid            = 2056;
+    /** In GeogLinearUnits.    */ public static final short GeogSemiMajorAxis        = 2057;
+    /** In GeogLinearUnits.    */ public static final short GeogSemiMinorAxis        = 2058;
+    /** A ratio.               */ public static final short GeogInvFlattening        = 2059;
+    /** Section 6.3.1.4 Codes. */ public static final short GeogAzimuthUnits         = 2060;
+    /** In GeogAngularUnit.    */ public static final short GeogPrimeMeridianLong    = 2061;
 
     // 6.2.3 Projected CS Parameter Keys
-    public static final short ProjectedCSType          = 3072;  /* Section 6.3.3.1 codes
*/
-    public static final short PCSCitation              = 3073;  /* documentation */
-    public static final short Projection               = 3074;  /* Section 6.3.3.2 codes
*/
-    public static final short ProjCoordTrans           = 3075;  /* Section 6.3.3.3 codes
*/
-    public static final short ProjLinearUnits          = 3076;  /* Section 6.3.1.3 codes
*/
-    public static final short ProjLinearUnitSize       = 3077;  /* meters */
-    public static final short ProjStdParallel1         = 3078;  /* GeogAngularUnit */
-    public static final short ProjStdParallel2         = 3079;  /* GeogAngularUnit */
-    public static final short ProjNatOriginLong        = 3080;  /* GeogAngularUnit */
-    public static final short ProjNatOriginLat         = 3081;  /* GeogAngularUnit */
-    public static final short ProjFalseEasting         = 3082;  /* ProjLinearUnits */
-    public static final short ProjFalseNorthing        = 3083;  /* ProjLinearUnits */
-    public static final short ProjFalseOriginLong      = 3084;  /* GeogAngularUnit */
-    public static final short ProjFalseOriginLat       = 3085;  /* GeogAngularUnit */
-    public static final short ProjFalseOriginEasting   = 3086;  /* ProjLinearUnits */
-    public static final short ProjFalseOriginNorthing  = 3087;  /* ProjLinearUnits */
-    public static final short ProjCenterLong           = 3088;  /* GeogAngularUnit */
-    public static final short ProjCenterLat            = 3089;  /* GeogAngularUnit */
-    public static final short ProjCenterEasting        = 3090;  /* ProjLinearUnits */
-    public static final short ProjCenterNorthing       = 3091;  /* ProjLinearUnits */
-    public static final short ProjScaleAtNatOrigin     = 3092;  /* ratio */
-    public static final short ProjScaleAtCenter        = 3093;  /* ratio */
-    public static final short ProjAzimuthAngle         = 3094;  /* GeogAzimuthUnit */
-    public static final short ProjStraightVertPoleLong = 3095;  /* GeogAngularUnit */
+    /** Section 6.3.3.1 codes. */ public static final short ProjectedCSType          = 3072;
+    /** Documentation.         */ public static final short PCSCitation              = 3073;
+    /** Section 6.3.3.2 codes. */ public static final short Projection               = 3074;
+    /** Section 6.3.3.3 codes. */ public static final short ProjCoordTrans           = 3075;
+    /** Section 6.3.1.3 codes. */ public static final short ProjLinearUnits          = 3076;
+    /** Relative to meters.    */ public static final short ProjLinearUnitSize       = 3077;
+    /** In GeogAngularUnit.    */ public static final short ProjStdParallel1         = 3078;
+    /** In GeogAngularUnit.    */ public static final short ProjStdParallel2         = 3079;
+    /** In GeogAngularUnit.    */ public static final short ProjNatOriginLong        = 3080;
+    /** In GeogAngularUnit.    */ public static final short ProjNatOriginLat         = 3081;
+    /** In ProjLinearUnits.    */ public static final short ProjFalseEasting         = 3082;
+    /** In ProjLinearUnits.    */ public static final short ProjFalseNorthing        = 3083;
+    /** In GeogAngularUnit.    */ public static final short ProjFalseOriginLong      = 3084;
+    /** In GeogAngularUnit.    */ public static final short ProjFalseOriginLat       = 3085;
+    /** In ProjLinearUnits.    */ public static final short ProjFalseOriginEasting   = 3086;
+    /** In ProjLinearUnits.    */ public static final short ProjFalseOriginNorthing  = 3087;
+    /** In GeogAngularUnit.    */ public static final short ProjCenterLong           = 3088;
+    /** In GeogAngularUnit.    */ public static final short ProjCenterLat            = 3089;
+    /** In ProjLinearUnits.    */ public static final short ProjCenterEasting        = 3090;
+    /** In ProjLinearUnits.    */ public static final short ProjCenterNorthing       = 3091;
+    /** A ratio.               */ public static final short ProjScaleAtNatOrigin     = 3092;
+    /** A ratio.               */ public static final short ProjScaleAtCenter        = 3093;
+    /** In GeogAzimuthUnit.    */ public static final short ProjAzimuthAngle         = 3094;
+    /** In GeogAngularUnit.    */ public static final short ProjStraightVertPoleLong = 3095;
 
     // 6.2.4 Vertical CS Keys
-    public static final short VerticalCSType    = 4096;   /* Section 6.3.4.1 codes */
-    public static final short VerticalCitation  = 4097;   /* documentation */
-    public static final short VerticalDatum     = 4098;   /* Section 6.3.4.2 codes */
-    public static final short VerticalUnits     = 4099;   /* Section 6.3.1.3 codes */
+    /** Section 6.3.4.1 codes. */ public static final short VerticalCSType           = 4096;
+    /** Documentation.         */ public static final short VerticalCitation         = 4097;
+    /** Section 6.3.4.2 codes. */ public static final short VerticalDatum            = 4098;
+    /** Section 6.3.1.3 codes. */ public static final short VerticalUnits            = 4099;
 
     /**
      * Returns the name of the given key. Implementation of this method is inefficient,



Mime
View raw message