0

I would like to change the coordinatereferencesystem for my application

I have this code :

QgsMapRenderer* myRender = mapRenderer();
mQgsCoordinate = new QgsCoordinateReferenceSystem(myRender->destinationCrs());
myRender->setMapUnits( QGis::Meters );
myRender->setProjectionsEnabled( true );
mQgsCoordinate->createFromOgcWmsCrs("CRS83");
qDebug() << " mQgsCoordinate = " << mQgsCoordinate->description();
if( mQgsCoordinate->isValid())
    qDebug() << "CMyQgsMapCanvas::setProjection OK";
else
    qDebug() << "CMyQgsMapCanvas::setProjection NOK";

I have always NOK and the mQgsCoordinate->desciption which return a QString is always Empty !!! What's wrong ? Did I forget a step to change the CorodinateReferenceSystem ?

1 Answer 1

1

Make sure you get the identifier correct:

mQgsCoordinate->createFromOgcWmsCrs("CRS:83");

You get a return value directly from the createFromOgcWmsCrs method which indicates if the call was ok.

To make your development easier: it's straightforward to use the python console for finding the correct usage:

>>> a = QgsCoordinateReferenceSystem()
>>> a.createFromOgcWmsCrs('CRS83')
False
>>> a.createFromOgcWmsCrs('CRS:83')
True
1
  • Thanks, I have checked the syntax and it was correct, I have made a test with "OGC:CRS83" and i have the same problem. Finally after check the code i found the problem. The problem is when i make a setExtent of the mMapCanvas.
    – ainardi
    Jul 23, 2015 at 13:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.