28 #include "../geometry/LinearRing.h" 
   29 #include "../geometry/MultiPoint.h" 
   30 #include "../geometry/MultiLineString.h" 
   31 #include "../geometry/Point.h" 
   32 #include "../geometry/Envelope.h" 
   33 #include "../geometry/Enums.h" 
   34 #include "../raster/Raster.h" 
   35 #include "../raster/Grid.h" 
   36 #include "../raster/Band.h" 
   37 #include "../raster/BandProperty.h" 
   46 #define getPerpendicularDistance( pX, pY, lineAX, lineAY, lineBX, lineBY, aux1, aux2, perpDist ) \ 
   47   aux1 = lineAX - lineBX; \ 
   48   aux2 = lineAY - lineBY; \ 
   51     perpDist = std::abs( pX - lineAX ); \ 
   53   else if( aux2 == 0.0 ) \ 
   55     perpDist = std::abs( pY - lineAY ); \ 
   61         ( aux2 * pX ) - ( aux1 * pY ) + ( lineAX * lineBY ) - ( lineBX * lineAY ) \ 
   64       std::sqrt( ( aux1 * aux1 ) + ( aux2 * aux2 ) ); \ 
   82       const std::vector< unsigned int >& raster1Bands, 
 
   84       const std::vector< unsigned int >& raster2Bands,
 
   88       const double& noDataValue,
 
   89       const bool forceInputNoDataValue,
 
   90       const std::vector< double >& pixelOffsets1,
 
   91       const std::vector< double >& pixelScales1,
 
   92       const std::vector< double >& pixelOffsets2,
 
   93       const std::vector< double >& pixelScales2,
 
  100         "Invalid raster 1" );        
 
  103         "Invalid raster 2" ); 
 
  105         raster2Bands.size(), 
"Invalid raster bands vector" );
 
  107         raster1Bands.size(), 
"Invalid pixel offsets" );
 
  109         raster1Bands.size(), 
"Invalid pixel scales" );        
 
  111         raster2Bands.size(), 
"Invalid pixel offsets" );
 
  113         raster2Bands.size(), 
"Invalid pixel scales" );        
 
  115         ( r1ValidDataDelimiterPtr->
getNPoints() > 1 ) : 
true ),
 
  116         "Invalid polygon 1" )
 
  118         ( r2ValidDataDelimiterPtr->
getNPoints() > 1 ) : 
true ),
 
  119         "Invalid polygon 2" )
 
  121         "Invalid transformation" );
 
  132       std::auto_ptr< te::gm::Polygon > indexedDelimiter1Ptr; 
 
  134       if( r1ValidDataDelimiterPtr )
 
  136         const std::size_t nRings = r1ValidDataDelimiterPtr->
getNumRings();
 
  141         for( std::size_t ringIdx = 0 ; ringIdx < nRings ; ++ringIdx )
 
  144             r1ValidDataDelimiterPtr->
getRingN( ringIdx ) );
 
  147           const std::size_t nPoints = inRingPtr->
getNPoints();
 
  154           for( std::size_t pIdx = 0 ; pIdx < nPoints ; ++pIdx )
 
  156             grid.
geoToGrid( inCoordsPtr[ pIdx ].x, inCoordsPtr[ pIdx ].y, 
 
  157               auxCoord.
x, auxCoord.
y ); 
 
  158             outRingPtr->
setPoint( pIdx, auxCoord.
x, auxCoord.
y );
 
  161           indexedDelimiter1Ptr->add( outRingPtr );
 
  187         indexedDelimiter1Ptr->add( outRingPtr );
 
  190       std::auto_ptr< te::gm::Polygon > indexedDelimiter2Ptr; 
 
  192       if( r2ValidDataDelimiterPtr )
 
  194         const std::size_t nRings = r2ValidDataDelimiterPtr->
getNumRings();
 
  199         for( std::size_t ringIdx = 0 ; ringIdx < nRings ; ++ringIdx )
 
  202             r2ValidDataDelimiterPtr->
getRingN( ringIdx ) );
 
  205           const std::size_t nPoints = inRingPtr->
getNPoints();
 
  213           for( std::size_t pIdx = 0 ; pIdx < nPoints ; ++pIdx )
 
  215             grid.
geoToGrid( inCoordsPtr[ pIdx ].x, inCoordsPtr[ pIdx ].y, 
 
  216               auxCoord.
x, auxCoord.
y ); 
 
  217             geomTransformation.
inverseMap( auxCoord.
x, auxCoord.
y, auxCoord2.
x, auxCoord2.
y );
 
  218             outRingPtr->
setPoint( pIdx, auxCoord2.
x, auxCoord2.
y );
 
  221           indexedDelimiter2Ptr->add( outRingPtr );
 
  236           auxCoord.
x, auxCoord.
y );
 
  237         outRingPtr->
setPoint( 0, auxCoord.
x, auxCoord.
y );
 
  238         outRingPtr->
setPoint( 4, auxCoord.
x, auxCoord.
y ); 
 
  243           auxCoord.
x, auxCoord.
y );
 
  244         outRingPtr->
setPoint( 1, auxCoord.
x, auxCoord.
y );
 
  249           auxCoord.
x, auxCoord.
y );
 
  250         outRingPtr->
setPoint( 2, auxCoord.
x, auxCoord.
y );
 
  255           auxCoord.
x, auxCoord.
y );
 
  256         outRingPtr->
setPoint( 3, auxCoord.
x, auxCoord.
y );
 
  258         indexedDelimiter2Ptr->add( outRingPtr );
 
  264         std::auto_ptr< te::gm::Geometry > geomIntersectionPtr( 
 
  265           indexedDelimiter2Ptr->intersection( indexedDelimiter1Ptr.get() ) );
 
  267         if( geomIntersectionPtr.get() )
 
  271             std::auto_ptr< te::gm::MultiPolygon > multiPolIntersectionPtr( 
 
  273             multiPolIntersectionPtr->add( geomIntersectionPtr.release() );
 
  288         std::size_t ringIdx = 0;
 
  290         for( ringIdx = 0 ; ringIdx < indexedDelimiter2Ptr->getNumRings() ;
 
  293           std::auto_ptr< te::gm::Geometry > ringIntersectionPtr;
 
  294           ringIntersectionPtr.reset( indexedDelimiter1Ptr->intersection( indexedDelimiter2Ptr->getRingN( ringIdx ) ) );
 
  296           if( ringIntersectionPtr.get() != 0 ) 
 
  301                 ringIntersectionPtr.get() );
 
  302               assert( ringIntersectionNPtr );
 
  306               for( std::size_t gIdx = 0 ; gIdx < numGeoms ; ++gIdx )
 
  310                 assert( segIndexedNPtr );
 
  312                 std::size_t nPoints = segIndexedNPtr->
size();
 
  315                 for( std::size_t pIdx = 1 ; pIdx < nPoints ; ++pIdx )
 
  318                     coodsPtr[ pIdx - 1 ], coodsPtr[ pIdx ] ) );
 
  325                 ringIntersectionPtr.get() );
 
  326               assert( segIndexedNPtr );
 
  328               std::size_t nPoints = segIndexedNPtr->
size();
 
  331               for( std::size_t pIdx = 1 ; pIdx < nPoints ; ++pIdx )
 
  334                   coodsPtr[ pIdx - 1 ], coodsPtr[ pIdx ] ) );
 
  340         for( ringIdx = 0 ; ringIdx < indexedDelimiter1Ptr->getNumRings() ;
 
  343           std::auto_ptr< te::gm::Geometry > ringIntersectionPtr;
 
  344           ringIntersectionPtr.reset( indexedDelimiter2Ptr->intersection( indexedDelimiter1Ptr->getRingN( ringIdx ) ) );
 
  346           if( ringIntersectionPtr.get() != 0 ) 
 
  351                 ringIntersectionPtr.get() );
 
  352               assert( ringIntersectionNPtr );
 
  356               for( std::size_t gIdx = 0 ; gIdx < numGeoms ; ++gIdx )
 
  360                 assert( segIndexedNPtr );
 
  362                 std::size_t nPoints = segIndexedNPtr->
size();
 
  365                 for( std::size_t pIdx = 1 ; pIdx < nPoints ; ++pIdx )
 
  368                     coodsPtr[ pIdx - 1 ], coodsPtr[ pIdx ] ) );
 
  375                 ringIntersectionPtr.get() );
 
  376               assert( segIndexedNPtr );
 
  378               std::size_t nPoints = segIndexedNPtr->
size();
 
  381               for( std::size_t pIdx = 1 ; pIdx < nPoints ; ++pIdx )
 
  384                   coodsPtr[ pIdx - 1 ], coodsPtr[ pIdx ] ) );
 
  417       switch( blendMethod )
 
  459       for( std::vector< unsigned int >::size_type rasterBandsIdx = 0 ; 
 
  460         rasterBandsIdx < raster1Bands.size() ; ++rasterBandsIdx )
 
  468         if( forceInputNoDataValue )
 
  537       std::vector< double >& values )
 
  583       std::vector< double >& values )
 
MultiLineString is a MultiCurve whose elements are LineStrings. 
 
std::vector< unsigned int > m_raster1Bands
Input raster 1 band indexes to use. 
 
te::rst::Interpolator * m_interp1
Raster 1 interpolator instance pointer. 
 
void setX(const double &x)
It sets the Point x-coordinate value. 
 
#define TERP_DEBUG_TRUE_OR_THROW(value, message)
Checks if value is true and throws an exception if not. 
 
std::vector< double > m_pixelOffsets2
The values offset to be applied to raster 2 pixel values before the blended value calcule (one elemen...
 
std::vector< std::pair< te::gm::Coord2D, te::gm::Coord2D > > m_r1IntersectionSegmentsPoints
A sub-set of the intersection polygon wich is part of raster 1 valid data polygon ( raster 1 indexed ...
 
std::vector< unsigned int > m_raster2Bands
Input raster 2 band indexes to use. 
 
void clear()
Clear all internal allocated resources. 
 
void noBlendMethodImp(const double &line1, const double &col1, std::vector< double > &values)
Implementation for NoBlendMethod. 
 
double m_euclideanDistanceMethodImp_aux1
 
std::size_t getNPoints() const 
It returns the number of points (vertexes) in the linestring. 
 
unsigned int getNumberOfRows() const 
Returns the raster number of rows. 
 
Euclidean distance method. 
 
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings. 
 
A LinearRing is a LineString that is both closed and simple. 
 
std::size_t m_euclideanDistanceMethodImp_vecIdx
 
std::vector< double > m_pixelScales2
The values scale to be applied to raster 2 pixel values before the blended value calcule (one element...
 
Geometry * getGeometryN(std::size_t i) const 
It returns the n-th geometry in this GeometryCollection. 
 
std::size_t getNumRings() const 
It returns the number of rings in this CurvePolygon. 
 
void setY(const double &y)
It sets the Point y-coordinate value. 
 
Grid * getGrid()
It returns the raster grid. 
 
std::complex< double > m_euclideanDistanceMethodImp_cValue2
 
std::size_t size() const 
It returns the number of points (vertexes) in the geometry. 
 
te::rst::Interpolator * m_interp2
Raster 2 interpolator instance pointer. 
 
te::rst::Interpolator::Method m_interpMethod1
The interpolation method to use when reading raster 1 data. 
 
virtual bool within(const Geometry *const rhs) const 
It returns true if the geometry object is spatially within rhs geometry. 
 
void getValue(const double &c, const double &r, std::complex< double > &v, const std::size_t &b)
Get the interpolated value at specific band. 
 
#define getPerpendicularDistance(pX, pY, lineAX, lineAY, lineBX, lineBY, aux1, aux2, perpDist)
 
double m_noBlendMethodImp_Point2Col
 
virtual std::size_t getNumberOfBands() const =0
Returns the number of bands (dimension of cells attribute values) in the raster. 
 
It interpolates one pixel based on a selected algorithm. Methods currently available are Nearest Neig...
 
te::gm::GeometricTransformation * m_geomTransformationPtr
A transformation mapping raster 1 pixels ( te::gm::GTParameters::TiePoint::first ) to raster 2 ( te::...
 
BlendMethod m_blendMethod
The blend method to apply. 
 
An utility struct for representing 2D coordinates. 
 
LineString is a curve with linear interpolation between points. 
 
Method
Allowed interpolation methods. 
 
#define TERP_TRUE_OR_RETURN_FALSE(value, message)
Checks if value is true. For false values a warning message will be logged and a return of context wi...
 
void initState()
Reset the instance to its initial default state. 
 
std::complex< double > m_euclideanDistanceMethodImp_cValue1
 
std::size_t getNumGeometries() const 
It returns the number of geometries in this GeometryCollection. 
 
te::rst::Raster const * m_raster1Ptr
Input raster 1. 
 
A rectified grid is the spatial support for raster data. 
 
MultiPolygon is a MultiSurface whose elements are Polygons. 
 
virtual GeometricTransformation * clone() const =0
Creat a clone copy of this instance. 
 
double m_euclideanDistanceMethodImp_Point2Line
 
unsigned int m_euclideanDistanceMethodImp_BandIdx
 
virtual bool isValid(const GTParameters ¶ms) const =0
Verifies if the supplied parameters already has a valid transformation. 
 
std::vector< double > m_raster1NoDataValues
 
te::rst::Raster const * m_raster2Ptr
Input raster 2. 
 
Coord2D * getCoordinates() const 
It returns a pointer to the internal array of coordinates. 
 
double m_euclideanDistanceMethodImp_Point2Col
 
std::size_t m_r2IntersectionSegmentsPointsSize
Size of m_r2IntersectionSegmentsPoints;. 
 
void euclideanDistanceMethodImp(const double &line1, const double &col1, std::vector< double > &values)
Implementation for EuclideanDistanceMethod. 
 
std::auto_ptr< te::gm::MultiPolygon > m_intersectionPtr
The Intersection geometry ( Multipolygon geometry - raster 1 indexed coods). 
 
double m_outputNoDataValue
The output raster no-data value. 
 
std::vector< double > m_raster2NoDataValues
Raster 1 no-data values (on value per band). 
 
te::gm::Point m_euclideanDistanceMethodImp_auxPoint
 
std::size_t m_r1IntersectionSegmentsPointsSize
Size of m_r1IntersectionSegmentsPoints;. 
 
double m_euclideanDistanceMethodImp_currDist
 
double m_noBlendMethodImp_Value
 
unsigned int getNumberOfColumns() const 
Returns the raster number of columns. 
 
double m_euclideanDistanceMethodImp_aux2
 
unsigned int m_noBlendMethodImp_BandIdx
 
void setPoint(std::size_t i, const double &x, const double &y)
It sets the value of the specified point. 
 
double m_noDataValue
Value to indicate elements where there is no data, default is std::numeric_limits<double>::max(). 
 
2D Geometric transformation base class. 
 
te::rst::Interpolator::Method m_interpMethod2
The interpolation method to use when reading raster 2 data. 
 
std::vector< std::pair< te::gm::Coord2D, te::gm::Coord2D > > m_r2IntersectionSegmentsPoints
A sub-set of the intersection polygon wich is part of raster 2 valid data polygon ( raster 1 indexed ...
 
std::vector< double > m_pixelOffsets1
The values offset to be applied to raster 1 pixel values before the blended value calcule (one elemen...
 
An abstract class for raster data strucutures. 
 
BandProperty * getProperty()
Returns the band property. 
 
virtual const Band * getBand(std::size_t i) const =0
Returns the raster i-th band. 
 
double m_euclideanDistanceMethodImp_dist2
 
std::size_t getNPoints() const 
it returns the number of points (vertexes) in the geometry. 
 
Blended pixel value calculation for two overlaped rasters. 
 
std::vector< double > m_pixelScales1
The values scale to be applied to raster 1 pixel values before the blended value calcule (one element...
 
Near neighborhood interpolation method. 
 
void geoToGrid(const double &x, const double &y, double &col, double &row) const 
Get the grid point associated to a spatial location. 
 
double m_noBlendMethodImp_Point2Line
 
virtual void directMap(const GTParameters ¶ms, const double &pt1X, const double &pt1Y, double &pt2X, double &pt2Y) const =0
Direct mapping (from pt1 space into pt2 space). 
 
BlendFunctPtr m_blendFuncPtr
The current blend function. 
 
Curve * getRingN(std::size_t i) const 
It returns the n-th ring for this curve polygon as a curve. 
 
std::complex< double > m_noBlendMethodImp_cValue
 
bool initialize(const te::rst::Raster &raster1, const std::vector< unsigned int > &raster1Bands, const te::rst::Raster &raster2, const std::vector< unsigned int > &raster2Bands, const BlendMethod &blendMethod, const te::rst::Interpolator::Method &interpMethod1, const te::rst::Interpolator::Method &interpMethod2, const double &noDataValue, const bool forceInputNoDataValue, const std::vector< double > &pixelOffsets1, const std::vector< double > &pixelScales1, const std::vector< double > &pixelOffsets2, const std::vector< double > &pixelScales2, te::gm::Polygon const *const r1ValidDataDelimiterPtr, te::gm::Polygon const *const r2ValidDataDelimiterPtr, const te::gm::GeometricTransformation &geomTransformation)
Inititate the blender instance. 
 
te::common::AccessPolicy getAccessPolicy() const 
Returns the raster access policy. 
 
virtual void inverseMap(const GTParameters ¶ms, const double &pt2X, const double &pt2Y, double &pt1X, double &pt1Y) const =0
Inverse mapping (from pt2 space into pt1 space). 
 
double m_euclideanDistanceMethodImp_dist1