diff --git a/Code/IO/otbKMLVectorDataIO.cxx b/Code/IO/otbKMLVectorDataIO.cxx index 74c3f4847e059c3b75784effdc528b0e0d488330..cd86b53aad18bb21ecb6b8acd2b72a5b9b4d37ae 100644 --- a/Code/IO/otbKMLVectorDataIO.cxx +++ b/Code/IO/otbKMLVectorDataIO.cxx @@ -454,6 +454,12 @@ KMLVectorDataIO ::Read(itk::DataObject* datag) { VectorDataPointerType data = dynamic_cast<VectorDataType*>(datag); + + if(!data) + { + itkExceptionMacro(<< "Dynamic cast error: data to write is not of type otb::VectorData (this should never happen)."); + } + std::string kml; bool status = kmlbase::File::ReadFileToString(this->m_FileName, &kml); if (status == false) @@ -519,8 +525,14 @@ void KMLVectorDataIO::Write(const itk::DataObject* datag, char ** itkNotUsed(pap // Retrieve data required for georeferencing VectorDataConstPointerType data_in = dynamic_cast<const VectorDataType*>(datag); + VectorDataConstPointerType data = data_in; + if(!data) + { + itkExceptionMacro(<< "Dynamic cast error: data to write is not of type otb::VectorData (this should never happen)."); + } + std::string projectionRefWkt = data->GetProjectionRef(); OGRSpatialReferenceH oSRS = OSRNewSpatialReference(projectionRefWkt.c_str()); if (!OSRIsGeographic(oSRS))