Skip to content
Permalink
Browse files

remove QgsOgrLayerItem::setCrs (overrided deprecated now unused method)

  • Loading branch information
jef-n committed Feb 18, 2019
1 parent f8e76db commit 13a127e609360a329c95325763af526a99823016
Showing with 0 additions and 44 deletions.
  1. +0 −42 src/providers/ogr/qgsogrdataitems.cpp
  2. +0 −2 src/providers/ogr/qgsogrdataitems.h
@@ -56,48 +56,6 @@ QgsOgrLayerItem::QgsOgrLayerItem( QgsDataItem *parent,
}


bool QgsOgrLayerItem::setCrs( const QgsCoordinateReferenceSystem &crs )
{
QString layerName = mPath.left( mPath.indexOf( QLatin1String( ".shp" ), Qt::CaseInsensitive ) );
QString wkt = crs.toWkt();

// save ordinary .prj file
OGRSpatialReferenceH hSRS = OSRNewSpatialReference( wkt.toLocal8Bit().data() );
OSRMorphToESRI( hSRS ); // this is the important stuff for shapefile .prj
char *pszOutWkt = nullptr;
OSRExportToWkt( hSRS, &pszOutWkt );
QFile prjFile( layerName + ".prj" );
if ( prjFile.open( QIODevice::WriteOnly | QIODevice::Truncate ) )
{
QTextStream prjStream( &prjFile );
prjStream << pszOutWkt << endl;
prjFile.close();
}
else
{
QgsMessageLog::logMessage( tr( "Couldn't open file %1.prj" ).arg( layerName ), tr( "OGR" ) );
return false;
}
OSRDestroySpatialReference( hSRS );
CPLFree( pszOutWkt );

// save qgis-specific .qpj file (maybe because of better wkt compatibility?)
QFile qpjFile( layerName + ".qpj" );
if ( qpjFile.open( QIODevice::WriteOnly | QIODevice::Truncate ) )
{
QTextStream qpjStream( &qpjFile );
qpjStream << wkt.toLocal8Bit().data() << endl;
qpjFile.close();
}
else
{
QgsMessageLog::logMessage( tr( "Couldn't open file %1.qpj" ).arg( layerName ), tr( "OGR" ) );
return false;
}

return true;
}

QgsLayerItem::LayerType QgsOgrLayerItem::layerTypeFromDb( const QString &geometryType )
{
if ( geometryType.contains( QStringLiteral( "Point" ), Qt::CaseInsensitive ) )
@@ -59,8 +59,6 @@ class QgsOgrLayerItem : public QgsLayerItem
public:
QgsOgrLayerItem( QgsDataItem *parent, const QString &name, const QString &path, const QString &uri, LayerType layerType, bool isSubLayer = false );

bool setCrs( const QgsCoordinateReferenceSystem &crs ) override;

QString layerName() const override;
//! Retrieve sub layers from a DB ogr layer \a path with the specified \a driver
static QList<QgsOgrDbLayerInfo *> subLayers( const QString &path, const QString &driver );

0 comments on commit 13a127e

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