def open_map_features(): """ Open MapFeatures """ desktop_service = QDesktopServices() desktop_service.openUrl( QUrl("http://wiki.openstreetmap.org/wiki/Mapfeatures"))
def open_doc_overpass(): """ Open Overpass's documentation """ url = "http://wiki.openstreetmap.org/wiki/Overpass_API/Language_Guide" desktop_service = QDesktopServices() desktop_service.openUrl(QUrl(url))
def exportAsPDF(self): ''' Run the PDF export ''' paths = [] # Export as many pdf as compte communal if self.isMulti: if self.iface: # Show print progress dialog self.setupPrintProgressDialog() nb = len(self.comptecommunal) # Export PDF for each compte for comptecommunal in self.comptecommunal: # export as PDF comptecommunal = comptecommunal.strip("' ") apath = self.exportItemAsPdf(comptecommunal) if apath: paths.append(apath) # update progress bar if self.iface: self.printStep+=1 self.printProgress.pbPrint.setValue(int(self.printStep * 100 / nb)) if self.iface: info = u"Les relevés ont été enregistrés dans le répertoire :\n%s\n\nOuvrir le dossier ?" % self.targetDir openFolder = QDesktopServices() openFolder.openUrl(QUrl('file:///%s' % self.targetDir)) else: apath = self.exportItemAsPdf(self.comptecommunal) if apath: paths.append(apath) return paths
def open_webpage(url): """Open a specific webpage.""" desktop_service = QDesktopServices() if isinstance(url, str): desktop_service.openUrl(QUrl(url)) else: desktop_service.openUrl(url)
def open_help(self): ''' Method to open the help pages ''' QDesktopServices().openUrl( QUrl.fromLocalFile( os.path.join("file://", self.plugin_dir, 'help/build/html', 'index.html')))
def exportAsPDF(self): paths = super().exportAsPDF() if self.isMulti: # info = u"Les relevés ont été enregistrés dans le répertoire :\n%s\n\nOuvrir le dossier ?" % self.targetDir openFolder = QDesktopServices() openFolder.openUrl(QUrl('file:///%s' % self.targetDir)) return paths
def run(field, value): """ Run an action with only one value as parameter @param field:Type of the action @type field:str @param value:Value of the field for one entity @type value:str """ if value == '': iface.messageBar().pushMessage(tr( "QuickOSM", u"Sorry man, this field is empty for this entity."), level=Qgis.Warning, duration=7) else: field = str(field, "UTF-8") value = str(value, "UTF-8") if field in ["url", "website", "wikipedia"]: var = QDesktopServices() url = None if field == "url" or field == "website": url = value if field == "ref_UAI": url = "http://www.education.gouv.fr/pid24302/annuaire-" \ "resultat-recherche.html?lycee_name=" + value if field == "wikipedia": url = "http://en.wikipedia.org/wiki/" + value var.openUrl(QUrl(url)) elif field == "josm": import urllib.request, urllib.error, urllib.parse try: url = "http://localhost:8111/load_object?objects=" + value urllib.request.urlopen(url).read() except urllib.error.URLError: iface.messageBar().pushMessage(tr( "QuickOSM", u"The JOSM remote seems to be disabled."), level=Qgis.Critical, duration=7) # NOT USED elif field == "rawedit": # url = QUrl("http://rawedit.openstreetmap.fr/edit/" + value) # web_browser = QWebView(None) # web_browser.load(url) # web_browser.show() pass
def run_sketch_line(network, ref): """ Run an action with two values for sketchline @param network:network of the bus @type network:str @param ref:ref of the bus @type ref:str """ if network == '' or ref == '': iface.messageBar().pushMessage( tr('Sorry man, this field is empty for this entity.'), level=Qgis.Warning, duration=7) else: var = QDesktopServices() url = 'http://www.overpass-api.de/api/sketch-line?' \ 'network=' + network + '&ref=' + ref var.openUrl(QUrl(url))
def run_sketch_line(network, ref): """ Run an action with two values for sketchline @param network:network of the bus @type network:str @param ref:ref of the bus @type ref:str """ network = str(network, "UTF-8") ref = str(ref, "UTF-8") if network == '' or ref == '': iface.messageBar().pushMessage(tr( "QuickOSM", u"Sorry man, this field is empty for this entity."), level=Qgis.Warning, duration=7) else: var = QDesktopServices() url = "http://www.overpass-api.de/api/sketch-line?" \ "network=" + network + "&ref=" + ref var.openUrl(QUrl(url))
def mostrarSalut(self): PDF = 'file:///' + 'L:/DADES/SIT/qVista/CATALEG/MAPES PRIVATS/Marxes de ciutat/PdfFitxes/03_La_salut.pdf' QDesktopServices().openUrl(QUrl(PDF))
def open_overpass_turbo(): """ Open Overpass Turbo """ desktop_service = QDesktopServices() desktop_service.openUrl(QUrl("http://overpass-turbo.eu/"))
def mostrarInformeMPV(self): PDF = 'file:///L:/DADES/SIT/qVista/CATALEG/MAPES PRIVATS/Marxes de ciutat/PdfFitxes/2.2-I_BESOS MARESME_Informe Marxa Explora.pdf' QDesktopServices().openUrl(QUrl(PDF))
def mostrarTVella(self): PDF = 'file:///' + 'L:/DADES/SIT/qVista/CATALEG/MAPES PRIVATS/Marxes de ciutat/PdfFitxes/08_Trinitat_Vella.pdf' QDesktopServices().openUrl(QUrl(PDF))
def mostrarColl(self): # QDesktopServices().openUrl(QUrl('d:/MarxesCiutat/ElColl_resultats.png')) # QDesktopServices().openUrl(QUrl('L:/DADES/SIT/qVista/CATALEG/MAPES PRIVATS/Marxes de ciutat/PdfFitxes/02_El_coll.pdf')) PDF = 'file:///' + 'L:/DADES/SIT/qVista/CATALEG/MAPES PRIVATS/Marxes de ciutat/PdfFitxes/02_El_coll.pdf' QDesktopServices().openUrl(QUrl(PDF))
def mostrarGrassot(self): PDF = 'file:///' + 'L:/DADES/SIT/qVista/CATALEG/MAPES PRIVATS/Marxes de ciutat/PdfFitxes/05_el_Camp_den_Grassot.pdf' QDesktopServices().openUrl(QUrl(PDF))
def mostrarBesos(self): PDF = 'file:///' + 'L:/DADES/SIT/qVista/CATALEG/MAPES PRIVATS/Marxes de ciutat/PdfFitxes/12_El_Besos_el_Maresme.pdf' QDesktopServices().openUrl(QUrl(PDF))
def mostrarRetornTrinitatVella(self): PDF = 'file:///L:/DADES/SIT/qVista/CATALEG/MAPES PRIVATS/Marxes de ciutat/PdfFitxes/2.3-Retorn 180710-G-Marxa Trinitat Vella-23-07-2018.pdf' QDesktopServices().openUrl(QUrl(PDF))
def mostrarVerneda(self): PDF = 'file:///L:/DADES/SIT/qVista/CATALEG/MAPES PRIVATS/Marxes de ciutat/PdfFitxes/10_La_Verneda_la_Pau.pdf' QDesktopServices().openUrl(QUrl(PDF))
def mostrarMarina(self): PDF = 'file:///L:/DADES/SIT/qVista/CATALEG/MAPES PRIVATS/Marxes de ciutat/PdfFitxes/11_La_Marina.pdf' QDesktopServices().openUrl(QUrl(PDF))
def mostrarVallcarca(self): PDF = 'file:///' + r'L:\DADES\SIT\qVista\CATALEG\MAPES PRIVATS\Marxes de ciutat/PdfFitxes/06_Vallcarca.pdf' QDesktopServices().openUrl(QUrl(PDF))
def mostrarGracia(self): PDF = 'file:///' + 'L:/DADES/SIT/qVista/CATALEG/MAPES PRIVATS/Marxes de ciutat/PdfFitxes/04_Vila_de_gracia.pdf' QDesktopServices().openUrl(QUrl(PDF))
def run(field, value): """ Run an action with only one value as parameter @param field:Type of the action @type field:str @param value:Value of the field for one entity @type value:str """ if value == '': iface.messageBar().pushMessage( tr('Sorry man, this field \'{}\' is empty for this entity.'. format(field)), level=Qgis.Warning, duration=7) else: if field in ['url', 'website', 'wikipedia', 'wikidata']: var = QDesktopServices() url = None if field == 'url' or field == 'website': url = value if field == 'ref_UAI': url = "http://www.education.gouv.fr/pid24302/annuaire-" \ "resultat-recherche.html?lycee_name=" + value if field == 'wikipedia': url = "http://en.wikipedia.org/wiki/" + value if field == 'wikidata': url = "http://www.wikidata.org/wiki/" + value var.openUrl(QUrl(url)) elif field == 'mapillary': if 'go2mapillary' in plugins: plugins['go2mapillary'].dockwidget.show() plugins["go2mapillary"].mainAction.setChecked(False) plugins['go2mapillary'].viewer.openLocation(value) else: var = QDesktopServices() url = 'https://www.mapillary.com/map/im/' + value var.openUrl(QUrl(url)) elif field == 'josm': import urllib.request, urllib.error, urllib.parse try: url = 'http://localhost:8111/load_object?objects=' + value urllib.request.urlopen(url).read() except urllib.error.URLError: iface.messageBar().pushMessage( tr('The JOSM remote seems to be disabled.'), level=Qgis.Critical, duration=7) # NOT USED elif field == 'rawedit': # url = QUrl("http://rawedit.openstreetmap.fr/edit/" + value) # web_browser = QWebView(None) # web_browser.load(url) # web_browser.show() pass
def mostrarMapaXarxa(self): # QDesktopServices().openUrl(QUrl('N:\9SITEB\Publicacions\qVista\CATALEG\MAPES PRIVATS\Marxes de ciutat\PdfFitxes\190228_Marxes_exploratories_A4.pdf')) PDF = 'file:///' + r'N:\9SITEB\Publicacions\qVista\CATALEG\MAPES PRIVATS\Marxes de ciutat\PdfFitxes\Marxes_xarxa_quotidiana_A4.pdf' QDesktopServices().openUrl(QUrl(PDF))
def mostrarInformeVP(self): PDF = 'file:///L:/DADES/SIT/qVista/CATALEG/MAPES PRIVATS/Marxes de ciutat/PdfFitxes/2.2-J_LA VERNEDA I LA PAU_Informe Marxa Explora.pdf' QDesktopServices().openUrl(QUrl(PDF))
def mostrarRetornBonPastor(self): PDF = 'file:///L:/DADES/SIT/qVista/CATALEG/MAPES PRIVATS/Marxes de ciutat/PdfFitxes/2.3-Retorn-180717-H-Marxa Bon Pastor.pdf' QDesktopServices().openUrl(QUrl(PDF))
def mostrarBonPastor(self): PDF = 'file:///' + 'L:/DADES/SIT/qVista/CATALEG/MAPES PRIVATS/Marxes de ciutat/PdfFitxes/09_Bon_Pastor.pdf' QDesktopServices().openUrl(QUrl(PDF))
def imprimirPlanol(self, x, y, escala, rotacion, midaPagina, templateFile, fitxerSortida, tipusSortida): tInicial = time.time() template = QFile(templateFile) doc = QDomDocument() doc.setContent(template, False) layout = QgsLayout(self.project) # page=QgsLayoutItemPage(layout) # page.setPageSize(midaPagina) # layout.pageCollection().addPage(page) # layout.initializeDefaults() # p=layout.pageCollection().pages()[0] # p.setPageSize(midaPagina) context = QgsReadWriteContext() [items, ok] = layout.loadFromTemplate(doc, context) # p=layout.pageCollection().pages()[0] # p.setPageSize(midaPagina) if ok: refMap = layout.referenceMap() titol = layout.itemById('idNomMapa') dataMapa = layout.itemById('idData') if self.leTitol.text() != '': titol.setText(self.leTitol.text()) #comentat pk peta else: titol.setText('') try: t = time.localtime() dataMapa.setText(strftime('%b-%d-%Y %H:%M', t)) except: pass rect = refMap.extent() vector = QgsVector(x - rect.center().x(), y - rect.center().y()) rect += vector refMap.setExtent(rect) refMap.setScale(escala) refMap.setMapRotation(rotacion) #Depenent del tipus de sortida... exporter = QgsLayoutExporter(layout) # image_settings = exporter.ImageExportSettings() # image_settings.dpi = 30 # result = exporter.exportToImage('d:/dropbox/qpic/preview.png', image_settings) # imatge = QPixmap('d:/dropbox/qpic/preview.png') # self.ui.lblImatgeResultat.setPixmap(imatge) if tipusSortida == 'PDF': settings = QgsLayoutExporter.PdfExportSettings() settings.dpi = 300 settings.exportMetadata = False # fitxerSortida='d:/sortida_'+timestamp+'.PDF' fitxerSortida += '.PDF' result = exporter.exportToPdf( fitxerSortida, settings) #Cal desar el resultat (???) print(fitxerSortida) if tipusSortida == 'PNG': settings = QgsLayoutExporter.ImageExportSettings() settings.dpi = 300 # fitxerSortida='d:/sortida_'+timestamp+'.PNG' fitxerSortida += '.PNG' result = exporter.exportToImage( fitxerSortida, settings) #Cal desar el resultat (???) #Obra el document si està marcat checkObrirResultat QDesktopServices().openUrl(QUrl(fitxerSortida)) segonsEmprats = round(time.time() - tInicial, 1) #??? layersTemporals = self.project.mapLayersByName( "Capa temporal d'impressió") estatDirtybit = self.parent.canvisPendents for layer in layersTemporals: self.project.removeMapLayer(layer.id()) self.parent.setDirtyBit(estatDirtybit)
def mostrarInformeG(self): PDF = 'file:///L:/DADES/SIT/qVista/CATALEG/MAPES PRIVATS/2.2-GRACIA-Informe resultats-Passejades_FINAL_5Barris.pdf' QDesktopServices().openUrl(QUrl(PDF))
def mostrarInformeTV(self): PDF = 'file:///L:/DADES/SIT/qVista/CATALEG/MAPES PRIVATS/Marxes de ciutat/PdfFitxes/2.2-G_TRINITAT VELLA_Informe Marxa Explora.pdf' QDesktopServices().openUrl(QUrl(PDF))
def mostrarDocGen(self): QDesktopServices().openUrl( QUrl( 'file:///L:/DADES/SIT/qVista/CATALEG/MAPES%20PRIVATS/Marxes%20de%20ciutat/PdfFitxes/1.3-190318_Marxes_exploratories_A3.pdf' ))