Loading...
Searching...
No Matches
CoverageSeries.h
Go to the documentation of this file.
1/* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2
3 This file is part of the TerraLib - a Framework for building GIS enabled applications.
4
5 TerraLib is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 TerraLib is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with TerraLib. See COPYING. If not, write to
17 TerraLib Team at <terralib-team@terralib.org>.
18 */
19
20/*!
21 \file CoverageSeries.h
22
23 \brief This file contains a class to represent a coverage series.
24*/
25
26#ifndef __TERRALIB_ST_INTERNAL_COVERAGESERIES_H
27#define __TERRALIB_ST_INTERNAL_COVERAGESERIES_H
28
29//TerraLib
30#include "../../../datatype/DateTimePeriod.h"
31#include "../../../geometry/Geometry.h"
32
33//ST
34#include "../../Config.h"
35#include "../../Enums.h"
36#include "../timeseries/TimeSeries.h"
37#include "Coverage.h"
39
40//STL
41#include <vector>
42#include <map>
43#include <memory>
44
45// Boost
46#include <boost/ptr_container/ptr_vector.hpp>
47
48// Forward declarations
49namespace te { namespace dt { class DateTime; } }
50
51namespace te { namespace gm { class Point; } }
52
53namespace te
54{
55 namespace st
56 {
57 // Forward declarations
58 class TimeSeries;
59 class AbstractCoverageSeriesInterp;
60
61 /*!
62 \class CoverageSeries
63
64 \brief A class to represent a coverage series.
65
66 A coverage series is a sequence of coverages over time (T -> Coverage)
67
68 \ingroup st
69
70 \sa Coverage RasterCoverage PointCoverage TimeSeries
71 */
73 {
74 public:
75
76 /*!
77 \brief A constructor.
78
79 \note Internally, it will use the interpolator NearestCoverageAtTimeInterp
80 */
82
83 /*!
84 \brief A constructor.
85
86 \param obs The coverage series observations
87 \param interp The interpolator associated to the coverage series.
88 \param se The coverage series spatial extent.
89 \param t The type of the coverages that are in the observation set.
90
91 \note It will take the ownership of the given pointers.
92 */
95
96 /*!
97 \brief It returns the coverage series observations.
98
99 \return A reference to the coverage series observations.
100 */
102
103 /*!
104 \brief It returns the type of the internal coverages.
105
106 For while, there are two kinds of Coverages: Point Coverage and Raster Coverage.
107
108 \return Returns the coverage type.
109 */
111
112 /*!
113 \brief It returns the spatial extent of the coverage series
114
115 \return Returns the coverage series spatial extent.
116
117 \note The caller will NOT take the ownership of the returned geometry.
118 */
120
121 /*!
122 \brief It returns the temporal extent of the coverage series
123
124 \return Returns the coverage series temporal extent.
125
126 \note The caller will take the ownership of the returned geometry.
127 */
128 std::unique_ptr<te::dt::DateTimePeriod> getTemporalExtent() const;
129
130 /*!
131 \brief It adds an observation (time and coverage) into the coverage series.
132
133 \param time A pointer to the time.
134 \param cv A coverage.
135
136 \note The caller will take the ownership of the given pointers.
137 */
139
140 /*!
141 \brief It adds an observation (time and coverage) into the coverage series.
142
143 \param o An observation
144 */
146
147 /*!
148 \brief It returns the size of the coverage series observations.
149
150 \return The observations size of the coverage series.
151 */
152 std::size_t size() const;
153
154 /*! \name CoverageSeries Iterator
155
156 An example of use:
157
158 CoverageSeriesIterator it = cvs.begin();
159 while(it!=cvs.end())
160 {
161 DateTime* t = it.getTime();
162 Coverage* c = it.getCoverage();
163 ++it;
164 }
165 */
166 //@{
167 /*!
168 \brief It returns an iterator that points to the first observation of the point coverage
169
170 \return The coverage series iterator.
171 */
173
174 /*!
175 \brief It returns an iterator that points to the end of the time series.
176
177 \return The coverage series iterator.
178 */
180
181 /*!
182 \brief It returns an iterator that points to an observation at a given time.
183
184 If there is no observation at this given time, the returned iterator
185 points to the end of the coverage series.
186
187 \return The coverage series iterator.
188 \note This does not take the ownership of the given pointer.
189 */
191 //@}
192
193 /*!
194 \brief It returns the coverage associated to a given date and time.
195
196 If there is no coverage associated to the given date and time, it will
197 use internally its interpolation function.
198
199 \param t A date and time.
200
201 \return A pointer to the coverage associated to the given date and time.
202
203 \note The caller will take the ownership of the returned pointer.
204 \note The caller will NOT take the ownership of the given date and time pointer.
205 */
206 std::unique_ptr<te::st::Coverage> getCoverage(te::dt::DateTime* t) const;
207
208
209 /*! \name Methods to return time series from the coverage series */
210 //@{
211 /*!
212 \brief It returns a time series of the p-th property associated to a given location
213
214 \param l A given location.
215 \param p A given property or band
216
217 \return A pointer to the time series of the p-th property associated to a given location
218
219 \note The caller will take the ownership of the returned pointer.
220 \note The caller will NOT take the ownership of the given date and time pointer.
221 */
222 std::unique_ptr<te::st::TimeSeries> getTimeSeries(const te::gm::Point& l, unsigned int p=0) const;
223
224 /*!
225 \brief It returns the time series associated to a given location
226
227 It returns a set of time series, one for each property of the coverage.
228
229 \param l A given location.
230 \param r The resulting time series
231
232 \note The caller will take the ownership of the returned pointer.
233 */
234 void getTimeSeries(const te::gm::Point& l, boost::ptr_vector<TimeSeries>& r) const;
235
236 /*!
237 \brief It returns the time series of the p-th property inside the given polygon
238
239 It returns a set of time series, one for each point inside the polygon
240
241 \param l A given polygon.
242 \param p A given property.
243 \param r The resulting time series
244
245 \note The caller will take the ownership of the returned pointer.
246 */
247 void getTimeSeries(const te::gm::Polygon& l, unsigned int p, boost::ptr_vector<TimeSeries>& r) const;
248
249 /*!
250 \brief It returns the time series of the p-th property inside the given envelope
251
252 It returns a set of time series, one for each point inside the envelope
253
254 \param l A given envelope.
255 \param p A given property.
256 \param r The resulting time series
257
258 \note The caller will take the ownership of the returned pointer.
259 */
260 void getTimeSeries(const te::gm::Envelope& e, unsigned int p, boost::ptr_vector<TimeSeries>& r) const;
261
262 /*!
263 \brief It returns the time series inside the given polygon
264
265 It returns a set of time series, one for each point inside the polygon and for
266 each property of the coverage.
267
268 This method returns the time series of all properties of the coverages, ordered by locations.
269
270 An example, if the coverages have two properties:
271 The first position of the result vector contains the a time series of the first property of first location.
272 The second position of the result vector contains the a time series of the second property of the first location.
273 The third position of the result vector contains the a time series of the first property of the second location.
274 And so on.
275
276 \param l A given polygon.
277 \param r The resulting time series
278
279 \note The caller will take the ownership of the returned pointer.
280 */
281 void getTimeSeries(const te::gm::Polygon& l, boost::ptr_vector<TimeSeries>& r) const;
282
283 /*!
284 \brief It returns the time series inside the given envelope
285
286 It returns a set of time series, one for each point inside the envelope and for
287 each property of the coverage.
288
289 This method returns the time series of all properties of the coverages, ordered by locations.
290
291 An example, if the coverages have two properties:
292 The first position of the result vector contains the a time series of the first property of first location.
293 The second position of the result vector contains the a time series of the second property of the first location.
294 The third position of the result vector contains the a time series of the first property of the second location.
295 And so on.
296
297 \param e A given envelope.
298 \param r The resulting time series
299
300 \note The caller will take the ownership of the returned pointer.
301 */
302 void getTimeSeries(const te::gm::Envelope& e, boost::ptr_vector<TimeSeries>& r) const;
303
304 /*!
305 \brief It returns a time series of the p-th property associated to a given location
306 and considering a given temporal restriction.
307
308 \param l A given location.
309 \param t A given time
310 \param tr A given temporal restriction
311 \param p A given property or band
312
313 \return A pointer to the time series of the p-th property associated to a given location
314
315 \note The caller will take the ownership of the returned pointer.
316 \note The caller will NOT take the ownership of the given date and time pointer.
317 */
318 std::unique_ptr<te::st::TimeSeries> getTimeSeries(const te::gm::Point& l, const te::dt::DateTime& t,
320 unsigned int p=0) const;
321
322 /*!
323 \brief It returns the time series associated to a given location
324 and considering a given temporal restriction.
325
326 It returns a set of time series, one for each property of the coverage.
327
328 \param l A given location.
329 \param t A given time
330 \param tr A given temporal restriction
331 \param r The resulting time series
332
333 \note The caller will take the ownership of the returned pointer.
334 */
336 te::dt::TemporalRelation tr, boost::ptr_vector<TimeSeries>& r) const;
337
338 /*!
339 \brief It returns the time series of the p-th property inside the given polygon
340 and considering a given temporal restriction.
341
342 It returns a set of time series, one for each point inside the polygon
343
344 \param l A given polygon.
345 \param p A given property.
346 \param t A given time
347 \param tr A given temporal restriction
348 \param r The resulting time series
349
350 \note The caller will take the ownership of the returned pointer.
351 */
352 void getTimeSeries(const te::gm::Polygon& l, unsigned int p, const te::dt::DateTime& t,
353 te::dt::TemporalRelation tr, boost::ptr_vector<TimeSeries>& r) const;
354
355 /*!
356 \brief It returns the time series of the p-th property inside the given envelope
357 and considering a given temporal restriction.
358
359 It returns a set of time series, one for each point inside the envelope
360
361 \param l A given envelope.
362 \param p A given property.
363 \param t A given time
364 \param tr A given temporal restriction
365 \param r The resulting time series
366
367 \note The caller will take the ownership of the returned pointer.
368 */
369 void getTimeSeries(const te::gm::Envelope& e, unsigned int p, const te::dt::DateTime& t,
370 te::dt::TemporalRelation tr, boost::ptr_vector<TimeSeries>& r) const;
371
372 /*!
373 \brief It returns the time series inside the given polygon
374 and considering a given temporal restriction.
375
376 It returns a set of time series, one for each point inside the polygon and for
377 each property of the coverage
378
379 \param l A given polygon.
380 \param t A given time
381 \param tr A given temporal restriction
382 \param r The resulting time series
383
384 \note The caller will take the ownership of the returned pointer.
385 */
387 te::dt::TemporalRelation tr, boost::ptr_vector<TimeSeries>& r) const;
388
389 /*!
390 \brief It returns the time series inside the given envelope
391 and considering a given temporal restriction.
392
393 It returns a set of time series, one for each point inside the envelope and for
394 each property of the coverage
395
396 \param e A given envelope.
397 \param t A given time
398 \param tr A given temporal restriction
399 \param r The resulting time series
400
401 \note The caller will take the ownership of the returned pointer.
402 */
404 te::dt::TemporalRelation tr, boost::ptr_vector<TimeSeries>& r) const;
405 //@}
406
407 /*! \name Methods to return a subset or patch of a coverage series given a spatial and temporal restriction. */
408 //@{
409
410 /*!
411 \brief It returns a subset or patch of the coverage series considering a given temporal restriction.
412
413 \param dt A given time
414 \param r A given temporal restriction
415
416 \note The caller will take the ownership of the returned pointer.
417 \note The retorned coverage series will share the internal coverage pointers.
418 */
419 std::unique_ptr<CoverageSeries> getPatch(const te::dt::DateTime& dt, te::dt::TemporalRelation r = te::dt::DURING) const;
420
421 /*!
422 \brief It returns a subset or patch of the coverage series considering a given spatial restriction.
423
424 \param e A given envelope.
425 \param sr A given spatial restriction
426
427 \note The caller will take the ownership of the returned pointer.
428 \note The retorned coverage series will NOT share the internal coverage pointers.
429 */
430 std::unique_ptr<CoverageSeries> getPatch(const te::gm::Envelope& e, te::gm::SpatialRelation sr = te::gm::INTERSECTS) const;
431
432 /*!
433 \brief It returns a subset or patch of the coverage series considering a given spatial restriction.
434
435 \param e A given geometry.
436 \param sr A given spatial restriction
437
438 \note The caller will take the ownership of the returned pointer.
439 \note The retorned coverage series will NOT share the internal coverage pointers.
440 */
441 std::unique_ptr<CoverageSeries> getPatch(const te::gm::Geometry& e, te::gm::SpatialRelation sr = te::gm::INTERSECTS) const;
442
443 /*!
444 \brief It returns a subset or patch of the coverage series considering a given spatial and temporal restriction.
445
446 \param e A given envelope.
447 \param sr A given spatial restriction
448 \param dt A given date and time
449 \param tr A given temporal restriction
450
451 \note The caller will take the ownership of the returned pointer.
452 \note The retorned coverage series will NOT share the internal coverage pointers.
453 */
454 std::unique_ptr<CoverageSeries> getPatch(const te::gm::Envelope& e, te::gm::SpatialRelation sr,
456
457 /*!
458 \brief It returns a subset or patch of the coverage series considering a given spatial and temporal restriction.
459
460 \param e A given geometry.
461 \param sr A given spatial restriction
462 \param dt A given date and time
463 \param tr A given temporal restriction
464
465 \note The caller will take the ownership of the returned pointer.
466 \note The retorned coverage series will NOT share the internal coverage pointers.
467 */
468 std::unique_ptr<CoverageSeries> getPatch(const te::gm::Geometry& e, te::gm::SpatialRelation sr,
470 //@}
471
472 /*! \brief Virtual destructor. */
474
475 protected:
476
477 CoverageSeriesObservationSet m_observations; //! The coverage series observations
478 AbstractCoverageSeriesInterp* m_interpolator; //!< The interpolator used to estimate non-observed times.
480 std::unique_ptr<te::gm::Geometry> m_sextent;
481 };
482 } // end namespace st
483} // end namespace te
484
485#endif // __TERRALIB_ST_INTERNAL_COVERAGE_H
486
This file contains an iterator that is able to traverse all observations of a coverage series.
This file contains an abstract class to represent a coverage.
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:52
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:78
A point with x and y coordinate values.
Definition: Point.h:51
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
Definition: Polygon.h:51
An abstract class for interpolation function or interpolator that estimate coverages at non-observed ...
A class to traverse the observations of a CoverageSeries.
A class to represent a coverage series.
void getTimeSeries(const te::gm::Polygon &l, unsigned int p, const te::dt::DateTime &t, te::dt::TemporalRelation tr, boost::ptr_vector< TimeSeries > &r) const
It returns the time series of the p-th property inside the given polygon and considering a given temp...
std::size_t size() const
It returns the size of the coverage series observations.
const CoverageSeriesObservationSet & getObservations() const
It returns the coverage series observations.
void getTimeSeries(const te::gm::Point &l, const te::dt::DateTime &t, te::dt::TemporalRelation tr, boost::ptr_vector< TimeSeries > &r) const
It returns the time series associated to a given location and considering a given temporal restrictio...
std::unique_ptr< te::gm::Geometry > m_sextent
std::unique_ptr< CoverageSeries > getPatch(const te::dt::DateTime &dt, te::dt::TemporalRelation r=te::dt::DURING) const
It returns a subset or patch of the coverage series considering a given temporal restriction.
CoverageSeriesIterator begin() const
It returns an iterator that points to the first observation of the point coverage.
CoverageSeries(const CoverageSeriesObservationSet &obs, AbstractCoverageSeriesInterp *interp, te::gm::Geometry *se, CoverageType t)
A constructor.
std::unique_ptr< te::st::TimeSeries > getTimeSeries(const te::gm::Point &l, unsigned int p=0) const
It returns a time series of the p-th property associated to a given location.
std::unique_ptr< CoverageSeries > getPatch(const te::gm::Envelope &e, te::gm::SpatialRelation sr, const te::dt::DateTime &dt, te::dt::TemporalRelation r=te::dt::DURING) const
It returns a subset or patch of the coverage series considering a given spatial and temporal restrict...
std::unique_ptr< CoverageSeries > getPatch(const te::gm::Geometry &e, te::gm::SpatialRelation sr=te::gm::INTERSECTS) const
It returns a subset or patch of the coverage series considering a given spatial restriction.
std::unique_ptr< te::st::Coverage > getCoverage(te::dt::DateTime *t) const
It returns the coverage associated to a given date and time.
CoverageSeries()
A constructor.
AbstractCoverageSeriesInterp * m_interpolator
The coverage series observations.
void getTimeSeries(const te::gm::Envelope &e, unsigned int p, boost::ptr_vector< TimeSeries > &r) const
It returns the time series of the p-th property inside the given envelope.
void getTimeSeries(const te::gm::Envelope &e, unsigned int p, const te::dt::DateTime &t, te::dt::TemporalRelation tr, boost::ptr_vector< TimeSeries > &r) const
It returns the time series of the p-th property inside the given envelope and considering a given tem...
te::gm::Geometry * getSpatialExtent() const
It returns the spatial extent of the coverage series.
virtual ~CoverageSeries()
Virtual destructor.
void getTimeSeries(const te::gm::Polygon &l, boost::ptr_vector< TimeSeries > &r) const
It returns the time series inside the given polygon.
std::unique_ptr< te::dt::DateTimePeriod > getTemporalExtent() const
It returns the temporal extent of the coverage series.
std::unique_ptr< CoverageSeries > getPatch(const te::gm::Envelope &e, te::gm::SpatialRelation sr=te::gm::INTERSECTS) const
It returns a subset or patch of the coverage series considering a given spatial restriction.
CoverageSeriesIterator end() const
It returns an iterator that points to the end of the time series.
CoverageType getType() const
It returns the type of the internal coverages.
void getTimeSeries(const te::gm::Polygon &l, unsigned int p, boost::ptr_vector< TimeSeries > &r) const
It returns the time series of the p-th property inside the given polygon.
void add(te::dt::DateTime *time, te::st::Coverage *cv)
It adds an observation (time and coverage) into the coverage series.
std::unique_ptr< CoverageSeries > getPatch(const te::gm::Geometry &e, te::gm::SpatialRelation sr, const te::dt::DateTime &dt, te::dt::TemporalRelation tr=te::dt::DURING) const
It returns a subset or patch of the coverage series considering a given spatial and temporal restrict...
void getTimeSeries(const te::gm::Envelope &e, boost::ptr_vector< TimeSeries > &r) const
It returns the time series inside the given envelope.
void getTimeSeries(const te::gm::Point &l, boost::ptr_vector< TimeSeries > &r) const
It returns the time series associated to a given location.
void getTimeSeries(const te::gm::Polygon &l, const te::dt::DateTime &t, te::dt::TemporalRelation tr, boost::ptr_vector< TimeSeries > &r) const
It returns the time series inside the given polygon and considering a given temporal restriction.
void getTimeSeries(const te::gm::Envelope &e, const te::dt::DateTime &t, te::dt::TemporalRelation tr, boost::ptr_vector< TimeSeries > &r) const
It returns the time series inside the given envelope and considering a given temporal restriction.
CoverageSeriesObservationSet m_observations
CoverageSeriesIterator at(te::dt::DateTime *t) const
It returns an iterator that points to an observation at a given time.
void add(const CoverageSeriesObservation &o)
It adds an observation (time and coverage) into the coverage series.
std::unique_ptr< te::st::TimeSeries > getTimeSeries(const te::gm::Point &l, const te::dt::DateTime &t, te::dt::TemporalRelation tr=te::dt::DURING, unsigned int p=0) const
It returns a time series of the p-th property associated to a given location and considering a given ...
An abstract class to represent a coverage.
Definition: Coverage.h:64
TemporalRelation
Temporal relations between date and time (Source: Allen, 1991).
Definition: Enums.h:141
@ DURING
Definition: Enums.h:145
SpatialRelation
Spatial relations between geometric objects.
Definition: Enums.h:128
@ INTERSECTS
Definition: Enums.h:130
CoverageType
An enum for the types of coverage.
Definition: Enums.h:44
std::pair< te::dt::DateTimeShrPtr, CoverageShrPtr > CoverageSeriesObservation
std::map< te::dt::DateTimeShrPtr, CoverageShrPtr, CompareShrDateTime > CoverageSeriesObservationSet
TerraLib.
#define TESTEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:88