You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2016/10/05 10:18:06 UTC
svn commit: r1763391 - in
/sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis:
internal/ internal/geotiff/ storage/geotiff/
Author: desruisseaux
Date: Wed Oct 5 10:18:05 2016
New Revision: 1763391
URL: http://svn.apache.org/viewvc?rev=1763391&view=rev
Log:
Add resources for the sis-geotiff module and throw a more accurate exception when "BitsPerSample" can not be decoded.
Added:
sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/internal/
sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/
sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/Resources.java
- copied, changed from r1763327, sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Resources.java
sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/Resources.properties
- copied, changed from r1763327, sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Resources.properties
sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/Resources_fr.properties
- copied, changed from r1763327, sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Resources_fr.properties
sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/package-info.java
- copied, changed from r1763327, sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/package-info.java
Modified:
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
Copied: sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/Resources.java (from r1763327, sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Resources.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/Resources.java?p2=sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/Resources.java&p1=sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Resources.java&r1=1763327&r2=1763391&rev=1763391&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Resources.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/Resources.java [UTF-8] Wed Oct 5 10:18:05 2016
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sis.internal.netcdf;
+package org.apache.sis.internal.geotiff;
import java.net.URL;
import java.util.Locale;
@@ -25,7 +25,7 @@ import org.apache.sis.util.resources.Ind
/**
- * Warning and error messages that are specific to the {@code sis-netcdf} module.
+ * Warning and error messages that are specific to the {@code sis-geotiff} module.
* Resources in this file should not be used by any other module. For resources shared by
* all modules in the Apache SIS project, see {@link org.apache.sis.util.resources} package.
*
@@ -59,19 +59,10 @@ public final class Resources extends Ind
}
/**
- * Dimension \u201c{2}\u201d declared by attribute \u201c{1}\u201d is not found in the \u201c{0}\u201d file.
+ * Apache SIS implementation requires that all \u201c{0}\u201d elements have the same value, but the
+ * element found in \u201c{1}\u201d are {2}.
*/
- public static final short DimensionNotFound_3 = 0;
-
- /**
- * Variable \u201c{1}\u201d in file \u201c{0}\u201d has a dimension \u201c{3}\u201d while we expected \u201c{2}\u201d.
- */
- public static final short UnexpectedDimensionForVariable_4 = 1;
-
- /**
- * Variable \u201c{1}\u201d is not found in the \u201c{0}\u201d file.
- */
- public static final short VariableNotFound_2 = 2;
+ public static final short ConstantValueRequired_3 = 0;
}
/**
@@ -104,87 +95,4 @@ public final class Resources extends Ind
public static Resources forLocale(final Locale locale) throws MissingResourceException {
return getBundle(Resources.class, locale);
}
-
- /**
- * Gets a string for the given key from this resource bundle or one of its parents.
- *
- * @param key the key for the desired string.
- * @return the string for the given key.
- * @throws MissingResourceException if no object for the given key can be found.
- */
- public static String format(final short key) throws MissingResourceException {
- return forLocale(null).getString(key);
- }
-
- /**
- * Gets a string for the given key are replace all occurrence of "{0}"
- * with values of {@code arg0}.
- *
- * @param key the key for the desired string.
- * @param arg0 value to substitute to "{0}".
- * @return the formatted string for the given key.
- * @throws MissingResourceException if no object for the given key can be found.
- */
- public static String format(final short key,
- final Object arg0) throws MissingResourceException
- {
- return forLocale(null).getString(key, arg0);
- }
-
- /**
- * Gets a string for the given key are replace all occurrence of "{0}",
- * "{1}", with values of {@code arg0}, {@code arg1}.
- *
- * @param key the key for the desired string.
- * @param arg0 value to substitute to "{0}".
- * @param arg1 value to substitute to "{1}".
- * @return the formatted string for the given key.
- * @throws MissingResourceException if no object for the given key can be found.
- */
- public static String format(final short key,
- final Object arg0,
- final Object arg1) throws MissingResourceException
- {
- return forLocale(null).getString(key, arg0, arg1);
- }
-
- /**
- * Gets a string for the given key are replace all occurrence of "{0}",
- * "{1}", with values of {@code arg0}, {@code arg1}, etc.
- *
- * @param key the key for the desired string.
- * @param arg0 value to substitute to "{0}".
- * @param arg1 value to substitute to "{1}".
- * @param arg2 value to substitute to "{2}".
- * @return the formatted string for the given key.
- * @throws MissingResourceException if no object for the given key can be found.
- */
- public static String format(final short key,
- final Object arg0,
- final Object arg1,
- final Object arg2) throws MissingResourceException
- {
- return forLocale(null).getString(key, arg0, arg1, arg2);
- }
-
- /**
- * Gets a string for the given key are replace all occurrence of "{0}",
- * "{1}", with values of {@code arg0}, {@code arg1}, etc.
- *
- * @param key the key for the desired string.
- * @param arg0 value to substitute to "{0}".
- * @param arg1 value to substitute to "{1}".
- * @param arg2 value to substitute to "{2}".
- * @param arg3 value to substitute to "{3}".
- * @return the formatted string for the given key.
- * @throws MissingResourceException if no object for the given key can be found.
- */
- public static String format(final short key,
- final Object arg0,
- final Object arg1,
- final Object arg2,
- final Object arg3) throws MissingResourceException
- {
- return forLocale(null).getString(key, arg0, arg1, arg2, arg3);
- }
}
Copied: sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/Resources.properties (from r1763327, sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Resources.properties)
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/Resources.properties?p2=sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/Resources.properties&p1=sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Resources.properties&r1=1763327&r2=1763391&rev=1763391&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Resources.properties [ISO-8859-1] (original)
+++ sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/Resources.properties [ISO-8859-1] Wed Oct 5 10:18:05 2016
@@ -16,9 +16,7 @@
#
#
-# Resources in this file are for "sis-netcdf" usage only and should not be used by any other module.
+# Resources in this file are for "sis-geotiff" usage only and should not be used by any other module.
# For resources shared by all modules in the Apache SIS project, see "org.apache.sis.util.resources" package.
#
-DimensionNotFound_3 = Dimension \u201c{2}\u201d declared by attribute \u201c{1}\u201d is not found in the \u201c{0}\u201d file.
-UnexpectedDimensionForVariable_4 = Variable \u201c{1}\u201d in file \u201c{0}\u201d has a dimension \u201c{3}\u201d while we expected \u201c{2}\u201d.
-VariableNotFound_2 = Variable \u201c{1}\u201d is not found in the \u201c{0}\u201d file.
+ConstantValueRequired_3 = Apache SIS implementation requires that all \u201c{0}\u201d elements have the same value, but the element found in \u201c{1}\u201d are {2}.
Copied: sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/Resources_fr.properties (from r1763327, sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Resources_fr.properties)
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/Resources_fr.properties?p2=sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/Resources_fr.properties&p1=sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Resources_fr.properties&r1=1763327&r2=1763391&rev=1763391&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Resources_fr.properties [ISO-8859-1] (original)
+++ sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/Resources_fr.properties [ISO-8859-1] Wed Oct 5 10:18:05 2016
@@ -16,7 +16,7 @@
#
#
-# Resources in this file are for "sis-netcdf" usage only and should not be used by any other module.
+# Resources in this file are for "sis-geotiff" usage only and should not be used by any other module.
# For resources shared by all modules in the Apache SIS project, see "org.apache.sis.util.resources" package.
#
# Punctuation rules in French (source: http://unicode.org/udhr/n/notes_fra.html)
@@ -24,6 +24,4 @@
# U+202F NARROW NO-BREAK SPACE before ; ! and ?
# U+00A0 NO-BREAK SPACE before :
#
-DimensionNotFound_3 = La dimension \u00ab\u202f{2}\u202f\u00bb d\u00e9clar\u00e9e par l\u2019attribut \u00ab\u202f{1}\u202f\u00bb n\u2019a pas \u00e9t\u00e9 trouv\u00e9e dans le fichier \u00ab\u202f{0}\u202f\u00bb.
-UnexpectedDimensionForVariable_4 = La variable \u00ab\u202f{1}\u202f\u00bb dans le fichier \u00ab\u202f{0}\u202f\u00bb a une dimension \u00ab\u202f{3}\u202f\u00bb alors qu\u2019on attendait \u00ab\u202f{2}\u202f\u00bb.
-VariableNotFound_2 = La variable \u00ab\u202f{1}\u202f\u00bb n\u2019a pas \u00e9t\u00e9 trouv\u00e9e dans le fichier \u00ab\u202f{0}\u202f\u00bb.
+ConstantValueRequired_3 = L\u2019impl\u00e9mentation de Apache SIS requiert que tous les \u00e9l\u00e9ments de \u00ab\u202f{0}\u202f\u00bb aient la m\u00eame valeur, mais les \u00e9l\u00e9ments trouv\u00e9s dans \u00ab\u202f{1}\u202f\u00bb sont {2}.
Copied: sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/package-info.java (from r1763327, sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/package-info.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/package-info.java?p2=sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/package-info.java&p1=sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/package-info.java&r1=1763327&r2=1763391&rev=1763391&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/package-info.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/package-info.java [UTF-8] Wed Oct 5 10:18:05 2016
@@ -16,7 +16,7 @@
*/
/**
- * Utility classes for the implementation of SIS storage classes.
+ * Utility classes for the implementation of GeoTIFF reader and writer.
*
* <STRONG>Do not use!</STRONG>
*
@@ -24,8 +24,8 @@
* may change in incompatible ways in any future version without notice.
*
* @author Martin Desruisseaux (Geomatys)
- * @since 0.3
- * @version 0.3
+ * @since 0.8
+ * @version 0.8
* @module
*/
-package org.apache.sis.internal.storage;
+package org.apache.sis.internal.geotiff;
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=1763391&r1=1763390&r2=1763391&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] Wed Oct 5 10:18:05 2016
@@ -22,6 +22,7 @@ import java.io.Closeable;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import org.apache.sis.util.resources.Errors;
+import org.apache.sis.internal.geotiff.Resources;
/**
@@ -69,6 +70,13 @@ abstract class GeoTIFF implements Closea
}
/**
+ * Returns the GeoTIFF-specific resource for error messages and warnings.
+ */
+ final Resources resources() {
+ return Resources.forLocale(owner.getLocale());
+ }
+
+ /**
* Returns the object to use for parsing and formatting dates.
*/
final DateFormat getDateFormat() {
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=1763391&r1=1763390&r2=1763391&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] Wed Oct 5 10:18:05 2016
@@ -20,6 +20,9 @@ import java.util.Locale;
import java.io.IOException;
import java.text.ParseException;
import org.opengis.metadata.citation.DateType;
+import org.apache.sis.internal.geotiff.Resources;
+import org.apache.sis.storage.DataStoreException;
+import org.apache.sis.storage.DataStoreContentException;
import org.apache.sis.internal.storage.MetadataBuilder;
import org.apache.sis.math.Vector;
@@ -130,8 +133,11 @@ final class ImageFileDirectory {
* @throws ArithmeticException if the value can not be represented in the expected Java type.
* @throws IllegalArgumentException if a value which was expected to be a singleton is not.
* @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 Reader reader, final int tag, final Type type, final long count) throws IOException, ParseException {
+ Object addEntry(final Reader reader, final int tag, final Type type, final long count)
+ throws IOException, ParseException, DataStoreException
+ {
switch (tag) {
////////////////////////////////////////////////////////////////////////////////////////////////
@@ -225,8 +231,8 @@ final class ImageFileDirectory {
final int length = values.size();
for (int i = 1; i < length; i++) {
if (values.shortValue(i) != bitsPerSample) {
- throw new IllegalArgumentException("SIS GeoTiff image reader does not support "
- + "different BitsPerSample values. Found: " + values);
+ throw new DataStoreContentException(reader.resources().getString(
+ Resources.Keys.ConstantValueRequired_3, "BitsPerSample", reader.input.filename, values));
}
}
break;
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=1763391&r1=1763390&r2=1763391&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] Wed Oct 5 10:18:05 2016
@@ -304,7 +304,9 @@ final class Reader extends GeoTIFF {
* @param ignoreAfter offset relative to the beginning of TIFF file at which entries should be ignored.
* This hint does not apply to the IFD specified by the {@code dir} argument.
*/
- private void resolveDeferredEntries(final ImageFileDirectory dir, final long ignoreAfter) throws IOException {
+ private void resolveDeferredEntries(final ImageFileDirectory dir, final long ignoreAfter)
+ throws IOException, DataStoreException
+ {
if (deferredNeedsSort) {
deferredEntries.sort(null); // Sequential order in input stream.
deferredNeedsSort = false;