27 #include "../../../datatype/DateTime.h" 28 #include "../../../datatype/DateTimePeriod.h" 29 #include "../../../datatype/DateTimeInstant.h" 30 #include "../../../datatype/DateTimeUtils.h" 31 #include "../../../geometry/Geometry.h" 32 #include "../../../geometry/Utils.h" 33 #include "../../../sam/rtree/Index.h" 37 #include "../timeseries/TimeSeries.h" 38 #include "../interpolator/AbstractTrajectoryInterp.h" 39 #include "../interpolator/NearestGeometryAtTimeInterp.h" 61 const std::string&
id)
70 const std::string&
id)
82 const std::string&
id)
92 const std::string&
id)
100 while(it!=patch.
end())
127 TrajectoryObservationSet::const_iterator it =
m_observations.begin();
168 std::pair<te::dt::DateTimeShrPtr, te::gm::GeometryShrPtr> pr(t,g);
176 m_rtree->insert(*env, p.first.get());
186 TrajectoryObservationSet::const_iterator it =
m_observations.begin();
192 TrajectoryObservationSet::const_iterator it =
m_observations.end();
199 TrajectoryObservationSet::const_iterator it =
m_observations.find(aux);
206 TrajectoryObservationSet::const_iterator it =
m_observations.find(aux);
208 return std::unique_ptr<te::gm::Geometry>(static_cast<te::gm::Geometry*>(it->second->clone()));
231 TrajectoryObservationSet::const_iterator itb =
m_observations.end();
232 TrajectoryObservationSet::const_iterator ite =
m_observations.end();
274 std::pair<TrajectoryObservationSet::const_iterator, TrajectoryObservationSet::const_iterator> itPair;
288 std::vector<TrajectoryPatch>& result)
const 295 std::vector<te::dt::DateTime*> report;
299 std::vector<te::dt::DateTime*>::const_iterator itResultBegin = report.begin();
300 std::vector<te::dt::DateTime*>::const_iterator itResultEnd = report.end();
303 TrajectoryObservationSet::const_iterator itOriginBegin =
m_observations.find(shrdt);
304 TrajectoryObservationSet::const_iterator itOriginEnd =
m_observations.end();
306 TrajectoryObservationSet::const_iterator pathBegin;
307 TrajectoryObservationSet::const_iterator pathEnd;
309 while(itResultBegin!=itResultEnd && itOriginBegin!=itOriginEnd)
311 pathBegin = itOriginBegin;
314 while( (itResultBegin!=itResultEnd) && (itOriginBegin!=itOriginEnd) &&
315 (*itResultBegin == itOriginBegin->first.get()))
317 pathEnd = itOriginBegin;
324 if(pathEnd!=itOriginEnd)
330 if(itResultBegin!=itResultEnd)
332 shrdt.reset(static_cast<te::dt::DateTime*>((*itResultBegin)->clone()));
342 std::vector<TrajectoryPatch>& result)
const 348 std::vector<te::dt::DateTime*> report;
353 std::vector<te::dt::DateTime*>::const_iterator itResultBegin = report.begin();
354 std::vector<te::dt::DateTime*>::const_iterator itResultEnd = report.end();
357 TrajectoryObservationSet::const_iterator itOriginBegin =
m_observations.find(shrdt);
358 TrajectoryObservationSet::const_iterator itOriginEnd =
m_observations.end();
360 TrajectoryObservationSet::const_iterator pathBegin;
361 TrajectoryObservationSet::const_iterator pathEnd;
363 while(itResultBegin!=itResultEnd && itOriginBegin!=itOriginEnd)
365 if(!geom.
intersects(itOriginBegin->second.get()))
368 if(itResultBegin!=itResultEnd)
370 shrdt.reset(static_cast<te::dt::DateTime*>((*itResultBegin)->clone()));
376 pathBegin = itOriginBegin;
378 while( itResultBegin!=itResultEnd && itOriginBegin!=itOriginEnd
379 && (*itResultBegin == itOriginBegin->first.get())
380 && geom.
intersects(itOriginBegin->second.get()))
382 pathEnd = itOriginBegin;
384 if(itResultBegin!=itResultEnd)
386 shrdt.reset(static_cast<te::dt::DateTime*>((*itResultBegin)->clone()));
393 if(pathEnd!=itOriginEnd)
407 std::vector<TrajectoryPatch>& result)
const 414 std::vector<TrajectoryPatch> res2;
417 std::vector<TrajectoryPatch>::const_iterator it = res2.begin();
419 TrajectoryObservationSet::const_iterator itObsEnd =
m_observations.end();
421 while(it!=res2.end())
430 if(itAuxBegin!=tj.
end())
437 if(itAuxEnd==tj.
end())
459 std::vector<TrajectoryPatch>& result)
const 466 std::vector<TrajectoryPatch> res2;
469 std::vector<TrajectoryPatch>::const_iterator it = res2.begin();
471 TrajectoryObservationSet::const_iterator itObsEnd =
m_observations.end();
473 while(it!=res2.end())
482 if(itAuxBegin!=tj.
end())
489 if(itAuxEnd==tj.
end())
511 const std::vector<TrajectoryPatch>& )
const 518 TrajectoryObservationSet::const_iterator it =
m_observations.begin();
523 std::unique_ptr<te::gm::Geometry> otherGeom(other.
getGeometry(t));
525 double dist = it->second->distance(otherGeom.get());
528 result->add(static_cast<te::dt::DateTime*>(t->
clone()),dist);
537 std::unique_ptr<te::st::TimeSeries> res;
static boost::posix_time::ptime bt
AbstractTrajectoryInterp * m_interpolator
The interpolator used to estimate non-observed times.
This file contains a class to represent a trajectory.
void setId(const std::string &id)
It sets the trajectory id.
A struct to represent a patch or a continuous piece of a trajectory.
A class that represents an R-tree.
TrajectoryIterator end() const
It returns an iterator that points to the end of the trajectory.
TrajectoryIterator end() const
TemporalRelation
Temporal relations between date and time (Source: Allen, 1991).
Trajectory()
Empty constructor.
An auxiliary struct to compare two datetime pointers.
SpatialRelation
Spatial relations between geometric objects.
It is an interpolation function the estimates the nearest geometry at a given non-observed time of a ...
const TrajectoryObservationSet & getObservations() const
It returns the trajectory observations.
virtual bool intersects(const Geometry *const rhs) const _NOEXCEPT_OP(false)
It returns true if the geometry object spatially intersects rhs geometry.
TrajectoryIterator at(te::dt::DateTime *t) const
It returns an iterator that points to an observation at a given time.
std::map< te::dt::DateTimeShrPtr, te::gm::GeometryShrPtr, CompareShrDateTime > TrajectoryObservationSet
TrajectoryPatch getPatch(const te::dt::DateTime &dt, te::dt::TemporalRelation r=te::dt::DURING) const
It returns a trajectory subset that satisfies a given temporal relation.
boost::shared_ptr< DateTime > DateTimeShrPtr
TrajectoryObservationSet m_observations
The trajectory observations.
An abstract class for an interpolation function or interpolator that estimates geometries at non-obse...
SpatioTemporalRelation
An enum for the types of spatiotemporal relation.
std::pair< te::dt::DateTimeShrPtr, te::gm::GeometryShrPtr > TrajectoryObservation
std::string getId() const
It returns the trajectory id.
const Envelope * getMBR() const _NOEXCEPT_OP(true)
It returns the minimum bounding rectangle for the geometry in an internal representation.
An Envelope defines a 2D rectangular region.
static te::dt::TimeDuration dt(20, 30, 50, 11)
void getPatches(const te::gm::Envelope &g, te::gm::SpatialRelation r, std::vector< TrajectoryPatch > &result) const
It returns trajectory subsets that satisfy a given spatial relation.
virtual AbstractData * clone() const =0
It returns a clone of this object.
std::unique_ptr< te::dt::DateTimePeriod > getTemporalExtent() const
It returns the temporal extent of the trajectory observations.
void setInterpolator(AbstractTrajectoryInterp *interp)
It sets the interpolator associated to the path.
te::gm::Envelope getSpatialExtent() const
It returns the spatial extent of the trajectory observations.
Trajectory * clone() const
It returns a clone of this trajectory.
te::dt::DateTime * getTime() const
It returns the datetime pointed by the internal cursor.
Trajectory & operator=(const Trajectory &other)
Copy assignment operator.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
std::size_t size() const
It returns the size of the trajectory observations.
TrajectoryIterator begin() const
virtual ~Trajectory()
Virtual destructor.
virtual std::unique_ptr< te::gm::Geometry > estimate(const Trajectory &tj, te::dt::DateTime *time) const =0
It estimates a geometry of a trajectory at a given non-observed time .
A class to represent time series.
std::unique_ptr< te::gm::Geometry > getGeometry(te::dt::DateTime *t) const
It returns the geometry associated to a given date and time.
A class to represent trajectory.
TjRTreeShrPtr m_rtree
The RTree to index the trajectory geometries.
TEDATATYPEEXPORT DateTimePeriod * GetTemporalExtent(const DateTime *t1, const DateTime *t2)
It returns the temporal extent of two date and time types.
std::string m_id
The trajectory identification.
A class to traverse the observations of a trajectory.
std::unique_ptr< TimeSeries > getDistance(const Trajectory &other) const
It returns the distance between two trajectories.
boost::shared_ptr< Geometry > GeometryShrPtr
void add(te::dt::DateTime *time, te::gm::Geometry *geom)
It adds an observation (time and geometry) into the trajectory.
AbstractTrajectoryInterp * getInterpolator() const
It returns the interpolator associated to the trajectory.
TrajectoryIterator begin() const
It returns an iterator that points to the first observation of the trajectory.