Last active
July 31, 2019 16:50
-
-
Save gledsoncruz/45697cb107ccd89066eecdcd6cb4f750 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from qgis.core import * | |
| from qgis.gui import * | |
| from qgis.utils import iface | |
| @qgsfunction(args='auto', group='IPPU-RESP-OFICIOS') | |
| def gerarQRCode(feature, parent): | |
| lote = iface.activeLayer().selectedFeatures()[0] | |
| geom = lote.geometry() | |
| sourceCrs = QgsCoordinateReferenceSystem(31983) | |
| destCrs = QgsCoordinateReferenceSystem(4326) | |
| tr = QgsCoordinateTransform(sourceCrs, destCrs, QgsProject.instance()) | |
| geom.transform(tr) | |
| eixo_y = geom.centroid().asPoint().y() | |
| eixo_x = geom.centroid().asPoint().x() | |
| url = "http://maps.google.com/maps?q=loc:{0},{1}".format(eixo_y, eixo_x) | |
| return "<img src='https://chart.googleapis.com/chart?chs=150x150&cht=qr&chl={0}'>".format(url) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment