Commit 93a71540 authored by Otmane Lahlou's avatar Otmane Lahlou
Browse files

ENH : use osm xml file to avoid proxy issues

parent 43be77eb
...@@ -2613,6 +2613,7 @@ ADD_TEST(ioTvOSMToVectorDataGeneratorTest ${IO_TESTS19} ...@@ -2613,6 +2613,7 @@ ADD_TEST(ioTvOSMToVectorDataGeneratorTest ${IO_TESTS19}
${BASELINE_FILES}/ioTvOSMToVectorDataFilterTest_highway.shp ${BASELINE_FILES}/ioTvOSMToVectorDataFilterTest_highway.shp
${TEMP}/ioTvOSMToVectorDataFilterTest_highway.shp ${TEMP}/ioTvOSMToVectorDataFilterTest_highway.shp
otbOSMToVectorDataGeneratorTest otbOSMToVectorDataGeneratorTest
${INPUTDATA}/qb_road.osm
${TEMP}/ioTvOSMToVectorDataFilterTest_highway.shp ${TEMP}/ioTvOSMToVectorDataFilterTest_highway.shp
) )
...@@ -2630,13 +2631,13 @@ ADD_TEST(ioTuImageToOSMVectorDataGeneratorNew ${IO_TESTS19} ...@@ -2630,13 +2631,13 @@ ADD_TEST(ioTuImageToOSMVectorDataGeneratorNew ${IO_TESTS19}
otbImageToOSMVectorDataGeneratorNew otbImageToOSMVectorDataGeneratorNew
) )
ADD_TEST(ioTvImageToOSMVectorDataGenerator ${IO_TESTS19} ADD_TEST(ioTvImageToOSMVectorDataGenerator ${IO_TESTS19}
--compare-ogr ${EPSILON_9} --compare-ogr ${EPSILON_9}
${BASELINE_FILES}/ioTvImageToOSMVectorDataGenerator_highway_motorway.shp ${BASELINE_FILES}/ioTvImageToOSMVectorDataGenerator_highway_motorway.shp
${TEMP}/ioTvImageToOSMVectorDataGenerator_highway_motorway.shp ${TEMP}/ioTvImageToOSMVectorDataGenerator_highway_motorway.shp
otbImageToOSMVectorDataGenerator otbImageToOSMVectorDataGenerator
-in ${EXAMPLEDATA}/qb_RoadExtract.tif -in ${EXAMPLEDATA}/qb_RoadExtract.tif
-osm ${INPUTDATA}/qb_road.osm
-out ${TEMP}/ioTvImageToOSMVectorDataGenerator_highway_motorway.shp -out ${TEMP}/ioTvImageToOSMVectorDataGenerator_highway_motorway.shp
-key highvay,motorway -key highvay,motorway
) )
......
...@@ -52,6 +52,7 @@ int otbImageToOSMVectorDataGenerator(int argc, char * argv[]) ...@@ -52,6 +52,7 @@ int otbImageToOSMVectorDataGenerator(int argc, char * argv[])
parser->AddInputImage(); parser->AddInputImage();
parser->AddOption("--OutputVectorData","Output VectorData","-out",true); parser->AddOption("--OutputVectorData","Output VectorData","-out",true);
parser->AddOption("--Key","Key to search in the XML OSM file","-key",1, false); 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; typedef otb::CommandLineArgumentParseResult ParserResultType;
ParserResultType::Pointer parseResult = ParserResultType::New(); ParserResultType::Pointer parseResult = ParserResultType::New();
...@@ -77,6 +78,11 @@ int otbImageToOSMVectorDataGenerator(int argc, char * argv[]) ...@@ -77,6 +78,11 @@ int otbImageToOSMVectorDataGenerator(int argc, char * argv[])
// VectorData generator instanciation // VectorData generator instanciation
FilterType::Pointer vdgenerator = FilterType::New(); FilterType::Pointer vdgenerator = FilterType::New();
vdgenerator->SetInput(reader->GetOutput()); vdgenerator->SetInput(reader->GetOutput());
if(parseResult->IsOptionPresent("--OSM"))
{
vdgenerator->SetUseUrl(false);
vdgenerator->SetFileName(parseResult->GetParameterString("--OSM"));
}
vdgenerator->Update(); vdgenerator->Update();
// Split the classes to get classes and values // Split the classes to get classes and values
...@@ -98,7 +104,8 @@ int otbImageToOSMVectorDataGenerator(int argc, char * argv[]) ...@@ -98,7 +104,8 @@ int otbImageToOSMVectorDataGenerator(int argc, char * argv[])
keyvalueList.push_back(currentkeyvalue); keyvalueList.push_back(currentkeyvalue);
} }
std::cout <<"Searching for class "<<keyvalueList[0].first << " and subclass "<< keyvalueList[0].second << std::endl; std::cout <<"Searching for class "<<keyvalueList[0].first
<< " and subclass "<< keyvalueList[0].second << std::endl;
// Write the generated vector data // Write the generated vector data
......
...@@ -34,12 +34,14 @@ int otbOSMToVectorDataGeneratorNew (int argc, char * argv[]) ...@@ -34,12 +34,14 @@ int otbOSMToVectorDataGeneratorNew (int argc, char * argv[])
int otbOSMToVectorDataGeneratorTest (int argc, char * argv[]) int otbOSMToVectorDataGeneratorTest (int argc, char * argv[])
{ {
FilterType::Pointer filter = FilterType::New(); FilterType::Pointer filter = FilterType::New();
filter->SetFileName(argv[1]);
filter->SetUseUrl(false);
filter->Update(); filter->Update();
// Write the IndexTile // Write the IndexTile
VectorDataFileWriterType::Pointer writer = VectorDataFileWriterType::New(); VectorDataFileWriterType::Pointer writer = VectorDataFileWriterType::New();
writer->SetInput(filter->GetVectorDataByName("highway")); writer->SetInput(filter->GetVectorDataByName("building"));
writer->SetFileName(argv[1]); writer->SetFileName(argv[2]);
writer->Update(); writer->Update();
return EXIT_SUCCESS; return EXIT_SUCCESS;
......
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