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:
57 57
         layerName = layerName[:-1]
58 58
         
59 59
         #Prepare outputs
60
-        dialog.setProgressText("Prepare outputs")
60
+        dialog.setProgressText(QApplication.translate("QuickOSM",u"Prepare outputs"))
61 61
         #If a file already exist, we avoid downloading data for nothing
62 62
         outputs = {}
63 63
         for layer in ['points','lines','multilinestrings','multipolygons']:
@@ -84,7 +84,7 @@ class Process:
84 84
         
85 85
         #Getting the default OAPI and running the query
86 86
         server = Tools.getSetting('defaultOAPI')
87
-        dialog.setProgressText("Downloading data from Overpass")
87
+        dialog.setProgressText(QApplication.translate("QuickOSM",u"Downloading data from Overpass"))
88 88
         QApplication.processEvents()
89 89
         connexionOAPI = ConnexionOAPI(url=server,output = "xml")
90 90
         osmFile = connexionOAPI.getFileFromQuery(query)
@@ -97,7 +97,7 @@ class Process:
97 97
         
98 98
         #Geojson to shapefile
99 99
         numLayers = 0
100
-        dialog.setProgressText("From GeoJSON to Shapefile")  
100
+        dialog.setProgressText(QApplication.translate("QuickOSM",u"From GeoJSON to Shapefile"))
101 101
         for i, (layer,item) in enumerate(layers.iteritems()):
102 102
             dialog.setProgressPercentage(i/len(layers)*100)  
103 103
             QApplication.processEvents()

+ 25
- 7
CoreQuickOSM/ExceptionQuickOSM.py View File

@@ -7,16 +7,24 @@ Created on 4 juil. 2014
7 7
 from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
8 8
 from PyQt4.QtGui import QApplication
9 9
 
10
+"""
11
+QApplication.translate doesn't work in contructor's parameters
12
+"""
13
+
10 14
 '''
11 15
 Error 10-19 - Overpass
12 16
 '''
13 17
 class OverpassBadRequestException(GeoAlgorithmExecutionException):
14
-    def __init__(self, msg = QApplication.translate("Exception", u"Bad request OverpassAPI")):
18
+    def __init__(self, msg=None):
19
+        if not msg:
20
+            msg = QApplication.translate("Exception", u"Bad request OverpassAPI")
15 21
         GeoAlgorithmExecutionException.__init__(self,msg)
16 22
         self.errorNumber = 10
17 23
         
18 24
 class OverpassTimeoutException(GeoAlgorithmExecutionException):
19
-    def __init__(self,msg= QApplication.translate("Exception", u"OverpassAPI timeout")):
25
+    def __init__(self, msg=None):
26
+        if not msg:
27
+            msg = QApplication.translate("Exception", u"OverpassAPI timeout")
20 28
         GeoAlgorithmExecutionException.__init__(self,msg)
21 29
         self.errorNumber = 11
22 30
 
@@ -24,7 +32,9 @@ class OverpassTimeoutException(GeoAlgorithmExecutionException):
24 32
 Error 20-29 - Nominatim
25 33
 '''
26 34
 class NominatimAreaException(GeoAlgorithmExecutionException):
27
-    def __init__(self,msg= QApplication.translate("Exception", u"No nominatim area")):
35
+    def __init__(self, msg=None):
36
+        if not msg:
37
+            msg = QApplication.translate("Exception", u"No nominatim area")
28 38
         GeoAlgorithmExecutionException.__init__(self,msg)
29 39
         self.errorNumber = 20
30 40
 
@@ -32,23 +42,31 @@ class NominatimAreaException(GeoAlgorithmExecutionException):
32 42
 Error 30-39 - Other
33 43
 '''
34 44
 class DirectoryOutPutException(GeoAlgorithmExecutionException):
35
-    def __init__(self,msg= QApplication.translate("Exception", u"The output directory does not exist.")):
45
+    def __init__(self, msg=None):
46
+        if not msg:
47
+            msg = QApplication.translate("Exception", u"The output directory does not exist.")
36 48
         GeoAlgorithmExecutionException.__init__(self,msg)
37 49
         self.errorNumber = 30
38 50
         
39 51
 class FileOutPutException(GeoAlgorithmExecutionException):
40
-    def __init__(self,msg= QApplication.translate("Exception", u"The output file already exist, set a prefix"), suffix=None):
52
+    def __init__(self, msg=None, suffix=None):
53
+        if not msg:
54
+            msg= QApplication.translate("Exception", u"The output file already exist, set a prefix")
41 55
         if suffix:
42 56
             msg = msg + " " + suffix
43 57
         GeoAlgorithmExecutionException.__init__(self,msg)
44 58
         self.errorNumber = 31
45 59
         
46 60
 class OutPutFormatException(GeoAlgorithmExecutionException):
47
-    def __init__(self,msg= QApplication.translate("Exception", u"Output not available")):
61
+    def __init__(self,msg=None):
62
+        if not msg:
63
+            msg = QApplication.translate("Exception", u"Output not available")
48 64
         GeoAlgorithmExecutionException.__init__(self,msg)
49 65
         self.errorNumber = 32
50 66
 
51 67
 class Ogr2OgrException(GeoAlgorithmExecutionException):
52
-    def __init__(self,msg= QApplication.translate("Exception", u"Error with ogr2ogr")):
68
+    def __init__(self,msg=None):
69
+        if not msg:
70
+            msg = QApplication.translate("Exception", u"Error with ogr2ogr")
53 71
         GeoAlgorithmExecutionException.__init__(self,msg)
54 72
         self.errorNumber = 33

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

@@ -1,6 +1,7 @@
1 1
 # -*- coding: utf-8 -*-
2 2
 from qgis.core import QgsVectorLayer, QgsFeature, QgsField, QgsFields, QgsVectorFileWriter
3 3
 from PyQt4.QtCore import *
4
+from PyQt4.QtGui import QApplication
4 5
 
5 6
 from osgeo import gdal
6 7
 from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
@@ -65,7 +66,7 @@ class OsmParser(QObject):
65 66
         
66 67
         #Foreach layers
67 68
         for layer in self.__layers:
68
-            self.signalText.emit("Parsing layer : " + layer)
69
+            self.signalText.emit(QApplication.translate("QuickOSM",u"Parsing layer : " + layer))
69 70
             layers[layer] = {}
70 71
             
71 72
             #Reading it with a QgsVectorLayer
@@ -117,7 +118,7 @@ class OsmParser(QObject):
117 118
 
118 119
         #Creating GeoJSON files for each layers
119 120
         for layer in self.__layers:
120
-            self.signalText.emit("Creating GeoJSON file : " + layer)
121
+            self.signalText.emit(QApplication.translate("QuickOSM",u"Creating GeoJSON file : " + layer))
121 122
             self.signalPercentage.emit(0)
122 123
             
123 124
             #Creating the temp file

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

@@ -38,28 +38,9 @@ class OverpassQueryGeoAlgorithm(GeoAlgorithm):
38 38
         self.group = "API"
39 39
 
40 40
         self.addParameter(ParameterString(self.SERVER, 'Overpass API','http://overpass-api.de/api/', False, False))
41
-        self.addParameter(ParameterString(self.QUERY_STRING,'Query (XML or OQL)', '<osm-script output="json">\n \
42
-              <id-query into="area" ref="3600028722" type="area"/>\n \
43
-              <union into="_">\n \
44
-                <query into="_" type="node">\n \
45
-                  <has-kv k="amenity" modv="" v="school"/>\n \
46
-                  <area-query from="area" into="_" ref=""/>\n \
47
-                </query>\n \
48
-                <query into="_" type="way">\n \
49
-                  <has-kv k="amenity" modv="" v="school"/>\n \
50
-                  <area-query from="area" into="_" ref=""/>\n \
51
-                </query>\n \
52
-                <query into="_" type="relation">\n \
53
-                  <has-kv k="amenity" modv="" v="school"/>\n \
54
-                  <area-query from="area" into="_" ref=""/>\n \
55
-                </query>\n \
56
-              </union>\n \
57
-              <print from="_" limit="" mode="body" order="id"/>\n \
58
-              <recurse from="_" into="_" type="down"/>\n \
59
-              <print from="_" limit="" mode="skeleton" order="quadtile"/>\n \
60
-            </osm-script>', True,False))
61
-        self.addParameter(ParameterExtent(self.EXTENT, 'Extent for {{bbox}} '))
62
-        self.addParameter(ParameterString(self.NOMINATIM, 'Place for {{nominatim}}','Montpellier', False, True))
41
+        self.addParameter(ParameterString(self.QUERY_STRING,'Query (XML or OQL)', '', True,False))
42
+        self.addParameter(ParameterExtent(self.EXTENT, 'If {{bbox}} in the query, extent :'))
43
+        self.addParameter(ParameterString(self.NOMINATIM, 'If {{nominatim}} in the query, place :','', False, True))
63 44
         
64 45
         self.addOutput(OutputFile(self.OUTPUT_FILE, 'OSM file'))
65 46
 

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

@@ -36,7 +36,7 @@ class XapiQueryGeoAlgorithm(GeoAlgorithm):
36 36
         self.group = "API"
37 37
 
38 38
         self.addParameter(ParameterString(self.SERVER, 'XAPI','http://www.overpass-api.de/api/xapi?', False, False))
39
-        self.addParameter(ParameterString(self.QUERY_STRING,'Query', 'relation[ref:INSEE=25047]', False,False))
39
+        self.addParameter(ParameterString(self.QUERY_STRING,'Query', '', False,False))
40 40
         
41 41
         self.addOutput(OutputFile(self.OUTPUT_FILE,'OSM file'))
42 42
 

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

@@ -1,49 +0,0 @@
1
-# -*- coding: utf-8 -*-
2
-
3
-'''
4
-Created on 10 juin 2014
5
-
6
-@author: etienne
7
-'''
8
-
9
-from PyQt4.QtCore import *
10
-from PyQt4.QtGui import *
11
-from qgis.core import *
12
-
13
-from processing.core.Processing import Processing
14
-from processing.core.GeoAlgorithm import GeoAlgorithm
15
-from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
16
-from processing.parameters.ParameterFile import ParameterFile
17
-from processing.outputs.OutputNumber import OutputNumber
18
-from QuickOSM.CoreQuickOSM.Parser.FirstRelationIdParser import FirstRelationIdParser
19
-from os.path import dirname,abspath
20
-
21
-
22
-class FirstRelationIdParserGeoAlgorithm(GeoAlgorithm):
23
-
24
-    OSM_FILE = 'OSM_FILE'
25
-    OSM_ID = 'OSM_ID'
26
-
27
-    def defineCharacteristics(self):
28
-        self.name = "First relation ID"
29
-        self.group = "OSM Parser"
30
-
31
-        self.addParameter(ParameterFile(self.OSM_FILE, 'Osm file', False, False))
32
-        self.addOutput(OutputNumber(self.OSM_ID, 'OSM id'))
33
-
34
-    def help(self):
35
-        return True, 'Help soon'
36
-    
37
-    '''def getIcon(self):
38
-        return QIcon(dirname(dirname(dirname(abspath(__file__))))+"/icon.png")'''
39
-
40
-    def processAlgorithm(self, progress):
41
-        osmFile = self.getParameterValue(self.OSM_FILE)
42
-        
43
-        parser = FirstRelationIdParser(osmFile)
44
-        try:
45
-            osmID = parser.parse()
46
-            progress.setInfo("Getting first OSM relation ID from file :",osmID)
47
-        except:
48
-            raise
49
-        self.setOutputValue("OSM_ID",osmID)

+ 2
- 5
ProcessingQuickOSM/QuickOSMAlgorithmProvider.py View File

@@ -16,7 +16,6 @@ from Tools.ReadIniFileGeoAlgorithm import ReadIniFileGeoAlgorithm
16 16
 from Tools.ReadIniFilePathGeoAlgorithm import ReadIniFilePathGeoAlgorithm
17 17
 from Tools.QueryFactoryGeoAlgorithm import QueryFactoryGeoAlgorithm
18 18
 from Parser.OsmParserGeoAlgorithm import OsmParserGeoAlgorithm
19
-from Parser.FirstRelationIdParserGeoAlgorithm import FirstRelationIdParserGeoAlgorithm
20 19
 from Tools.GetFirstFieldGeoAlgorithm import GetFirstFieldGeoAlgorithm
21 20
 from PyQt4.QtGui import QIcon
22 21
 from os.path import dirname,abspath,join
@@ -36,10 +35,9 @@ class QuickOSMAlgorithmProvider(AlgorithmProvider):
36 35
 
37 36
         # Load algorithms
38 37
         self.alglist = [OverpassQueryGeoAlgorithm(),
39
-                        NominatimQueryGeoAlgorithm(),
38
+                        #NominatimQueryGeoAlgorithm(),
40 39
                         OsmParserGeoAlgorithm(),
41
-                        XapiQueryGeoAlgorithm(),
42
-                        FirstRelationIdParserGeoAlgorithm(),
40
+                        #XapiQueryGeoAlgorithm(),
43 41
                         ReadIniFileGeoAlgorithm(),
44 42
                         ReadIniFilePathGeoAlgorithm(),
45 43
                         ListIniFilesGeoAlgorithm(),
@@ -54,7 +52,6 @@ class QuickOSMAlgorithmProvider(AlgorithmProvider):
54 52
         AlgorithmProvider.initializeSettings(self)
55 53
         directory = join(dirname(dirname(abspath(__file__))),'queries')       
56 54
         ProcessingConfig.addSetting(Setting(self.getDescription(),self.QUERIES_FOLDER,'Queries folder',directory))
57
-        
58 55
 
59 56
     def unload(self):
60 57
         AlgorithmProvider.unload(self)

BIN
i18n/QuickOSM_fr.qm View File


+ 33
- 9
i18n/QuickOSM_fr.ts View File

@@ -1,40 +1,39 @@
1 1
 <?xml version="1.0" encoding="utf-8"?>
2
-<!DOCTYPE TS>
3
-<TS version="2.0" language="fr_FR" sourcelanguage="en">
2
+<!DOCTYPE TS><TS version="2.0" language="fr_FR" sourcelanguage="en">
4 3
 <context>
5 4
     <name>Exception</name>
6 5
     <message>
7
-        <location filename="CoreQuickOSM/ExceptionQuickOSM.py" line="14"/>
6
+        <location filename="CoreQuickOSM/ExceptionQuickOSM.py" line="20"/>
8 7
         <source>Bad request OverpassAPI</source>
9 8
         <translation>Erreur de requête OverpassAPI</translation>
10 9
     </message>
11 10
     <message>
12
-        <location filename="CoreQuickOSM/ExceptionQuickOSM.py" line="19"/>
11
+        <location filename="CoreQuickOSM/ExceptionQuickOSM.py" line="27"/>
13 12
         <source>OverpassAPI timeout</source>
14 13
         <translation>Temps d&apos;exécution OverpassAPI atteint</translation>
15 14
     </message>
16 15
     <message>
17
-        <location filename="CoreQuickOSM/ExceptionQuickOSM.py" line="27"/>
16
+        <location filename="CoreQuickOSM/ExceptionQuickOSM.py" line="37"/>
18 17
         <source>No nominatim area</source>
19 18
         <translation>Absence de résultat Nominatim</translation>
20 19
     </message>
21 20
     <message>
22
-        <location filename="CoreQuickOSM/ExceptionQuickOSM.py" line="35"/>
21
+        <location filename="CoreQuickOSM/ExceptionQuickOSM.py" line="47"/>
23 22
         <source>The output directory does not exist.</source>
24 23
         <translation>Le dossier de sortie n&apos;existe pas.</translation>
25 24
     </message>
26 25
     <message>
27
-        <location filename="CoreQuickOSM/ExceptionQuickOSM.py" line="40"/>
26
+        <location filename="CoreQuickOSM/ExceptionQuickOSM.py" line="54"/>
28 27
         <source>The output file already exist, set a prefix</source>
29 28
         <translation>Le fichier de sortie existe déjà, préfixez</translation>
30 29
     </message>
31 30
     <message>
32
-        <location filename="CoreQuickOSM/ExceptionQuickOSM.py" line="47"/>
31
+        <location filename="CoreQuickOSM/ExceptionQuickOSM.py" line="63"/>
33 32
         <source>Output not available</source>
34 33
         <translation>Format non disponible</translation>
35 34
     </message>
36 35
     <message>
37
-        <location filename="CoreQuickOSM/ExceptionQuickOSM.py" line="52"/>
36
+        <location filename="CoreQuickOSM/ExceptionQuickOSM.py" line="70"/>
38 37
         <source>Error with ogr2ogr</source>
39 38
         <translation>Erreur avec ogr2ogr</translation>
40 39
     </message>
@@ -51,6 +50,31 @@
51 50
         <source>Running query ...</source>
52 51
         <translation>Requête en cours ...</translation>
53 52
     </message>
53
+    <message>
54
+        <location filename="ui/quick_query_dialog.py" line="144"/>
55
+        <source>Successful query !</source>
56
+        <translation>Requête réussie !</translation>
57
+    </message>
58
+    <message>
59
+        <location filename="ui/quick_query_dialog.py" line="146"/>
60
+        <source>Successful query, but no result.</source>
61
+        <translation>Requête réussie, mais pas de résultat.</translation>
62
+    </message>
63
+    <message>
64
+        <location filename="Controller/Process.py" line="61"/>
65
+        <source>Prepare outputs</source>
66
+        <translation>Préparation des fichiers</translation>
67
+    </message>
68
+    <message>
69
+        <location filename="Controller/Process.py" line="88"/>
70
+        <source>Downloading data from Overpass</source>
71
+        <translation>Téléchargement des données OSM</translation>
72
+    </message>
73
+    <message>
74
+        <location filename="Controller/Process.py" line="101"/>
75
+        <source>From GeoJSON to Shapefile</source>
76
+        <translation>Du GeoJSON au Shapefile</translation>
77
+    </message>
54 78
 </context>
55 79
 <context>
56 80
     <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):
141 141
 
142 142
             numLayers = Process.ProcessQuickQuery(dialog = self, key=key, value=value, nominatim=nominatim, bbox=self.bbox, osmObjects=osmObjects, timeout=timeout, outputDir=outputDir, prefixFile=prefixFile,outputGeomTypes=outputGeomTypes)
143 143
             if numLayers:
144
-                iface.messageBar().pushMessage(u"Successful query !", level=QgsMessageBar.INFO , duration=5)
144
+                iface.messageBar().pushMessage(QApplication.translate("QuickOSM",u"Successful query !"), level=QgsMessageBar.INFO , duration=5)
145 145
             else:
146
-                iface.messageBar().pushMessage(u"Successful query, but no result.", level=QgsMessageBar.WARNING , duration=7)
146
+                iface.messageBar().pushMessage(QApplication.translate("QuickOSM", u"Successful query, but no result."), level=QgsMessageBar.WARNING , duration=7)
147 147
         
148 148
         except GeoAlgorithmExecutionException,e:
149
-            iface.messageBar().pushMessage(QApplication.translate("Exception", e.msg), level=QgsMessageBar.CRITICAL , duration=7)
149
+            iface.messageBar().pushMessage(e.msg, level=QgsMessageBar.CRITICAL , duration=7)
150 150
         except Exception,e:
151 151
             import sys
152 152
             exc_type, exc_obj, exc_tb = sys.exc_info()
@@ -166,13 +166,13 @@ class QuickQueryWidget(QWidget, Ui_ui_quick_query):
166 166
             self.progressBar_execution.setMinimum(0)
167 167
             self.progressBar_execution.setMaximum(100)
168 168
             self.progressBar_execution.setValue(100)
169
-            self.label_progress.setText("Successful query !")
169
+            self.label_progress.setText(QApplication.translate("QuickOSM",u"Successful query !"))
170 170
             QApplication.restoreOverrideCursor()
171 171
             QApplication.processEvents()
172 172
         
173 173
     def showQuery(self):
174 174
         msg = u"Sorry man, not implemented yet ! ;-)"
175
-        QApplication.translate("Exception", msg)
175
+        msg = QApplication.translate("Exception", msg)
176 176
         iface.messageBar().pushMessage(msg, level=QgsMessageBar.CRITICAL , duration=5)
177 177
         
178 178
     def setProgressPercentage(self,percent):

Loading…
Cancel
Save