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 cdaefbb20776bf9aff82f3d0fe94c893763413f4 Author: Martin Desruisseaux <martin.desruisse...@geomatys.com> AuthorDate: Sat Aug 14 11:46:52 2021 +0200 Support a few tags from TIFF Section 12: Document Storage and Retrieval. --- .../org/apache/sis/util/resources/Vocabulary.java | 10 ++++ .../sis/util/resources/Vocabulary.properties | 2 + .../sis/util/resources/Vocabulary_fr.properties | 2 + .../sis/storage/geotiff/ImageFileDirectory.java | 34 +++++++++++ .../sis/internal/storage/MetadataBuilder.java | 69 ++++++++++++++++++++++ 5 files changed, 117 insertions(+) diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java b/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java index 917329c..604e834 100644 --- a/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java +++ b/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java @@ -945,6 +945,16 @@ public final class Vocabulary extends IndexedResourceBundle { public static final short Others = 157; /** + * Page {0} + */ + public static final short Page_1 = 254; + + /** + * Page {0} of {1} + */ + public static final short Page_2 = 255; + + /** * {0} ({1}) */ public static final short Parenthesis_2 = 158; diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties b/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties index 92e79d2..54cf640 100644 --- a/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties +++ b/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties @@ -192,6 +192,8 @@ Origin = Origin OriginInCellCenter = Origin in a cell center Others = Others OtherSurface = Other surface +Page_1 = Page {0} +Page_2 = Page {0} of {1} Parenthesis_2 = {0} ({1}) Paths = Paths Plugins = Plug-ins diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties b/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties index d4a7abc..b97822a 100644 --- a/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties +++ b/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties @@ -199,6 +199,8 @@ Origin = Origine OriginInCellCenter = Origine au centre d\u2019une cellule Others = Autres OtherSurface = Autre surface +Page_1 = Page {0} +Page_2 = Page {0} de {1} Parenthesis_2 = {0} ({1}) Paths = Chemins Plugins = Modules d\u2019extension diff --git a/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/ImageFileDirectory.java b/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/ImageFileDirectory.java index c469dea..3acf5fa 100644 --- a/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/ImageFileDirectory.java +++ b/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/ImageFileDirectory.java @@ -812,6 +812,40 @@ final class ImageFileDirectory extends DataCube { //////////////////////////////////////////////////////////////////////////////////////////////// /* + * The name of the document from which this image was scanned. + */ + case Tags.DocumentName: { + for (final String value : type.readString(input(), count, encoding())) { + reader.metadata.addSeries(value); + } + break; + } + /* + * The name of the page from which this image was scanned. + */ + case Tags.PageName: { + for (final String value : type.readString(input(), count, encoding())) { + reader.metadata.addPage(value); + } + break; + } + /* + * The page number of the page from which this image was scanned. + * Should be a vector of length 2 containing the page number and + * the total number of pages (with 0 meaning unavailable). + */ + case Tags.PageNumber: { + final Vector v = type.readVector(input(), count); + int p = 0, n = 0; + switch (v.size()) { + default: n = v.intValue(1); // Fall through + case 1: p = v.intValue(0); + case 0: break; + } + reader.metadata.addPage(p, n); + break; + } + /* * A string that describes the subject of the image. * For example, a user may wish to attach a comment such as "1988 company picnic" to an image. */ diff --git a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MetadataBuilder.java b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MetadataBuilder.java index 51a60d9..6e3a924 100644 --- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MetadataBuilder.java +++ b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MetadataBuilder.java @@ -96,6 +96,7 @@ import org.apache.sis.metadata.iso.content.DefaultImageDescription; import org.apache.sis.metadata.iso.content.DefaultFeatureTypeInfo; import org.apache.sis.metadata.iso.citation.Citations; import org.apache.sis.metadata.iso.citation.AbstractParty; +import org.apache.sis.metadata.iso.citation.DefaultSeries; import org.apache.sis.metadata.iso.citation.DefaultCitation; import org.apache.sis.metadata.iso.citation.DefaultCitationDate; import org.apache.sis.metadata.iso.citation.DefaultResponsibility; @@ -128,6 +129,7 @@ import org.apache.sis.coverage.grid.GridExtent; import org.apache.sis.coverage.SampleDimension; import org.apache.sis.internal.util.Numerics; import org.apache.sis.internal.util.Strings; +import org.apache.sis.util.resources.Vocabulary; import org.apache.sis.util.ArgumentChecks; import org.apache.sis.util.CharSequences; import org.apache.sis.util.Characters; @@ -270,6 +272,19 @@ public class MetadataBuilder { } /** + * Returns the information about the series, or aggregate dataset, of which the dataset is a part. + */ + private DefaultSeries series() { + final DefaultCitation citation = citation(); + DefaultSeries series = DefaultSeries.castOrCopy(citation.getSeries()); + if (series == null) { + series = new DefaultSeries(); + citation.setSeries(series); + } + return series; + } + + /** * Part of the responsible party of the {@linkplain #citation}, or {@code null} if none. */ private DefaultResponsibility responsibility; @@ -1220,6 +1235,60 @@ public class MetadataBuilder { } /** + * Adds the name of the series, or aggregate dataset, of which the dataset is a part. + * Storage location is: + * + * <ul> + * <li>{@code metadata/identificationInfo/citation/series/name}</li> + * </ul> + * + * @param name name of the series, or {@code null} for no-operation. + */ + public final void addSeries(final CharSequence name) { + final InternationalString i18n = trim(name); + if (i18n != null) { + final DefaultSeries series = series(); + series.setName(append(series.getName(), i18n)); + } + } + + /** + * Adds details on which pages of the publication the article was published. + * Storage location is: + * + * <ul> + * <li>{@code metadata/identificationInfo/citation/series/page}</li> + * </ul> + * + * @param page the page, or {@code null} for no-operation. + */ + public final void addPage(final CharSequence page) { + final InternationalString i18n = trim(page); + if (i18n != null) { + final DefaultSeries series = series(); + series.setPage(append(series.getPage(), i18n)); + } + } + + /** + * Adds details on which pages of the publication the article was published. + * Storage location is: + * + * <ul> + * <li>{@code metadata/identificationInfo/citation/series/page}</li> + * </ul> + * + * @param page the page number, or 0 or negative for no-operation. + * @param total the total number of pages, or 0 or negative if unknown. + */ + public final void addPage(final int page, final int total) { + if (page > 0) { + addPage(Vocabulary.formatInternational( + (total > 0) ? Vocabulary.Keys.Page_2 : Vocabulary.Keys.Page_1, page, total)); + } + } + + /** * Adds a brief narrative summary of the resource(s). * If a summary already exists, the new one will be appended after a new line. * Storage location is: