Skip to content

Commit 62f90d0

Browse files
committed
Merge pull request #2569 from SebDieBln/Improve_CrsReadXML
Improve QgsCoordinateReferenceSystem::readXML()
2 parents 6e3b1da + ac1ee1c commit 62f90d0

4 files changed

+8
-13
lines changed

python/core/qgscoordinatereferencesystem.sip

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ class QgsCoordinateReferenceSystem
185185
* @param theNode The node from which state will be restored
186186
* @return bool True on success, False on failure
187187
*/
188-
bool readXML( QDomNode & theNode );
188+
bool readXML( const QDomNode & theNode );
189189
/** Stores state to the given Dom node in the given document.
190190
* Below is an example of the generated tag.
191191
\code{.xml}

src/core/composer/qgscomposermapgrid.cpp

+2-9
Original file line numberDiff line numberDiff line change
@@ -400,16 +400,9 @@ bool QgsComposerMapGrid::readXML( const QDomElement& itemElem, const QDomDocumen
400400
}
401401
}
402402

403-
404-
QDomElement crsElem = itemElem.firstChildElement( "spatialrefsys" );
405-
if ( !crsElem.isNull() )
406-
{
407-
mCRS.readXML( const_cast<QDomElement&>( itemElem ) ); //better would be to change argument in QgsCoordinateReferenceSystem::readXML to const
408-
}
409-
else
410-
{
403+
if ( !mCRS.readXML( itemElem ) )
411404
mCRS = QgsCoordinateReferenceSystem();
412-
}
405+
413406
mBlendMode = ( QPainter::CompositionMode )( itemElem.attribute( "blendMode", "0" ).toUInt() );
414407

415408
//annotation

src/core/qgscoordinatereferencesystem.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -1145,9 +1145,10 @@ QString QgsCoordinateReferenceSystem::toWkt() const
11451145
return mWkt;
11461146
}
11471147

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

11531154
if ( ! srsNode.isNull() )
@@ -1260,8 +1261,9 @@ bool QgsCoordinateReferenceSystem::readXML( QDomNode & theNode )
12601261
{
12611262
// Return default CRS if none was found in the XML.
12621263
createFromId( GEOCRS_ID, InternalCrsId );
1264+
result = false;
12631265
}
1264-
return true;
1266+
return result;
12651267
}
12661268

12671269
bool QgsCoordinateReferenceSystem::writeXML( QDomNode & theNode, QDomDocument & theDoc ) const

src/core/qgscoordinatereferencesystem.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ class CORE_EXPORT QgsCoordinateReferenceSystem
230230
* @param theNode The node from which state will be restored
231231
* @return bool True on success, False on failure
232232
*/
233-
bool readXML( QDomNode & theNode );
233+
bool readXML( const QDomNode & theNode );
234234
/** Stores state to the given Dom node in the given document.
235235
* Below is an example of the generated tag.
236236
\code{.xml}

0 commit comments

Comments
 (0)