This is an automated email from the ASF dual-hosted git repository.
desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git
The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
new 5aa4b67d01 Rename `GeoTiffOption` as `FormatModifier`.
5aa4b67d01 is described below
commit 5aa4b67d012625cd29b7573b3522693bdc5af987
Author: Martin Desruisseaux <[email protected]>
AuthorDate: Mon Oct 30 23:03:48 2023 +0100
Rename `GeoTiffOption` as `FormatModifier`.
---
.../apache/sis/storage/geotiff/Compression.java | 1 +
.../{GeoTiffOption.java => FormatModifier.java} | 39 +++++++++++++---------
.../apache/sis/storage/geotiff/GeoTiffStore.java | 18 +++++-----
.../sis/storage/geotiff/GeoTiffStoreProvider.java | 8 ++---
.../org/apache/sis/storage/geotiff/IOBase.java | 6 ++--
.../org/apache/sis/storage/geotiff/Reader.java | 6 ++--
.../org/apache/sis/storage/geotiff/Writer.java | 12 +++----
.../org/apache/sis/storage/geotiff/WriterTest.java | 28 ++++++++--------
8 files changed, 63 insertions(+), 55 deletions(-)
diff --git
a/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/Compression.java
b/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/Compression.java
index 51532f6ffa..24470c5d13 100644
---
a/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/Compression.java
+++
b/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/Compression.java
@@ -41,6 +41,7 @@ import org.apache.sis.util.ArgumentChecks;
* try (GeoTiffStore ds = new GeoTiffStore(null, connector)) {
* // Write data here.
* }
+ * }
*
* @author Martin Desruisseaux (Geomatys)
* @version 1.5
diff --git
a/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/GeoTiffOption.java
b/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/FormatModifier.java
similarity index 52%
rename from
endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/GeoTiffOption.java
rename to
endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/FormatModifier.java
index 9d74388a74..dc3aafcafa 100644
---
a/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/GeoTiffOption.java
+++
b/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/FormatModifier.java
@@ -17,27 +17,40 @@
package org.apache.sis.storage.geotiff;
import org.apache.sis.setup.OptionKey;
+import org.apache.sis.storage.StorageConnector;
import org.apache.sis.io.stream.InternalOptionKey;
/**
* Characteristics of the GeoTIFF file to write.
- * The options can control, for example, the maximal size and number of images
that can be stored in a TIFF file.
- * See {@link #OPTION_KEY} for an usage example.
+ * The modifiers can control, for example, the maximal size and number of
images that can be stored in a TIFF file.
+ *
+ * <p>The modifiers can be specified as an option when opening the data store.
+ * For example for writing a BigTIFF file, the following code can be used:</p>
+ *
+ * {@snippet lang="java" :
+ * var file = Path.of("my_output_file.tiff");
+ * var connector = new StorageConnector(file);
+ * var modifiers = new FormatModifier[] {FormatModifier.BIG_TIFF};
+ * connector.setOption(FormatModifier.OPTION_KEY, modifiers);
+ * try (GeoTiffStore ds = new GeoTiffStore(null, connector)) {
+ * // Write data here.
+ * }
+ * }
*
* @author Martin Desruisseaux (Geomatys)
* @version 1.5
*
- * @see GeoTiffStore#getOptions()
+ * @see GeoTiffStore#getModifiers()
*
* @since 1.5
*/
-public enum GeoTiffOption {
+public enum FormatModifier {
/**
* The Big TIFF extension (non-standard).
- * When this option is absent (which is the default), the standard TIFF
format as defined by Adobe is used.
+ * When this modifier is absent (which is the default), the standard TIFF
format as defined by Adobe is used.
* That standard uses the addressable space of 32-bits integers, which
allows a maximal file size of about 4 GB.
- * When the {@code BIG_TIFF} option is present, the addressable space of
64-bits integers is used.
+ * When the {@code BIG_TIFF} modifier is present, the addressable space of
64-bits integers is used.
* The BigTIFF format is non-standard and files written with this option
may not be read by all TIFF readers.
*/
BIG_TIFF;
@@ -45,16 +58,10 @@ public enum GeoTiffOption {
// TODO: COG, SPARSE.
/**
- * The key for declaring GeoTIFF options at store creation time.
- * For writing a BigTIFF file, the following code can be used:
+ * The key for declaring GeoTIFF format modifiers at store creation time.
+ * See class Javadoc for usage example.
*
- * {@snippet lang="java" :
- * var file = Path.of("my_output_file.tiff");
- * var connector = new StorageConnector(file);
- * var options = new GeoTiffOption[] {GeoTiffOption.BIG_TIFF};
- * connector.setOption(GeoTiffOption.OPTION_KEY, options);
- * DataStore ds = DataStores.open(c);
- * }
+ * @see StorageConnector#setOption(OptionKey, Object)
*/
- public static final OptionKey<GeoTiffOption[]> OPTION_KEY = new
InternalOptionKey<>("TIFF_OPTIONS", GeoTiffOption[].class);
+ public static final OptionKey<FormatModifier[]> OPTION_KEY = new
InternalOptionKey<>("TIFF_MODIFIERS", FormatModifier[].class);
}
diff --git
a/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/GeoTiffStore.java
b/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/GeoTiffStore.java
index 5385f1406f..e075cc7100 100644
---
a/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/GeoTiffStore.java
+++
b/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/GeoTiffStore.java
@@ -253,7 +253,7 @@ public class GeoTiffStore extends DataStore implements
Aggregate {
try {
if (URIDataStore.Provider.isWritable(connector, true)) {
ChannelDataOutput output =
connector.commit(ChannelDataOutput.class, Constants.GEOTIFF);
- writer = new Writer(this, output,
connector.getOption(GeoTiffOption.OPTION_KEY));
+ writer = new Writer(this, output,
connector.getOption(FormatModifier.OPTION_KEY));
} else {
ChannelDataInput input =
connector.commit(ChannelDataInput.class, Constants.GEOTIFF);
reader = new Reader(this, input);
@@ -264,15 +264,15 @@ public class GeoTiffStore extends DataStore implements
Aggregate {
}
/**
- * Returns the options (BigTIFF, COG…) of this data store.
+ * Returns the modifiers (BigTIFF, COG…) of this data store.
*
- * @return options of this data store.
+ * @return format modifiers of this data store.
*
* @since 1.5
*/
- public Set<GeoTiffOption> getOptions() {
- final Writer w = writer; if (w != null) return w.getOptions();
- final Reader r = reader; if (r != null) return r.getOptions();
+ public Set<FormatModifier> getModifiers() {
+ final Writer w = writer; if (w != null) return w.getModifiers();
+ final Reader r = reader; if (r != null) return r.getModifiers();
return Set.of();
}
@@ -325,9 +325,9 @@ public class GeoTiffStore extends DataStore implements
Aggregate {
if (param != null) {
final Writer w = writer;
if (w != null) {
- final Set<GeoTiffOption> options = w.getOptions();
- if (!options.isEmpty()) {
-
param.parameter(GeoTiffStoreProvider.OPTIONS).setValue(options.toArray(GeoTiffOption[]::new));
+ final Set<FormatModifier> modifiers = w.getModifiers();
+ if (!modifiers.isEmpty()) {
+
param.parameter(GeoTiffStoreProvider.MODIFIERS).setValue(modifiers.toArray(FormatModifier[]::new));
}
if (compression != null) {
param.parameter(GeoTiffStoreProvider.COMPRESSION).setValue(compression);
diff --git
a/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/GeoTiffStoreProvider.java
b/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/GeoTiffStoreProvider.java
index 409faf5e23..e8fa8bb3bc 100644
---
a/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/GeoTiffStoreProvider.java
+++
b/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/GeoTiffStoreProvider.java
@@ -74,9 +74,9 @@ public class GeoTiffStoreProvider extends DataStoreProvider {
private static final Logger LOGGER =
Logger.getLogger("org.apache.sis.storage.geotiff");
/**
- * Name of the parameter for specifying the options (BigTIFF, COG…).
+ * Name of the parameter for specifying the format modifiers (BigTIFF,
COG…).
*/
- static final String OPTIONS = "options";
+ static final String MODIFIERS = "modifiers";
/**
* Name of the parameter for specifying the compression.
@@ -89,9 +89,9 @@ public class GeoTiffStoreProvider extends DataStoreProvider {
private static final ParameterDescriptorGroup OPEN_DESCRIPTOR;
static {
final var builder = new ParameterBuilder();
- final var options =
builder.addName(OPTIONS).setDescription(Vocabulary.formatInternational(Vocabulary.Keys.Options)).create(GeoTiffOption[].class,
null);
+ final var modifiers =
builder.addName(MODIFIERS).setDescription(Vocabulary.formatInternational(Vocabulary.Keys.Options)).create(FormatModifier[].class,
null);
final var compression =
builder.addName(COMPRESSION).setDescription(Vocabulary.formatInternational(Vocabulary.Keys.Compression)).create(Compression.class,
null);
- OPEN_DESCRIPTOR =
builder.addName(Constants.GEOTIFF).createGroup(URIDataStore.Provider.LOCATION_PARAM,
options, compression);
+ OPEN_DESCRIPTOR =
builder.addName(Constants.GEOTIFF).createGroup(URIDataStore.Provider.LOCATION_PARAM,
modifiers, compression);
}
/**
diff --git
a/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/IOBase.java
b/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/IOBase.java
index 49d611cccd..5be75f0bcd 100644
---
a/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/IOBase.java
+++
b/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/IOBase.java
@@ -59,11 +59,11 @@ abstract class IOBase implements Closeable {
}
/**
- * {@return the options (BigTIFF, COG…) used by this reader or writer}.
+ * {@return the modifiers (BigTIFF, COG…) used by this reader or writer}.
*
- * @see GeoTiffStore#getOptions()
+ * @see GeoTiffStore#getModifiers()
*/
- public abstract Set<GeoTiffOption> getOptions();
+ public abstract Set<FormatModifier> getModifiers();
/**
* {@return the resources to use for formatting error messages}.
diff --git
a/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/Reader.java
b/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/Reader.java
index 3dda195317..cbc96163e9 100644
---
a/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/Reader.java
+++
b/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/Reader.java
@@ -197,11 +197,11 @@ final class Reader extends IOBase {
}
/**
- * {@return the options (BigTIFF, COG…) used by this reader}.
+ * {@return the modifiers (BigTIFF, COG…) used by this reader}.
*/
@Override
- public final Set<GeoTiffOption> getOptions() {
- return (intSizeExpansion != 0) ? Set.of(GeoTiffOption.BIG_TIFF) :
Set.of();
+ public final Set<FormatModifier> getModifiers() {
+ return (intSizeExpansion != 0) ? Set.of(FormatModifier.BIG_TIFF) :
Set.of();
}
/**
diff --git
a/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/Writer.java
b/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/Writer.java
index f760802872..09caad5b16 100644
---
a/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/Writer.java
+++
b/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/Writer.java
@@ -166,15 +166,15 @@ final class Writer extends IOBase implements Flushable {
*
* @param store the store writing data.
* @param output where to write the bytes.
- * @param options the options (BigTIFF, COG…), or {@code null} if none.
+ * @param options the format modifiers (BigTIFF, COG…), or {@code null}
if none.
* @throws IOException if an error occurred while writing the first bytes
to the stream.
*/
- Writer(final GeoTiffStore store, final ChannelDataOutput output, final
GeoTiffOption[] options)
+ Writer(final GeoTiffStore store, final ChannelDataOutput output, final
FormatModifier[] options)
throws IOException, DataStoreException
{
super(store);
this.output = output;
- isBigTIFF = ArraysExt.contains(options, GeoTiffOption.BIG_TIFF);
+ isBigTIFF = ArraysExt.contains(options, FormatModifier.BIG_TIFF);
/*
* Write the TIFF file header before first IFD. Stream position matter
and must start at zero.
* Note that it does not necessarily mean that the stream has no bytes
before current position.
@@ -233,11 +233,11 @@ final class Writer extends IOBase implements Flushable {
}
/**
- * {@return the options (BigTIFF, COG…) used by this writer}.
+ * {@return the modifiers (BigTIFF, COG…) used by this writer}.
*/
@Override
- public final Set<GeoTiffOption> getOptions() {
- return isBigTIFF ? Set.of(GeoTiffOption.BIG_TIFF) : Set.of();
+ public final Set<FormatModifier> getModifiers() {
+ return isBigTIFF ? Set.of(FormatModifier.BIG_TIFF) : Set.of();
}
/**
diff --git
a/endorsed/src/org.apache.sis.storage.geotiff/test/org/apache/sis/storage/geotiff/WriterTest.java
b/endorsed/src/org.apache.sis.storage.geotiff/test/org/apache/sis/storage/geotiff/WriterTest.java
index e0d6c2ec74..663557865c 100644
---
a/endorsed/src/org.apache.sis.storage.geotiff/test/org/apache/sis/storage/geotiff/WriterTest.java
+++
b/endorsed/src/org.apache.sis.storage.geotiff/test/org/apache/sis/storage/geotiff/WriterTest.java
@@ -125,7 +125,7 @@ public final class WriterTest extends TestCase {
* @throws DataStoreException should never happen since we control the
output class.
*/
private void initialize(final DataType type, final ByteOrder order, final
boolean banded, final int numBands,
- final int numTileX, final int numTileY, final
GeoTiffOption... options)
+ final int numTileX, final int numTileY, final
FormatModifier... options)
throws IOException, DataStoreException
{
final var random = TestUtilities.createRandomNumberGenerator();
@@ -145,7 +145,7 @@ public final class WriterTest extends TestCase {
output = new ByteArrayChannel(new byte[image.getWidth() *
image.getHeight() * numBands * type.bytes() + 800], false);
var d = new ChannelDataOutput("TIFF", output,
ByteBuffer.allocate(random.nextInt(128) + 20).order(order));
var c = new StorageConnector(d);
- c.setOption(GeoTiffOption.OPTION_KEY, options);
+ c.setOption(FormatModifier.OPTION_KEY, options);
c.setOption(Compression.OPTION_KEY, Compression.NONE);
store = new GeoTiffStore(null, c);
data = output.toBuffer().order(order);
@@ -199,7 +199,7 @@ public final class WriterTest extends TestCase {
*/
@Test
public void testUntiledBigTIFF() throws IOException, DataStoreException {
- initialize(DataType.BYTE, ByteOrder.LITTLE_ENDIAN, false, 1, 1, 1,
GeoTiffOption.BIG_TIFF);
+ initialize(DataType.BYTE, ByteOrder.LITTLE_ENDIAN, false, 1, 1, 1,
FormatModifier.BIG_TIFF);
writeImage();
verifyHeader(true, IOBase.LITTLE_ENDIAN);
verifyImageFileDirectory(Writer.MINIMAL_NUMBER_OF_TAGS,
PHOTOMETRIC_INTERPRETATION_BLACK_IS_ZERO,
@@ -272,17 +272,17 @@ public final class WriterTest extends TestCase {
@SuppressWarnings("LocalVariableHidesMemberVariable")
final ByteBuffer data = this.data;
if (isBigTIFF) {
- assertEquals(Set.of(GeoTiffOption.BIG_TIFF), store.getOptions());
- assertEquals(endianness, data.getShort());
- assertEquals(Writer.BIG_TIFF, data.getShort());
- assertEquals(Long.BYTES, data.getShort());
// Byte size of offsets.
- assertEquals(0, data.getShort());
// Constant.
- assertEquals(data.position() + Long.BYTES, data.getLong());
// Offset of the first IFD.
+ assertEquals(Set.of(FormatModifier.BIG_TIFF),
store.getModifiers());
+ assertEquals(endianness, data.getShort());
+ assertEquals(Writer.BIG_TIFF, data.getShort());
+ assertEquals(Long.BYTES, data.getShort());
// Byte size of offsets.
+ assertEquals(0, data.getShort());
// Constant.
+ assertEquals(data.position() + Long.BYTES, data.getLong());
// Offset of the first IFD.
} else {
- assertEquals(Set.of(), store.getOptions());
- assertEquals(endianness, data.getShort());
- assertEquals(Writer.CLASSIC, data.getShort());
- assertEquals(data.position() + Integer.BYTES, data.getInt());
// Offset of the first IFD.
+ assertEquals(Set.of(),
store.getModifiers());
+ assertEquals(endianness, data.getShort());
+ assertEquals(Writer.CLASSIC, data.getShort());
+ assertEquals(data.position() + Integer.BYTES, data.getInt());
// Offset of the first IFD.
}
}
@@ -308,7 +308,7 @@ public final class WriterTest extends TestCase {
@SuppressWarnings("LocalVariableHidesMemberVariable")
final ByteBuffer data = this.data;
final boolean isTiled = true;
- final boolean isBigTIFF =
store.getOptions().contains(GeoTiffOption.BIG_TIFF);
+ final boolean isBigTIFF =
store.getModifiers().contains(FormatModifier.BIG_TIFF);
final boolean isBigEndian = ByteOrder.BIG_ENDIAN.equals(data.order());
assertEquals(tagCount, isBigTIFF ? data.getLong() : data.getShort());
/*