diff --git a/Code/Common/otbPolyLineParametricPathWithValue.h b/Code/Common/otbPolyLineParametricPathWithValue.h index 182c642301bd30f9ad29a106c9847a240744167b..f507305f975d6944db017fd984dc8ca961af879b 100644 --- a/Code/Common/otbPolyLineParametricPathWithValue.h +++ b/Code/Common/otbPolyLineParametricPathWithValue.h @@ -65,10 +65,10 @@ class ITK_EXPORT PolyLineParametricPathWithValue itk::EncapsulateMetaData<ValueType>(dict,m_Key,value); } - ValueType GetValue(void) + ValueType GetValue(void) const { ValueType resp = itk::NumericTraits<ValueType>::Zero; - itk::MetaDataDictionary & dict = this->GetMetaDataDictionary(); + const itk::MetaDataDictionary & dict = this->GetMetaDataDictionary(); if(dict.HasKey(m_Key)) { itk::ExposeMetaData<ValueType>(dict,m_Key,resp); @@ -84,7 +84,7 @@ class ITK_EXPORT PolyLineParametricPathWithValue * Return the path length (perimeter). * \return The length. */ - virtual double GetLength(); + virtual double GetLength() const; protected: /** Constructor */ diff --git a/Code/Common/otbPolyLineParametricPathWithValue.txx b/Code/Common/otbPolyLineParametricPathWithValue.txx index d2c397e3fae77bb973c5519024a71f3ce87f0e49..f63b986addf5e70dfda6aab32eea46cba7b6675f 100644 --- a/Code/Common/otbPolyLineParametricPathWithValue.txx +++ b/Code/Common/otbPolyLineParametricPathWithValue.txx @@ -36,7 +36,7 @@ namespace otb template < class TValue,unsigned int VDimension> double PolyLineParametricPathWithValue<TValue,VDimension> - ::GetLength() + ::GetLength() const { double length = 0.0; VertexListConstIteratorType it = this->GetVertexList()->Begin(); diff --git a/Code/Common/otbPolygon.h b/Code/Common/otbPolygon.h index f6af07a65637d9da091aa6977d28592d4827a43e..6429f47d05c16153af1ac94b3709a9c9f3352706 100644 --- a/Code/Common/otbPolygon.h +++ b/Code/Common/otbPolygon.h @@ -71,14 +71,14 @@ class ITK_EXPORT Polygon * \param point The point to check. * \return True if the point is inside the polygon. */ - bool IsInside(VertexType point); + bool IsInside(VertexType point) const; /** * Check wether point is strictly on the edge of the polygon. * \param point The point to check. * \return True if the point is on the edge of the polygon. */ - bool IsOnEdge(VertexType point); + bool IsOnEdge(VertexType point) const; /** * Returns the number of crossings of the polygon with a given segment. @@ -86,7 +86,7 @@ class ITK_EXPORT Polygon * \param b Second point of the segment, * \return the number of strict crossings of segment [ab] with the polygon. */ - unsigned int NbCrossing(VertexType a, VertexType b); + unsigned int NbCrossing(VertexType a, VertexType b) const; /** * Returns the number of touchings without crossing of the polygon with a given segment. @@ -94,7 +94,7 @@ class ITK_EXPORT Polygon * \param b Second point of the segment, * \return the number of touchings without crossing of segment [ab] with the polygon. */ - unsigned int NbTouching(VertexType a, VertexType b); + unsigned int NbTouching(VertexType a, VertexType b) const; /** * Check wether two segments [a1a2] and [b1b2] are strictly crossing. @@ -104,7 +104,7 @@ class ITK_EXPORT Polygon * \param a1 Second point of the second segment. * \return True if the two segments are strictly crossing. */ - bool IsCrossing(VertexType a1, VertexType a2, VertexType b1, VertexType b2); + bool IsCrossing(VertexType a1, VertexType a2, VertexType b1, VertexType b2) const; /** * Check wether two segments[a1a2] and [b1b2] are touching without crossing. @@ -114,7 +114,7 @@ class ITK_EXPORT Polygon * \param a1 Second point of the second segment. * \return True if the two segments are touching without crossing. */ - bool IsTouching(VertexType a1, VertexType a2, VertexType b1, VertexType b2); + bool IsTouching(VertexType a1, VertexType a2, VertexType b1, VertexType b2) const; /** * Compute the polygon bounding region. @@ -126,13 +126,13 @@ class ITK_EXPORT Polygon * Return the polygon surface. * \return The surface. */ - double GetSurface(); + double GetSurface() const; /** * Return the polygon length (perimeter). * \return The length. */ - virtual double GetLength(); + virtual double GetLength() const; protected: /** Constructor */ @@ -153,7 +153,7 @@ private: void operator=(const Self&); //purposely not implemented double m_Epsilon; - double m_Surface; + }; }// End namespace otb diff --git a/Code/Common/otbPolygon.txx b/Code/Common/otbPolygon.txx index c5e620a7334ec19fb73ddd08305332185f6f739f..0b9c548b66a87296feeb0647e72d2455aef3d8e9 100644 --- a/Code/Common/otbPolygon.txx +++ b/Code/Common/otbPolygon.txx @@ -31,7 +31,7 @@ namespace otb template<class TValue> bool Polygon<TValue> -::IsInside(VertexType point) +::IsInside(VertexType point) const { double x = point[0]; double y = point[1]; @@ -110,7 +110,7 @@ Polygon<TValue> template<class TValue> bool Polygon<TValue> -::IsOnEdge(VertexType point) +::IsOnEdge(VertexType point) const { //std::cout<<"Checking point "<<point<<std::endl; bool resp = false; @@ -198,7 +198,7 @@ Polygon<TValue> template<class TValue> unsigned int Polygon<TValue> -::NbCrossing(VertexType a, VertexType b) +::NbCrossing(VertexType a, VertexType b) const { unsigned int resp = 0; VertexListConstIteratorType it = this->GetVertexList()->Begin(); @@ -232,7 +232,7 @@ Polygon<TValue> template<class TValue> unsigned int Polygon<TValue> -::NbTouching(VertexType a, VertexType b) +::NbTouching(VertexType a, VertexType b) const { unsigned int resp = 0; VertexListConstIteratorType it = this->GetVertexList()->Begin(); @@ -268,7 +268,7 @@ Polygon<TValue> template<class TValue> bool Polygon<TValue> -::IsCrossing(VertexType a1, VertexType a2, VertexType b1, VertexType b2) +::IsCrossing(VertexType a1, VertexType a2, VertexType b1, VertexType b2) const { bool resp = false; double xbmin = std::min(b1[0],b2[0]); @@ -325,7 +325,7 @@ Polygon<TValue> template<class TValue> bool Polygon<TValue> -::IsTouching(VertexType a1, VertexType a2, VertexType b1, VertexType b2) +::IsTouching(VertexType a1, VertexType a2, VertexType b1, VertexType b2) const { bool resp = false; double xbmin = std::min(b1[0],b2[0]); @@ -480,8 +480,9 @@ Polygon<TValue> template<class TValue> double Polygon<TValue> - ::GetSurface() + ::GetSurface() const { + double m_Surface; m_Surface = 0.0; VertexListConstIteratorType it = this->GetVertexList()->Begin(); @@ -522,7 +523,7 @@ template<class TValue> */ template < class TValue> double Polygon<TValue> - ::GetLength() + ::GetLength() const { double length = 0.0; VertexListConstIteratorType it = this->GetVertexList()->Begin(); diff --git a/Examples/Projections/CMakeLists.txt b/Examples/Projections/CMakeLists.txt index f09d0e73f34096bdbd155ff7da5482efbb033378..cb57a1f404d92ef9af05e68451d8f512f772620f 100644 --- a/Examples/Projections/CMakeLists.txt +++ b/Examples/Projections/CMakeLists.txt @@ -15,6 +15,9 @@ SET(PROJECTIONS_EXAMPLES ${CXX_TEST_PATH}/otbProjectionsExamplesTests) ADD_EXECUTABLE(SensorModelExample SensorModelExample.cxx ) TARGET_LINK_LIBRARIES(SensorModelExample OTBProjections OTBCommon OTBIO ITKCommon ITKIO) +ADD_EXECUTABLE(MapProjectionExample MapProjectionExample.cxx ) +TARGET_LINK_LIBRARIES(MapProjectionExample OTBProjections OTBCommon OTBIO) + ADD_EXECUTABLE(OrthoRectificationExample OrthoRectificationExample.cxx ) TARGET_LINK_LIBRARIES(OrthoRectificationExample OTBProjections OTBCommon OTBIO ITKCommon ITKIO) diff --git a/Examples/Projections/MapProjectionExample.cxx b/Examples/Projections/MapProjectionExample.cxx new file mode 100644 index 0000000000000000000000000000000000000000..d162c0cf0991f5038b7920ca52fdf0366885c946 --- /dev/null +++ b/Examples/Projections/MapProjectionExample.cxx @@ -0,0 +1,47 @@ +/*========================================================================= + + Program: ORFEO Toolbox + Language: C++ + Date: $Date$ + Version: $Revision$ + + + Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. + See OTBCopyright.txt for details. + + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#if defined(_MSC_VER) +#pragma warning ( disable : 4786 ) +#endif + +#include "otbMapProjections.h" + +int main( int argc, char* argv[] ) +{ + if(argc < 3 ) + { + std::cout << argv[0] <<" <lon> <lat> <outputfile>" << std::endl; + + return EXIT_FAILURE; + } + + double lon = atof(argv[1]); + double lat = atof(argv[2]); + const char * outFileName = argv[3]; + + std::ofstream file; + file.open(outFileName); + file << std::setprecision(15); + + otb::UtmForwardProjection::Pointer lUtmProjection = otb::UtmForwardProjection::New(); + + + + + return EXIT_SUCCESS; +}