blob: cb0052003d55d69fc24fe0754df5326f2372e2f0 [file] [log] [blame]
<!DOCTYPE HTML>
<html lang="en">
<head>
<!-- Generated by javadoc (21) on Thu Oct 05 19:54:57 CEST 2023 -->
<title>MergeStrategy (Apache SIS 1.4 API)</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="dc.created" content="2023-10-05">
<meta name="description" content="declaration: module: org.apache.sis.storage, package: org.apache.sis.storage.aggregate, class: MergeStrategy">
<meta name="generator" content="javadoc/ClassWriterImpl">
<meta name="keywords" content="org.apache.sis.storage.aggregate.MergeStrategy class">
<meta name="keywords" content="selectByTimeThenArea()">
<meta name="keywords" content="apply()">
<meta name="keywords" content="toString()">
<link rel="stylesheet" type="text/css" href="../../../../../../stylesheet.css" title="Style">
<link rel="stylesheet" type="text/css" href="../../../../../../sis.css" title="Style">
<link rel="stylesheet" type="text/css" href="../../../../../../script-dir/jquery-ui.min.css" title="Style">
<script type="text/javascript" src="../../../../../../script.js"></script>
<script type="text/javascript" src="../../../../../../script-dir/jquery-3.6.1.min.js"></script>
<script type="text/javascript" src="../../../../../../script-dir/jquery-ui.min.js"></script>
</head>
<body class="class-declaration-page">
<script type="text/javascript">var pathtoroot = "../../../../../../";
loadScripts(document, 'script');</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<div class="flex-box">
<header role="banner" class="flex-header">
<nav role="navigation">
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="top-nav" id="navbar-top"><button id="navbar-toggle-button" aria-controls="navbar-top" aria-expanded="false" aria-label="Toggle navigation links"><span class="nav-bar-toggle-icon">&nbsp;</span><span class="nav-bar-toggle-icon">&nbsp;</span><span class="nav-bar-toggle-icon">&nbsp;</span></button>
<div class="skip-nav"><a href="#skip-navbar-top" title="Skip navigation links">Skip navigation links</a></div>
<ul id="navbar-top-firstrow" class="nav-list" title="Navigation">
<li><a href="../../../../../../index.html">Overview</a></li>
<li><a href="../../../../../module-summary.html">Module</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="nav-bar-cell1-rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../../help-doc.html#class">Help</a></li>
</ul>
<ul class="sub-nav-list-small">
<li>
<p>Summary:</p>
<ul>
<li>Nested</li>
<li>Field</li>
<li>Constr</li>
<li><a href="#method-summary">Method</a></li>
</ul>
</li>
<li>
<p>Detail:</p>
<ul>
<li>Field</li>
<li>Constr</li>
<li><a href="#method-detail">Method</a></li>
</ul>
</li>
</ul>
</div>
<div class="sub-nav">
<div id="navbar-sub-list">
<ul class="sub-nav-list">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method-summary">Method</a></li>
</ul>
<ul class="sub-nav-list">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method-detail">Method</a></li>
</ul>
</div>
<div class="nav-list-search"><a href="../../../../../../search.html">SEARCH</a>
<input type="text" id="search-input" disabled placeholder="Search">
<input type="reset" id="reset-button" disabled value="reset">
</div>
</div>
<!-- ========= END OF TOP NAVBAR ========= -->
<span class="skip-nav" id="skip-navbar-top"></span></nav>
</header>
<div class="flex-content">
<main role="main">
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="sub-title"><span class="module-label-in-type">Module</span>&nbsp;<a href="../../../../../module-summary.html">org.apache.sis.storage</a></div>
<div class="sub-title"><span class="package-label-in-type">Package</span>&nbsp;<a href="package-summary.html">org.apache.sis.storage.aggregate</a></div>
<h1 title="Class MergeStrategy" class="title">Class MergeStrategy</h1>
</div>
<div class="inheritance" title="Inheritance Tree"><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang" class="external-link">Object</a>
<div class="inheritance">MergeStrategy</div>
</div>
<section class="class-description" id="class-description">
<hr>
<div class="type-signature"><span class="modifiers">public final class </span><span class="element-name type-name-label">MergeStrategy</span>
<span class="extends-implements">extends <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang" class="external-link">Object</a></span></div>
<div class="block">Algorithm to apply when more than one grid coverage can be found at the same grid index.
A merge may happen if an aggregated coverage is created with <a href="CoverageAggregator.html" title="class in org.apache.sis.storage.aggregate"><code>Coverage­Aggregator</code></a>,
and the extent of some source coverages are overlapping in the dimension to aggregate.
<h2 id="example-heading">Example</h2>
A collection of <a href="../../../../../../org.apache.sis.feature/org/apache/sis/coverage/grid/GridCoverage.html" title="class in org.apache.sis.coverage.grid"><code>Grid­Coverage</code></a> instances may represent the same phenomenon
(for example Sea Surface Temperature) over the same geographic area but at different dates and times.
<a href="CoverageAggregator.html" title="class in org.apache.sis.storage.aggregate"><code>Coverage­Aggregator</code></a> can be used for building a single data cube with a time axis.
But if two coverages have overlapping time ranges, and if a user request data in the overlapping region,
then the aggregated coverages have more than one source coverages capable to provide the requested data.
This enumeration specify how to handle this multiplicity.
<h2 id="default-behavior-heading">Default behavior</h2>
If no merge strategy is specified, then the default behavior is to throw
<a href="../../../../../../org.apache.sis.feature/org/apache/sis/coverage/SubspaceNotSpecifiedException.html" title="class in org.apache.sis.coverage"><code>Subspace­Not­Specified­Exception</code></a> when the <a href="../../../../../../org.apache.sis.feature/org/apache/sis/coverage/grid/GridCoverage.html#render(org.apache.sis.coverage.grid.GridExtent)"><code>Grid­Coverage​.render(Grid­Extent)</code></a> method
is invoked and more than one source coverage (slice) is found for a specified grid index.</div>
<dl class="notes">
<dt>Since:</dt>
<dd>1.3</dd>
</dl>
</section>
<section class="summary">
<ul class="summary-list">
<!-- ========== METHOD SUMMARY =========== -->
<li>
<section class="method-summary" id="method-summary">
<h2>Method Summary</h2>
<div id="method-summary-table">
<div class="table-tabs" role="tablist" aria-orientation="horizontal"><button id="method-summary-table-tab0" role="tab" aria-selected="true" aria-controls="method-summary-table.tabpanel" tabindex="0" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table', 3)" class="active-table-tab">All Methods</button><button id="method-summary-table-tab1" role="tab" aria-selected="false" aria-controls="method-summary-table.tabpanel" tabindex="-1" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table-tab1', 3)" class="table-tab">Static Methods</button><button id="method-summary-table-tab2" role="tab" aria-selected="false" aria-controls="method-summary-table.tabpanel" tabindex="-1" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table-tab2', 3)" class="table-tab">Instance Methods</button><button id="method-summary-table-tab4" role="tab" aria-selected="false" aria-controls="method-summary-table.tabpanel" tabindex="-1" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table-tab4', 3)" class="table-tab">Concrete Methods</button></div>
<div id="method-summary-table.tabpanel" role="tabpanel">
<div class="summary-table three-column-summary" aria-labelledby="method-summary-table-tab0">
<div class="table-header col-first">Modifier and Type</div>
<div class="table-header col-second">Method</div>
<div class="table-header col-last">Description</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="../Resource.html" title="interface in org.apache.sis.storage">Resource</a></code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#apply(org.apache.sis.storage.Resource)" class="member-name-link">apply</a><wbr>(<a href="../Resource.html" title="interface in org.apache.sis.storage">Resource</a>&nbsp;resource)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Returns a resource with same data than specified resource but using this merge strategy.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code>static <a href="MergeStrategy.html" title="class in org.apache.sis.storage.aggregate">Merge­Strategy</a></code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code><a href="#selectByTimeThenArea(java.time.Duration)" class="member-name-link">select­By­Time­Then­Area</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/time/Duration.html" title="class or interface in java.time" class="external-link">Duration</a>&nbsp;time­Granularity)</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4">
<div class="block">Selects a single slice using criteria based first on temporal extent, then on geographic area.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a></code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#toString()" class="member-name-link">to­String</a>()</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Returns a string representation of this strategy for debugging purposes.</div>
</div>
</div>
</div>
</div>
<div class="inherited-list">
<h3 id="methods-inherited-from-class-Object">Methods inherited from class&nbsp;<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang" class="external-link">Object</a></h3>
<code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html#clone()" title="class or interface in java.lang" class="external-link">clone</a>, <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html#equals(java.lang.Object)" title="class or interface in java.lang" class="external-link">equals</a>, <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html#finalize()" title="class or interface in java.lang" class="external-link">finalize</a>, <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html#getClass()" title="class or interface in java.lang" class="external-link">get­Class</a>, <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html#hashCode()" title="class or interface in java.lang" class="external-link">hash­Code</a>, <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html#notify()" title="class or interface in java.lang" class="external-link">notify</a>, <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html#notifyAll()" title="class or interface in java.lang" class="external-link">notify­All</a>, <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html#wait()" title="class or interface in java.lang" class="external-link">wait</a>, <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html#wait(long)" title="class or interface in java.lang" class="external-link">wait</a>, <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html#wait(long,int)" title="class or interface in java.lang" class="external-link">wait</a></code></div>
</section>
</li>
</ul>
</section>
<section class="details">
<ul class="details-list">
<!-- ============ METHOD DETAIL ========== -->
<li>
<section class="method-details" id="method-detail">
<h2>Method Details</h2>
<ul class="member-list">
<li>
<section class="detail" id="selectByTimeThenArea(java.time.Duration)">
<h3>selectByTimeThenArea</h3>
<div class="member-signature"><span class="modifiers">public static</span>&nbsp;<span class="return-type"><a href="MergeStrategy.html" title="class in org.apache.sis.storage.aggregate">MergeStrategy</a></span>&nbsp;<span class="element-name">selectByTimeThenArea</span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/time/Duration.html" title="class or interface in java.time" class="external-link">Duration</a>&nbsp;timeGranularity)</span></div>
<div class="block">Selects a single slice using criteria based first on temporal extent, then on geographic area.
This strategy applies the following rules, in order:
<ol>
<li>Slice having largest intersection with the time of interest (TOI) is selected.</li>
<li>If two or more slices have the same intersection with TOI,
then the one with less "overtime" (time outside TOI) is selected.</li>
<li>If two or more slices are considered equal after above criteria,
then the one best centered on the TOI is selected.</li>
</ol>
<div class="note"><b>Rational:</b>
the "smallest time outside" criterion (rule 2) is before "best centered" criterion (rule 3)
because of the following scenario: if a user specifies a "time of interest" (TOI) of 1 day
and if there is two slices intersecting the TOI, with one slice being a raster of monthly
averages the other slice being a raster of daily data, we want the daily data to be selected
even if by coincidence the monthly averages is better centered.</div>
If the <code>time­Granularity</code> argument is non-null, then intersections with TOI will be rounded
to an integer amount of the specified granularity and the last criterion in above list is relaxed.
This is useful when data are expected at an approximately regular time interval (for example one remote
sensing image per day) and we want to ignore slight variations in the temporal extent declared for each image.
<p>If there is no time of interest, or the slices do not declare time range,
or some slices are still at equality after application of above criteria,
then the selection continues on the basis of geographic criteria:</p>
<ol>
<li>Largest intersection with the area of interest (AOI) is selected.</li>
<li>If two or more slices have the same intersection area with AOI, then the one with the less
"irrelevant" material is selected. "Irrelevant" material are area outside the AOI.</li>
<li>If two or more slices are considered equal after above criteria,
the one best centered on the AOI is selected.</li>
<li>If two or more slices are considered equal after above criteria,
then the first of those candidates is selected.</li>
</ol>
If two slices are still considered equal after all above criteria, then an arbitrary one is selected.
<h4 id="limitations-heading">Limitations</h4>
Current implementation does not check the vertical dimension.
This check may be added in a future version.</div>
<dl class="notes">
<dt>Parameters:</dt>
<dd><code>time­Granularity</code> - the temporal granularity of the Time of Interest (TOI), or <code>null</code> if none.</dd>
<dt>Returns:</dt>
<dd>a merge strategy for selecting a slice based on temporal criteria first.</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="apply(org.apache.sis.storage.Resource)">
<h3>apply</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type"><a href="../Resource.html" title="interface in org.apache.sis.storage">Resource</a></span>&nbsp;<span class="element-name">apply</span><wbr><span class="parameters">(<a href="../Resource.html" title="interface in org.apache.sis.storage">Resource</a>&nbsp;resource)</span></div>
<div class="block">Returns a resource with same data than specified resource but using this merge strategy.
If the given resource is an instance created by <a href="CoverageAggregator.html" title="class in org.apache.sis.storage.aggregate"><code>Coverage­Aggregator</code></a> and uses a different strategy,
then a new resource using this merge strategy is returned. Otherwise the given resource is returned as-is.
The returned resource will share the same resources and caches than the given resource.</div>
<dl class="notes">
<dt>Parameters:</dt>
<dd><code>resource</code> - the resource for which to update the merge strategy, or <code>null</code>.</dd>
<dt>Returns:</dt>
<dd>resource with updated merge strategy, or <code>null</code> if the given resource was null.</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="toString()">
<h3>toString</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a></span>&nbsp;<span class="element-name">toString</span>()</div>
<div class="block">Returns a string representation of this strategy for debugging purposes.</div>
<dl class="notes">
<dt>Overrides:</dt>
<dd><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html#toString()" title="class or interface in java.lang" class="external-link">to­String</a></code>&nbsp;in class&nbsp;<code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang" class="external-link">Object</a></code></dd>
<dt>Returns:</dt>
<dd>string representation of this strategy.</dd>
</dl>
</section>
</li>
</ul>
</section>
</li>
</ul>
</section>
<!-- ========= END OF CLASS DATA ========= -->
</main>
</div>
</div>
</body>
</html>