Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
remove QgsOgrLayerItem::setCrs (overrided deprecated now unused method)
  • Loading branch information
jef-n committed Feb 18, 2019
1 parent f8e76db commit 13a127e
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 44 deletions.
42 changes: 0 additions & 42 deletions src/providers/ogr/qgsogrdataitems.cpp
Expand Up @@ -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 ) )
Expand Down
2 changes: 0 additions & 2 deletions src/providers/ogr/qgsogrdataitems.h
Expand Up @@ -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 );
Expand Down

0 comments on commit 13a127e

Please sign in to comment.