001/* 002 * GeoAPI - Java interfaces for OGC/ISO standards 003 * Copyright © 2005-2023 Open Geospatial Consortium, Inc. 004 * http://www.geoapi.org 005 * 006 * Licensed under the Apache License, Version 2.0 (the "License"); 007 * you may not use this file except in compliance with the License. 008 * You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.opengis.metadata.quality; 019 020import java.util.Collection; 021import java.util.Collections; 022import org.opengis.util.InternationalString; 023import org.opengis.util.TypeName; 024import org.opengis.annotation.UML; 025import org.opengis.metadata.Identifier; 026import org.opengis.parameter.ParameterDescriptor; 027 028import static org.opengis.annotation.Obligation.*; 029import static org.opengis.annotation.Specification.*; 030 031 032/** 033 * Data quality measure. 034 * 035 * <h2>Where measures are stored</h2> 036 * Measures may be verbose and may not be of interest when only the {@linkplain Element#getResults() result} 037 * of data quality measures is desired. For allowing more compact {@link Element}s, ISO 19157 does not store 038 * {@code Measure} instance directly into {@link Element}, but instead stores {@link MeasureReference} which 039 * can be used for fetching full {@link Measure} description from a measure register or catalogue if desired. 040 * 041 * <p>GeoAPI extends the ISO 19157 model by allowing {@link Element} to provide directly a {@link Measure} instance. 042 * This optional feature gives access to full measure description without forcing users to connect to a catalogue or 043 * measure registry. Implementers can fetch the measure description only when first requested, for example by 044 * connecting themselves to a catalogue when {@link Element#getMeasure()} is first invoked.</p> 045 * 046 * @author Alexis Gaillard (Geomatys) 047 * @author Martin Desruisseaux (Geomatys) 048 * @version 3.1 049 * 050 * @see MeasureReference 051 * @see Element#getMeasure() 052 * 053 * @since 3.1 054 * 055 * @todo Renamed in 19157:2022: {@code QualityMeasure}. 056 */ 057@UML(identifier="DQM_Measure", specification=ISO_19157) 058public interface Measure { 059 /** 060 * Value uniquely identifying the measure within a namespace. 061 * This identifier enables references to the data quality measure within the data quality elements. 062 * 063 * @return value uniquely identifying the measure within a namespace. 064 * 065 * @see MeasureReference#getMeasureIdentification() 066 */ 067 @UML(identifier="measureIdentifier", obligation=MANDATORY, specification=ISO_19157) 068 Identifier getMeasureIdentifier(); 069 070 /** 071 * Name of the data quality measure applied to the data. 072 * If the measure already has a commonly used name, this name should be used. 073 * If no name exists, a name should be chosen that reflects the nature of the measure. 074 * 075 * @return name of the data quality measure applied to the data. 076 * 077 * @see BasicMeasure#getName() 078 * @see MeasureReference#getNamesOfMeasure() 079 */ 080 @UML(identifier="name", obligation=MANDATORY, specification=ISO_19157) 081 InternationalString getName(); 082 083 /** 084 * Other recognized names, abbreviations or short names for the same data quality measure. 085 * It may be a different commonly used name, or an abbreviation, or a short name. 086 * More than one alias may be provided. 087 * 088 * @return others recognized names, abbreviations or short names. 089 */ 090 @UML(identifier="alias", obligation=OPTIONAL, specification=ISO_19157) 091 default Collection<? extends InternationalString> getAliases() { 092 return Collections.emptyList(); 093 } 094 095 /** 096 * Names of the data quality element to which a measure applies. 097 * More than one element name may be provided. 098 * 099 * @return names of the data quality element for which quality is reported. 100 */ 101 @UML(identifier="elementName", obligation=MANDATORY, specification=ISO_19157) 102 Collection<? extends TypeName> getElementNames(); 103 104 /** 105 * Predefined basic measure on which this measure is based. 106 * If a measure is based on one of the basic measures, 107 * it shall be described by its name, definition and value type. 108 * 109 * <p>A variety of measures are based on counting of erroneous items. 110 * There are also several measures dealing with the uncertainty of numerical values. 111 * In order to avoid repetition, the most common methods of constructing count-related measures, 112 * as well as general statistical measures, for one- and two-dimensional random variables 113 * should be defined in terms of basic measures.</p> 114 * 115 * @condition mandatory if this measure is derived from basic measures. 116 * 117 * @return predefined basic measure on which this measure is based, or {@code null} if none. 118 */ 119 @UML(identifier="basicMeasure", obligation=CONDITIONAL, specification=ISO_19157) 120 default BasicMeasure getBasicMeasure() { 121 return null; 122 } 123 124 /** 125 * Definition of the fundamental concept for the data quality measure. 126 * If the measure is derived from a {@linkplain #getBasicMeasure() basic measure}, 127 * the definition is based on the basic measure definition and specialized for this measure. 128 * 129 * @return definition of the fundamental concept for the data quality measure. 130 * 131 * @see BasicMeasure#getDefinition() 132 */ 133 @UML(identifier="definition", obligation=MANDATORY, specification=ISO_19157) 134 InternationalString getDefinition(); 135 136 /** 137 * Description of the data quality measure. 138 * Includes methods of calculation, with all formulae and/or illustrations 139 * needed to establish the result of applying the measure. 140 * 141 * <p>If the measure uses the concept of errors, it should be stated how an item is classified as incorrect. 142 * This is the case when the quality only can be reported as correct or incorrect.</p> 143 * 144 * @condition mandatory if the {@linkplain #getDefinition() definition} is not sufficient 145 * for the understanding of the data quality measure concept. 146 * 147 * @return description of data quality measure, or {@code null} if none. 148 * 149 * @see MeasureReference#getMeasureDescription() 150 */ 151 @UML(identifier="description", obligation=CONDITIONAL, specification=ISO_19157) 152 Description getDescription(); 153 154 /** 155 * References to the source of an item that has been adopted from an external source. 156 * 157 * @condition mandatory is an external source exists. 158 * 159 * @return references to the source. 160 */ 161 @UML(identifier="sourceReference", obligation=CONDITIONAL, specification=ISO_19157) 162 default Collection<? extends SourceReference> getSourceReferences() { 163 return Collections.emptyList(); 164 } 165 166 /** 167 * Value type for reporting a data quality result. 168 * If a {@linkplain #getValueStructure() value structure} is used, then this method returns 169 * the type of components in the value structure. For example if the value structure is 170 * {@link ValueStructure#MATRIX matrix}, then the value type is typically {@code "Real"}. 171 * 172 * @return value type for reporting a data quality result. 173 * 174 * @see BasicMeasure#getValueType() 175 */ 176 @UML(identifier="valueType", obligation=MANDATORY, specification=ISO_19157) 177 TypeName getValueType(); 178 179 /** 180 * Structure for reporting a complex data quality result. 181 * A result may consist of multiple values. 182 * In such cases, the result shall be structured using the value structure. 183 * Common value structures are listed below. 184 * 185 * <table class="ogc"> 186 * <caption>Mapping from {@code ValueStructure} to Java type</caption> 187 * <tr><th>Code list value</th> <th>Java or GeoAPI type</th> <th>Description</th></tr> 188 * <tr><td>{@code bag}</td> <td>{@link java.util.Collection}</td> <td>Finite, unordered collection of related items that may be repeated.</td></tr> 189 * <tr><td>{@code set}</td> <td>{@link java.util.Set}</td> <td>Unordered collection of related items with no repetition.</td></tr> 190 * <tr><td>{@code sequence}</td> <td>{@link java.util.List}</td> <td>Finite, ordered collection of related items that may be repeated.</td></tr> 191 * <tr><td>{@code table}</td> <td>{@link java.util.Map}</td> <td>An arrangement of data in which each item is identified by means of keys.</td></tr> 192 * <tr><td>{@code matrix}</td> <td>{@link org.opengis.referencing.operation.Matrix}</td> <td>Rectangular array of numbers.</td></tr> 193 * <tr><td>{@code coverage}</td> <td>{@link org.opengis.coverage.Coverage}</td> <td>Function to return values for any direct position within its domain.</td></tr> 194 * </table> 195 * 196 * @return structure for reporting a complex data quality result, or {@code null} if none. 197 */ 198 @UML(identifier="valueStructure", obligation=OPTIONAL, specification=ISO_19157) 199 default ValueStructure getValueStructure() { 200 return null; 201 } 202 203 /** 204 * Auxiliary variable(s) used by the data quality measure. 205 * It shall include its name, definition and value type. 206 * More than one measure parameter may be provided. 207 * 208 * <h4>Unified parameter API</h4> 209 * In GeoAPI, the {@code DQM_Parameter} type defined by ISO 19157 is replaced by {@link ParameterDescriptor} 210 * in order to provide a single parameter API (see {@link org.opengis.parameter} for more information). 211 * The mapping from ISO 19115 to GeoAPI is defined as bellow: 212 * 213 * <table class="ogc"> 214 * <caption>Quality metadata properties mapped to GeoAPI</caption> 215 * <tr> 216 * <th>{@code DQM_Parameter} property</th> 217 * <th>{@code ParameterDescriptor} property</th> 218 * <th>Remarks</th> 219 * </tr><tr> 220 * <td>{@code name}</td> 221 * <td><code>{@linkplain ParameterDescriptor#getName() name}.{@linkplain Identifier#getCode() code}</code></td> 222 * <td>Value retrofitted in an {@link Identifier} object.</td> 223 * </tr><tr> 224 * <td>{@code definition}</td> 225 * <td><code>{@linkplain ParameterDescriptor#getName() name}.{@linkplain Identifier#getDescription() description}</code></td> 226 * <td>Value retrofitted in an {@link Identifier} object.</td> 227 * </tr><tr> 228 * <td>{@code description.textDescription}</td> 229 * <td>{@link ParameterDescriptor#getDescription() description}</td> 230 * <td></td> 231 * </tr><tr> 232 * <td>{@code description.extendedDescription}</td> 233 * <td>(none)</td> 234 * <td></td> 235 * </tr><tr> 236 * <td>{@code valueType}</td> 237 * <td>{@link ParameterDescriptor#getValueType() valueType}</td> 238 * <td></td> 239 * </tr><tr> 240 * <td>{@code valueStructure}</td> 241 * <td>{@link ParameterDescriptor#getValueClass() valueClass}</td> 242 * <td>See {@link ValueStructure#valueOf(Class)} for the mapping.</td> 243 * </tr> 244 * </table> 245 * 246 * @departure harmonization 247 * Usage of the ISO 19157 {@code DQM_Parameter} type has been replaced by usage of the ISO 19111 248 * {@code OperationParameter} type, completed with some new {@code DQM_Parameter} properties, 249 * in order to provide a unified parameter API. Note that {@code OperationParameter} is named 250 * {@link org.opengis.parameter.ParameterDescriptor} in GeoAPI to reflect its extended scope. 251 * 252 * @return auxiliary variable(s) used by data quality measure, or an empty collection if none. 253 * 254 * @see org.opengis.parameter.GeneralParameterDescriptor 255 */ 256 @UML(identifier="parameter", obligation=CONDITIONAL, specification=ISO_19157) 257 default Collection<? extends ParameterDescriptor<?>> getParameters() { 258 return Collections.emptyList(); 259 } 260 261 /** 262 * Illustrations of the use of a data quality measure. 263 * More than one example may be provided. 264 * 265 * @return examples of applying the measure or the result obtained for the measure. 266 * 267 * @see BasicMeasure#getExample() 268 */ 269 @UML(identifier="example", obligation=OPTIONAL, specification=ISO_19157) 270 default Collection<? extends Description> getExamples() { 271 return Collections.emptyList(); 272 } 273}