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 2022/04/21 16:55:27 UTC
[sis] 05/05: Move ASCII Grid store implementation to an "esri" package and rename as `AsciiGridStore`. This is in anticipation for the addition of other simple ESRI grid formats (BIL, BIP and BSQ).
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
commit 8f57f757212c78e064f12190f3516000240b5da6
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Thu Apr 21 18:52:35 2022 +0200
Move ASCII Grid store implementation to an "esri" package and rename as `AsciiGridStore`.
This is in anticipation for the addition of other simple ESRI grid formats (BIL, BIP and BSQ).
---
.../sis/internal/storage/ascii/package-info.java | 113 ---------------------
.../{ascii/Store.java => esri/AsciiGridStore.java} | 95 +++++++++++++++--
.../AsciiGridStoreProvider.java} | 36 +++----
.../storage/{ascii => esri}/CharactersView.java | 6 +-
.../storage/{ascii => esri}/WritableStore.java | 10 +-
.../sis/internal/storage/esri/package-info.java | 40 ++++++++
.../sis/internal/storage/image/package-info.java | 3 +
.../org.apache.sis.storage.DataStoreProvider | 2 +-
.../AsciiGridStoreTest.java} | 16 +--
.../storage/{ascii => esri}/WritableStoreTest.java | 2 +-
.../apache/sis/test/suite/StorageTestSuite.java | 4 +-
.../sis/internal/storage/{ascii => esri}/grid.asc | 0
.../sis/internal/storage/{ascii => esri}/grid.prj | 0
13 files changed, 167 insertions(+), 160 deletions(-)
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ascii/package-info.java b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ascii/package-info.java
deleted file mode 100644
index a4399ed435..0000000000
--- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ascii/package-info.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * {@link org.apache.sis.storage.DataStore} implementation for ESRI ASCII grid format.
- * This is a very simple format for reading and writing single-banded raster data.
- * As the "ASCII" name implies, files are text files in US-ASCII character encoding
- * no matter what the {@link org.apache.sis.setup.OptionKey#ENCODING} value is,
- * and numbers are parsed or formatted according the US locale no matter
- * what the {@link org.apache.sis.setup.OptionKey#LOCALE} value is.
- *
- * <p>ASCII grid files contains a header before the actual data.
- * The header contains (<var>key</var> <var>value</var>) pairs,
- * one pair per line and using spaces as separator between keys and values
- * (Apache SIS accepts also {@code '='} and {@code ':'} as separators).
- * The valid keys are listed in the table below
- * (note that some of them are extensions to the ESRI ASCII Grid format).</p>
- *
- * <table class="sis">
- * <caption>Recognized keywords in ASCII Grid header</caption>
- * <tr>
- * <th>Keyword</th>
- * <th>Value type</th>
- * <th>Obligation</th>
- * </tr>
- * <tr>
- * <td>{@code NCOLS}</td>
- * <td>{@link java.lang.Integer}</td>
- * <td>Mandatory</td>
- * </tr>
- * <tr>
- * <td>{@code NROWS}</td>
- * <td>{@link java.lang.Integer}</td>
- * <td>Mandatory</td>
- * </tr>
- * <tr>
- * <td>{@code XLLCORNER} or {@code XLLCENTER}</td>
- * <td>{@link java.lang.Double}</td>
- * <td>Mandatory</td>
- * </tr>
- * <tr>
- * <td>{@code YLLCORNER} or {@code YLLCENTER}</td>
- * <td>{@link java.lang.Double}</td>
- * <td>Mandatory</td>
- * </tr>
- * <tr>
- * <td>{@code CELLSIZE}</td>
- * <td>{@link java.lang.Double}</td>
- * <td>Mandatory, unless an alternative below is present</td>
- * </tr>
- * <tr>
- * <td>{@code XCELLSIZE} and {@code YCELLSIZE}</td>
- * <td>{@link java.lang.Double}</td>
- * <td>Non-standard alternative to {@code CELLSIZE}</td>
- * </tr>
- * <tr>
- * <td>{@code XDIM} and {@code YDIM}</td>
- * <td>{@link java.lang.Double}</td>
- * <td>Non-standard alternative to {@code CELLSIZE}</td>
- * </tr>
- * <tr>
- * <td>{@code DX} and {@code DY}</td>
- * <td>{@link java.lang.Double}</td>
- * <td>Non-standard alternative to {@code CELLSIZE}</td>
- * </tr>
- * <tr>
- * <td>{@code NODATA_VALUE}</td>
- * <td>{@link java.lang.Double}</td>
- * <td>Optional</td>
- * </tr>
- * </table>
- *
- * <h2>Extensions</h2>
- * The implementation in this package adds the following extensions
- * (some of them are taken from GDAL):
- *
- * <ul class="verbose">
- * <li>Coordinate reference system specified by auxiliary {@code *.prj} file.
- * If the format is WKT 1, the GDAL variant is used (that variant differs from
- * the OGC 01-009 standard in their interpretation of units of measurement).</li>
- * <li>{@code DX} and {@code DY} parameters in the header are used instead of {@code CELLSIZE}
- * if the pixels are non-square.</li>
- * <li>Lines in the header starting with {@code '#'} are ignored as comment lines.</li>
- * </ul>
- *
- * <h2>Limitations</h2>
- * Current implementation loads and caches the full image no matter the subregion or subsampling
- * specified to the {@code read(…)} method. The image is loaded by {@code getSampleDimensions()}
- * call too, because there is no other way to build a reliable sample dimension.
- * Even the data type can not be determined for sure without loading the full image.
- * Loading the full image is reasonable if ASCII Grid files contain only small images,
- * which is usually the case given how inefficient this format is.
- *
- * @author Martin Desruisseaux (Geomatys)
- * @version 1.2
- * @since 1.2
- * @module
- */
-package org.apache.sis.internal.storage.ascii;
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ascii/Store.java b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/esri/AsciiGridStore.java
similarity index 87%
rename from storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ascii/Store.java
rename to storage/sis-storage/src/main/java/org/apache/sis/internal/storage/esri/AsciiGridStore.java
index ead3dceeca..9fa01da1cc 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ascii/Store.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/esri/AsciiGridStore.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sis.internal.storage.ascii;
+package org.apache.sis.internal.storage.esri;
import java.util.Map;
import java.util.List;
@@ -55,10 +55,85 @@ import org.apache.sis.util.resources.Errors;
/**
- * A data store which creates grid coverages from an ESRI ASCII grid file.
+ * Data store implementation for ESRI ASCII grid format.
+ * This is a very simple format for reading and writing single-banded raster data.
+ * As the "ASCII" name implies, files are text files in US-ASCII character encoding
+ * no matter what the {@link org.apache.sis.setup.OptionKey#ENCODING} value is,
+ * and numbers are parsed or formatted according the US locale no matter
+ * what the {@link org.apache.sis.setup.OptionKey#LOCALE} value is.
+ *
+ * <p>ASCII grid files contains a header before the actual data.
* The header contains (<var>key</var> <var>value</var>) pairs,
* one pair per line and using spaces as separator between keys and values.
- * The package javadoc lists the recognized keywords.
+ * The valid keys are listed in the table below
+ * (note that some of them are extensions to the ESRI ASCII Grid format).</p>
+ *
+ * <table class="sis">
+ * <caption>Recognized keywords in ASCII Grid header</caption>
+ * <tr>
+ * <th>Keyword</th>
+ * <th>Value type</th>
+ * <th>Obligation</th>
+ * </tr>
+ * <tr>
+ * <td>{@code NCOLS}</td>
+ * <td>{@link java.lang.Integer}</td>
+ * <td>Mandatory</td>
+ * </tr>
+ * <tr>
+ * <td>{@code NROWS}</td>
+ * <td>{@link java.lang.Integer}</td>
+ * <td>Mandatory</td>
+ * </tr>
+ * <tr>
+ * <td>{@code XLLCORNER} or {@code XLLCENTER}</td>
+ * <td>{@link java.lang.Double}</td>
+ * <td>Mandatory</td>
+ * </tr>
+ * <tr>
+ * <td>{@code YLLCORNER} or {@code YLLCENTER}</td>
+ * <td>{@link java.lang.Double}</td>
+ * <td>Mandatory</td>
+ * </tr>
+ * <tr>
+ * <td>{@code CELLSIZE}</td>
+ * <td>{@link java.lang.Double}</td>
+ * <td>Mandatory, unless an alternative below is present</td>
+ * </tr>
+ * <tr>
+ * <td>{@code XCELLSIZE} and {@code YCELLSIZE}</td>
+ * <td>{@link java.lang.Double}</td>
+ * <td>Non-standard alternative to {@code CELLSIZE}</td>
+ * </tr>
+ * <tr>
+ * <td>{@code XDIM} and {@code YDIM}</td>
+ * <td>{@link java.lang.Double}</td>
+ * <td>Non-standard alternative to {@code CELLSIZE}</td>
+ * </tr>
+ * <tr>
+ * <td>{@code DX} and {@code DY}</td>
+ * <td>{@link java.lang.Double}</td>
+ * <td>Non-standard alternative to {@code CELLSIZE}</td>
+ * </tr>
+ * <tr>
+ * <td>{@code NODATA_VALUE}</td>
+ * <td>{@link java.lang.Double}</td>
+ * <td>Optional</td>
+ * </tr>
+ * </table>
+ *
+ * <h2>Extensions</h2>
+ * The implementation in this package adds the following extensions
+ * (some of them are taken from GDAL):
+ *
+ * <ul class="verbose">
+ * <li>Coordinate reference system specified by auxiliary {@code *.prj} file.
+ * If the format is WKT 1, the GDAL variant is used (that variant differs from
+ * the OGC 01-009 standard in their interpretation of units of measurement).</li>
+ * <li>{@code XCELLSIZE} and {@code YCELLSIZE} parameters in the header are used
+ * instead of {@code CELLSIZE} if the pixels are non-square.</li>
+ * <li>Lines in the header starting with {@code '#'} are ignored as comment lines.</li>
+ * </ul>
*
* <h2>Possible evolutions</h2>
* If we allow subclasses in a future version, we could add a {@code processHeader(Map)} method
@@ -70,13 +145,15 @@ import org.apache.sis.util.resources.Errors;
* specified to the {@code read(…)} method. The image is loaded by {@link #getSampleDimensions()}
* call too, because there is no other way to build a reliable sample dimension.
* Even the data type can not be determined for sure without loading the full image.
+ * Loading the full image is reasonable if ASCII Grid files contain only small images,
+ * which is usually the case given how inefficient this format is.
*
* @author Martin Desruisseaux (Geomatys)
* @version 1.2
* @since 1.2
* @module
*/
-class Store extends PRJDataStore implements GridCoverageResource {
+class AsciiGridStore extends PRJDataStore implements GridCoverageResource {
/**
* Keys of elements expected in the header. Must be in upper-case letters.
*/
@@ -161,13 +238,13 @@ class Store extends PRJDataStore implements GridCoverageResource {
* @param readOnly whether to fail if the channel can not be opened at least in read mode.
* @throws DataStoreException if an error occurred while opening the stream.
*/
- Store(final StoreProvider provider, final StorageConnector connector, final boolean readOnly)
+ AsciiGridStore(final AsciiGridStoreProvider provider, final StorageConnector connector, final boolean readOnly)
throws DataStoreException
{
super(provider, connector);
final ChannelDataInput channel;
if (readOnly) {
- channel = connector.commit(ChannelDataInput.class, StoreProvider.NAME);
+ channel = connector.commit(ChannelDataInput.class, AsciiGridStoreProvider.NAME);
} else {
channel = connector.getStorageAs(ChannelDataInput.class);
if (channel != null) {
@@ -334,7 +411,7 @@ cellsize: if (value != null) {
try {
builder.setPredefinedFormat("ASCGRD");
} catch (MetadataStoreException e) {
- builder.addFormatName(StoreProvider.NAME);
+ builder.addFormatName(AsciiGridStoreProvider.NAME);
listeners.warning(e);
}
builder.addEncoding(encoding, MetadataBuilder.Scope.METADATA);
@@ -342,7 +419,7 @@ cellsize: if (value != null) {
try {
builder.addExtent(gridGeometry.getEnvelope());
} catch (TransformException e) {
- throw new DataStoreReferencingException(getLocale(), StoreProvider.NAME, getDisplayName(), null).initCause(e);
+ throw new DataStoreReferencingException(getLocale(), AsciiGridStoreProvider.NAME, getDisplayName(), null).initCause(e);
}
/*
* Do not add the sample dimension, because in current version computing the sample dimension
@@ -524,7 +601,7 @@ cellsize: if (value != null) {
final CharactersView input() throws DataStoreException {
final CharactersView in = input;
if (in == null) {
- throw new DataStoreClosedException(getLocale(), StoreProvider.NAME, StandardOpenOption.READ);
+ throw new DataStoreClosedException(getLocale(), AsciiGridStoreProvider.NAME, StandardOpenOption.READ);
}
return in;
}
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ascii/StoreProvider.java b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/esri/AsciiGridStoreProvider.java
similarity index 76%
rename from storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ascii/StoreProvider.java
rename to storage/sis-storage/src/main/java/org/apache/sis/internal/storage/esri/AsciiGridStoreProvider.java
index 7e625150c9..de9151bb4b 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ascii/StoreProvider.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/esri/AsciiGridStoreProvider.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sis.internal.storage.ascii;
+package org.apache.sis.internal.storage.esri;
import java.util.Map;
import java.nio.ByteBuffer;
@@ -30,23 +30,23 @@ import org.apache.sis.internal.storage.PRJDataStore;
/**
- * The provider of {@link Store} instances.
- * Given a {@link StorageConnector} input, this class tries to instantiate an ESRI ASCII Grid {@code Store}.
+ * The provider of {@link AsciiGridStore} instances.
+ * Given a {@link StorageConnector} input, this class tries to instantiate an ESRI ASCII Grid {@code AsciiGridStore}.
*
* <h2>Thread safety</h2>
- * The same {@code StoreProvider} instance can be safely used by many threads without synchronization on
- * the part of the caller. However the {@link Store} instances created by this factory are not thread-safe.
+ * The same {@code AsciiGridStoreProvider} instance can be safely used by many threads without synchronization on
+ * the part of the caller. However the {@link AsciiGridStore} instances created by this factory are not thread-safe.
*
* @author Martin Desruisseaux (Geomatys)
* @version 1.2
* @since 1.2
* @module
*/
-@StoreMetadata(formatName = StoreProvider.NAME,
+@StoreMetadata(formatName = AsciiGridStoreProvider.NAME,
fileSuffixes = {"asc", "grd", "agr", "aig"},
capabilities = {Capability.READ, Capability.WRITE, Capability.CREATE},
resourceTypes = GridCoverageResource.class)
-public final class StoreProvider extends PRJDataStore.Provider {
+public final class AsciiGridStoreProvider extends PRJDataStore.Provider {
/**
* The format names for ESRI ASCII grid files.
*/
@@ -55,7 +55,7 @@ public final class StoreProvider extends PRJDataStore.Provider {
/**
* Creates a new provider.
*/
- public StoreProvider() {
+ public AsciiGridStoreProvider() {
}
/**
@@ -69,7 +69,7 @@ public final class StoreProvider extends PRJDataStore.Provider {
}
/**
- * Returns the MIME type if the given storage appears to be supported by ASCII Grid {@link Store}.
+ * Returns the MIME type if the given storage appears to be supported by ASCII Grid {@link AsciiGridStore}.
* A {@linkplain ProbeResult#isSupported() supported} status does not guarantee that reading
* or writing will succeed, only that there appears to be a reasonable chance of success
* based on a brief inspection of the file header.
@@ -97,15 +97,15 @@ public final class StoreProvider extends PRJDataStore.Provider {
final CharactersView view = new CharactersView(null, buffer);
try {
final Map<String, String> header = view.readHeader();
- if (header.containsKey(Store.NROWS) && header.containsKey(Store.NCOLS) &&
- (header.containsKey(Store.XLLCORNER) || header.containsKey(Store.XLLCENTER)) &&
- (header.containsKey(Store.YLLCORNER) || header.containsKey(Store.YLLCENTER)))
+ if (header.containsKey(AsciiGridStore.NROWS) && header.containsKey(AsciiGridStore.NCOLS) &&
+ (header.containsKey(AsciiGridStore.XLLCORNER) || header.containsKey(AsciiGridStore.XLLCENTER)) &&
+ (header.containsKey(AsciiGridStore.YLLCORNER) || header.containsKey(AsciiGridStore.YLLCENTER)))
{
-cellsize: if (!header.containsKey(Store.CELLSIZE)) {
+cellsize: if (!header.containsKey(AsciiGridStore.CELLSIZE)) {
int def = 0;
- for (int i=0; i < Store.CELLSIZES.length;) {
- if (header.containsKey(Store.CELLSIZES[i++])) def |= 1;
- if (header.containsKey(Store.CELLSIZES[i++])) def |= 2;
+ for (int i=0; i < AsciiGridStore.CELLSIZES.length;) {
+ if (header.containsKey(AsciiGridStore.CELLSIZES[i++])) def |= 1;
+ if (header.containsKey(AsciiGridStore.CELLSIZES[i++])) def |= 2;
if (def == 3) break cellsize;
}
return ProbeResult.UNSUPPORTED_STORAGE;
@@ -122,7 +122,7 @@ cellsize: if (!header.containsKey(Store.CELLSIZE)) {
}
/**
- * Returns a CSV {@link Store} implementation associated with this provider.
+ * Returns a CSV {@link AsciiGridStore} implementation associated with this provider.
*
* @param connector information about the storage (URL, stream, <i>etc</i>).
* @return a data store implementation associated with this provider for the given storage.
@@ -133,7 +133,7 @@ cellsize: if (!header.containsKey(Store.CELLSIZE)) {
if (isWritable(connector)) {
return new WritableStore(this, connector);
} else {
- return new Store(this, connector, true);
+ return new AsciiGridStore(this, connector, true);
}
}
}
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ascii/CharactersView.java b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/esri/CharactersView.java
similarity index 97%
rename from storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ascii/CharactersView.java
rename to storage/sis-storage/src/main/java/org/apache/sis/internal/storage/esri/CharactersView.java
index 47851621c2..4ccc6fb392 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ascii/CharactersView.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/esri/CharactersView.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sis.internal.storage.ascii;
+package org.apache.sis.internal.storage.esri;
import java.util.Map;
import java.util.HashMap;
@@ -48,8 +48,8 @@ final class CharactersView implements CharSequence {
/**
* The object to use for reading data, or {@code null} if unavailable.
- * This is null during {@linkplain StoreProvider#probeContent probe} operation.
- * Shall never be null when this instance is the {@link Store#input} instance.
+ * This is null during {@linkplain AsciiGridStoreProvider#probeContent probe} operation.
+ * Shall never be null when this instance is the {@link AsciiGridStore#input} instance.
*/
final ChannelDataInput input;
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ascii/WritableStore.java b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/esri/WritableStore.java
similarity index 96%
rename from storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ascii/WritableStore.java
rename to storage/sis-storage/src/main/java/org/apache/sis/internal/storage/esri/WritableStore.java
index e2085e7241..2ee47ae26e 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ascii/WritableStore.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/esri/WritableStore.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sis.internal.storage.ascii;
+package org.apache.sis.internal.storage.esri;
import java.util.Map;
import java.util.LinkedHashMap;
@@ -51,7 +51,7 @@ import org.apache.sis.util.StringBuilders;
* @since 1.2
* @module
*/
-final class WritableStore extends Store implements WritableGridCoverageResource {
+final class WritableStore extends AsciiGridStore implements WritableGridCoverageResource {
/**
* The line separator for writing the ASCII file.
*/
@@ -70,11 +70,11 @@ final class WritableStore extends Store implements WritableGridCoverageResource
* @param connector information about the storage (URL, stream, <i>etc</i>).
* @throws DataStoreException if an error occurred while opening the stream.
*/
- public WritableStore(final StoreProvider provider, final StorageConnector connector) throws DataStoreException {
+ public WritableStore(final AsciiGridStoreProvider provider, final StorageConnector connector) throws DataStoreException {
super(provider, connector, false);
lineSeparator = System.lineSeparator();
if (!super.canReadOrWrite(false)) {
- output = connector.commit(ChannelDataOutput.class, StoreProvider.NAME);
+ output = connector.commit(ChannelDataOutput.class, AsciiGridStoreProvider.NAME);
}
}
@@ -132,7 +132,7 @@ final class WritableStore extends Store implements WritableGridCoverageResource
}
final AffineTransform at = h.getAffineTransform2D(gg.getExtent(), gridToCRS);
if (at.getShearX() != 0 || at.getShearY() != 0) {
- throw new IncompatibleResourceException(h.rotationNotSupported(StoreProvider.NAME));
+ throw new IncompatibleResourceException(h.rotationNotSupported(AsciiGridStoreProvider.NAME));
}
double scaleX = at.getScaleX();
double scaleY = -at.getScaleY();
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/esri/package-info.java b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/esri/package-info.java
new file mode 100644
index 0000000000..c32a629d97
--- /dev/null
+++ b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/esri/package-info.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Simple data store implementations for some ESRI grid formats (ASCII and binary).
+ * The data formats supported by this package are relatively simple.
+ * Values are stored either in plain ASCII text or in RAW binary encoding (without compression).
+ *
+ * <h2>Extensions</h2>
+ * The implementation in this package adds the following extensions
+ * (some of them are taken from GDAL):
+ *
+ * <ul class="verbose">
+ * <li>Coordinate reference system specified by auxiliary {@code *.prj} file.
+ * If the format is WKT 1, the GDAL variant is used (that variant differs from
+ * the OGC 01-009 standard in their interpretation of units of measurement).</li>
+ * <li>ASCII Grid reader accepts also some metadata defined for the binary formats
+ * ({@code XDIM}, {@code YDIM}, color file, statistics file, <i>etc.</i>).</li>
+ * </ul>
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ * @version 1.2
+ * @since 1.2
+ * @module
+ */
+package org.apache.sis.internal.storage.esri;
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/image/package-info.java b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/image/package-info.java
index de642ab341..d5768d82dd 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/image/package-info.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/image/package-info.java
@@ -36,6 +36,9 @@
* because image indices are no longer stable identifiers in such case.</li>
* </ul>
*
+ * <p><b>TODO:</b> avoid extending internal classes directly,
+ * then move in a public package with {@code imageio} package name.</p>
+ *
* @author Martin Desruisseaux (Geomatys)
* @version 1.2
*
diff --git a/storage/sis-storage/src/main/resources/META-INF/services/org.apache.sis.storage.DataStoreProvider b/storage/sis-storage/src/main/resources/META-INF/services/org.apache.sis.storage.DataStoreProvider
index e907801595..c240859b32 100644
--- a/storage/sis-storage/src/main/resources/META-INF/services/org.apache.sis.storage.DataStoreProvider
+++ b/storage/sis-storage/src/main/resources/META-INF/services/org.apache.sis.storage.DataStoreProvider
@@ -1,5 +1,5 @@
org.apache.sis.internal.storage.image.WorldFileStoreProvider
-org.apache.sis.internal.storage.ascii.StoreProvider
+org.apache.sis.internal.storage.esri.AsciiGridStoreProvider
org.apache.sis.internal.storage.csv.StoreProvider
org.apache.sis.internal.storage.xml.StoreProvider
org.apache.sis.internal.storage.wkt.StoreProvider
diff --git a/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ascii/StoreTest.java b/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/esri/AsciiGridStoreTest.java
similarity index 90%
rename from storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ascii/StoreTest.java
rename to storage/sis-storage/src/test/java/org/apache/sis/internal/storage/esri/AsciiGridStoreTest.java
index 5e253e7617..ee5d64bd2a 100644
--- a/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ascii/StoreTest.java
+++ b/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/esri/AsciiGridStoreTest.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sis.internal.storage.ascii;
+package org.apache.sis.internal.storage.esri;
import java.util.List;
import java.awt.image.Raster;
@@ -35,29 +35,29 @@ import static org.apache.sis.test.TestUtilities.getSingleton;
/**
- * Tests {@link Store} and {@link StoreProvider}.
+ * Tests {@link AsciiGridStore} and {@link AsciiGridStoreProvider}.
*
* @author Martin Desruisseaux (Geomatys)
* @version 1.2
* @since 1.2
* @module
*/
-public final strictfp class StoreTest extends TestCase {
+public final strictfp class AsciiGridStoreTest extends TestCase {
/**
* Returns a storage connector with the URL to the test data.
*/
private static StorageConnector testData() {
- return new StorageConnector(StoreTest.class.getResource("grid.asc"));
+ return new StorageConnector(AsciiGridStoreTest.class.getResource("grid.asc"));
}
/**
- * Tests {@link StoreProvider#probeContent(StorageConnector)} method.
+ * Tests {@link AsciiGridStoreProvider#probeContent(StorageConnector)} method.
*
* @throws DataStoreException if en error occurred while reading the CSV file.
*/
@Test
public void testProbeContent() throws DataStoreException {
- final StoreProvider p = new StoreProvider();
+ final AsciiGridStoreProvider p = new AsciiGridStoreProvider();
final ProbeResult r = p.probeContent(testData());
assertTrue(r.isSupported());
assertEquals("text/plain", r.getMimeType());
@@ -72,7 +72,7 @@ public final strictfp class StoreTest extends TestCase {
*/
@Test
public void testMetadata() throws DataStoreException {
- try (Store store = new Store(null, testData(), true)) {
+ try (AsciiGridStore store = new AsciiGridStore(null, testData(), true)) {
assertEquals("grid", store.getIdentifier().get().toString());
final Metadata metadata = store.getMetadata();
/*
@@ -105,7 +105,7 @@ public final strictfp class StoreTest extends TestCase {
*/
@Test
public void testRead() throws DataStoreException {
- try (Store store = new Store(null, testData(), true)) {
+ try (AsciiGridStore store = new AsciiGridStore(null, testData(), true)) {
final List<Category> categories = getSingleton(store.getSampleDimensions()).getCategories();
assertEquals(2, categories.size());
assertEquals( -2, categories.get(0).getSampleRange().getMinDouble(), 1);
diff --git a/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ascii/WritableStoreTest.java b/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/esri/WritableStoreTest.java
similarity index 99%
rename from storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ascii/WritableStoreTest.java
rename to storage/sis-storage/src/test/java/org/apache/sis/internal/storage/esri/WritableStoreTest.java
index 36e68ebd66..a589191d3d 100644
--- a/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ascii/WritableStoreTest.java
+++ b/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/esri/WritableStoreTest.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sis.internal.storage.ascii;
+package org.apache.sis.internal.storage.esri;
import java.nio.file.Path;
import java.nio.file.Files;
diff --git a/storage/sis-storage/src/test/java/org/apache/sis/test/suite/StorageTestSuite.java b/storage/sis-storage/src/test/java/org/apache/sis/test/suite/StorageTestSuite.java
index 1bdf997a3f..2a5e64104e 100644
--- a/storage/sis-storage/src/test/java/org/apache/sis/test/suite/StorageTestSuite.java
+++ b/storage/sis-storage/src/test/java/org/apache/sis/test/suite/StorageTestSuite.java
@@ -59,8 +59,8 @@ import org.junit.BeforeClass;
org.apache.sis.internal.storage.csv.StoreTest.class,
org.apache.sis.internal.storage.image.WorldFileStoreTest.class,
org.apache.sis.internal.storage.image.SelfConsistencyTest.class,
- org.apache.sis.internal.storage.ascii.StoreTest.class,
- org.apache.sis.internal.storage.ascii.WritableStoreTest.class,
+ org.apache.sis.internal.storage.esri.AsciiGridStoreTest.class,
+ org.apache.sis.internal.storage.esri.WritableStoreTest.class,
org.apache.sis.internal.storage.folder.StoreTest.class,
org.apache.sis.internal.storage.JoinFeatureSetTest.class,
org.apache.sis.internal.storage.ConcatenatedFeatureSetTest.class,
diff --git a/storage/sis-storage/src/test/resources/org/apache/sis/internal/storage/ascii/grid.asc b/storage/sis-storage/src/test/resources/org/apache/sis/internal/storage/esri/grid.asc
similarity index 100%
rename from storage/sis-storage/src/test/resources/org/apache/sis/internal/storage/ascii/grid.asc
rename to storage/sis-storage/src/test/resources/org/apache/sis/internal/storage/esri/grid.asc
diff --git a/storage/sis-storage/src/test/resources/org/apache/sis/internal/storage/ascii/grid.prj b/storage/sis-storage/src/test/resources/org/apache/sis/internal/storage/esri/grid.prj
similarity index 100%
rename from storage/sis-storage/src/test/resources/org/apache/sis/internal/storage/ascii/grid.prj
rename to storage/sis-storage/src/test/resources/org/apache/sis/internal/storage/esri/grid.prj