Browse Source

add logo, i18n

tags/1.0
Etienne Trimaille 5 years ago
parent
commit
6cfd4c70d5

+ 3
- 3
Controller/Process.py View File

@@ -57,7 +57,7 @@ class Process:
layerName = layerName[:-1]
#Prepare outputs
dialog.setProgressText("Prepare outputs")
dialog.setProgressText(QApplication.translate("QuickOSM",u"Prepare outputs"))
#If a file already exist, we avoid downloading data for nothing
outputs = {}
for layer in ['points','lines','multilinestrings','multipolygons']:
@@ -84,7 +84,7 @@ class Process:
#Getting the default OAPI and running the query
server = Tools.getSetting('defaultOAPI')
dialog.setProgressText("Downloading data from Overpass")
dialog.setProgressText(QApplication.translate("QuickOSM",u"Downloading data from Overpass"))
QApplication.processEvents()
connexionOAPI = ConnexionOAPI(url=server,output = "xml")
osmFile = connexionOAPI.getFileFromQuery(query)
@@ -97,7 +97,7 @@ class Process:
#Geojson to shapefile
numLayers = 0
dialog.setProgressText("From GeoJSON to Shapefile")
dialog.setProgressText(QApplication.translate("QuickOSM",u"From GeoJSON to Shapefile"))
for i, (layer,item) in enumerate(layers.iteritems()):
dialog.setProgressPercentage(i/len(layers)*100)
QApplication.processEvents()

+ 25
- 7
CoreQuickOSM/ExceptionQuickOSM.py View File

@@ -7,16 +7,24 @@ Created on 4 juil. 2014
from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
from PyQt4.QtGui import QApplication

"""
QApplication.translate doesn't work in contructor's parameters
"""

'''
Error 10-19 - Overpass
'''
class OverpassBadRequestException(GeoAlgorithmExecutionException):
def __init__(self, msg = QApplication.translate("Exception", u"Bad request OverpassAPI")):
def __init__(self, msg=None):
if not msg:
msg = QApplication.translate("Exception", u"Bad request OverpassAPI")
GeoAlgorithmExecutionException.__init__(self,msg)
self.errorNumber = 10
class OverpassTimeoutException(GeoAlgorithmExecutionException):
def __init__(self,msg= QApplication.translate("Exception", u"OverpassAPI timeout")):
def __init__(self, msg=None):
if not msg:
msg = QApplication.translate("Exception", u"OverpassAPI timeout")
GeoAlgorithmExecutionException.__init__(self,msg)
self.errorNumber = 11

@@ -24,7 +32,9 @@ class OverpassTimeoutException(GeoAlgorithmExecutionException):
Error 20-29 - Nominatim
'''
class NominatimAreaException(GeoAlgorithmExecutionException):
def __init__(self,msg= QApplication.translate("Exception", u"No nominatim area")):
def __init__(self, msg=None):
if not msg:
msg = QApplication.translate("Exception", u"No nominatim area")
GeoAlgorithmExecutionException.__init__(self,msg)
self.errorNumber = 20

@@ -32,23 +42,31 @@ class NominatimAreaException(GeoAlgorithmExecutionException):
Error 30-39 - Other
'''
class DirectoryOutPutException(GeoAlgorithmExecutionException):
def __init__(self,msg= QApplication.translate("Exception", u"The output directory does not exist.")):
def __init__(self, msg=None):
if not msg:
msg = QApplication.translate("Exception", u"The output directory does not exist.")
GeoAlgorithmExecutionException.__init__(self,msg)
self.errorNumber = 30
class FileOutPutException(GeoAlgorithmExecutionException):
def __init__(self,msg= QApplication.translate("Exception", u"The output file already exist, set a prefix"), suffix=None):
def __init__(self, msg=None, suffix=None):
if not msg:
msg= QApplication.translate("Exception", u"The output file already exist, set a prefix")
if suffix:
msg = msg + " " + suffix
GeoAlgorithmExecutionException.__init__(self,msg)
self.errorNumber = 31
class OutPutFormatException(GeoAlgorithmExecutionException):
def __init__(self,msg= QApplication.translate("Exception", u"Output not available")):
def __init__(self,msg=None):
if not msg:
msg = QApplication.translate("Exception", u"Output not available")
GeoAlgorithmExecutionException.__init__(self,msg)
self.errorNumber = 32

class Ogr2OgrException(GeoAlgorithmExecutionException):
def __init__(self,msg= QApplication.translate("Exception", u"Error with ogr2ogr")):
def __init__(self,msg=None):
if not msg:
msg = QApplication.translate("Exception", u"Error with ogr2ogr")
GeoAlgorithmExecutionException.__init__(self,msg)
self.errorNumber = 33

+ 3
- 2
CoreQuickOSM/Parser/OsmParser.py View File

@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from qgis.core import QgsVectorLayer, QgsFeature, QgsField, QgsFields, QgsVectorFileWriter
from PyQt4.QtCore import *
from PyQt4.QtGui import QApplication

from osgeo import gdal
from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
@@ -65,7 +66,7 @@ class OsmParser(QObject):
#Foreach layers
for layer in self.__layers:
self.signalText.emit("Parsing layer : " + layer)
self.signalText.emit(QApplication.translate("QuickOSM",u"Parsing layer : " + layer))
layers[layer] = {}
#Reading it with a QgsVectorLayer
@@ -117,7 +118,7 @@ class OsmParser(QObject):

#Creating GeoJSON files for each layers
for layer in self.__layers:
self.signalText.emit("Creating GeoJSON file : " + layer)
self.signalText.emit(QApplication.translate("QuickOSM",u"Creating GeoJSON file : " + layer))
self.signalPercentage.emit(0)
#Creating the temp file

+ 3
- 22
ProcessingQuickOSM/API/OverpassQueryGeoAlgorithm.py View File

@@ -38,28 +38,9 @@ class OverpassQueryGeoAlgorithm(GeoAlgorithm):
self.group = "API"

self.addParameter(ParameterString(self.SERVER, 'Overpass API','http://overpass-api.de/api/', False, False))
self.addParameter(ParameterString(self.QUERY_STRING,'Query (XML or OQL)', '<osm-script output="json">\n \
<id-query into="area" ref="3600028722" type="area"/>\n \
<union into="_">\n \
<query into="_" type="node">\n \
<has-kv k="amenity" modv="" v="school"/>\n \
<area-query from="area" into="_" ref=""/>\n \
</query>\n \
<query into="_" type="way">\n \
<has-kv k="amenity" modv="" v="school"/>\n \
<area-query from="area" into="_" ref=""/>\n \
</query>\n \
<query into="_" type="relation">\n \
<has-kv k="amenity" modv="" v="school"/>\n \
<area-query from="area" into="_" ref=""/>\n \
</query>\n \
</union>\n \
<print from="_" limit="" mode="body" order="id"/>\n \
<recurse from="_" into="_" type="down"/>\n \
<print from="_" limit="" mode="skeleton" order="quadtile"/>\n \
</osm-script>', True,False))
self.addParameter(ParameterExtent(self.EXTENT, 'Extent for {{bbox}} '))
self.addParameter(ParameterString(self.NOMINATIM, 'Place for {{nominatim}}','Montpellier', False, True))
self.addParameter(ParameterString(self.QUERY_STRING,'Query (XML or OQL)', '', True,False))
self.addParameter(ParameterExtent(self.EXTENT, 'If {{bbox}} in the query, extent :'))
self.addParameter(ParameterString(self.NOMINATIM, 'If {{nominatim}} in the query, place :','', False, True))
self.addOutput(OutputFile(self.OUTPUT_FILE, 'OSM file'))


+ 1
- 1
ProcessingQuickOSM/API/XapiQueryGeoAlgorithm.py View File

@@ -36,7 +36,7 @@ class XapiQueryGeoAlgorithm(GeoAlgorithm):
self.group = "API"

self.addParameter(ParameterString(self.SERVER, 'XAPI','http://www.overpass-api.de/api/xapi?', False, False))
self.addParameter(ParameterString(self.QUERY_STRING,'Query', 'relation[ref:INSEE=25047]', False,False))
self.addParameter(ParameterString(self.QUERY_STRING,'Query', '', False,False))
self.addOutput(OutputFile(self.OUTPUT_FILE,'OSM file'))


+ 0
- 49
ProcessingQuickOSM/Parser/FirstRelationIdParserGeoAlgorithm.py View File

@@ -1,49 +0,0 @@
# -*- coding: utf-8 -*-

'''
Created on 10 juin 2014

@author: etienne
'''

from PyQt4.QtCore import *
from PyQt4.QtGui import *
from qgis.core import *

from processing.core.Processing import Processing
from processing.core.GeoAlgorithm import GeoAlgorithm
from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
from processing.parameters.ParameterFile import ParameterFile
from processing.outputs.OutputNumber import OutputNumber
from QuickOSM.CoreQuickOSM.Parser.FirstRelationIdParser import FirstRelationIdParser
from os.path import dirname,abspath


class FirstRelationIdParserGeoAlgorithm(GeoAlgorithm):

OSM_FILE = 'OSM_FILE'
OSM_ID = 'OSM_ID'

def defineCharacteristics(self):
self.name = "First relation ID"
self.group = "OSM Parser"

self.addParameter(ParameterFile(self.OSM_FILE, 'Osm file', False, False))
self.addOutput(OutputNumber(self.OSM_ID, 'OSM id'))

def help(self):
return True, 'Help soon'
'''def getIcon(self):
return QIcon(dirname(dirname(dirname(abspath(__file__))))+"/icon.png")'''

def processAlgorithm(self, progress):
osmFile = self.getParameterValue(self.OSM_FILE)
parser = FirstRelationIdParser(osmFile)
try:
osmID = parser.parse()
progress.setInfo("Getting first OSM relation ID from file :",osmID)
except:
raise
self.setOutputValue("OSM_ID",osmID)

+ 2
- 5
ProcessingQuickOSM/QuickOSMAlgorithmProvider.py View File

@@ -16,7 +16,6 @@ from Tools.ReadIniFileGeoAlgorithm import ReadIniFileGeoAlgorithm
from Tools.ReadIniFilePathGeoAlgorithm import ReadIniFilePathGeoAlgorithm
from Tools.QueryFactoryGeoAlgorithm import QueryFactoryGeoAlgorithm
from Parser.OsmParserGeoAlgorithm import OsmParserGeoAlgorithm
from Parser.FirstRelationIdParserGeoAlgorithm import FirstRelationIdParserGeoAlgorithm
from Tools.GetFirstFieldGeoAlgorithm import GetFirstFieldGeoAlgorithm
from PyQt4.QtGui import QIcon
from os.path import dirname,abspath,join
@@ -36,10 +35,9 @@ class QuickOSMAlgorithmProvider(AlgorithmProvider):

# Load algorithms
self.alglist = [OverpassQueryGeoAlgorithm(),
NominatimQueryGeoAlgorithm(),
#NominatimQueryGeoAlgorithm(),
OsmParserGeoAlgorithm(),
XapiQueryGeoAlgorithm(),
FirstRelationIdParserGeoAlgorithm(),
#XapiQueryGeoAlgorithm(),
ReadIniFileGeoAlgorithm(),
ReadIniFilePathGeoAlgorithm(),
ListIniFilesGeoAlgorithm(),
@@ -54,7 +52,6 @@ class QuickOSMAlgorithmProvider(AlgorithmProvider):
AlgorithmProvider.initializeSettings(self)
directory = join(dirname(dirname(abspath(__file__))),'queries')
ProcessingConfig.addSetting(Setting(self.getDescription(),self.QUERIES_FOLDER,'Queries folder',directory))

def unload(self):
AlgorithmProvider.unload(self)

BIN
i18n/QuickOSM_fr.qm View File


+ 33
- 9
i18n/QuickOSM_fr.ts View File

@@ -1,40 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.0" language="fr_FR" sourcelanguage="en">
<!DOCTYPE TS><TS version="2.0" language="fr_FR" sourcelanguage="en">
<context>
<name>Exception</name>
<message>
<location filename="CoreQuickOSM/ExceptionQuickOSM.py" line="14"/>
<location filename="CoreQuickOSM/ExceptionQuickOSM.py" line="20"/>
<source>Bad request OverpassAPI</source>
<translation>Erreur de requête OverpassAPI</translation>
</message>
<message>
<location filename="CoreQuickOSM/ExceptionQuickOSM.py" line="19"/>
<location filename="CoreQuickOSM/ExceptionQuickOSM.py" line="27"/>
<source>OverpassAPI timeout</source>
<translation>Temps d&apos;exécution OverpassAPI atteint</translation>
</message>
<message>
<location filename="CoreQuickOSM/ExceptionQuickOSM.py" line="27"/>
<location filename="CoreQuickOSM/ExceptionQuickOSM.py" line="37"/>
<source>No nominatim area</source>
<translation>Absence de résultat Nominatim</translation>
</message>
<message>
<location filename="CoreQuickOSM/ExceptionQuickOSM.py" line="35"/>
<location filename="CoreQuickOSM/ExceptionQuickOSM.py" line="47"/>
<source>The output directory does not exist.</source>
<translation>Le dossier de sortie n&apos;existe pas.</translation>
</message>
<message>
<location filename="CoreQuickOSM/ExceptionQuickOSM.py" line="40"/>
<location filename="CoreQuickOSM/ExceptionQuickOSM.py" line="54"/>
<source>The output file already exist, set a prefix</source>
<translation>Le fichier de sortie existe déjà, préfixez</translation>
</message>
<message>
<location filename="CoreQuickOSM/ExceptionQuickOSM.py" line="47"/>
<location filename="CoreQuickOSM/ExceptionQuickOSM.py" line="63"/>
<source>Output not available</source>
<translation>Format non disponible</translation>
</message>
<message>
<location filename="CoreQuickOSM/ExceptionQuickOSM.py" line="52"/>
<location filename="CoreQuickOSM/ExceptionQuickOSM.py" line="70"/>
<source>Error with ogr2ogr</source>
<translation>Erreur avec ogr2ogr</translation>
</message>
@@ -51,6 +50,31 @@
<source>Running query ...</source>
<translation>Requête en cours ...</translation>
</message>
<message>
<location filename="ui/quick_query_dialog.py" line="144"/>
<source>Successful query !</source>
<translation>Requête réussie !</translation>
</message>
<message>
<location filename="ui/quick_query_dialog.py" line="146"/>
<source>Successful query, but no result.</source>
<translation>Requête réussie, mais pas de résultat.</translation>
</message>
<message>
<location filename="Controller/Process.py" line="61"/>
<source>Prepare outputs</source>
<translation>Préparation des fichiers</translation>
</message>
<message>
<location filename="Controller/Process.py" line="88"/>
<source>Downloading data from Overpass</source>
<translation>Téléchargement des données OSM</translation>
</message>
<message>
<location filename="Controller/Process.py" line="101"/>
<source>From GeoJSON to Shapefile</source>
<translation>Du GeoJSON au Shapefile</translation>
</message>
</context>
<context>
<name>ui_main_window</name>

BIN
icon.png View File


+ 4019
- 0
resources/QuickOSM.svg
File diff suppressed because it is too large
View File


BIN
resources/layer2.png View File


+ 5
- 5
ui/quick_query_dialog.py View File

@@ -141,12 +141,12 @@ class QuickQueryWidget(QWidget, Ui_ui_quick_query):

numLayers = Process.ProcessQuickQuery(dialog = self, key=key, value=value, nominatim=nominatim, bbox=self.bbox, osmObjects=osmObjects, timeout=timeout, outputDir=outputDir, prefixFile=prefixFile,outputGeomTypes=outputGeomTypes)
if numLayers:
iface.messageBar().pushMessage(u"Successful query !", level=QgsMessageBar.INFO , duration=5)
iface.messageBar().pushMessage(QApplication.translate("QuickOSM",u"Successful query !"), level=QgsMessageBar.INFO , duration=5)
else:
iface.messageBar().pushMessage(u"Successful query, but no result.", level=QgsMessageBar.WARNING , duration=7)
iface.messageBar().pushMessage(QApplication.translate("QuickOSM", u"Successful query, but no result."), level=QgsMessageBar.WARNING , duration=7)
except GeoAlgorithmExecutionException,e:
iface.messageBar().pushMessage(QApplication.translate("Exception", e.msg), level=QgsMessageBar.CRITICAL , duration=7)
iface.messageBar().pushMessage(e.msg, level=QgsMessageBar.CRITICAL , duration=7)
except Exception,e:
import sys
exc_type, exc_obj, exc_tb = sys.exc_info()
@@ -166,13 +166,13 @@ class QuickQueryWidget(QWidget, Ui_ui_quick_query):
self.progressBar_execution.setMinimum(0)
self.progressBar_execution.setMaximum(100)
self.progressBar_execution.setValue(100)
self.label_progress.setText("Successful query !")
self.label_progress.setText(QApplication.translate("QuickOSM",u"Successful query !"))
QApplication.restoreOverrideCursor()
QApplication.processEvents()
def showQuery(self):
msg = u"Sorry man, not implemented yet ! ;-)"
QApplication.translate("Exception", msg)
msg = QApplication.translate("Exception", msg)
iface.messageBar().pushMessage(msg, level=QgsMessageBar.CRITICAL , duration=5)
def setProgressPercentage(self,percent):

Loading…
Cancel
Save