Python qgis.PyQt.QtCore.QUrl() Examples

The following are 7 code examples of qgis.PyQt.QtCore.QUrl(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module qgis.PyQt.QtCore , or try the search function .
Example #1
Source File: reverseGeocode.py    From qgis-bulk-nominatim with GNU General Public License v2.0 5 votes vote down vote up
def request(self, url):
        fetcher = QgsNetworkContentFetcher()
        fetcher.fetchContent(QUrl(url))
        evloop = QEventLoop()
        fetcher.finished.connect(evloop.quit)
        evloop.exec_(QEventLoop.ExcludeUserInputEvents)
        fetcher.finished.disconnect(evloop.quit)
        return fetcher.contentAsString() 
Example #2
Source File: bulkDialog.py    From qgis-bulk-nominatim with GNU General Public License v2.0 5 votes vote down vote up
def request(self, url):
        fetcher = QgsNetworkContentFetcher()
        fetcher.fetchContent(QUrl(url))
        evloop = QEventLoop()
        fetcher.finished.connect(evloop.quit)
        evloop.exec_(QEventLoop.ExcludeUserInputEvents)
        fetcher.finished.disconnect(evloop.quit)
        return fetcher.contentAsString() 
Example #3
Source File: QgsFmvAbout.py    From QGISFMV with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self):
        """ Contructor """
        QDialog.__init__(self)
        self.setupUi(self)
        self.webView.setContextMenuPolicy(Qt.NoContextMenu)
        self.webView.load(QUrl("https://all4gis.github.io/QGISFMV/")) 
Example #4
Source File: extra_sources.py    From quickmapservices with GNU General Public License v2.0 5 votes vote down vote up
def __sync_request(self, url):
        _url = QUrl(url)
        _request = QNetworkRequest(_url)
        self.__replies.append(_request)

        QgsNetworkAccessManager.instance().sslErrors.connect(self.__supress_ssl_errors)

        _reply = QgsNetworkAccessManager.instance().get(_request)

        # wait
        loop = QEventLoop()
        _reply.finished.connect(loop.quit)
        loop.exec_()
        _reply.finished.disconnect(loop.quit)
        QgsNetworkAccessManager.instance().sslErrors.disconnect(self.__supress_ssl_errors)
        loop = None

        error = _reply.error()
        if error != QNetworkReply.NoError:
            raise Exception(error)

        result_code = _reply.attribute(QNetworkRequest.HttpStatusCodeAttribute)

        result = _reply.readAll()
        self.__replies.append(_reply)
        _reply.deleteLater()

        if result_code in [301, 302, 307]:
            redirect_url = _reply.attribute(QNetworkRequest.RedirectionTargetAttribute)
            return self.__sync_request(redirect_url)
        else:
            return result 
Example #5
Source File: quick_map_services.py    From quickmapservices with GNU General Public License v2.0 5 votes vote down vote up
def openURL(self):
        QDesktopServices.openUrl(QUrl("https://qms.nextgis.com/create")) 
Example #6
Source File: downloader.py    From quickmapservices with GNU General Public License v2.0 5 votes vote down vote up
def fetchNext(self):
        if len(self.queue) == 0:
            return
        url = self.queue.pop(0)
        self.log("fetchNext: %s" % url)

        request = QNetworkRequest(QUrl(url))
        request.setRawHeader("User-Agent", self.userAgent)
        reply = QgsNetworkAccessManager.instance().get(request)
        reply.finished.connect(self.replyFinishedSlot)
        self.requestingUrls.append(url)
        self.replies.append(reply)
        return reply 
Example #7
Source File: showOnMapTool.py    From qgis-latlontools-plugin with GNU General Public License v2.0 4 votes vote down vote up
def canvasPressEvent(self, event):
        '''Capture the coordinate when the mouse button has been released,
        format it, and copy it to the clipboard.'''
        pt = self.snappoint(event.originalPixelPoint())
        self.removeVertexMarker()
        if settings.externalMapShowLocation:
            if self.marker is None:
                self.marker = QgsVertexMarker(self.canvas)
                self.marker.setIconSize(18)
                self.marker.setPenWidth(2)
                self.marker.setIconType(QgsVertexMarker.ICON_CROSS)
            self.marker.setCenter(pt)
        else:
            self.removeMarker()

        button = event.button()

        canvasCRS = self.canvas.mapSettings().destinationCrs()
        transform = QgsCoordinateTransform(canvasCRS, epsg4326, QgsProject.instance())
        pt4326 = transform.transform(pt.x(), pt.y())
        lat = pt4326.y()
        lon = pt4326.x()
        if settings.googleEarthMapProvider(button):
            f = tempfile.NamedTemporaryFile(mode='w', suffix=".kml", delete=False)
            f.write('<?xml version="1.0" encoding="UTF-8"?>')
            f.write('<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">')
            f.write('<Document>')
            f.write('   <name>QGIS Location</name>')
            f.write('   <description>{:.8f}, {:.8f}</description>'.format(lon, lat))
            f.write('   <Placemark>')
            f.write('       <name>QGIS Location</name>')
            f.write('       <Point>')
            f.write('           <coordinates>{:.8f},{:.8f},0</coordinates>'.format(lon, lat))
            f.write('       </Point>')
            f.write('   </Placemark>')
            f.write('</Document>')
            f.write('</kml>')
            f.close()
            if platform.system() == 'Windows':
                os.startfile(f.name)
            else:
                webbrowser.open(f.name)
            self.iface.messageBar().pushMessage("", "Viewing Coordinate %f,%f in Google Earth" % (lat, lon), level=Qgis.Info, duration=3)
        else:
            mapprovider = settings.getMapProviderString(lat, lon, button)
            url = QUrl(mapprovider).toString()
            webbrowser.open(url, new=2)
            self.iface.messageBar().pushMessage("", "Viewing Coordinate %f,%f in external map" % (lat, lon), level=Qgis.Info, duration=3)