Skip to content
Snippets Groups Projects
Commit ca4aec9f authored by Emmanuel Christophe's avatar Emmanuel Christophe
Browse files

ENH: adding fun info on the viewer

parent c6c25002
No related branches found
No related tags found
No related merge requests found
...@@ -37,6 +37,8 @@ CoordinateToName::CoordinateToName(): ...@@ -37,6 +37,8 @@ CoordinateToName::CoordinateToName():
m_Threader = itk::MultiThreader::New(); m_Threader = itk::MultiThreader::New();
m_UpdateDistance = 0.01;//about 1km at equator
} }
/** /**
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "itkObject.h" #include "itkObject.h"
#include "itkObjectFactory.h" #include "itkObjectFactory.h"
#include "itkPoint.h"
#include "itkMultiThreader.h" #include "itkMultiThreader.h"
namespace otb namespace otb
...@@ -50,12 +51,36 @@ public: ...@@ -50,12 +51,36 @@ public:
/** Method for creation through the object factory. */ /** Method for creation through the object factory. */
itkNewMacro(Self); itkNewMacro(Self);
typedef itk::Point<double,2> PointType;
itkGetMacro( Lon, double ); itkGetMacro( Lon, double );
itkGetMacro( Lat, double ); itkGetMacro( Lat, double );
itkSetMacro( Lon, double ); itkSetMacro( Lon, double );
itkSetMacro( Lat, double ); itkSetMacro( Lat, double );
/**
* Set the lon/lat only if they are far enough from the current point to
* avoid triggering too many updates
*/
bool SetLonLat(PointType point)
{
if ((vcl_abs(point[0] - m_Lon) > m_UpdateDistance) || (vcl_abs(point[1] - m_Lat) > m_UpdateDistance))
{
std::cout << "Update lon/lat " << m_Lon << ", " << m_Lat << " -> " << point << std::endl;
m_Lon = point[0];
m_Lat = point[1];
//TODO Check whether it is better to have something imprecise or nothing at all
m_IsValid = false;
return true;
}
else
{
std::cout << "Keeping lon/lat" << std::endl;
return false;
}
}
std::string GetPlaceName() const std::string GetPlaceName() const
{ {
if (m_IsValid) if (m_IsValid)
...@@ -105,6 +130,9 @@ private: ...@@ -105,6 +130,9 @@ private:
double m_Lat; double m_Lat;
bool m_Multithread; bool m_Multithread;
bool m_IsValid; bool m_IsValid;
//Minimum distance to trigger an update of the coordinates
//specified in degrees
double m_UpdateDistance;
std::string m_PlaceName; std::string m_PlaceName;
std::string m_CountryName; std::string m_CountryName;
......
...@@ -29,6 +29,8 @@ ...@@ -29,6 +29,8 @@
#include "otbRenderingImageFilter.h" #include "otbRenderingImageFilter.h"
#include "otbGenericRSTransform.h" #include "otbGenericRSTransform.h"
#include "otbCoordinateToName.h"
namespace otb namespace otb
{ {
/** \class ImageLayer /** \class ImageLayer
...@@ -246,6 +248,7 @@ private: ...@@ -246,6 +248,7 @@ private:
/** Coordinate transform */ /** Coordinate transform */
TransformType::Pointer m_Transform; TransformType::Pointer m_Transform;
CoordinateToName::Pointer m_CoordinateToName;
/** General info about the image*/ /** General info about the image*/
std::string m_PlaceName;//FIXME the call should be done by a more general method outside of the layer std::string m_PlaceName;//FIXME the call should be done by a more general method outside of the layer
......
...@@ -59,6 +59,7 @@ ImageLayer<TImage,TOutputImage> ...@@ -59,6 +59,7 @@ ImageLayer<TImage,TOutputImage>
m_ScaledExtractRenderingFilter->SetInput(m_ScaledExtractFilter->GetOutput()); m_ScaledExtractRenderingFilter->SetInput(m_ScaledExtractFilter->GetOutput());
m_Transform = TransformType::New(); m_Transform = TransformType::New();
m_CoordinateToName = CoordinateToName::New();
m_PlaceName = ""; m_PlaceName = "";
m_CountryName = ""; m_CountryName = "";
...@@ -273,18 +274,16 @@ ImageLayer<TImage,TOutputImage> ...@@ -273,18 +274,16 @@ ImageLayer<TImage,TOutputImage>
if (m_Transform->GetTransformAccuracy() == Projection::PRECISE) oss<< "(precise location)" << std::endl; if (m_Transform->GetTransformAccuracy() == Projection::PRECISE) oss<< "(precise location)" << std::endl;
if (m_Transform->GetTransformAccuracy() == Projection::ESTIMATE) oss<< "(estimated location)" << std::endl; if (m_Transform->GetTransformAccuracy() == Projection::ESTIMATE) oss<< "(estimated location)" << std::endl;
// if ((m_PlaceName == "") && (m_CountryName == "")) if (m_CoordinateToName->SetLonLat(point))
// { {
// CoordinateToName::Pointer conv = CoordinateToName::New(); m_CoordinateToName->Evaluate();
// conv->SetLon(point[0]); }
// conv->SetLat(point[1]);
// conv->Evaluate(); m_PlaceName = m_CoordinateToName->GetPlaceName();
// m_CountryName = m_CoordinateToName->GetCountryName();
// m_PlaceName = conv->GetPlaceName();
// m_CountryName = conv->GetCountryName(); if (m_PlaceName != "") oss << "Near " << m_PlaceName;
// } if (m_CountryName != "") oss << " in " << m_CountryName;
// if (m_PlaceName != "") oss << "Near " << m_PlaceName;
// if (m_CountryName != "") oss << " in " << m_CountryName;
} }
else else
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment