On Wed, Sep 10, 2014 at 7:05 AM, Leyan <[email protected]> wrote:
> 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. I'm aware that there exist myriad geographic coordinate systems. However, I'm as yet aware of a QgsCoordinateTransform that will allow me to convert from a projected coordinate reference system to a "gee, I don't care, whatever geographic coordinate system." I just referenced a popular geographic coordinate system because it was good enough for my purposes. However, this may be a valid concern if this does become a snippet on the web site. So, I'll ask again: how do I get this code added as a snippet to the web site since it's likely a common use case for plugin development?
_______________________________________________ Qgis-developer mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/qgis-developer
