28 #include "../core/filesystem/FileSystem.h" 29 #include "../raster/RasterFactory.h" 30 #include "../raster/Grid.h" 31 #include "../geometry/LinearRing.h" 32 #include "../common/Exception.h" 35 #include <boost/filesystem.hpp> 44 const std::vector< const te::rst::Raster* >
rasters )
45 : m_currentOffset( 0 ), m_rasters( rasters )
106 const std::vector< std::string >& rTypes,
107 const std::vector< std::map< std::string, std::string > >& rInfos )
111 "Invalid rasters info" )
211 return (
unsigned int)
m_rTypes.size();
222 const std::vector< const te::rst::Raster* > rastersPtrsVec,
223 const std::vector< std::string >& rTypes,
224 const std::vector< std::map< std::string, std::string > >& rInfos )
226 m_CurrentRasterOffset( 0 ),
227 m_currentRasterNakedPtr( nullptr ),
228 m_rasters( rastersPtrsVec ),
233 "Invalid rasters info" )
316 const std::string& directoryName,
317 const bool recursive,
318 const std::string& rType,
319 const bool sortFileNames,
320 const std::vector< std::string >& fileExtensions )
323 sortFileNames, fileExtensions,
nullptr,
false ),
"Feeder initialization error" );
327 const std::string& directoryName,
328 const bool recursive,
329 const std::string& rType,
330 const bool sortFileNames,
331 const std::vector< std::string >& fileExtensions,
333 const bool ignoreInvalidRasterFiles )
336 sortFileNames, fileExtensions, restrictionGeomPtr, ignoreInvalidRasterFiles ),
337 "Feeder initialization error" );
341 : m_selectedRasterIndexesOffset( 0 )
355 static std::string emptyStr;
369 std::map< std::string, std::string > mInfo;
376 nextSelectedRasterIndexesOffset ] ];
399 ++nextSelectedRasterIndexesOffset;
423 std::map< std::string, std::string > mInfo;
456 std::map< std::string, std::string > mInfo;
457 std::size_t nextSelectedRasterIndexesOffset = 0;
462 nextSelectedRasterIndexesOffset ] ];
485 ++nextSelectedRasterIndexesOffset;
503 std::unique_ptr< te::dt::AbstractData > cloneResult( restrictionGeom.
clone() );
505 "Invalid geometry" );
517 std::map< std::string, std::string > mInfo;
518 std::unique_ptr< te::rst::Raster > rasterPtr;
521 for(
unsigned int allRasterFileNamesIdx = 0 ; allRasterFileNamesIdx <
546 if( rasterPtr.get() )
548 rasterExtPtr = rasterPtr->getGrid()->getExtent();
552 rasterExtPtr->
m_ury );
554 rasterExtPtr->
m_ury );
556 rasterExtPtr->
m_lly );
558 rasterExtPtr->
m_lly );
560 rasterExtPtr->
m_ury );
561 auxLinearRingPtr->
setSRID( rasterPtr->getSRID() );
564 auxPolygon.
push_back( auxLinearRingPtr );
566 auxPolygon.
setSRID( rasterPtr->getSRID() );
577 for(
unsigned int allRastersBoundingBoxesIdx = 0 ; allRastersBoundingBoxesIdx <
581 allRastersBoundingBoxesIdx ].getSRID() )
584 allRastersBoundingBoxesIdx ].getSRID() );
588 allRastersBoundingBoxesIdx ] ) ) )
600 const std::string& directoryName,
601 const bool recursive,
602 const std::string& rType,
603 const bool sortFileNames,
604 const std::vector< std::string >& fileExtensions,
606 const bool ignoreInvalidRasterFiles )
616 const std::vector< std::string >::size_type fileExtensionsSize =
617 fileExtensions.size();
618 std::vector< std::string >::size_type fileExtensionsIdx = 0;
620 boost::filesystem::path directoryPath( directoryName );
625 boost::filesystem::recursive_directory_iterator dirIt( directoryPath );
626 const boost::filesystem::recursive_directory_iterator dirItE;
627 std::string auxString;
629 while( dirIt != dirItE )
633 if( fileExtensionsSize )
635 for( fileExtensionsIdx = 0 ; fileExtensionsIdx < fileExtensionsSize ;
636 ++fileExtensionsIdx )
638 if( dirIt->path().extension().generic_string()
639 == fileExtensions[ fileExtensionsIdx ] )
656 boost::filesystem::directory_iterator dirIt( directoryPath );
657 const boost::filesystem::directory_iterator dirItE;
659 while( dirIt != dirItE )
663 if( fileExtensionsSize )
665 for( fileExtensionsIdx = 0 ; fileExtensionsIdx < fileExtensionsSize ;
666 ++fileExtensionsIdx )
668 if( dirIt->path().extension().generic_string()
669 == fileExtensions[ fileExtensionsIdx ] )
694 for( std::vector< std::string >::size_type allRasterFileNamesIdx = 0 ;
696 ++allRasterFileNamesIdx )
706 if( restrictionGeomPtr )
bool moveTo(const unsigned int index)
Jump to the given object index.
FeederConstRasterDirectory()
void push_back(Curve *ring)
It adds the curve to the curve polygon.
te::rst::Raster const * getCurrentObj() const
Return the current sequence object.
bool moveNext()
Advances to the next sequence obeject.
std::vector< te::gm::Polygon > m_allRastersBoundingBoxes
te::rst::Raster const * getCurrentObj() const
Return the current sequence object.
bool moveTo(const unsigned int index)
Jump to the given object index.
static bool isDirectory(const std::string &path)
Checks if a given path in UTF-8 is a directory.
unsigned int getCurrentOffset() const
Return the index of the current object.
void setSRID(int srid)
It sets the Spatial Reference System ID of the geometry and all its parts if it is a GeometryCollecti...
unsigned int getCurrentOffset() const
Return the index of the current object.
~FeederConstRasterDirectory()
bool moveNext()
Advances to the next sequence obeject.
void reset()
Reset the feeder to the first position (subsequent accesses will start from the first sequence obejct...
virtual const char * what() const
It outputs the exception message.
std::vector< const te::rst::Raster * > m_rasters
#define TERP_LOGWARN(message)
Logs a warning message.
std::unique_ptr< te::rst::Raster > m_currentRasterPtr
unsigned int getObjsCount() const
Return the total number of feeder objects.
unsigned int getObjsCount() const
Return the total number of feeder objects.
double m_urx
Upper right corner x-coordinate.
void reset()
Reset the feeder to the first position (subsequent accesses will start from the first sequence obejct...
te::rst::Raster const * m_currentRasterNakedPtr
std::vector< const te::rst::Raster * >::size_type m_currentOffset
std::vector< unsigned int >::size_type m_selectedRasterIndexesOffset
std::unique_ptr< te::gm::Geometry > m_restrictionGeomPtr
std::vector< const te::rst::Raster * > m_rasters
std::vector< const te::rst::Raster * >::size_type m_CurrentRasterOffset
void applyGeometryRestriction(const te::gm::Geometry &restrictionGeom)
Apply a new geometry intersect restriction selecting only those rasters intersecting the given geomet...
te::rst::Raster const * getCurrentObj() const
Return the current sequence object.
~FeederConstRasterVector()
unsigned int getObjsCount() const
Return the total number of feeder objects.
A LinearRing is a LineString that is both closed and simple.
double m_llx
Lower left corner x-coordinate.
void setPoint(std::size_t i, const double &x, const double &y)
It sets the value of the specified point.
An Envelope defines a 2D rectangular region.
FeederConstRasterInfoAndVector()
An abstract class for raster data strucutures.
#define TERP_LOG_AND_THROW(message)
Logs a error message and throws.
bool moveTo(const unsigned int index)
Jump to the given object index.
virtual AbstractData * clone() const =0
It returns a clone of this object.
std::vector< std::map< std::string, std::string > > m_rInfos
te::rst::Raster const * getCurrentObj() const
Return the current sequence object.
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
std::unique_ptr< te::rst::Raster > m_currentRasterHandler
double m_lly
Lower left corner y-coordinate.
unsigned int getObjsCount() const
Return the total number of feeder objects.
std::vector< std::string > m_rTypes
bool moveTo(const unsigned int index)
Jump to the given object index.
#define TERP_LOG_AND_RETURN_FALSE(message)
Logs a warning message will and return false.
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
bool moveNext()
Advances to the next sequence obeject.
double m_ury
Upper right corner y-coordinate.
FeederConstRasterVector()
void clear()
It deletes all the rings of the CurvePolygon and clear it.
unsigned int getCurrentOffset() const
Return the index of the current object.
void setSRID(int srid)
It sets the Spatial Reference System ID of the linestring.
void reset()
Reset the feeder to the first position (subsequent accesses will start from the first sequence obejct...
void reset()
Reset the feeder to the first position (subsequent accesses will start from the first sequence obejct...
unsigned int getCurrentOffset() const
Return the index of the current object.
std::vector< std::map< std::string, std::string > > m_rInfos
~FeederConstRasterInfoAndVector()
bool initialize(const std::string &directoryName, const bool recursive, const std::string &rType, const bool sortFileNames, const std::vector< std::string > &fileExtensions, te::gm::Geometry const *const restrictionGeomPtr, const bool ignoreInvalidRasterFiles)
Initialize this instance.
static bool isRegularFile(const std::string &path)
Checks if a given path in UTF-8 is a regular file.
std::unique_ptr< te::rst::Raster > m_currentRasterPtr
std::vector< unsigned int > m_selectedRastersIndexes
std::vector< std::string >::size_type m_currentOffset
bool moveNext()
Advances to the next sequence obeject.
#define TERP_TRUE_OR_THROW(value, message)
Checks if value is true and throws an exception if not.
bool m_ignoreInvalidRasterFiles
If true, invalid raster files will be ignored.
const std::string & getCurrentRasterFileName()
Returns the current raster file name.
static Raster * open(const std::map< std::string, std::string > &rinfo, te::common::AccessPolicy p=te::common::RAccess)
It opens a raster with the given parameters and default raster driver.
std::vector< std::string > m_rTypes
std::vector< std::string > m_allRasterFileNames