Skip to content

Commit

Permalink
deprecate QgsMapLayer::srs()
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15346 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Mar 5, 2011
1 parent e5676f4 commit 3d52473
Show file tree
Hide file tree
Showing 15 changed files with 64 additions and 65 deletions.
2 changes: 1 addition & 1 deletion python/core/qgsmaplayer.sip
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public:
and will be deprecated in 2.0
@see crs()
*/
const QgsCoordinateReferenceSystem& srs();
const QgsCoordinateReferenceSystem& srs() /Deprecated/;

/** Sets layer's spatial reference system
@note emitSignal added in 1.4 */
Expand Down
12 changes: 6 additions & 6 deletions src/analysis/vector/qgsgeometryanalyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ bool QgsGeometryAnalyzer::simplify( QgsVectorLayer* layer, const QString& shapef
}

QGis::WkbType outputType = dp->geometryType();
const QgsCoordinateReferenceSystem crs = layer->srs();
const QgsCoordinateReferenceSystem crs = layer->crs();

QgsVectorFileWriter vWriter( shapefileName, dp->encoding(), dp->fields(), outputType, &crs );
QgsFeature currentFeature;
Expand Down Expand Up @@ -157,7 +157,7 @@ bool QgsGeometryAnalyzer::centroids( QgsVectorLayer* layer, const QString& shape
}

QGis::WkbType outputType = QGis::WKBPoint;
const QgsCoordinateReferenceSystem crs = layer->srs();
const QgsCoordinateReferenceSystem crs = layer->crs();

QgsVectorFileWriter vWriter( shapefileName, dp->encoding(), dp->fields(), outputType, &crs );
QgsFeature currentFeature;
Expand Down Expand Up @@ -271,7 +271,7 @@ bool QgsGeometryAnalyzer::extent( QgsVectorLayer* layer, const QString& shapefil
}

QGis::WkbType outputType = QGis::WKBPolygon;
const QgsCoordinateReferenceSystem crs = layer->srs();
const QgsCoordinateReferenceSystem crs = layer->crs();

QgsFieldMap fields;
fields.insert( 0 , QgsField( QString( "MINX" ), QVariant::Double ) );
Expand Down Expand Up @@ -404,7 +404,7 @@ bool QgsGeometryAnalyzer::convexHull( QgsVectorLayer* layer, const QString& shap
fields.insert( 2 , QgsField( QString( "PERIM" ), QVariant::Double ) );

QGis::WkbType outputType = QGis::WKBPolygon;
const QgsCoordinateReferenceSystem crs = layer->srs();
const QgsCoordinateReferenceSystem crs = layer->crs();

QgsVectorFileWriter vWriter( shapefileName, dp->encoding(), fields, outputType, &crs );
QgsFeature currentFeature;
Expand Down Expand Up @@ -610,7 +610,7 @@ bool QgsGeometryAnalyzer::dissolve( QgsVectorLayer* layer, const QString& shapef
}

QGis::WkbType outputType = dp->geometryType();
const QgsCoordinateReferenceSystem crs = layer->srs();
const QgsCoordinateReferenceSystem crs = layer->crs();

QgsVectorFileWriter vWriter( shapefileName, dp->encoding(), dp->fields(), outputType, &crs );
QgsFeature currentFeature;
Expand Down Expand Up @@ -763,7 +763,7 @@ bool QgsGeometryAnalyzer::buffer( QgsVectorLayer* layer, const QString& shapefil
{
outputType = QGis::WKBMultiPolygon;
}
const QgsCoordinateReferenceSystem crs = layer->srs();
const QgsCoordinateReferenceSystem crs = layer->crs();

QgsVectorFileWriter vWriter( shapefileName, dp->encoding(), dp->fields(), outputType, &crs );
QgsFeature currentFeature;
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/vector/qgsoverlayanalyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ bool QgsOverlayAnalyzer::intersection( QgsVectorLayer* layerA, QgsVectorLayer* l
}

QGis::WkbType outputType = dpA->geometryType();
const QgsCoordinateReferenceSystem crs = layerA->srs();
const QgsCoordinateReferenceSystem crs = layerA->crs();
QgsFieldMap fieldsA = dpA->fields();
QgsFieldMap fieldsB = dpB->fields();
combineFieldLists( fieldsA, fieldsB );
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsmaptoolidentify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ bool QgsMapToolIdentify::identifyVectorLayer( QgsVectorLayer *layer, int x, int
QgsDistanceArea calc;
calc.setProjectionsEnabled( mCanvas->hasCrsTransformEnabled() ); // project?
calc.setEllipsoid( ellipsoid );
calc.setSourceCrs( layer->srs().srsid() );
calc.setSourceCrs( layer->crs().srsid() );

QgsFeatureList featureList;

Expand Down
6 changes: 3 additions & 3 deletions src/core/qgsmaplayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,10 @@ class CORE_EXPORT QgsMapLayer : public QObject

/** Returns layer's spatial reference system
@note This method is here for API compatibility
and will be deprecited in 2.0
@see crs()
and will be deprecated in 2.0
@deprecated use crs()
*/
const QgsCoordinateReferenceSystem& srs();
QGISDEPRECATED const QgsCoordinateReferenceSystem& srs();

/** Sets layer's spatial reference system
@note emitSignal added in 1.4 */
Expand Down
14 changes: 7 additions & 7 deletions src/core/qgsmaprenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ void QgsMapRenderer::render( QPainter* painter )
{
r1 = mExtent;
split = splitLayersExtent( ml, r1, r2 );
ct = new QgsCoordinateTransform( ml->srs(), *mDestCRS );
ct = new QgsCoordinateTransform( ml->crs(), *mDestCRS );
mRenderContext.setExtent( r1 );
if ( !r1.isFinite() || !r2.isFinite() ) //there was a problem transforming the extent. Skip the layer
{
Expand Down Expand Up @@ -566,7 +566,7 @@ void QgsMapRenderer::render( QPainter* painter )
{
QgsRectangle r1 = mExtent;
split = splitLayersExtent( ml, r1, r2 );
ct = new QgsCoordinateTransform( ml->srs(), *mDestCRS );
ct = new QgsCoordinateTransform( ml->crs(), *mDestCRS );
mRenderContext.setExtent( r1 );
}
else
Expand Down Expand Up @@ -691,7 +691,7 @@ bool QgsMapRenderer::splitLayersExtent( QgsMapLayer* layer, QgsRectangle& extent
{
try
{
QgsCoordinateTransform tr( layer->srs(), *mDestCRS );
QgsCoordinateTransform tr( layer->crs(), *mDestCRS );

#ifdef QGISDEBUG
// QgsLogger::debug<QgsRectangle>("Getting extent of canvas in layers CS. Canvas is ", extent, __FILE__, __FUNCTION__, __LINE__);
Expand Down Expand Up @@ -747,7 +747,7 @@ QgsRectangle QgsMapRenderer::layerExtentToOutputExtent( QgsMapLayer* theLayer, Q
{
try
{
QgsCoordinateTransform tr( theLayer->srs(), *mDestCRS );
QgsCoordinateTransform tr( theLayer->crs(), *mDestCRS );
extent = tr.transformBoundingBox( extent );
}
catch ( QgsCsException &cse )
Expand All @@ -770,7 +770,7 @@ QgsPoint QgsMapRenderer::layerToMapCoordinates( QgsMapLayer* theLayer, QgsPoint
{
try
{
QgsCoordinateTransform tr( theLayer->srs(), *mDestCRS );
QgsCoordinateTransform tr( theLayer->crs(), *mDestCRS );
point = tr.transform( point, QgsCoordinateTransform::ForwardTransform );
}
catch ( QgsCsException &cse )
Expand All @@ -792,7 +792,7 @@ QgsPoint QgsMapRenderer::mapToLayerCoordinates( QgsMapLayer* theLayer, QgsPoint
{
try
{
QgsCoordinateTransform tr( theLayer->srs(), *mDestCRS );
QgsCoordinateTransform tr( theLayer->crs(), *mDestCRS );
point = tr.transform( point, QgsCoordinateTransform::ReverseTransform );
}
catch ( QgsCsException &cse )
Expand All @@ -814,7 +814,7 @@ QgsRectangle QgsMapRenderer::mapToLayerCoordinates( QgsMapLayer* theLayer, QgsRe
{
try
{
QgsCoordinateTransform tr( theLayer->srs(), *mDestCRS );
QgsCoordinateTransform tr( theLayer->crs(), *mDestCRS );
rect = tr.transform( rect, QgsCoordinateTransform::ReverseTransform );
}
catch ( QgsCsException &cse )
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgspallabeling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ int QgsPalLabeling::prepareLayer( QgsVectorLayer* layer, QSet<int>& attrIndices,

lyr.xform = mMapRenderer->coordinateTransform();
if ( mMapRenderer->hasCrsTransformEnabled() )
lyr.ct = new QgsCoordinateTransform( layer->srs(), mMapRenderer->destinationSrs() );
lyr.ct = new QgsCoordinateTransform( layer->crs(), mMapRenderer->destinationSrs() );
else
lyr.ct = NULL;
lyr.ptZero = lyr.xform->toMapCoordinates( 0, 0 );
Expand Down
61 changes: 31 additions & 30 deletions src/core/qgsproject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,43 +486,44 @@ _getProperties( QDomDocument const &doc, QgsPropertyKey & project_properties )
QgsDebugMsg( "Project_properties.readXML() failed" );
}

#if 0
// DEPRECATED as functionality has been shoved down to QgsProperyKey::readXML()
size_t i = 0;
while ( i < scopes.count() )
{
QDomNode curr_scope_node = scopes.item( i );

// size_t i = 0;
// while (i < scopes.count())
// {
// QDomNode curr_scope_node = scopes.item(i);

// qDebug("found %d property node(s) for scope %s",
// curr_scope_node.childNodes().count(),
// curr_scope_node.nodeName().utf8().constData());
qDebug( "found %d property node(s) for scope %s",
curr_scope_node.childNodes().count(),
curr_scope_node.nodeName().utf8().constData() );

// QString key(curr_scope_node.nodeName());
QString key( curr_scope_node.nodeName() );

// QgsPropertyKey * currentKey =
// dynamic_cast<QgsPropertyKey*>(project_properties.find( key ));
QgsPropertyKey * currentKey =
dynamic_cast<QgsPropertyKey*>( project_properties.find( key ) );

// if ( ! currentKey )
// {
// // if the property key doesn't yet exist, create an empty instance
// // of that key
if ( ! currentKey )
{
// if the property key doesn't yet exist, create an empty instance
// of that key

// currentKey = project_properties.addKey( key );
currentKey = project_properties.addKey( key );

// if ( ! currentKey )
// {
// qDebug( "%s:%d unable to add key", __FILE__, __LINE__ );
// }
// }
if ( ! currentKey )
{
qDebug( "%s:%d unable to add key", __FILE__, __LINE__ );
}
}

// if (! currentKey->readXML(curr_scope_node))
// {
// qDebug("%s:%d unable to read XML for property %s", __FILE__, __LINE__,
// curr_scope_node.nodeName().utf8().constData());
// }
if ( ! currentKey->readXML( curr_scope_node ) )
{
qDebug( "%s:%d unable to read XML for property %s", __FILE__, __LINE__,
curr_scope_node.nodeName().utf8().constData() );
}

// ++i;
// }
++i;
}
#endif
} // _getProperties


Expand Down Expand Up @@ -647,7 +648,7 @@ static QgsProjectVersion _getVersion( QDomDocument const &doc )
QPair< bool, QList<QDomNode> > QgsProject::_getMapLayers( QDomDocument const &doc )
{
// Layer order is set by the restoring the legend settings from project file.
// This is done on the 'readProject( ... ) signal
// This is done on the 'readProject( ... )' signal

QDomNodeList nl = doc.elementsByTagName( "maplayer" );

Expand Down Expand Up @@ -763,7 +764,7 @@ bool QgsProject::read( QFileInfo const &file )


/**
it's presumed that the caller has already reset the map canvas, map registry, and legend
presuming that the caller has already reset the map canvas, map registry, and legend
*/
bool QgsProject::read()
{
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsvectorfilewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ QgsVectorFileWriter::writeAsVectorFormat( QgsVectorLayer* layer,
else
{
// This means we shouldn't transform, use source CRS as output (if defined)
outputCRS = &layer->srs();
outputCRS = &layer->crs();
}
QgsVectorFileWriter* writer =
new QgsVectorFileWriter( fileName, fileEncoding, skipAttributeCreation ? QgsFieldMap() : layer->pendingFields(), layer->wkbType(), outputCRS, driverName, datasourceOptions, layerOptions );
Expand Down Expand Up @@ -603,7 +603,7 @@ QgsVectorFileWriter::writeAsVectorFormat( QgsVectorLayer* layer,
// Create our transform
if ( destCRS )
{
ct = new QgsCoordinateTransform( layer->srs(), *destCRS );
ct = new QgsCoordinateTransform( layer->crs(), *destCRS );
}

// Check for failure
Expand Down
5 changes: 2 additions & 3 deletions src/core/qgsvectorlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer

/** Joins another vector layer to this layer
@param joinInfo join object containing join layer id, target and source field
@param cacheInMemory if true: caches the content of the join layer in virtual memory
@note added in 1.7 */
void addJoin( QgsVectorJoinInfo joinInfo );

Expand Down Expand Up @@ -648,8 +647,8 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
/**Returns unique values for column
@param index column index for attribute
@param uniqueValues out: result list
@limit maximum number of values to return (-1 if unlimited)
@note: this method was added in version 1.7*/
@param limit maximum number of values to return (-1 if unlimited)
@note this method was added in version 1.7*/
void uniqueValues( int index, QList<QVariant> &uniqueValues, int limit = -1 );


Expand Down
4 changes: 2 additions & 2 deletions src/core/raster/qgsrasterlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4014,9 +4014,9 @@ bool QgsRasterLayer::readXml( QDomNode & layer_node )
QString format = rpNode.namedItem( "wmsFormat" ).toElement().text();

// Collect CRS
QString crs = srs().authid();
QString authid = crs().authid();

setDataProvider( mProviderKey, layers, styles, format, crs );
setDataProvider( mProviderKey, layers, styles, format, authid );
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions src/mapserver/qgsconfigparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ QStringList QgsConfigParser::createCRSListForLayer( QgsMapLayer* theMapLayer ) c
if ( myResult )
{
//if the database cannot be opened, add at least the epsg number of the source coordinate system
crsNumbers.push_back( theMapLayer->srs().authid() );
crsNumbers.push_back( theMapLayer->crs().authid() );
return crsNumbers;
};
QString mySql = "select upper(auth_name||':'||auth_id) from tbl_srs";
Expand All @@ -154,7 +154,7 @@ QStringList QgsConfigParser::createCRSListForLayer( QgsMapLayer* theMapLayer ) c
}
else //rasters cannot be reprojected. Use the epsg number of the layers native CRS
{
crsNumbers.push_back( theMapLayer->srs().authid() );
crsNumbers.push_back( theMapLayer->crs().authid() );
}
return crsNumbers;
}
Expand Down
2 changes: 1 addition & 1 deletion src/mapserver/qgsprojectparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ void QgsProjectParser::addLayers( QDomDocument &doc,
//Ex_GeographicBoundingBox
if ( mapExtent.isEmpty() )
{
appendExGeographicBoundingBox( layerElem, doc, currentLayer->extent(), currentLayer->srs() );
appendExGeographicBoundingBox( layerElem, doc, currentLayer->extent(), currentLayer->crs() );
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/mapserver/qgssldparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ void QgsSLDParser::layersAndStylesCapabilities( QDomElement& parentElement, QDom
//append geographic bbox and the CRS elements
QStringList crsNumbers = createCRSListForLayer( theMapLayer );
appendCRSElementsToLayer( layerElement, doc, crsNumbers );
appendExGeographicBoundingBox( layerElement, doc, theMapLayer->extent(), theMapLayer->srs() );
appendExGeographicBoundingBox( layerElement, doc, theMapLayer->extent(), theMapLayer->crs() );

//iterate over all <UserStyle> nodes within a user layer
QDomNodeList userStyleList = layerNodeList.item( i ).toElement().elementsByTagName( "UserStyle" );
Expand Down
7 changes: 3 additions & 4 deletions src/plugins/spatialquery/qgsgeometrycoordinatetransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* (at your option) any later version. *
* *
***************************************************************************/
/* $Id: qgsgeometrycoordinatetransform.cpp 13377 2010-04-25 01:07:36Z jef $ */
/* $Id$ */

#include "qgsgeometrycoordinatetransform.h"

Expand All @@ -30,9 +30,8 @@ QgsGeometryCoordinateTransform::~QgsGeometryCoordinateTransform()
void QgsGeometryCoordinateTransform::setCoordinateTransform( QgsVectorLayer* lyrTarget, QgsVectorLayer* lyrReference )
{
// Transform Forward: Target to Reference
// * Use srs() to use old versions QGis - will be deprecited in 2.0 (after use crs())
QgsCoordinateReferenceSystem srsTarget = lyrTarget->srs();
QgsCoordinateReferenceSystem srsReference = lyrReference->srs();
QgsCoordinateReferenceSystem srsTarget = lyrTarget->crs();
QgsCoordinateReferenceSystem srsReference = lyrReference->crs();

mCoordTransform = new QgsCoordinateTransform( srsTarget, srsReference );

Expand Down

0 comments on commit 3d52473

Please sign in to comment.