Commit 40534f43 authored by OTB Bot's avatar OTB Bot

STYLE

parent 93a71540
......@@ -84,7 +84,7 @@ GetMetadataByKey(const std::string& key) const
return it->second;
}
void
void
ImageKeywordlist::
ClearMetadataByKey(const std::string& key)
{
......
......@@ -26,16 +26,16 @@ namespace otb {
/** \class OSMDataToVectorDataGenerator
*
* \brief Helper class to compute the extent of the input image and
* use it to fill the bbox for the OSM request.
* use it to fill the bbox for the OSM request.
*
* This class compute the extent of the input image. The extent is
* than used to fill the bbox values.
* than used to fill the bbox values.
* The class OSMDataToVectorDataGenerator request the OSM server to get
* the OSM XML file within this bbox.
*
* \sa otb::OSMDataToVectorDataGenerator
*/
template < class TImage>
template < class TImage>
class ITK_EXPORT ImageToOSMVectorDataGenerator :
public OSMDataToVectorDataGenerator
{
......@@ -52,13 +52,13 @@ public:
/** Method for creation through the object factory. */
itkNewMacro(Self);
// Image typedef
// Image typedef
typedef TImage ImageType;
typedef typename ImageType::SizeType SizeType;
typedef typename ImageType::IndexType IndexType;
typedef typename ImageType::PointType PointType;
// VectorData
// VectorData
typedef Superclass::VectorDataType VectorDataType;
// Struct to store the extent of the image
......@@ -90,7 +90,7 @@ private:
ImageExtentType m_ImageExtent;
}; // end of class
}; // end of class
} // end of namespace otb
......
......@@ -27,7 +27,7 @@
namespace otb
{
OSMDataToVectorDataGenerator::OSMDataToVectorDataGenerator():m_North(43.62811),
OSMDataToVectorDataGenerator::OSMDataToVectorDataGenerator():m_North(43.62811),
m_South(43.60185),
m_East(1.59323),
m_West(1.54911),
......@@ -72,7 +72,7 @@ void OSMDataToVectorDataGenerator::GenerateData()
urlStream<<"bbox="<<m_West<<","<<m_South<<","<<m_East<<","<<m_North;
// Use Curl to request the OSM Server
// TODO use the RetrieveUrlInMemory
// TODO use the RetrieveUrlInMemory
if(m_Curl->RetrieveFile(urlStream.str(), m_FileName) != 0)
{
itkExceptionMacro(<<"Problem while getting "<< m_Url);
......@@ -85,7 +85,7 @@ void OSMDataToVectorDataGenerator::GenerateData()
itkExceptionMacro(<<"The XML output FileName is empty, please set the filename via the method SetFileName");
//Check that the right extension is given : expected .xml */
if (itksys::SystemTools::GetFilenameLastExtension(m_FileName) != ".xml"
if (itksys::SystemTools::GetFilenameLastExtension(m_FileName) != ".xml"
&& itksys::SystemTools::GetFilenameLastExtension(m_FileName)!= ".osm" )
{
itkExceptionMacro(<<itksys::SystemTools::GetFilenameLastExtension(m_FileName)
......@@ -93,7 +93,7 @@ void OSMDataToVectorDataGenerator::GenerateData()
}
}
// Parse the XML File
// Parse the XML File
this->ParseXmlFile();
// Remove the osm temp file only if the url request is used
......@@ -115,7 +115,7 @@ void OSMDataToVectorDataGenerator::ParseXmlFile()
std::cout <<"Cannot open the file "<<m_FileName <<std::endl;
}
// Parse the xml
// Parse the xml
TiXmlHandle hDoc(&doc);
TiXmlHandle root = hDoc.FirstChildElement();
......@@ -127,19 +127,19 @@ void OSMDataToVectorDataGenerator::ParseXmlFile()
/* Step 1 : Store the nodes in a std::map */
//////////// //////////// //////////// //////////// ////////////
// Iterate through the tree to get all the nodes and store them in
// Iterate through the tree to get all the nodes and store them in
// a std::map
for( TiXmlElement* node = root.FirstChild("node").ToElement();
node != NULL && strcmp(node->Value(),"node")==0 ;
node != NULL && strcmp(node->Value(),"node")==0;
node = node->NextSiblingElement() )
{
int id = 0;
double longitude = 0.;
double latitude = 0.;
if ( node->QueryIntAttribute("id",&id) == TIXML_SUCCESS
&& node->QueryDoubleAttribute("lat",&latitude) == TIXML_SUCCESS
&& node->QueryDoubleAttribute("lon",&longitude) == TIXML_SUCCESS )
if ( node->QueryIntAttribute("id", &id) == TIXML_SUCCESS
&& node->QueryDoubleAttribute("lat", &latitude) == TIXML_SUCCESS
&& node->QueryDoubleAttribute("lon", &longitude) == TIXML_SUCCESS )
{
// current point
VertexType geoPoint;
......@@ -189,7 +189,7 @@ void OSMDataToVectorDataGenerator::ParseXmlFile()
elementPair.first = result;
elementPair.second = resultValue;
// Add the key,value to map
// Add the key, value to map
this->AddKeyTypeToMap(result, resultValue);
break;
......@@ -203,18 +203,18 @@ void OSMDataToVectorDataGenerator::ParseXmlFile()
// put the current layer pointer to the begining
for( TiXmlElement* currentNode = currentLayer->FirstChildElement("nd");
currentNode != NULL ;
currentNode != NULL;
currentNode = currentNode->NextSiblingElement() )
{
int value=0;
if(currentNode->QueryIntAttribute("ref",&value) == TIXML_SUCCESS)
if(currentNode->QueryIntAttribute("ref", &value) == TIXML_SUCCESS)
{
// Add the current point to the list
pointList.push_back((*m_GeoPointContainer.find(value)).second);
}
}
// Form the VectorDataElement
// Form the VectorDataElement
if(pointList.size()>0)
{
vdelement.first = elementPair;
......@@ -242,7 +242,7 @@ OSMDataToVectorDataGenerator::AddKeyTypeToMap(std::string key, std::string value
bool found = false;
// Add the type if not present
for(unsigned int i = 0; i < currentTypes.size() ; i++)
for(unsigned int i = 0; i < currentTypes.size(); i++)
{
if(currentTypes[i].compare(value) == 0)
found = true;
......@@ -258,7 +258,7 @@ OSMDataToVectorDataGenerator::AddKeyTypeToMap(std::string key, std::string value
std::pair< std::string, StringVectorType > keytype;
keytype.first = key;
keytype.second.push_back(value);
m_KeysMap.insert(keytype);
m_KeysMap.insert(keytype);
}
}
......@@ -283,10 +283,10 @@ OSMDataToVectorDataGenerator::ProcessVectorData(std::string key, std::string val
m_OutputVectorData->GetDataTree()->Add(document, root);
m_OutputVectorData->GetDataTree()->Add(folder, document);
// Form the vector data with the values parsed
// Form the vector data with the values parsed
for(unsigned int idx = 0; idx < m_VectorDataElementList.size(); idx++)
{
// Instanciate a datanode
// Instanciate a datanode
DataNodeType::Pointer currentDataNode = DataNodeType::New();
// Get the current PointTypeList
......@@ -301,12 +301,12 @@ OSMDataToVectorDataGenerator::ProcessVectorData(std::string key, std::string val
{
// value is empty
// or if it is not empty it has to match the requestd value
// or if it is not empty it has to match the requestd value
if(value.empty() || elementPair.second.compare(value) == 0)
{
// If the first and the last vertex are the same = polygon else
// line
// line
if(currentPointList[0].EuclideanDistanceTo(currentPointList[currentPointList.size()-1]) < 1e-10) // polygon
{
currentDataNode->SetNodeId("FEATURE_POLYGON");
......@@ -357,10 +357,10 @@ OSMDataToVectorDataGenerator::GetVectorDataByName(std::string key)
this->ParseXmlFile();
}
// Build the output
// Build the output
this->ProcessVectorData(key,"");
// Get the output
// Get the output
return m_OutputVectorData;
}
......@@ -378,7 +378,7 @@ OSMDataToVectorDataGenerator::GetVectorDataByName(std::string key, std::string v
this->ParseXmlFile();
}
// Build the output
// Build the output
this->ProcessVectorData(key, value);
// Get the output
......
......@@ -37,29 +37,29 @@ namespace otb {
* parameters can be set using the methods Set{North, South, East,
* West}. Thus, only the vector elements that are within this bbox
* are returned in the Xml file.
*
*
* The class parse the XML file for certain keys by default, the
* class allow adding key to be searched in the XML file. Use
* AddKey(std::string key) to add it to the search list.
*
*
* Adding a field and its integer value is possible through the
* methods SetClassKey(std::string) and SetClassKeyValue()
* The field is retrieved by GetFieldAsInt(), thus must be int-compatible
*
* Getting output VectorData is possible via two methods :
*
* Getting output VectorData is possible via two methods :
*
* 1: Get all the features of key in a vector data via
* GetVectorDataByName(std::string key)
* For instance : GetVectorDataByName("highway")
*
* 2: Get only the features for a key that match a given value via
*
* 2: Get only the features for a key that match a given value via
* GetVectorDataByName(std::string key, std::string value)
* For instance : GetVectorDataByName("highway", "motorway")
*
*
* All the keys and their relative values are stored in a map. To get
* this map use the method GetKeysMap().
*
*
*
* TODO - Get the number of elements within the bbox requested. OSM
* server can return only 5000 elements per request ( Cannot
......@@ -69,7 +69,7 @@ namespace otb {
* to process the bbox (split it) and concatenate the result.
*
*/
class ITK_EXPORT OSMDataToVectorDataGenerator :
class ITK_EXPORT OSMDataToVectorDataGenerator :
public VectorDataSource< otb::VectorData<> >
{
public:
......@@ -88,10 +88,10 @@ public:
// typedefs for objects to store results
typedef std::map<int, VertexType> ContainerType;
// Vector to store <Key, value>
// Vector to store <Key, value>
typedef std::pair <std::string, std::string> ElementPairType;
// Coordinates of the nodes
// Coordinates of the nodes
typedef std::vector<VertexType > PointTypeList;
typedef std::pair<ElementPairType, PointTypeList> VectorDataElementType;
typedef std::vector<VectorDataElementType> VectorDataElementListType;
......@@ -131,7 +131,7 @@ public:
/* flag to choose between requesting the url using curl or a file
in the disk */
itkSetMacro(UseUrl,bool);
itkSetMacro(UseUrl, bool);
/** Add a key to search into the list */
void AddKey(std::string key)
......@@ -140,40 +140,40 @@ public:
m_KeyList.push_back(key);
}
/** Method to get the map where are stored the keys and their value
/** Method to get the map where are stored the keys and their value
* found when parsing the osm file.
*/
const KeyMapType GetKeysMap() const
*/
const KeyMapType GetKeysMap() const
{
return m_KeysMap;
}
/** Method to get a VectorData where are stored elements
* corresponding the key
*/
/** Method to get a VectorData where are stored elements
* corresponding the key
*/
const VectorDataType* GetVectorDataByName(std::string key);
/** Method to get a VectorData where are stored elements
/** Method to get a VectorData where are stored elements
* corresponding the key and the value
*/
const VectorDataType* GetVectorDataByName(std::string key, std::string value);
*/
const VectorDataType* GetVectorDataByName(std::string key, std::string value);
protected:
/** Generate Data method : lauch the process */
virtual void GenerateData();
/**
/**
* Parse the xml file get from OSM to compose the requested vector
* data
* data
*/
void ParseXmlFile();
/**
* Compose the vector data
/**
* Compose the vector data
*/
void ProcessVectorData(std::string key, std::string value);
/**
/**
* internal convenient method to serach if a key was already added
*/
bool IsKeyPresent(std::string key);
......@@ -186,7 +186,7 @@ private:
OSMDataToVectorDataGenerator(const Self&); //purposely not implemented
void operator=(const Self&); //purposely not implemented
// Private method to add the key,type to the map
// Private method to add the key, type to the map
void AddKeyTypeToMap(std::string key, std::string value);
// Extent of the region to get from OSM
......@@ -220,6 +220,6 @@ private:
std::string m_ClassKey;
int m_ClassKeyValue;
}; // end of class
}; // end of class
} // end of namespace otb
......@@ -128,7 +128,7 @@ VectorDataIntoImageProjectionFilter<TInputVectorData, TInputImage>
std::cout << "Origin of the input image: "<< m_InputImage->GetOrigin() << std::endl;
std::cout << "Size of the input image: "<< m_InputImage->GetLargestPossibleRegion() << std::endl;
std::cout << "ProjRef of the input image: "<< m_InputImage->GetProjectionRef() << std::endl;
std::cout << "ProjRef of the input vector data: "<< this->GetInput()->GetProjectionRef() << std::endl;*/
std::cout << "ProjRef of the input vector data: "<< this->GetInput()->GetProjectionRef() << std::endl; */
// Get the index of the corner of the image
IndexType ul, ur, ll, lr;
......
......@@ -87,7 +87,7 @@ int otbSpectralAngleDataNodeFeatureFunction(int argc, char* argv[])
imgReader->SetFileName(inputImg);
imgReader->UpdateOutputInformation();
imgReader->Update();//Needed to set m_EndIndex, m_StartIndex in otbDataNodeImageFunction
imgReader->Update(); //Needed to set m_EndIndex, m_StartIndex in otbDataNodeImageFunction
vdReProjFilter->SetInputImage(imgReader->GetOutput());
vdReProjFilter->SetInputVectorData(vdReader->GetOutput());
......
......@@ -26,7 +26,7 @@
#include "otbVectorDataFileWriter.h"
typedef otb::VectorImage<unsigned int,2> ImageType;
typedef otb::VectorImage<unsigned int, 2> ImageType;
typedef otb::ImageToOSMVectorDataGenerator<ImageType> FilterType;
typedef FilterType::VectorDataType VectorDataType;
......@@ -49,17 +49,17 @@ int otbImageToOSMVectorDataGenerator(int argc, char * argv[])
// Parse command line parameters
typedef otb::CommandLineArgumentParser ParserType;
ParserType::Pointer parser = ParserType::New();
parser->AddInputImage();
parser->AddOption("--OutputVectorData","Output VectorData","-out",true);
parser->AddOption("--Key","Key to search in the XML OSM file","-key",1, false);
parser->AddOption("--OSM","OSM XML file to be parsed","-osm",1, false);
parser->AddInputImage();
parser->AddOption("--OutputVectorData","Output VectorData","-out", true);
parser->AddOption("--Key","Key to search in the XML OSM file","-key", 1, false);
parser->AddOption("--OSM","OSM XML file to be parsed","-osm", 1, false);
typedef otb::CommandLineArgumentParseResult ParserResultType;
ParserResultType::Pointer parseResult = ParserResultType::New();
try
{
parser->ParseCommandLine(argc,argv,parseResult);
parser->ParseCommandLine(argc, argv, parseResult);
}
catch ( itk::ExceptionObject & err )
{
......@@ -70,7 +70,7 @@ int otbImageToOSMVectorDataGenerator(int argc, char * argv[])
typedef std::pair<std::string, std::string> KeyValueType;
typedef std::vector<KeyValueType> KeyValueListType;
// Instanciate the image reader
// Instanciate the image reader
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName(parseResult->GetInputImage());
reader->UpdateOutputInformation();
......@@ -93,18 +93,18 @@ int otbImageToOSMVectorDataGenerator(int argc, char * argv[])
KeyValueType currentkeyvalue;
std::string str = parseResult->GetParameterString("--Key");
// find the position of the separator ,
// find the position of the separator ,
size_t pos = str.find(",");
// split the string
currentkeyvalue.first = str.substr (0,pos);
currentkeyvalue.first = str.substr (0, pos);
if(pos != std::string::npos)
currentkeyvalue.second = str.substr (pos+1);
keyvalueList.push_back(currentkeyvalue);
}
std::cout <<"Searching for class "<<keyvalueList[0].first
std::cout <<"Searching for class "<<keyvalueList[0].first
<< " and subclass "<< keyvalueList[0].second << std::endl;
......@@ -114,14 +114,14 @@ int otbImageToOSMVectorDataGenerator(int argc, char * argv[])
if(parseResult->IsOptionPresent("--Key"))
{
const VectorDataType *vd =
vdgenerator->GetVectorDataByName(keyvalueList[0].first,
const VectorDataType *vd =
vdgenerator->GetVectorDataByName(keyvalueList[0].first,
keyvalueList[0].second);
writer->SetInput(vd);
}
else
{
const VectorDataType *vd =
const VectorDataType *vd =
vdgenerator->GetVectorDataByName("highway");
writer->SetInput(vd);
}
......
......@@ -63,7 +63,7 @@ int otbOSMToVectorDataGeneratorByName (int argc, char * argv[])
try
{
parser->ParseCommandLine(argc,argv,parseResult);
parser->ParseCommandLine(argc, argv, parseResult);
}
catch ( itk::ExceptionObject & err )
{
......@@ -88,7 +88,7 @@ int otbOSMToVectorDataGeneratorByName (int argc, char * argv[])
const FilterType::VectorDataType* v4 = filter->GetVectorDataByName("highway","motorway_link");
std::cout <<"Size of the vectordata v4 : "<< v4->Size() << std::endl;
// Write the VectorData
// Write the VectorData
VectorDataFileWriterType::Pointer writer = VectorDataFileWriterType::New();
writer->SetFileName(parseResult->GetParameterString("--OutputVectorData"));
writer->SetInput(v4);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment