diff --git a/Code/Common/otbDataNode.txx b/Code/Common/otbDataNode.txx index e2d9f4dfea8595602a03fe07b37748898aabcefd..efaf159e8eaa5d59b88494579b4aafec85749900 100644 --- a/Code/Common/otbDataNode.txx +++ b/Code/Common/otbDataNode.txx @@ -296,7 +296,7 @@ template <class TPrecision, unsigned int VDimension> DataNode<TPrecision,VDimension> ::IsDocument() const { - return m_NodeType==DOCUMENT; + return m_NodeType == DOCUMENT; } template <class TPrecision, unsigned int VDimension> bool diff --git a/Code/IO/otbGDALImageIO.cxx b/Code/IO/otbGDALImageIO.cxx index df7a54282c13aff0374ce9b035c1f787dfd3c25d..0da7d0076f3fe8488045b5124d8b686ca6201820 100755 --- a/Code/IO/otbGDALImageIO.cxx +++ b/Code/IO/otbGDALImageIO.cxx @@ -361,7 +361,6 @@ void GDALImageIO::InternalReadImageInformation() // (take time to check !!) if(m_PxType == GDT_Byte) { -// SetComponentType(CHAR); SetComponentType(UCHAR); } else if(m_PxType == GDT_UInt16) @@ -435,7 +434,7 @@ void GDALImageIO::InternalReadImageInformation() /******************************************************************/ // Pixel Type always set to Scalar for GDAL ? maybe also to vector ? -// Modif Patrick: LIRE LES IMAGES COMPLEXES + // Modif Patrick: LIRE LES IMAGES COMPLEXES if( GDALDataTypeIsComplex(m_PxType) ) { otbMsgDevMacro(<<"SetPixelType(COMPLEX)"); @@ -466,9 +465,9 @@ void GDALImageIO::InternalReadImageInformation() } -/*----------------------------------------------------------------------*/ -/*-------------------------- METADATA ----------------------------------*/ -/*----------------------------------------------------------------------*/ + /*----------------------------------------------------------------------*/ + /*-------------------------- METADATA ----------------------------------*/ + /*----------------------------------------------------------------------*/ // Now initialize the itk dictionary itk::MetaDataDictionary & dico = this->GetMetaDataDictionary(); @@ -485,18 +484,7 @@ void GDALImageIO::InternalReadImageInformation() m_Spacing[2]=1; char** papszMetadata; - papszMetadata = m_poDataset->GetMetadata( NULL ); - -// const char *pszValue; - -// pszValue = CSLFetchNameValue( papszMetadata, "CEOS_LINE_SPACING_METERS" ); -// if ( pszValue != NULL ) -// m_Spacing[0] = atof( pszValue ); - -// pszValue = CSLFetchNameValue( papszMetadata, "CEOS_PIXEL_SPACING_METERS" ); -// if ( pszValue != NULL ) -// m_Spacing[1] = atof( pszValue ); - + papszMetadata = m_poDataset->GetMetadata( NULL ); /* -------------------------------------------------------------------- */ @@ -512,9 +500,9 @@ void GDALImageIO::InternalReadImageInformation() static_cast<std::string>( GDALGetDriverLongName( hDriver ) ) ); -/* -------------------------------------------------------------------- */ -/* Get the projection coordinate system of the image : ProjectionRef */ -/* -------------------------------------------------------------------- */ + /* -------------------------------------------------------------------- */ + /* Get the projection coordinate system of the image : ProjectionRef */ + /* -------------------------------------------------------------------- */ if( m_poDataset->GetProjectionRef() != NULL ) { @@ -561,11 +549,7 @@ void GDALImageIO::InternalReadImageInformation() itk::EncapsulateMetaData<unsigned int>(dico, MetaDataKey::m_GCPCountKey, static_cast<unsigned int>( m_poDataset->GetGCPCount() ) ); -// double minGCPRow(m_width); -// double minGCPCol(m_height); -// double minGCPX; -// double minGCPY; - + for( int cpt = 0; cpt < m_poDataset->GetGCPCount(); cpt++ ) { @@ -575,16 +559,6 @@ void GDALImageIO::InternalReadImageInformation() OTB_GCP pOtbGCP(psGCP); - // Origin -// if ( ( psGCP->dfGCPLine < minGCPRow ) && -// ( psGCP->dfGCPPixel < minGCPCol ) ) -// { -// minGCPRow = psGCP->dfGCPLine; -// minGCPCol = psGCP->dfGCPPixel; -// minGCPX = psGCP->dfGCPX; -// minGCPY = psGCP->dfGCPY; -// } - // Complete the key with the GCP number : GCP_i ::itk::OStringStream lStream; lStream << MetaDataKey::m_GCPParametersKey << cpt; @@ -594,8 +568,7 @@ void GDALImageIO::InternalReadImageInformation() } -// m_Origin[0] = minGCPX; -// m_Origin[1] = minGCPY; + } @@ -846,6 +819,9 @@ otbMsgDevMacro( <<" TailleBuffer allocated : "<< lTailleBuffer); delete [] value; value = NULL; + + m_poDataset->FlushCache(); + otbMsgDevMacro( << "GDALImageIO::Write() terminee"); } @@ -972,83 +948,58 @@ void GDALImageIO::InternalWriteImageInformation() /*----------------------------------------------------------------------*/ // Now initialize the itk dictionary - itk::MetaDataDictionary & dico = this->GetMetaDataDictionary(); - - - /* -------------------------------------------------------------------- */ - /* Set Spacing */ - /* -------------------------------------------------------------------- */ - + itk::MetaDataDictionary & dico = this->GetMetaDataDictionary(); char** papszMetadata; papszMetadata = m_poDataset->GetMetadata( NULL ); itk::OStringStream oss; -// oss.str(""); -// oss<<m_Spacing[0]; -// CSLSetNameValue( papszMetadata, "CEOS_LINE_SPACING_METERS",oss.str().c_str()); -// oss.str(""); -// oss<<m_Spacing[1]; -// CSLSetNameValue( papszMetadata, "CEOS_PIXEL_SPACING_METERS",oss.str().c_str()); -// oss.str(""); - - -/* -------------------------------------------------------------------- */ -/* Set the projection coordinate system of the image : ProjectionRef */ -/* -------------------------------------------------------------------- */ - - if(ImageBase::GetProjectionRef(dico)!="") - { - m_poDataset->SetProjection(ImageBase::GetProjectionRef(dico).c_str()); - } -/* -------------------------------------------------------------------- */ -/* Set the GCPs */ -/* -------------------------------------------------------------------- */ + + /* -------------------------------------------------------------------- */ + /* Set the GCPs */ + /* -------------------------------------------------------------------- */ unsigned int gcpCount = ImageBase::GetGCPCount(dico); - GDAL_GCP * gdalGcps = new GDAL_GCP[gcpCount+1]; + if(gcpCount>0) + { -// bool gcpHasOrigin = false; + GDAL_GCP * gdalGcps = new GDAL_GCP[gcpCount]; + + + for(unsigned int gcpIndex = 0; gcpIndex < gcpCount;++gcpIndex) + { + gdalGcps[gcpIndex].pszId = const_cast<char *>(ImageBase::GetGCPId(dico,gcpIndex).c_str()); + gdalGcps[gcpIndex].pszInfo = const_cast<char *>(ImageBase::GetGCPInfo(dico,gcpIndex).c_str()); + gdalGcps[gcpIndex].dfGCPPixel = ImageBase::GetGCPCol(dico,gcpIndex); + gdalGcps[gcpIndex].dfGCPLine = ImageBase::GetGCPRow(dico,gcpIndex); + gdalGcps[gcpIndex].dfGCPX = ImageBase::GetGCPX(dico,gcpIndex); + gdalGcps[gcpIndex].dfGCPY = ImageBase::GetGCPY(dico,gcpIndex); + gdalGcps[gcpIndex].dfGCPZ = ImageBase::GetGCPZ(dico,gcpIndex); + + } + + m_poDataset->SetGCPs(gcpCount,gdalGcps,ImageBase::GetGCPProjection(dico).c_str()); + + delete [] gdalGcps; + } - for(unsigned int gcpIndex = 0; gcpIndex < gcpCount;++gcpIndex) + /* -------------------------------------------------------------------- */ + /* Set the projection coordinate system of the image : ProjectionRef */ + /* -------------------------------------------------------------------- */ + + + if(!ImageBase::GetProjectionRef(dico).empty()) { - gdalGcps[gcpIndex].pszId = const_cast<char *>(ImageBase::GetGCPId(dico,gcpIndex).c_str()); - gdalGcps[gcpIndex].pszInfo = const_cast<char *>(ImageBase::GetGCPInfo(dico,gcpIndex).c_str()); - gdalGcps[gcpIndex].dfGCPPixel = ImageBase::GetGCPCol(dico,gcpIndex); - gdalGcps[gcpIndex].dfGCPLine = ImageBase::GetGCPRow(dico,gcpIndex); - gdalGcps[gcpIndex].dfGCPX = ImageBase::GetGCPX(dico,gcpIndex); - gdalGcps[gcpIndex].dfGCPY = ImageBase::GetGCPY(dico,gcpIndex); - gdalGcps[gcpIndex].dfGCPZ = ImageBase::GetGCPZ(dico,gcpIndex); - // gcpHasOrigin = ImageBase::GetGCPCol(dico,gcpIndex)==0 && ImageBase::GetGCPRow(dico,gcpIndex)==0; + m_poDataset->SetProjection(ImageBase::GetProjectionRef(dico).c_str()); } - gdalGcps[gcpCount].pszId = const_cast<char*>(std::string("Origin").c_str()); - gdalGcps[gcpCount].pszInfo = const_cast<char*>(std::string("Origin gcp added by OTB").c_str()); - gdalGcps[gcpCount].dfGCPPixel = 0; - gdalGcps[gcpCount].dfGCPLine = 0; - gdalGcps[gcpCount].dfGCPX = m_Origin[0]; - gdalGcps[gcpCount].dfGCPY = m_Origin[1]; - gdalGcps[gcpCount].dfGCPZ = 0; - - // if(gcpHasOrigin) -// { - m_poDataset->SetGCPs(gcpCount,gdalGcps,ImageBase::GetGCPProjection(dico).c_str()); -// } - // else -// { -// otbMsgDebugMacro(<<"GCPs do not contain origin."); -// m_poDataset->SetGCPs(gcpCount+1,gdalGcps,ImageBase::GetGCPProjection(dico).c_str()); -// } - delete [] gdalGcps; - -/* -------------------------------------------------------------------- */ -/* Set the six coefficients of affine geoTtransform */ -/* -------------------------------------------------------------------- */ - + + /* -------------------------------------------------------------------- */ + /* Set the six coefficients of affine geoTtransform */ + /* -------------------------------------------------------------------- */ + -// if(!ImageBase::GetGeoTransform(dico).empty()) -// { + double * geoTransform = new double[6]; -// std::vector<double> transformVector = ImageBase::GetGeoTransform(dico); /// Reporting origin and spacing geoTransform[0]=m_Origin[0]; geoTransform[3]=m_Origin[1]; @@ -1060,31 +1011,31 @@ void GDALImageIO::InternalWriteImageInformation() geoTransform[4]=0.; m_poDataset->SetGeoTransform(geoTransform); delete [] geoTransform; -// } -/* -------------------------------------------------------------------- */ -/* Report metadata. */ -/* -------------------------------------------------------------------- */ - std::string svalue=""; - std::vector<std::string> keys = dico.GetKeys(); - MetaDataKey key; - - for (unsigned int itkey=0; itkey<keys.size(); itkey++) - { - if(keys[itkey].compare(0,key.m_MetadataKey.length(),key.m_MetadataKey)==0) - { - itk::ExposeMetaData<std::string>(dico,keys[itkey],svalue); - unsigned int equalityPos = svalue.find_first_of('='); - std::string tag = svalue.substr(0,equalityPos); - std::string value = svalue.substr(equalityPos+1); - otbMsgDevMacro(<<"Metadata: "<<tag<<"="<<value); - m_poDataset->SetMetadataItem(tag.c_str(),value.c_str(),NULL); - } - } - // END - + /* -------------------------------------------------------------------- */ + /* Report metadata. */ + /* -------------------------------------------------------------------- */ + + std::string svalue=""; + std::vector<std::string> keys = dico.GetKeys(); + MetaDataKey key; + + for (unsigned int itkey=0; itkey<keys.size(); itkey++) + { + if(keys[itkey].compare(0,key.m_MetadataKey.length(),key.m_MetadataKey)==0) + { + itk::ExposeMetaData<std::string>(dico,keys[itkey],svalue); + unsigned int equalityPos = svalue.find_first_of('='); + std::string tag = svalue.substr(0,equalityPos); + std::string value = svalue.substr(equalityPos+1); + otbMsgDevMacro(<<"Metadata: "<<tag<<"="<<value); + m_poDataset->SetMetadataItem(tag.c_str(),value.c_str(),NULL); + } + } + // END + } std::string GDALImageIO::TypeConversion(std::string name) diff --git a/Testing/Code/Common/otbDataNodeTest.cxx b/Testing/Code/Common/otbDataNodeTest.cxx index 112685616f380e73f6d00ff66d3440cad3dbd8e2..d8b1605bf7e7078fce7f79f48f4f0162daee07f9 100644 --- a/Testing/Code/Common/otbDataNodeTest.cxx +++ b/Testing/Code/Common/otbDataNodeTest.cxx @@ -76,8 +76,8 @@ int otbDataNodeTest(int argc, char * argv[]) otbControlConditionTestMacro(document->IsPolygonFeature(),"Wrong IsPolygonFeature() method return."); otbControlConditionTestMacro(folder->IsRoot(),"Wrong IsRoot() method return."); - otbControlConditionTestMacro(!folder->IsDocument(),"Wrong IsDocument() method return."); - otbControlConditionTestMacro(folder->IsFolder(),"Wrong IsFolder() method return."); + otbControlConditionTestMacro(folder->IsDocument(),"Wrong IsDocument() method return."); + otbControlConditionTestMacro(!folder->IsFolder(),"Wrong IsFolder() method return."); otbControlConditionTestMacro(folder->IsPointFeature(),"Wrong IsPointFeature() method return."); otbControlConditionTestMacro(folder->IsLineFeature(),"Wrong IsLineFeature() method return."); otbControlConditionTestMacro(folder->IsPolygonFeature(),"Wrong IsPolygonFeature() method return."); diff --git a/Testing/Code/FeatureExtraction/CMakeLists.txt b/Testing/Code/FeatureExtraction/CMakeLists.txt index 6e1dfbba0b4ae69148b544879e5007294ffc55ef..3d6816c7ae64c7b6f655a2c494616da470b6a99a 100755 --- a/Testing/Code/FeatureExtraction/CMakeLists.txt +++ b/Testing/Code/FeatureExtraction/CMakeLists.txt @@ -231,8 +231,8 @@ ADD_TEST(feTvAssociativeSymmetricalSum ${FEATUREEXTRACTION_TESTS4} --compare-image ${EPSILON} ${BASELINE}/feFiltreASS_amst_2_3.hdr ${TEMP}/feFiltreASS_amst_2_3.hdr otbAssociativeSymmetricalSum - ${TEMP}/feFiltreLineRatioLinear_amst_2_3.hdr - ${TEMP}/feFiltreLineCorrelationLinear_amst_2_3.hdr + ${BASELINE}/feFiltreLineRatioLinear_amst_2_3.hdr + ${BASELINE}/feFiltreLineCorrelationLinear_amst_2_3.hdr ${TEMP}/feFiltreASS_amst_2_3.hdr) # ------- otb::AssymmetricFusionOfLineDetector ------------------------------ diff --git a/Testing/Code/IO/CMakeLists.txt b/Testing/Code/IO/CMakeLists.txt index ddec47b51b9bb0e8fd03814da74ab8260076b28b..904a56a6e282e26e0f881a3b316afc7fd61ec2dd 100755 --- a/Testing/Code/IO/CMakeLists.txt +++ b/Testing/Code/IO/CMakeLists.txt @@ -1401,12 +1401,17 @@ ADD_TEST(ioTvVectorDataFileReader ${IO_TESTS15} ADD_TEST(ioTuVectorDataFileWriterNew ${IO_TESTS15} otbVectorDataFileWriterNew ) +# If the file exists, try remove it to prevent test failure +FILE(REMOVE ${TEMP}/ioTvVectorDataFileWriterOutput.shp) ADD_TEST(ioTvVectorDataFileWriter ${IO_TESTS15} otbVectorDataFileWriter ${TEMP}/ioTvVectorDataFileWriterOutput.shp ) +# If the file exists, try remove it to prevent test failure +FILE(REMOVE ${TEMP}/ioTvVectorDataFileReaderWriterOutput.shp) + ADD_TEST(ioTvVectorDataFileReaderWriter ${IO_TESTS15} otbVectorDataFileReaderWriter ${IMAGEDATA}/TOULOUSE/QuickBird/GIS_FILES/000000128955_01_ORDER_SHAPE.shp diff --git a/Testing/Utilities/CMakeLists.txt b/Testing/Utilities/CMakeLists.txt index edeed37f8a9f4746afb0e5b737bde1d5565f302a..9f7436a4f9a8ef5ad8bb7692b7a574d70979e14a 100644 --- a/Testing/Utilities/CMakeLists.txt +++ b/Testing/Utilities/CMakeLists.txt @@ -333,12 +333,12 @@ ADD_TEST( utTvGalibTest${num} ${CXX_TEST_PATH}/otbGalibTests${num} # ------- lib Kml ------------------------------ -FOREACH(id_test createkml helloattrs helloenum hellofolder hellogeometry helloregion helloserializer helloworld parsekml ) - ADD_TEST( utKml${id_test} ${CXX_TEST_PATH}/otbKmlTests${id_test} - kml${id_test} - ${TEMP}/utkml${id_test}.txt - ) -ENDFOREACH(id_test) +#FOREACH(id_test createkml helloattrs helloenum hellofolder hellogeometry helloregion helloserializer helloworld parsekml ) +# ADD_TEST( utKml${id_test} ${CXX_TEST_PATH}/otbKmlTests${id_test} +# kml${id_test} +# ${TEMP}/utkml${id_test}.txt +# ) +#ENDFOREACH(id_test) #ADD_TEST( utKmlhellofeatures ${CXX_TEST_PATH}/otbKmlTestshellofeatures @@ -347,28 +347,28 @@ ENDFOREACH(id_test) # ${TEMP}/utkmlhellofeatures.txt # ) -ADD_TEST( utKmlhellohref ${CXX_TEST_PATH}/otbKmlTestshellohref - kmlhellohref - ${INPUTDATA}/abstractview.kml - ${TEMP}/utkmlhellohref.txt - ) -ADD_TEST( utKmlhellokmz ${CXX_TEST_PATH}/otbKmlTestshellokmz - kmlhellokmz - ${INPUTDATA}/multikml-doc.kmz - ${TEMP}/utkmlhellokmz.txt - ) +#ADD_TEST( utKmlhellohref ${CXX_TEST_PATH}/otbKmlTestshellohref +# kmlhellohref +# ${INPUTDATA}/abstractview.kml +# ${TEMP}/utkmlhellohref.txt +# ) +#ADD_TEST( utKmlhellokmz ${CXX_TEST_PATH}/otbKmlTestshellokmz +# kmlhellokmz +# ${INPUTDATA}/multikml-doc.kmz +# ${TEMP}/utkmlhellokmz.txt +# ) -ADD_TEST( utKmlprettykml ${CXX_TEST_PATH}/otbKmlTestsprettykml - kmlprettykml - ${INPUTDATA}/polygons2d.kml - ${TEMP}/utkmlprettykml.txt - ) +#ADD_TEST( utKmlprettykml ${CXX_TEST_PATH}/otbKmlTestsprettykml +# kmlprettykml +# ${INPUTDATA}/polygons2d.kml +# ${TEMP}/utkmlprettykml.txt +# ) -ADD_TEST( utKmlprintgeometry ${CXX_TEST_PATH}/otbKmlTestsprintgeometry - kmlprintgeometry - ${INPUTDATA}/polygons2d.kml - ${TEMP}/utkmlprintgeometry.txt - ) +#ADD_TEST( utKmlprintgeometry ${CXX_TEST_PATH}/otbKmlTestsprintgeometry +# kmlprintgeometry +# ${INPUTDATA}/polygons2d.kml +# ${TEMP}/utkmlprintgeometry.txt +# )