Skip to content

Commit

Permalink
Merge pull request #2569 from SebDieBln/Improve_CrsReadXML
Browse files Browse the repository at this point in the history
Improve QgsCoordinateReferenceSystem::readXML()
  • Loading branch information
nyalldawson committed Dec 12, 2015
2 parents 6e3b1da + ac1ee1c commit 62f90d0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 13 deletions.
2 changes: 1 addition & 1 deletion python/core/qgscoordinatereferencesystem.sip
Expand Up @@ -185,7 +185,7 @@ class QgsCoordinateReferenceSystem
* @param theNode The node from which state will be restored
* @return bool True on success, False on failure
*/
bool readXML( QDomNode & theNode );
bool readXML( const QDomNode & theNode );
/** Stores state to the given Dom node in the given document.
* Below is an example of the generated tag.
\code{.xml}
Expand Down
11 changes: 2 additions & 9 deletions src/core/composer/qgscomposermapgrid.cpp
Expand Up @@ -400,16 +400,9 @@ bool QgsComposerMapGrid::readXML( const QDomElement& itemElem, const QDomDocumen
}
}


QDomElement crsElem = itemElem.firstChildElement( "spatialrefsys" );
if ( !crsElem.isNull() )
{
mCRS.readXML( const_cast<QDomElement&>( itemElem ) ); //better would be to change argument in QgsCoordinateReferenceSystem::readXML to const
}
else
{
if ( !mCRS.readXML( itemElem ) )
mCRS = QgsCoordinateReferenceSystem();
}

mBlendMode = ( QPainter::CompositionMode )( itemElem.attribute( "blendMode", "0" ).toUInt() );

//annotation
Expand Down
6 changes: 4 additions & 2 deletions src/core/qgscoordinatereferencesystem.cpp
Expand Up @@ -1145,9 +1145,10 @@ QString QgsCoordinateReferenceSystem::toWkt() const
return mWkt;
}

bool QgsCoordinateReferenceSystem::readXML( QDomNode & theNode )
bool QgsCoordinateReferenceSystem::readXML( const QDomNode & theNode )
{
QgsDebugMsg( "Reading Spatial Ref Sys from xml ------------------------!" );
bool result = true;
QDomNode srsNode = theNode.namedItem( "spatialrefsys" );

if ( ! srsNode.isNull() )
Expand Down Expand Up @@ -1260,8 +1261,9 @@ bool QgsCoordinateReferenceSystem::readXML( QDomNode & theNode )
{
// Return default CRS if none was found in the XML.
createFromId( GEOCRS_ID, InternalCrsId );
result = false;
}
return true;
return result;
}

bool QgsCoordinateReferenceSystem::writeXML( QDomNode & theNode, QDomDocument & theDoc ) const
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgscoordinatereferencesystem.h
Expand Up @@ -230,7 +230,7 @@ class CORE_EXPORT QgsCoordinateReferenceSystem
* @param theNode The node from which state will be restored
* @return bool True on success, False on failure
*/
bool readXML( QDomNode & theNode );
bool readXML( const QDomNode & theNode );
/** Stores state to the given Dom node in the given document.
* Below is an example of the generated tag.
\code{.xml}
Expand Down

0 comments on commit 62f90d0

Please sign in to comment.