Parcourir la source

osetreno ukladani group, notifikacni lista u chunk vrstvy, tabulatory v edit meta

Honza il y a 5 ans
Parent
commit
4fa7630580
3 fichiers modifiés avec 56 ajouts et 23 suppressions
  1. 42 23
      Atlas.py
  2. BIN
      __pycache__/Atlas.cpython-37.pyc
  3. 14 0
      dlg_editMap.ui

+ 42 - 23
Atlas.py

@@ -125,6 +125,9 @@ class Atlas:
         self.liferayServer = None
         self.laymanServer = None
         self.uri = 'http://layman.lesprojekt.cz/rest/'
+        self.iface.layerTreeView().currentLayerChanged.connect(lambda: self.layerChanged())
+        
+        
      #   global dlgGetLayers 
         self.dlgGetLayers= GetLayersDialog()
         # initialize locale
@@ -1488,6 +1491,7 @@ class Atlas:
                         #try:
                         if (os.path.getsize(geoPath) > self.CHUNK_SIZE):
                             self.postInChunks(layer_name, "patch")
+                           # iface.messageBar().pushWidget(iface.messageBar().createMessage("Import:", " Layer  " + layer_name + " was imported successfully."), Qgis.Success, duration=3)
                         else:
                             self.patchLayer(layer_name, data)
                             iface.messageBar().pushWidget(iface.messageBar().createMessage("Import:", " Layer  " + layer_name + " was imported successfully."), Qgis.Success, duration=3)
@@ -1734,7 +1738,7 @@ class Atlas:
             if (operation == "add"):                
                 msgbox = QMessageBox(QMessageBox.Question, "Import Map", "Chcete přidat do kompozice "+str(successful)+" vrstev?") 
             if (operation == "mod"): 
-                msgbox = QMessageBox(QMessageBox.Question, "Import Map", "Do you want save changes?") 
+                #msgbox = QMessageBox(QMessageBox.Question, "Import Map", "Do you want save changes?") 
                 
                 self.dlg.close()
                 self.afterCloseEditMapDialog()
@@ -1742,7 +1746,9 @@ class Atlas:
               
                 response = requests.delete(self.URI+'/rest/'+self.laymanUsername+'/maps/'+self.compositeList[x]['name'],headers = self.authHeader, verify=False)
                 print(response.content)
+                response = requests.post(self.URI+'/rest/'+self.laymanUsername+'/maps', files=files, data = data, headers = self.authHeader)
                 self.dlg.show()
+                return
             if (operation == "del"):
                 msgbox = QMessageBox(QMessageBox.Question, "Import Map", "Chcete smazat vybranou vrstvu?")
           
@@ -2007,7 +2013,7 @@ class Atlas:
                 
     def loadWms(self, url, layerName, format, epsg, groupName = ''):          
         print(url)
-        urlWithParams = 'contextualWMSLegend=0&crs='+epsg+'&dpiMode=7&featureCount=10&format=image/png&layers='+layerName+'&styles=&url=' + url 
+        urlWithParams = 'contextualWMSLegend=0&crs='+epsg+'&dpiMode=7&featureCount=10&format=image/png&layers='+layerName+'&styles=&url=' + url
         print(urlWithParams)
         rlayer = QgsRasterLayer(urlWithParams, layerName, 'wms')
         if (groupName != ''):
@@ -2017,7 +2023,7 @@ class Atlas:
 
     def loadWfs(self, url, layerName, groupName = ''):
         epsg = 'EPSG:4326'        
-        uri = "http://layman.lesprojekt.cz/geoserver/"+self.laymanUsername+"/ows?srsname="+epsg+"&typename="+self.laymanUsername+":"+layerName+"&restrictToRequestBBOX=1&pagingEnabled=True &version=auto&request=GetFeature&service=WFS"
+        uri = self.URI+"/geoserver/"+self.laymanUsername+"/ows?srsname="+epsg+"&typename="+self.laymanUsername+":"+layerName+"&restrictToRequestBBOX=1&pagingEnabled=True &version=auto&request=GetFeature&service=WFS"
         
         print(uri)        
         vlayer = QgsVectorLayer(uri, layerName, "WFS")
@@ -2102,27 +2108,29 @@ class Atlas:
         resumableFilename = layer_name+'.geojson'
         layman_original_parameter = "file"  
         resumableTotalChunks = len(arr)
-
-        for i in range (1, len(arr)+1):  ##chunky jsou počítané od 1 proto +1  
-            print("chunk" + str(i))
-            file = arr[i-1] # rozsekaná část souboru
-            resumableChunkNumber = i  # cislo casti
-            payload = {
-            'file' : "chunk"+str(i)+".geojson",
-            'resumableFilename': resumableFilename,
-            'layman_original_parameter': layman_original_parameter,
-            'resumableChunkNumber': i,
-            'resumableTotalChunks': resumableTotalChunks
-            } 
+        try:
+            for i in range (1, len(arr)+1):  ##chunky jsou počítané od 1 proto +1  
+                print("chunk" + str(i))
+                file = arr[i-1] # rozsekaná část souboru
+                resumableChunkNumber = i  # cislo casti
+                payload = {
+                'file' : "chunk"+str(i)+".geojson",
+                'resumableFilename': resumableFilename,
+                'layman_original_parameter': layman_original_parameter,
+                'resumableChunkNumber': i,
+                'resumableTotalChunks': resumableTotalChunks
+                } 
          
-            f = open(filePath + os.sep+"chunk"+str(i)+".geojson", "wb")
-            f.write(bytearray(arr[i-1]))
-            f.close()              
-            files = {'file': (layer_name+".geojson", open(filePath +os.sep+ "chunk"+str(i)+".geojson", 'rb')),}              
-            response = requests.post(url, files = files, data=payload, headers = self.authHeader)
-
-            print(response.content)
+                f = open(filePath + os.sep+"chunk"+str(i)+".geojson", "wb")
+                f.write(bytearray(arr[i-1]))
+                f.close()              
+                files = {'file': (layer_name+".geojson", open(filePath +os.sep+ "chunk"+str(i)+".geojson", 'rb')),}              
+                response = requests.post(url, files = files, data=payload, headers = self.authHeader)
 
+                print(response.content)
+            iface.messageBar().pushWidget(iface.messageBar().createMessage("Import:", " Layer  " + layer_name + " was imported successfully."), Qgis.Success, duration=3)
+        except:
+            iface.messageBar().pushWidget(iface.messageBar().createMessage("Import:", " Layer  " + layer_name + " was not imported successfully!"), Qgis.Warning, duration=3)
 
 ############################################# auth part############################
 
@@ -2332,6 +2340,16 @@ class Atlas:
         config = configparser.ConfigParser()
         config.read(file)
         return config   
+
+    def layerChanged(self):  
+        print("blabla")
+        print(iface.activeLayer())
+        if (iface.activeLayer() != None):
+            self.menu_saveLocalFile.setEnabled(True)
+        else:
+            self.menu_saveLocalFile.setEnabled(False)
+
+
     def run(self):
         """Run method that loads and starts the plugin"""
 
@@ -2349,7 +2367,8 @@ class Atlas:
 
             
             # connect to provide cleanup on closing of dockwidget
-            self.dockwidget.closingPlugin.connect(self.onClosePlugin)            
+            self.dockwidget.closingPlugin.connect(self.onClosePlugin)     
+            
             self.dockwidget.pushButton.clicked.connect(self.sendLayer)   
             self.dockwidget.pushButton_2.clicked.connect(self.loadLocalFile) 
             self.dockwidget.pushButton_3.clicked.connect(self.saveLocalFile)

BIN
__pycache__/Atlas.cpython-37.pyc


+ 14 - 0
dlg_editMap.ui

@@ -316,6 +316,20 @@
    </property>
   </widget>
  </widget>
+ <tabstops>
+  <tabstop>pushButton_save</tabstop>
+  <tabstop>pushButton_close</tabstop>
+  <tabstop>lineEdit_name</tabstop>
+  <tabstop>lineEdit_title</tabstop>
+  <tabstop>lineEdit_abstract</tabstop>
+  <tabstop>lineEdit_units</tabstop>
+  <tabstop>lineEdit_scale</tabstop>
+  <tabstop>lineEdit_user</tabstop>
+  <tabstop>lineEdit_xmin</tabstop>
+  <tabstop>lineEdit_xmax</tabstop>
+  <tabstop>lineEdit_ymin</tabstop>
+  <tabstop>lineEdit_ymax</tabstop>
+ </tabstops>
  <resources/>
  <connections/>
 </ui>