Skip to content
Permalink
Browse files

Crs (#5908)

* fix display of CRS if invalid CRS

* fix #17455 set an empty CRS if the read CRS from XML is wrong

* add warning about empty CRS node when reading XML
  • Loading branch information
Gustry authored and timlinux committed Dec 20, 2017
1 parent 9a5435f commit bf45d0b61811b8fb22e526979b749eba04385b6e
@@ -515,6 +515,7 @@ Returns opposite bool value to operator ==
bool readXml( const QDomNode &node );
%Docstring
Restores state from the given DOM node.
If it fails or if the node is empty, a default not empty CRS will be returned.

:param node: The node from which state will be restored

@@ -366,7 +366,8 @@ bool QgsLayerMetadata::readMetadataXml( const QDomElement &metadataElement )

// crs
mnl = metadataElement.namedItem( QStringLiteral( "crs" ) );
mCrs.readXml( mnl );
if ( !mCrs.readXml( mnl ) )
mCrs = QgsCoordinateReferenceSystem();

// extent
mnl = metadataElement.namedItem( QStringLiteral( "extent" ) );
@@ -466,6 +466,7 @@ class CORE_EXPORT QgsCoordinateReferenceSystem

/**
* Restores state from the given DOM node.
* If it fails or if the node is empty, a default not empty CRS will be returned.
* \param node The node from which state will be restored
* \returns bool True on success, False on failure
*/
@@ -4032,12 +4032,16 @@ QString QgsVectorLayer::htmlMetadata() const
}

// EPSG
myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" ) + tr( "CRS" ) + QStringLiteral( "</td><td>" ) + crs().authid() + QStringLiteral( " - " );
myMetadata += crs().description() + QStringLiteral( " - " );
if ( crs().isGeographic() )
myMetadata += tr( "Geographic" );
else
myMetadata += tr( "Projected" );
myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" ) + tr( "CRS" ) + QStringLiteral( "</td><td>" );
if ( crs().isValid() )
{
myMetadata += crs().authid() + QStringLiteral( " - " );
myMetadata += crs().description() + QStringLiteral( " - " );
if ( crs().isGeographic() )
myMetadata += tr( "Geographic" );
else
myMetadata += tr( "Projected" );
}
myMetadata += QLatin1String( "</td></tr>\n" );

// Extent
@@ -324,12 +324,16 @@ QString QgsRasterLayer::htmlMetadata() const
myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" ) + tr( "Provider" ) + QStringLiteral( "</td><td>" ) + providerType() + QStringLiteral( "</td></tr>\n" );

// EPSG
myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" ) + tr( "CRS" ) + QStringLiteral( "</td><td>" ) + crs().authid() + QStringLiteral( " - " );
myMetadata += crs().description() + QStringLiteral( " - " );
if ( crs().isGeographic() )
myMetadata += tr( "Geographic" );
else
myMetadata += tr( "Projected" );
myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" ) + tr( "CRS" ) + QStringLiteral( "</td><td>" );
if ( crs().isValid() )
{
myMetadata += crs().authid() + QStringLiteral( " - " );
myMetadata += crs().description() + QStringLiteral( " - " );
if ( crs().isGeographic() )
myMetadata += tr( "Geographic" );
else
myMetadata += tr( "Projected" );
}
myMetadata += QLatin1String( "</td></tr>\n" );

// Extent

0 comments on commit bf45d0b

Please sign in to comment.
You can’t perform that action at this time.