On 09/09/2014 05:36 AM, Mark Coletti wrote:
        layerCenter = layer.extent().center()

if layer.crs().geographicFlag() : # if already lat/long, do nothing
            return layerCenter
        else :
sourceCRC = layer.crs() # get the coordinate reference system being used
            # 4326 is WGS 84
coordinateTransform = QgsCoordinateTransform(sourceCRC.toWkt(), QgsCoordinateReferenceSystem(4326).toWkt())
            return coordinateTransform.transform(layerCenter)

If you want to be rigorous, there are different lat/long coordinate system, it is not only WGS84. The difference will be small of course, but I do not see the point of specifically testing for this case while it does not add anything.

Regards,

Leyan
_______________________________________________
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer

Reply via email to