[QGIS-Developer] PyQgis QgsCoordinateTransform constructor?

Richard Duivenvoorde rdmailings at duif.net
Fri Dec 22 00:24:10 PST 2017


Ah, Thanks Etienne

ok. It is clear in the source indeed:

https://github.com/qgis/QGIS/blob/master/src/core/qgscoordinatetransform.h#L75

  * \note Not available in Python bindings.

Beautifull docs in the source by the way!!!

What is plan/status to show this (also?) in the qgis.org/api docs?
I know there has been talk about it.

Would be a shame to show this very helpful documentation (thanks to the
writers) only in code?

Regards,

Richard

On 22-12-17 08:55, Etienne Trimaille wrote:
> Hi,
> 
> I had the same problem.
> 
> I looked in the source, this constructor is not available anymore in
> Python Bindings:
> https://github.com/qgis/QGIS/blob/master/src/core/qgscoordinatetransform.h#L75
> 
> You need to give a QgsCoordinateTransformContext in the constructor:
> 
> transform = QgsCoordinateTransform(crs, crs_4326,
> QgsCoordinateTransformContext())
> 
> I hope it's the right way to do it.
> But I guess, like you and me, a lot of users will wonder the same
> question about this new parameter and how to configure it so it would be
> nice to provide some snippet or to update the QGIS Cookbook.
> 
> Regards
> Etienne
> 
> 
> 
> 2017-12-22 8:44 GMT+01:00 Richard Duivenvoorde <rdmailings at duif.net
> <mailto:rdmailings at duif.net>>:
> 
>     Hi Devs,
> 
>     since ages, I use like the following to create/get 2
>     QgsCoordinateReferenceSystem's , then create a QgsCoordinateTransform
>     from those and transform geoms or points:
> 
>     crs = iface.mapCanvas().mapSettings().destinationCrs()
>     print(type(crs))
>     print(crs.srsid())
>     print(crs.toWkt())
> 
>     crs2 = QgsCoordinateReferenceSystem()
>     crs2.createFromId(4326)
>     print(type(crs2))
>     print(crs2.srsid())
>     print(crs2.toWkt())
> 
>     crsTransform = QgsCoordinateTransform(crs2, crs)
> 
>     But since some time (test in python console):
> 
>     Traceback (most recent call last):
>       File "/usr/lib/python3.6/code.py", line 91, in runcode
>         exec(code, self.locals)
>       File "<input>", line 1, in <module>
>       File "<string>", line 10, in <module>
>     TypeError: QgsCoordinateTransform(): arguments did not match any
>     overloaded call:
>       overload 1: too many arguments
>       overload 2: not enough arguments
>       overload 3: not enough arguments
>       overload 4: not enough arguments
>       overload 5: argument 1 has unexpected type
>     'QgsCoordinateReferenceSystem'
> 
>     While the api
> 
>     https://qgis.org/api/classQgsCoordinateTransform.html#a8c036726885d51e9fdfe1478a063dfcd
>     <https://qgis.org/api/classQgsCoordinateTransform.html#a8c036726885d51e9fdfe1478a063dfcd>
> 
>     still notes this constructor?
> 
>     Do I miss info? Or is something wrong with my sip stuff?
> 
>     Regards,
> 
>     Richard Duivenvoorde
> 
>     _______________________________________________
>     QGIS-Developer mailing list
>     QGIS-Developer at lists.osgeo.org <mailto:QGIS-Developer at lists.osgeo.org>
>     List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>     <https://lists.osgeo.org/mailman/listinfo/qgis-developer>
>     Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>     <https://lists.osgeo.org/mailman/listinfo/qgis-developer>
> 
> 
> 
> 
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> 



More information about the QGIS-Developer mailing list