28 #include "../../../datatype/DateTime.h"
29 #include "../../../datatype/DateTimeUtils.h"
30 #include "../../../geometry/Geometry.h"
33 #include "../trajectory/Trajectory.h"
44 std::auto_ptr<te::gm::Geometry>
48 TrajectoryObservationSet::const_iterator itlower, itupper, itbegin, itend;
52 itlower = tjObs.lower_bound(dtshr);
53 itupper = tjObs.upper_bound(dtshr);
57 if(itlower==itupper && itlower!=tjObs.begin())
60 if(itlower!=tjObs.end() && itupper!=tjObs.end())
62 long distLower =
GetDistance(itlower->first.get(),time);
63 long distUpper =
GetDistance(itupper->first.get(),time);
64 if(distLower<distUpper)
65 return std::auto_ptr<te::gm::Geometry>(
static_cast<te::gm::Geometry*
>(itlower->second->clone()));
67 return std::auto_ptr<te::gm::Geometry>(
static_cast<te::gm::Geometry*
>(itupper->second->clone()));
70 if(itlower!=tjObs.end() && itupper==tjObs.end())
71 return std::auto_ptr<te::gm::Geometry>(static_cast<te::gm::Geometry*>(itlower->second->clone()));
73 return std::auto_ptr<te::gm::Geometry>(0);
TEDATATYPEEXPORT long GetDistance(const te::dt::DateTime *t1, const te::dt::DateTime *t2)
It returns the distance between two datetime types.
const TrajectoryObservationSet & getObservations() const
It returns the trajectory observations.
This file contains an interpolation function that estimates the nearest geometry at time of a traject...
std::map< te::dt::DateTimeShrPtr, te::gm::GeometryShrPtr, CompareShrDateTime > TrajectoryObservationSet
boost::shared_ptr< DateTime > DateTimeShrPtr
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
virtual ~NearestGeometryAtTimeInterp()
Virtual destructor.
A class to represent trajectory.
virtual AbstractData * clone() const =0
It returns a clone of this object.
std::auto_ptr< te::gm::Geometry > estimate(const Trajectory &tj, te::dt::DateTime *time) const
It estimates a geometry of a trajectory at a given non-observed time .
NearestGeometryAtTimeInterp()
Constructor.