Ejemplo n.º 1
0
class LoadDefects(QObject):
    def __init__(self, iface, projectId, submodule):
        self.iface = iface
        self.projectId = projectId
        self.submodule = submodule
        self.qutils = QGeoAppUtils()

        
    def run(self):
        table = {}
        table["type"] = "postgres"
        table["title"] = u"Maengelliste"
        table["featuretype"] = "maengel"
        table["geom"] = "the_geom"
        table["key"] = "ogc_fid"
        table["readonly"] = "false"
        table["group"] = u"Mängel" + " (" + self.projectId + ")"
        table["style"] = "maengel.qml"
        
        
        vlayer = self.qutils.loadLayer(self.iface, table, None, "/python/plugins/qgeoapp/modules/qveriso/submodules/" + self.submodule + "/qml/")
        vlayer.setLayerName(u"Mängelliste")
        form = QDir.convertSeparators(QDir.cleanPath( QgsApplication.qgisSettingsDirPath() + '/python/plugins/qgeoapp/modules/qveriso/submodules/'+ self.submodule +'/defects/maengelForm.ui' ))
        vlayer.setEditForm(form)
        vlayer.setEditFormInit( "qgeoapp.modules.qveriso.submodules."+self.submodule+".defects.maengelFormInit.featureFormInit" )
Ejemplo n.º 2
0
class ComplexCheck(QObject):

    def __init__(self, iface, projectId, submodule):
        self.iface = iface
        self.canvas = self.iface.mapCanvas()
        self.projectId = projectId
        self.submodule = submodule
        self.qutils = QGeoAppUtils()

    def run(self):        
        group = "Zonen_Grundnutzung" + " (" + str(self.projectId) + ")"
        table = {}
        table["type"] = "postgres"
        table["title"] = "Zonengrundnutzung"
        table["featuretype"] = "zonen_grundnutzung_zone_grundng"
        table["geom"] = "geometrie"
        table["key"] = "ogc_fid"            
        table["sql"] = ""
        table["readonly"] = "true"
        table["group"] = group
        table["style"] = "tseinteilung/toleranzstufe.qml"

        self.qutils.loadLayer(self.iface, table, None, "/python/plugins/qgeoapp/modules/qveriso/submodules/" + self.submodule + "/qml/")       
Ejemplo n.º 3
0
class ComplexCheck(QObject):

    def __init__(self, iface):
        self.iface = iface
        self.canvas = self.iface.mapCanvas()
    
        self.qutils = QGeoAppUtils()

    def run(self):        
        self.settings = QSettings("CatAIS","QGeoApp")
        projectId = str(self.settings.value("project/active/id").toString())
        
        QApplication.setOverrideCursor(Qt.WaitCursor)
#        try:
        group = u"Checklayer - Bahn" + " (" + str(projectId) + ")"
        
        layer = {}
        layer["type"] = "postgres"
        layer["title"] = u"EO.Bahngeleise_ueberdeckt"
        layer["featuretype"] = "t_geleise_ueberdeckt"
        layer["geom"] = "the_geom"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "checks/checklayer_punkt.qml"

        vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if vlayer <> False:
            self.iface.legendInterface().setLayerVisible(vlayer, True)    


#        except:            
#            QApplication.restoreOverrideCursor()        
        QApplication.restoreOverrideCursor()        

        self.canvas.setMapUnits(0)		
Ejemplo n.º 4
0
    def __init__(self, iface, toolBar):
        self.iface = iface
        self.canvas = self.iface.mapCanvas()
        self.toolBar = toolBar
        self.vutils = QVerisoUtils()
        self.qutils = QGeoAppUtils()
        
        self.settings = QSettings("CatAIS","QGeoApp")
        self.projectsRootPath = self.settings.value("projects/rootdir").toString()
        self.projectId = str(self.settings.value("project/active/id").toString())
        self.ili = str(self.settings.value("project/active/ili").toString())
        self.moduleName = str(self.settings.value("project/active/module").toString())
        self.subModuleName = str(self.settings.value("project/active/submodule").toString())
        
        self.dbhost = str(self.settings.value("project/active/host").toString())
        self.dbport = str(self.settings.value("project/active/port").toString())
        self.dbname = str(self.settings.value("project/active/dbname").toString())
        self.dbschema = str(self.settings.value("project/active/schema").toString())
        self.dbuser = str(self.settings.value("project/active/readuser").toString())
        self.dbpwd = str(self.settings.value("project/active/readpwd").toString())
        self.dbadmin = str(self.settings.value("project/active/writeuser").toString())
        self.dbadminpwd = str(self.settings.value("project/active/writepwd").toString())

        self.DEBUG = True
Ejemplo n.º 5
0
class ComplexCheck(QObject):

    def __init__(self, iface):
        self.iface = iface
        self.canvas = self.iface.mapCanvas()
    
        self.qutils = QGeoAppUtils()

    def run(self):        
        self.settings = QSettings("CatAIS","QGeoApp")
        projectId = str(self.settings.value("project/active/id").toString())
        
        QApplication.setOverrideCursor(Qt.WaitCursor)
#        try:
        group = "Checklayer - Strasse" + " (" + str(projectId) + ")"
        
        layer = {}
        layer["type"] = "postgres"
        layer["title"] = "BB.BoFlaeche"
        layer["featuretype"] = "bodenbedeckung_boflaeche"
        layer["geom"] = "geometrie"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "bb/bb_strasse_bbplan.qml"

        vlayer = self.qutils.loadProjectLayer(self.iface, layer) 
        if vlayer <> False:
            self.iface.legendInterface().setLayerVisible(vlayer, True)     
            
        layer = {}
        layer["type"] = "postgres"
        layer["title"] = "EO.Einzelobjekt"
        layer["featuretype"] = "einzelobjekte_einzelobjekt"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group

        eoeolayer = self.qutils.loadProjectLayer(self.iface, layer)    

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = u"EO.Flaechenelement"
        layer["featuretype"] = "einzelobjekte_flaechenelement"
        layer["geom"] = "geometrie"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "eo/eo_fl_strasse_ortho.qml"

        eoflayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if eoflayer <> False:
            self.iface.legendInterface().setLayerVisible(eoflayer, True)    
            
        if eoeolayer <> False and eoflayer <> False:
            joinLayerId = eoeolayer.id()
            joinProvider = eoeolayer.dataProvider()
            joinProvider.select(joinProvider.attributeIndexes())
            joinIdx = joinProvider.fieldNameIndex("tid")
            
            targetProvider = eoflayer.dataProvider()
            targetProvider.select(targetProvider.attributeIndexes())
            targetIdx = targetProvider.fieldNameIndex("flaechenelement_von")

            joinInfo = QgsVectorJoinInfo()
            joinInfo.joinField = joinIdx
            joinInfo.joinLayerId = joinLayerId
            joinInfo.targetField = targetIdx
            joinInfo.memoryCache = True
            
            eoflayer.addJoin(joinInfo)

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = u"EO.Linienelement"
        layer["featuretype"] = "einzelobjekte_linienelement"
        layer["geom"] = "geometrie"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "eo/eo_li_strasse_ortho.qml"

        eolilayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if eolilayer <> False:
            self.iface.legendInterface().setLayerVisible(eolilayer, True)    

        if eoeolayer <> False and eolilayer <> False:
            joinLayerId = eoeolayer.id()
            joinProvider = eoeolayer.dataProvider()
            joinProvider.select(joinProvider.attributeIndexes())
            joinIdx = joinProvider.fieldNameIndex("tid")
            
            targetProvider = eolilayer.dataProvider()
            targetProvider.select(targetProvider.attributeIndexes())
            targetIdx = targetProvider.fieldNameIndex("linienelement_von")

            joinInfo = QgsVectorJoinInfo()
            joinInfo.joinField = joinIdx
            joinInfo.joinLayerId = joinLayerId
            joinInfo.targetField = targetIdx
            joinInfo.memoryCache = True
            
            eolilayer.addJoin(joinInfo)

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = u"LI.Liegenschaft"
        layer["featuretype"] = "liegenschaften_liegenschaft"
        layer["geom"] = "geometrie"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "li/liegenschaft_ortho.qml"

        vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if vlayer <> False:
            self.iface.legendInterface().setLayerVisible(vlayer, False)    

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = "Pfeiler < 0.25 m2"
        layer["featuretype"] = "t_pfeiler_50cm"
        layer["geom"] = "the_geom"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "false"
        layer["group"] = group
        layer["style"] = "checks/checklayer_punkt.qml"
        
        vlayer = self.qutils.loadProjectLayer(self.iface, layer)       
        if vlayer <> False:            
            self.iface.legendInterface().setLayerVisible(vlayer, True)        

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = "BB.Strasse_Weg > 10000 m2"
        layer["featuretype"] = "t_str_flaeche_10000"
        layer["geom"] = "the_geom"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "false"
        layer["group"] = group
        layer["style"] = "checks/checklayer_punkt.qml"
        
        vlayer = self.qutils.loadProjectLayer(self.iface, layer)       
        if vlayer <> False:            
            self.iface.legendInterface().setLayerVisible(vlayer, True)  

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = "EO.schmaler_Weg in TS 2"
        layer["featuretype"] = "t_schmaler_weg_ts2"
        layer["geom"] = "the_geom"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "false"
        layer["group"] = group
        layer["style"] = "checks/checklayer_punkt.qml"
        
        vlayer = self.qutils.loadProjectLayer(self.iface, layer)       
        if vlayer <> False:            
            self.iface.legendInterface().setLayerVisible(vlayer, True)  


#        except:            
#            QApplication.restoreOverrideCursor()        
        QApplication.restoreOverrideCursor()        

        self.canvas.setMapUnits(0)		
class ComplexCheck(QObject):

    def __init__(self, iface):
        self.iface = iface
        self.canvas = self.iface.mapCanvas()
    
        self.qutils = QGeoAppUtils()

    def run(self):        
        self.settings = QSettings("CatAIS","QGeoApp")
        projectId = str(self.settings.value("project/active/id").toString())
        
        QApplication.setOverrideCursor(Qt.WaitCursor)
#        try:
        group = u"Lagekontrolle - Landwirtschaft" + " (" + str(projectId) + ")"
        
        layer = {}
        layer["type"] = "wms"
        layer["title"] = "Orthofoto CIR"
        layer["url"] = "http://www.sogis1.so.ch/cgi-bin/sogis/sogis_orthofoto.wms"
        layer["layers"] = "Orthofoto_CIR_SO"
        layer["format"] = "image/jpeg"
        layer["crs"] = "EPSG:21781"
        layer["group"] = group
        rlayer = self.qutils.loadLayer(self.iface, layer, None, None)                 
        
        layer = {}
        layer["type"] = "wms"
        layer["title"] = "Orthofoto RGB"
        layer["url"] = "http://www.sogis1.so.ch/cgi-bin/sogis/sogis_orthofoto.wms"
        layer["layers"] = "Orthofoto_SO"
        layer["format"] = "image/jpeg"
        layer["crs"] = "EPSG:21781"
        layer["group"] = group
        rlayer = self.qutils.loadLayer(self.iface, layer, None, None) 
        if rlayer <> False:
            self.iface.legendInterface().setLayerVisible(rlayer, True)     
                    
        layer = {}
        layer["type"] = "postgres"
        layer["title"] = "Gemeindegrenze"
        layer["featuretype"] = "gemeindegrenzen_gemeindegrenze"
        layer["geom"] = "geometrie"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "gemeindegrenze/gemgre_strichliert.qml"

        gemgrelayer = self.qutils.loadProjectLayer(self.iface, layer) 
        if gemgrelayer <> False:
            self.iface.legendInterface().setLayerVisible(gemgrelayer, True)     
  
        layer = {}
        layer["type"] = "postgres"
        layer["title"] = "BB.BoFlaeche"
        layer["featuretype"] = "bodenbedeckung_boflaeche"
        layer["geom"] = "geometrie"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "bb/bb_landwirtschaft_ortho.qml"

        vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if vlayer <> False:
            self.iface.legendInterface().setLayerVisible(vlayer, True)    

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = "EO.Einzelobjekt"
        layer["featuretype"] = "einzelobjekte_einzelobjekt"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group

        eoeolayer = self.qutils.loadProjectLayer(self.iface, layer)    

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = u"EO.Flaechenelement"
        layer["featuretype"] = "einzelobjekte_flaechenelement"
        layer["geom"] = "geometrie"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "eo/eo_fl_landwirtschaft_ortho.qml"

        eoflayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if eoflayer <> False:
            self.iface.legendInterface().setLayerVisible(eoflayer, True)    
            
        if eoeolayer <> False and eoflayer <> False:
            joinLayerId = eoeolayer.id()
            joinProvider = eoeolayer.dataProvider()
            joinProvider.select(joinProvider.attributeIndexes())
            joinIdx = joinProvider.fieldNameIndex("tid")
            
            targetProvider = eoflayer.dataProvider()
            targetProvider.select(targetProvider.attributeIndexes())
            targetIdx = targetProvider.fieldNameIndex("flaechenelement_von")

            joinInfo = QgsVectorJoinInfo()
            joinInfo.joinField = joinIdx
            joinInfo.joinLayerId = joinLayerId
            joinInfo.targetField = targetIdx
            joinInfo.memoryCache = True
            
            eoflayer.addJoin(joinInfo)

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = u"EO.Linienelement"
        layer["featuretype"] = "einzelobjekte_linienelement"
        layer["geom"] = "geometrie"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "eo/eo_li_landwirtschaft_ortho.qml"

        eolilayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if eolilayer <> False:
            self.iface.legendInterface().setLayerVisible(eolilayer, True)    

        if eoeolayer <> False and eolilayer <> False:
            joinLayerId = eoeolayer.id()
            joinProvider = eoeolayer.dataProvider()
            joinProvider.select(joinProvider.attributeIndexes())
            joinIdx = joinProvider.fieldNameIndex("tid")
            
            targetProvider = eolilayer.dataProvider()
            targetProvider.select(targetProvider.attributeIndexes())
            targetIdx = targetProvider.fieldNameIndex("linienelement_von")

            joinInfo = QgsVectorJoinInfo()
            joinInfo.joinField = joinIdx
            joinInfo.joinLayerId = joinLayerId
            joinInfo.targetField = targetIdx
            joinInfo.memoryCache = True
            
            eolilayer.addJoin(joinInfo)

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = u"EO.Punktelement"
        layer["featuretype"] = "einzelobjekte_punktelement"
        layer["geom"] = "geometrie"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "eo/eo_pk_andere.qml"

        eopklayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if eopklayer <> False:
            self.iface.legendInterface().setLayerVisible(eopklayer, True)    

        if eoeolayer <> False and eopklayer <> False:
            joinLayerId = eoeolayer.id()
            joinProvider = eoeolayer.dataProvider()
            joinProvider.select(joinProvider.attributeIndexes())
            joinIdx = joinProvider.fieldNameIndex("tid")
            
            targetProvider = eopklayer.dataProvider()
            targetProvider.select(targetProvider.attributeIndexes())
            targetIdx = targetProvider.fieldNameIndex("punktelement_von")

            joinInfo = QgsVectorJoinInfo()
            joinInfo.joinField = joinIdx
            joinInfo.joinLayerId = joinLayerId
            joinInfo.targetField = targetIdx
            joinInfo.memoryCache = True
            
            eopklayer.addJoin(joinInfo)

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = u"LI.Liegenschaft"
        layer["featuretype"] = "liegenschaften_liegenschaft"
        layer["geom"] = "geometrie"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "li/liegenschaft_ortho.qml"

        vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if vlayer <> False:
            self.iface.legendInterface().setLayerVisible(vlayer, False)    

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = "TS-Einteilung"
        layer["featuretype"] = "tseinteilung_toleranzstufe"
        layer["geom"] = "geometrie"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "ts/ts_einteilung.qml"
        
        vlayer = self.qutils.loadProjectLayer(self.iface, layer)       

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = "Kontrollraster (Planeinteilung)"
        layer["featuretype"] = "t_kontrollraster_plan_landwirtschaft"
        layer["geom"] = "the_geom"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "false"
        layer["group"] = group
        layer["style"] = "kontrollraster/kontrollraster.qml"
        
        vlayer = self.qutils.loadProjectLayer(self.iface, layer)       
        if vlayer <> False:            
            self.iface.legendInterface().setLayerVisible(vlayer, False)        
            provider = vlayer.dataProvider()
            provider.select(provider.attributeIndexes())
            ogc_fid_idx = provider.fieldNameIndex("ogc_fid")
            vlayer.setEditType(ogc_fid_idx, 10)
            
            plannummer_idx = provider.fieldNameIndex("plannummer")
            vlayer.setEditType(plannummer_idx, 10)            
            
            kontrolliert_idx = provider.fieldNameIndex("kontrolliert")
            vlayer.setEditType(kontrolliert_idx, 7)
            vlayer.setCheckedState(kontrolliert_idx, 't', 'f')

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = "Kontrollraster"
        layer["featuretype"] = "t_kontrollraster_landwirtschaft_500"
        layer["geom"] = "the_geom"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "false"
        layer["group"] = group
        layer["style"] = "kontrollraster/kontrollraster.qml"
        
        vlayer = self.qutils.loadProjectLayer(self.iface, layer)       
        if vlayer <> False:            
            self.iface.legendInterface().setLayerVisible(vlayer, True)        
            provider = vlayer.dataProvider()
            provider.select(provider.attributeIndexes())
            ogc_fid_idx = provider.fieldNameIndex("ogc_fid")
#        vlayer.setEditType(ogc_fid_idx, QgsVectorLayer.EditType.Hidden)
            vlayer.setEditType(ogc_fid_idx, 10)
            
            kontrolliert_idx = provider.fieldNameIndex("kontrolliert")
            vlayer.setEditType(kontrolliert_idx, 7)
            vlayer.setCheckedState(kontrolliert_idx, 't', 'f')

        if gemgrelayer <> False:
            rect = gemgrelayer.extent()
            rect.scale(1.2)
            self.iface.mapCanvas().setExtent(rect)        
            self.iface.mapCanvas().refresh() 


#        except:            
#            QApplication.restoreOverrideCursor()        
        QApplication.restoreOverrideCursor()        

        self.canvas.setMapUnits(0)		
class ComplexCheck(QObject):

    def __init__(self, iface):
        self.iface = iface
        self.canvas = self.iface.mapCanvas()
    
        self.qutils = QGeoAppUtils()

    def run(self):        
        self.settings = QSettings("CatAIS","QGeoApp")
        projectId = str(self.settings.value("project/active/id").toString())
        
        QApplication.setOverrideCursor(Qt.WaitCursor)
#        try:
        group = u"Lagekontrolle - Seltene Objekte" + " (" + str(projectId) + ")"
        
        layer = {}
        layer["type"] = "wms"
        layer["title"] = "Orthofoto CIR"
        layer["url"] = "http://www.sogis1.so.ch/cgi-bin/sogis/sogis_orthofoto.wms"
        layer["layers"] = "Orthofoto_CIR_SO"
        layer["format"] = "image/jpeg"
        layer["crs"] = "EPSG:21781"
        layer["group"] = group
        rlayer = self.qutils.loadLayer(self.iface, layer, None, None)                 
        
        layer = {}
        layer["type"] = "wms"
        layer["title"] = "Orthofoto RGB"
        layer["url"] = "http://www.sogis1.so.ch/cgi-bin/sogis/sogis_orthofoto.wms"
        layer["layers"] = "Orthofoto_SO"
        layer["format"] = "image/jpeg"
        layer["crs"] = "EPSG:21781"
        layer["group"] = group
        rlayer = self.qutils.loadLayer(self.iface, layer, None, None) 
        if rlayer <> False:
            self.iface.legendInterface().setLayerVisible(rlayer, True)     
                    
        layer = {}
        layer["type"] = "postgres"
        layer["title"] = "Gemeindegrenze"
        layer["featuretype"] = "gemeindegrenzen_gemeindegrenze"
        layer["geom"] = "geometrie"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "gemeindegrenze/gemgre_strichliert.qml"

        gemgrelayer = self.qutils.loadProjectLayer(self.iface, layer) 
        if gemgrelayer <> False:
            self.iface.legendInterface().setLayerVisible(gemgrelayer, True)     
  
        layer = {}
        layer["type"] = "postgres"
        layer["title"] = "BB.BoFlaeche"
        layer["featuretype"] = "bodenbedeckung_boflaeche"
        layer["geom"] = "geometrie"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "bb/bb_seltene_objekte_ortho.qml"

        vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if vlayer <> False:
            self.iface.legendInterface().setLayerVisible(vlayer, True)    

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = "EO.Einzelobjekt"
        layer["featuretype"] = "einzelobjekte_einzelobjekt"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group

        eoeolayer = self.qutils.loadProjectLayer(self.iface, layer)    

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = u"EO.Flaechenelement"
        layer["featuretype"] = "einzelobjekte_flaechenelement"
        layer["geom"] = "geometrie"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "eo/eo_fl_seltene_objekte_ortho.qml"

        eoflayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if eoflayer <> False:
            self.iface.legendInterface().setLayerVisible(eoflayer, True)    
            
        if eoeolayer <> False and eoflayer <> False:
            joinLayerId = eoeolayer.id()
            joinProvider = eoeolayer.dataProvider()
            joinProvider.select(joinProvider.attributeIndexes())
            joinIdx = joinProvider.fieldNameIndex("tid")
            
            targetProvider = eoflayer.dataProvider()
            targetProvider.select(targetProvider.attributeIndexes())
            targetIdx = targetProvider.fieldNameIndex("flaechenelement_von")

            joinInfo = QgsVectorJoinInfo()
            joinInfo.joinField = joinIdx
            joinInfo.joinLayerId = joinLayerId
            joinInfo.targetField = targetIdx
            joinInfo.memoryCache = True
            
            eoflayer.addJoin(joinInfo)

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = u"EO.Linienelement"
        layer["featuretype"] = "einzelobjekte_linienelement"
        layer["geom"] = "geometrie"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "eo/eo_li_seltene_objekte_ortho.qml"

        eolilayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if eolilayer <> False:
            self.iface.legendInterface().setLayerVisible(eolilayer, True)    

        if eoeolayer <> False and eolilayer <> False:
            joinLayerId = eoeolayer.id()
            joinProvider = eoeolayer.dataProvider()
            joinProvider.select(joinProvider.attributeIndexes())
            joinIdx = joinProvider.fieldNameIndex("tid")
            
            targetProvider = eolilayer.dataProvider()
            targetProvider.select(targetProvider.attributeIndexes())
            targetIdx = targetProvider.fieldNameIndex("linienelement_von")

            joinInfo = QgsVectorJoinInfo()
            joinInfo.joinField = joinIdx
            joinInfo.joinLayerId = joinLayerId
            joinInfo.targetField = targetIdx
            joinInfo.memoryCache = True
            
            eolilayer.addJoin(joinInfo)

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = u"EO.Punktelement"
        layer["featuretype"] = "einzelobjekte_punktelement"
        layer["geom"] = "geometrie"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "eo/eo_pk_seltene_objekte_ortho.qml"

        eopklayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if eopklayer <> False:
            self.iface.legendInterface().setLayerVisible(eopklayer, True)    

        if eoeolayer <> False and eopklayer <> False:
            joinLayerId = eoeolayer.id()
            joinProvider = eoeolayer.dataProvider()
            joinProvider.select(joinProvider.attributeIndexes())
            joinIdx = joinProvider.fieldNameIndex("tid")
            
            targetProvider = eopklayer.dataProvider()
            targetProvider.select(targetProvider.attributeIndexes())
            targetIdx = targetProvider.fieldNameIndex("punktelement_von")

            joinInfo = QgsVectorJoinInfo()
            joinInfo.joinField = joinIdx
            joinInfo.joinLayerId = joinLayerId
            joinInfo.targetField = targetIdx
            joinInfo.memoryCache = True
            
            eopklayer.addJoin(joinInfo)

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = u"Abbaustellen (AfU)"
        layer["featuretype"] = "abbaustellen_afu"
        layer["geom"] = "geom"
        layer["key"] = "gid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "sogis/abbaustellen_afu.qml"
         
        params =  {}
        params["appmodule"] = str(self.settings.value("project/active/appmodule").toString())
        params["subappmodule"] = str(self.settings.value("project/active/subappmodule").toString())      
        params["provider"] = "postgres"
        params["dbhost"] = str(self.settings.value("project/active/dbhost").toString())
        params["dbport"] = str(self.settings.value("project/active/dbport").toString())
        params["dbname"] = "pnf_varia"
        params["dbschema"] = "sogis"
        params["dbuser"] = str(self.settings.value("project/active/dbuser").toString())
        params["dbpwd"] = str(self.settings.value("project/active/dbpwd").toString())
        params["dbadmin"] = str(self.settings.value("project/active/dbadmin").toString())
        params["dbadminpwd"] = str(self.settings.value("project/active/dbadminpwd").toString())
        
        layer["params"] = params

        vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if vlayer <> False:
            self.iface.legendInterface().setLayerVisible(vlayer, True)    

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = u"Flachmoor (AfU)"
        layer["featuretype"] = "flachmoor_afu"
        layer["geom"] = "geom"
        layer["key"] = "gid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "sogis/flachmoor_afu.qml"
         
        params =  {}
        params["appmodule"] = str(self.settings.value("project/active/appmodule").toString())
        params["subappmodule"] = str(self.settings.value("project/active/subappmodule").toString())      
        params["provider"] = "postgres"
        params["dbhost"] = str(self.settings.value("project/active/dbhost").toString())
        params["dbport"] = str(self.settings.value("project/active/dbport").toString())
        params["dbname"] = "pnf_varia"
        params["dbschema"] = "sogis"
        params["dbuser"] = str(self.settings.value("project/active/dbuser").toString())
        params["dbpwd"] = str(self.settings.value("project/active/dbpwd").toString())
        params["dbadmin"] = str(self.settings.value("project/active/dbadmin").toString())
        params["dbadminpwd"] = str(self.settings.value("project/active/dbadminpwd").toString())
        
        layer["params"] = params

        vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if vlayer <> False:
            self.iface.legendInterface().setLayerVisible(vlayer, True)    

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = u"Freileitungen (ARP)"
        layer["featuretype"] = "freileitungen_arp"
        layer["geom"] = "geom"
        layer["key"] = "gid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "sogis/freileitungen_arp.qml"
         
        params =  {}
        params["appmodule"] = str(self.settings.value("project/active/appmodule").toString())
        params["subappmodule"] = str(self.settings.value("project/active/subappmodule").toString())      
        params["provider"] = "postgres"
        params["dbhost"] = str(self.settings.value("project/active/dbhost").toString())
        params["dbport"] = str(self.settings.value("project/active/dbport").toString())
        params["dbname"] = "pnf_varia"
        params["dbschema"] = "sogis"
        params["dbuser"] = str(self.settings.value("project/active/dbuser").toString())
        params["dbpwd"] = str(self.settings.value("project/active/dbpwd").toString())
        params["dbadmin"] = str(self.settings.value("project/active/dbadmin").toString())
        params["dbadminpwd"] = str(self.settings.value("project/active/dbadminpwd").toString())
        
        layer["params"] = params

        vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if vlayer <> False:
            self.iface.legendInterface().setLayerVisible(vlayer, True)    


        layer = {}
        layer["type"] = "postgres"
        layer["title"] = u"LI.Liegenschaft"
        layer["featuretype"] = "liegenschaften_liegenschaft"
        layer["geom"] = "geometrie"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "li/liegenschaft_ortho.qml"

        vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if vlayer <> False:
            self.iface.legendInterface().setLayerVisible(vlayer, False)    

        layer = {}
        layer["type"] = "wms"
        layer["title"] = "Flachmoor (BAFU)"
        layer["url"] = "http://wms.geo.admin.ch/"
        layer["layers"] = "ch.bafu.bundesinventare-flachmoore"
        layer["format"] = "image/png"
        layer["crs"] = "EPSG:21781"
        layer["group"] = group
        rlayer = self.qutils.loadLayer(self.iface, layer, None, None) 
        if rlayer <> False:
            self.iface.legendInterface().setLayerVisible(rlayer, True)     

        layer = {}
        layer["type"] = "wms"
        layer["title"] = "Hochmoor (BAFU)"
        layer["url"] = "http://wms.geo.admin.ch/"
        layer["layers"] = "ch.bafu.bundesinventare-hochmoore"
        layer["format"] = "image/png"
        layer["crs"] = "EPSG:21781"
        layer["group"] = group
        rlayer = self.qutils.loadLayer(self.iface, layer, None, None) 
        if rlayer <> False:
            self.iface.legendInterface().setLayerVisible(rlayer, True)     

        layer = {}
        layer["type"] = "wms"
        layer["title"] = "Mobilfunkantennen GSM"
        layer["url"] = "http://wms.geo.admin.ch/"
        layer["layers"] = "ch.bakom.mobil-antennenstandorte-gsm"
        layer["format"] = "image/png"
        layer["crs"] = "EPSG:21781"
        layer["group"] = group
        rlayer = self.qutils.loadLayer(self.iface, layer, None, None) 
        if rlayer <> False:
            self.iface.legendInterface().setLayerVisible(rlayer, True)     

        layer = {}
        layer["type"] = "wms"
        layer["title"] = "Mobilfunkantennen UMTS"
        layer["url"] = "http://wms.geo.admin.ch/"
        layer["layers"] = "ch.bakom.mobil-antennenstandorte-umts"
        layer["format"] = "image/png"
        layer["crs"] = "EPSG:21781"
        layer["group"] = group
        rlayer = self.qutils.loadLayer(self.iface, layer, None, None) 
        if rlayer <> False:
            self.iface.legendInterface().setLayerVisible(rlayer, True)   

        layer = {}
        layer["type"] = "wms"
        layer["title"] = "Radio- und Fernsehsender"
        layer["url"] = "http://wms.geo.admin.ch/"
        layer["layers"] = "ch.bakom.radio-fernsehsender"
        layer["format"] = "image/png"
        layer["crs"] = "EPSG:21781"
        layer["group"] = group
        rlayer = self.qutils.loadLayer(self.iface, layer, None, None) 
        if rlayer <> False:
            self.iface.legendInterface().setLayerVisible(rlayer, True)   

        if gemgrelayer <> False:
            rect = gemgrelayer.extent()
            rect.scale(1.2)
            self.iface.mapCanvas().setExtent(rect)        
            self.iface.mapCanvas().refresh() 

#        except:            
#            QApplication.restoreOverrideCursor()        
        QApplication.restoreOverrideCursor()        

        self.canvas.setMapUnits(0)		
Ejemplo n.º 8
0
 def __init__(self, iface, projectId, submodule):
     self.iface = iface
     self.projectId = projectId
     self.submodule = submodule
     self.qutils = QGeoAppUtils()
class ComplexCheck(QObject):

    def __init__(self, iface):
        self.iface = iface
        self.canvas = self.iface.mapCanvas()
    
        self.qutils = QGeoAppUtils()

    def run(self):        
        self.settings = QSettings("CatAIS","QGeoApp")
        projectId = str(self.settings.value("project/active/id").toString())
        
        QApplication.setOverrideCursor(Qt.WaitCursor)
#        try:
        group = u"Checklayer - Landwirtschaft" + " (" + str(projectId) + ")"
        
        layer = {}
        layer["type"] = "postgres"
        layer["title"] = "BB.BoFlaeche"
        layer["featuretype"] = "bodenbedeckung_boflaeche"
        layer["geom"] = "geometrie"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "bb/bb_landwirtschaft_bbplan.qml"

        vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if vlayer <> False:
            self.iface.legendInterface().setLayerVisible(vlayer, True)    

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = "EO.Einzelobjekt"
        layer["featuretype"] = "einzelobjekte_einzelobjekt"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group

        eoeolayer = self.qutils.loadProjectLayer(self.iface, layer)    

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = u"EO.Flaechenelement"
        layer["featuretype"] = "einzelobjekte_flaechenelement"
        layer["geom"] = "geometrie"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "eo/eo_fl_landwirtschaft_ortho.qml"

        eoflayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if eoflayer <> False:
            self.iface.legendInterface().setLayerVisible(eoflayer, True)    
            
        if eoeolayer <> False and eoflayer <> False:
            joinLayerId = eoeolayer.id()
            joinProvider = eoeolayer.dataProvider()
            joinProvider.select(joinProvider.attributeIndexes())
            joinIdx = joinProvider.fieldNameIndex("tid")
            
            targetProvider = eoflayer.dataProvider()
            targetProvider.select(targetProvider.attributeIndexes())
            targetIdx = targetProvider.fieldNameIndex("flaechenelement_von")

            joinInfo = QgsVectorJoinInfo()
            joinInfo.joinField = joinIdx
            joinInfo.joinLayerId = joinLayerId
            joinInfo.targetField = targetIdx
            joinInfo.memoryCache = True
            
            eoflayer.addJoin(joinInfo)

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = u"EO.Linienelement"
        layer["featuretype"] = "einzelobjekte_linienelement"
        layer["geom"] = "geometrie"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "eo/eo_li_bestockte_ortho.qml"

        eolilayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if eolilayer <> False:
            self.iface.legendInterface().setLayerVisible(eolilayer, True)    

        if eoeolayer <> False and eolilayer <> False:
            joinLayerId = eoeolayer.id()
            joinProvider = eoeolayer.dataProvider()
            joinProvider.select(joinProvider.attributeIndexes())
            joinIdx = joinProvider.fieldNameIndex("tid")
            
            targetProvider = eolilayer.dataProvider()
            targetProvider.select(targetProvider.attributeIndexes())
            targetIdx = targetProvider.fieldNameIndex("linienelement_von")

            joinInfo = QgsVectorJoinInfo()
            joinInfo.joinField = joinIdx
            joinInfo.joinLayerId = joinLayerId
            joinInfo.targetField = targetIdx
            joinInfo.memoryCache = True
            
            eolilayer.addJoin(joinInfo)

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = u"LI.Liegenschaft"
        layer["featuretype"] = "liegenschaften_liegenschaft"
        layer["geom"] = "geometrie"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "li/liegenschaft_ortho.qml"

        vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if vlayer <> False:
            self.iface.legendInterface().setLayerVisible(vlayer, False)    

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = "BB.Kulturen < 1000 m2"
        layer["featuretype"] = "t_kulturen_1000"
        layer["geom"] = "the_geom"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "checks/checklayer_punkt.qml"

        vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if vlayer <> False:
            self.iface.legendInterface().setLayerVisible(vlayer, True)    
            vlayer.removeSelection()
            vlayer.invertSelection()  
            anz_kulturen_1000 = vlayer.selectedFeatureCount()
            vlayer.removeSelection()
     
        layer = {}
        layer["type"] = "postgres"
        layer["title"] = u"BB.Acker_Weide_Wiese in TS2"
        layer["featuretype"] = "t_ack_weid_wies_ts2"
        layer["geom"] = "the_geom"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "checks/checklayer_punkt.qml"

        vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if vlayer <> False:
            self.iface.legendInterface().setLayerVisible(vlayer, True)   

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = "BB.Weide"
        layer["featuretype"] = "t_weide"
        layer["geom"] = "the_geom"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "checks/checklayer_punkt.qml"

        vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if vlayer <> False:
            self.iface.legendInterface().setLayerVisible(vlayer, True)    
            vlayer.removeSelection()
            vlayer.invertSelection()  
            anz_weiden = vlayer.selectedFeatureCount()
            vlayer.removeSelection()            

        QApplication.restoreOverrideCursor()        

#        QMessageBox.information( None, "Checklayer", "<b>Checklayer:</b> <br>"
#                                + "<table>"
#                                + u"<tr> <td>Anzahl Kulturen &lt; 1000 m2: </td> <td>" + str(anz_kulturen_1000) +  "</td> </tr>"
#                                + u"<tr> <td>Anzahl Weiden: </td> <td>" + str(anz_weiden) +  "</td> </tr>"
#                                + "</table>")
#        except:            
#            QApplication.restoreOverrideCursor()        

        self.canvas.setMapUnits(0)		
Ejemplo n.º 10
0
class QGeoAppModule(QObject):
    
    def __init__(self, iface, toolBar):
        self.iface = iface
        self.canvas = self.iface.mapCanvas()
        self.toolBar = toolBar
        self.vutils = QVerisoUtils()
        self.qutils = QGeoAppUtils()
        
        self.settings = QSettings("CatAIS","QGeoApp")
        self.projectsRootPath = self.settings.value("projects/rootdir").toString()
        self.projectId = str(self.settings.value("project/active/id").toString())
        self.ili = str(self.settings.value("project/active/ili").toString())
        self.moduleName = str(self.settings.value("project/active/module").toString())
        self.subModuleName = str(self.settings.value("project/active/submodule").toString())
        
        self.dbhost = str(self.settings.value("project/active/host").toString())
        self.dbport = str(self.settings.value("project/active/port").toString())
        self.dbname = str(self.settings.value("project/active/dbname").toString())
        self.dbschema = str(self.settings.value("project/active/schema").toString())
        self.dbuser = str(self.settings.value("project/active/readuser").toString())
        self.dbpwd = str(self.settings.value("project/active/readpwd").toString())
        self.dbadmin = str(self.settings.value("project/active/writeuser").toString())
        self.dbadminpwd = str(self.settings.value("project/active/writepwd").toString())

        self.DEBUG = True
        
    def initGui(self):
        # remove all the module menus
        actions = self.toolBar.actions()
        for action in actions:
            try:
                objectName = action.defaultWidget().objectName()
                # delete existing module menus
                if objectName[0:13] == "QGeoAppModule":
                    self.toolBar.removeAction(action)
                # remember the action where we want to insert our new menu 
                # (e.g. settings menu bar)
                if objectName == "QGeoApp.Main.SettingsMenuBar":
                    self.beforeAction = action
            except AttributeError:
                pass
            
        # and now add our module specific menus
        self.doInitChecksLoader()
        self.doInitDefectsLoader()
        self.doInitTopicsTableLoader()
        self.doInitBaseLayerLoader()


    def doInitDefectsLoader(self):
        menuBar = QMenuBar(self.toolBar)
        menuBar.setObjectName("QGeoAppModule.QVeriso.LoadDefectsMenuBar")        
        menuBar.setSizePolicy(QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum))
        menu = QMenu(menuBar)
        menu.setTitle(QCoreApplication.translate( "QGeoAppModule.QVeriso","Defects"))  

        action = QAction(QCoreApplication.translate("QGeoAppModule.QVeriso", "Load defects layer"), self.iface.mainWindow())
        QObject.connect(action, SIGNAL( "triggered()"), lambda foo="bar": self.doLoadDefects(foo))
        menu.addAction(action)     
        
        action = QAction(QCoreApplication.translate("QGeoAppModule.QVeriso", "Export defects layer"), self.iface.mainWindow())
        QObject.connect(action, SIGNAL( "triggered()"), lambda foo="bar": self.doExportDefects(foo))
        menu.addAction(action)     

        menuBar.addMenu(menu)
        self.toolBar.insertWidget(self.beforeAction, menuBar)


    def doLoadDefects(self, foo):
        d = LoadDefects(self.iface, self.projectId, self.subModuleName)
        d.run()

        
    def doExportDefects(self, foo):
        d = ExportDefects(self.iface)
        d.run()


    def doInitChecksLoader(self):
        menuBar = QMenuBar(self.toolBar)
        menuBar.setObjectName("QGeoAppModule.QVeriso.LoadChecksMenuBar")        
        menuBar.setSizePolicy(QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum))
        menu = QMenu(menuBar)
        menu.setTitle(QCoreApplication.translate( "QGeoAppModule.QVeriso","Checks"))  
        
        # load checklist
        action = QAction(QCoreApplication.translate("QGeoAppModule.QVeriso", "Load checklist"), self.iface.mainWindow())
        QObject.connect(action, SIGNAL( "triggered()"), lambda foo="bar": self.doLoadChecklist(foo))
        menu.addAction(action)     

        menu.addSeparator()
        
        # load checks
        checkTopics = self.vutils.getCheckTopicsName(self.subModuleName)

        try:
            for checkTopic in checkTopics:
                singleCheckMenu = menu.addMenu(unicode(checkTopic))   
                checks = self.vutils.getChecks(self.subModuleName, checkTopic)
                for check in checks:
                    action = QAction(check["title"], self.iface.mainWindow())
                    try:
                        shortcut = check["shortcut"]
                        action.setShortcut(shortcut)
                    except:
                        pass
                    singleCheckMenu.addAction(action)                            
                    if check["type"] == "simple":
                        QObject.connect(action, SIGNAL( "triggered()"), lambda simpleCheck=check: self.doShowSimpleCheck(simpleCheck))
                    elif check["type"] == "complex":
                        QObject.connect(action, SIGNAL( "triggered()"), lambda complexCheck=check: self.doShowComplexCheck(complexCheck))
        except:
            print "No checks defined."
            #messagebox
            
        menuBar.addMenu(menu)
        self.toolBar.insertWidget(self.beforeAction, menuBar)
        
    
    def doShowSimpleCheck(self, check):
        print "simpleCheck"
        
        
    def doShowComplexCheck(self, check):
        try:
            module = str(check["file"])
            print module
            _temp = __import__("submodules." + self.subModuleName+ "." + module, globals(), locals(), ['ComplexCheck'])
            c = _temp.ComplexCheck(self.iface, self.projectId, self.subModuleName)
            c.run()
        except:
            print "error loading complex check"
           #messagebox
                
    
    def doLoadChecklist(self, foo):
        d = ShowChecklist(self.iface, self.projectId, self.projectsRootPath, self.subModuleName)
        d.run()        


    def doInitBaseLayerLoader(self):
        menuBar = QMenuBar(self.toolBar)
        menuBar.setObjectName("QGeoAppModule.QVeriso.LoadBaseLayersMenuBar")        
        menuBar.setSizePolicy(QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum))
        menu = QMenu(menuBar)
        menu.setTitle(QCoreApplication.translate( "QGeoAppModule.QVeriso","Baselayer"))        

        #add the baselayers
        baselayers = self.vutils.getBaselayers(self.subModuleName)
        try:
            for baselayer in baselayers:
                action = QAction(unicode(baselayer["title"]), self.iface.mainWindow())
                menu.addAction(action)
                QObject.connect(action, SIGNAL( "triggered()" ), lambda layer=baselayer: self.doShowBaseLayer(layer))
        except:
            print "no baselayers found"
            #messagebox

        menuBar.addMenu(menu)
        self.toolBar.insertWidget(self.beforeAction, menuBar)


    def doShowBaseLayer(self, layer):
        print "showbaselayer"
        QApplication.setOverrideCursor(Qt.WaitCursor)
        try:           
            layer["group"] = "Baselayers"
            self.qutils.loadLayer(self.iface, layer, None, "/python/plugins/qgeoapp/modules/qveriso/submodules/" + self.subModuleName + "/qml/")       
        except:        
            print "error adding baselayer"         
            QApplication.restoreOverrideCursor()
        QApplication.restoreOverrideCursor()


    def doInitTopicsTableLoader(self):
        menuBar = QMenuBar(self.toolBar)
        menuBar.setObjectName("QGeoAppModule.QVeriso.LoadTopicsTablesMenuBar")        
        menuBar.setSizePolicy(QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum))
        menu = QMenu(menuBar)
        menu.setTitle(QCoreApplication.translate( "QGeoAppModule.QVeriso","Data"))        

        # add the topic menus
        topics = self.vutils.getTopics(self.subModuleName)
        try:
            for topic in topics:
                singleTopicMenu = menu.addMenu(unicode(topic['title']))   
                action = QAction( QCoreApplication.translate("QGeoAppModule.QVeriso", "Load topic"), self.iface.mainWindow() )
                singleTopicMenu.addAction(action)    
                singleTopicMenu.addSeparator()      
                QObject.connect(action, SIGNAL("triggered()"), lambda topic=topic: self.doShowTopic(topic))                   
                for table in topic["tables"]:
                    action = QAction(unicode(table["title"]), self.iface.mainWindow())
                    singleTopicMenu.addAction(action)     
                    QObject.connect( action, SIGNAL( "triggered()" ), lambda layer=table: self.doShowSingleTopicLayer(layer) )    
        except:
            print "No topics found."
            #messagebox

        menuBar.addMenu(menu)
        self.toolBar.insertWidget(self.beforeAction, menuBar)


    def doShowTopic(self, topic):
        tables = topic["tables"]
        n = len(tables)
        for i in reversed(xrange(0, n)):
            QApplication.setOverrideCursor(Qt.WaitCursor)                    
            try:
                tables[i]["group"] =  tables[i]["group"] + " (" + str(self.dbschema) + ")"
                self.qutils.loadLayer(self.iface, tables[i], None, "/python/plugins/qgeoapp/modules/qveriso/submodules/" + self.subModuleName + "/qml/")   
            except:
                QApplication.setOverrideCursor(Qt.WaitCursor)        
            QApplication.restoreOverrideCursor()

        
    def doShowSingleTopicLayer(self, layer):
        QApplication.setOverrideCursor(Qt.WaitCursor)          
        try:
            layer["group"] =  layer["group"] + " (" + str(self.dbschema) + ")"
            self.qutils.loadLayer(self.iface, layer, None, "/python/plugins/qgeoapp/modules/qveriso/submodules/" + self.subModuleName + "/qml/")       
        except:        
            QApplication.restoreOverrideCursor()
        QApplication.restoreOverrideCursor()


    def run(self):
        print "fooooooooooo"
Ejemplo n.º 11
0
 def __init__(self, iface, projectId):
     self.iface = iface
     self.projectId = projectId
     self.canvas = self.iface.mapCanvas()
     self.qutils = QGeoAppUtils()
Ejemplo n.º 12
0
class ComplexCheck(QObject):

    def __init__(self, iface):
        self.iface = iface
        self.canvas = self.iface.mapCanvas()
    
        self.qutils = QGeoAppUtils()

    def run(self):        
        self.settings = QSettings("CatAIS","QGeoApp")
        projectId = str(self.settings.value("project/active/id").toString())
        
        QApplication.setOverrideCursor(Qt.WaitCursor)
#        try:
        group = u"Lagekontrolle - Gewässer" + " (" + str(projectId) + ")"
        
        layer = {}
        layer["type"] = "wms"
        layer["title"] = "Orthofoto CIR"
        layer["url"] = "http://www.sogis1.so.ch/cgi-bin/sogis/sogis_orthofoto.wms"
        layer["layers"] = "Orthofoto_CIR_SO"
        layer["format"] = "image/jpeg"
        layer["crs"] = "EPSG:21781"
        layer["group"] = group
        rlayer = self.qutils.loadLayer(self.iface, layer, None, None)                 
        
        layer = {}
        layer["type"] = "wms"
        layer["title"] = "Orthofoto RGB"
        layer["url"] = "http://www.sogis1.so.ch/cgi-bin/sogis/sogis_orthofoto.wms"
        layer["layers"] = "Orthofoto_SO"
        layer["format"] = "image/jpeg"
        layer["crs"] = "EPSG:21781"
        layer["group"] = group
        rlayer = self.qutils.loadLayer(self.iface, layer, None, None) 
        if rlayer <> False:
            self.iface.legendInterface().setLayerVisible(rlayer, True)     
            
        layer = {}
        layer["type"] = "wms"
        layer["title"] = "DTM"
        layer["url"] = "http://www.sogis1.so.ch/wms/wms_lidar"
        layer["layers"] = "dtm_hangneigung_2014"
        layer["format"] = "image/jpeg"
        layer["crs"] = "EPSG:21781"
        layer["group"] = group
        rlayer = self.qutils.loadLayer(self.iface, layer, None, None)                 
                        
        layer = {}
        layer["type"] = "wms"
        layer["title"] = "GEWISSO"
        layer["url"] = "http://www.sogis1.so.ch/cgi-bin/sogis/sogis_gewaesser.wms"
        layer["layers"] = "gewaesser"
        layer["format"] = "image/png"
        layer["crs"] = "EPSG:21781"
        layer["group"] = group
        layer["style"] = "gewaesser/gewisso.qml"        
        rlayer = self.qutils.loadLayer(self.iface, layer, None, None) 
        if rlayer <> False:
           self.iface.legendInterface().setLayerVisible(rlayer, True)                 
           
        layer = {}
        layer["type"] = "postgres"
        layer["title"] = "Gemeindegrenze"
        layer["featuretype"] = "gemeindegrenzen_gemeindegrenze"
        layer["geom"] = "geometrie"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "gemeindegrenze/gemgre_strichliert.qml"

        gemgrelayer = self.qutils.loadProjectLayer(self.iface, layer) 
        if gemgrelayer <> False:
            self.iface.legendInterface().setLayerVisible(gemgrelayer, True)     
  
        layer = {}
        layer["type"] = "postgres"
        layer["title"] = "BB.BoFlaeche"
        layer["featuretype"] = "bodenbedeckung_boflaeche"
        layer["geom"] = "geometrie"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "bb/bb_gewaesser_ortho.qml"

        vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if vlayer <> False:
            self.iface.legendInterface().setLayerVisible(vlayer, True)    

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = "EO.Einzelobjekt"
        layer["featuretype"] = "einzelobjekte_einzelobjekt"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group

        eoeolayer = self.qutils.loadProjectLayer(self.iface, layer)    

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = u"EO.Flaechenelement"
        layer["featuretype"] = "einzelobjekte_flaechenelement"
        layer["geom"] = "geometrie"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "eo/eo_fl_gewaesser_ortho.qml"

        eoflayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if eoflayer <> False:
            self.iface.legendInterface().setLayerVisible(eoflayer, True)    
            
        if eoeolayer <> False and eoflayer <> False:
            joinLayerId = eoeolayer.id()
            joinProvider = eoeolayer.dataProvider()
            joinProvider.select(joinProvider.attributeIndexes())
            joinIdx = joinProvider.fieldNameIndex("tid")
            
            targetProvider = eoflayer.dataProvider()
            targetProvider.select(targetProvider.attributeIndexes())
            targetIdx = targetProvider.fieldNameIndex("flaechenelement_von")

            joinInfo = QgsVectorJoinInfo()
            joinInfo.joinField = joinIdx
            joinInfo.joinLayerId = joinLayerId
            joinInfo.targetField = targetIdx
            joinInfo.memoryCache = True
            
            eoflayer.addJoin(joinInfo)

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = u"EO.Linienelement"
        layer["featuretype"] = "einzelobjekte_linienelement"
        layer["geom"] = "geometrie"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "eo/eo_li_gewaesser_ortho.qml"

        eolilayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if eolilayer <> False:
            self.iface.legendInterface().setLayerVisible(eolilayer, True)    

        if eoeolayer <> False and eolilayer <> False:
            joinLayerId = eoeolayer.id()
            joinProvider = eoeolayer.dataProvider()
            joinProvider.select(joinProvider.attributeIndexes())
            joinIdx = joinProvider.fieldNameIndex("tid")
            
            targetProvider = eolilayer.dataProvider()
            targetProvider.select(targetProvider.attributeIndexes())
            targetIdx = targetProvider.fieldNameIndex("linienelement_von")

            joinInfo = QgsVectorJoinInfo()
            joinInfo.joinField = joinIdx
            joinInfo.joinLayerId = joinLayerId
            joinInfo.targetField = targetIdx
            joinInfo.memoryCache = True
            
            eolilayer.addJoin(joinInfo)

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = u"EO.Punktelement"
        layer["featuretype"] = "einzelobjekte_punktelement"
        layer["geom"] = "geometrie"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "eo/eo_pk_andere.qml"

        eopklayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if eopklayer <> False:
            self.iface.legendInterface().setLayerVisible(eopklayer, True)    

        if eoeolayer <> False and eopklayer <> False:
            joinLayerId = eoeolayer.id()
            joinProvider = eoeolayer.dataProvider()
            joinProvider.select(joinProvider.attributeIndexes())
            joinIdx = joinProvider.fieldNameIndex("tid")
            
            targetProvider = eopklayer.dataProvider()
            targetProvider.select(targetProvider.attributeIndexes())
            targetIdx = targetProvider.fieldNameIndex("punktelement_von")

            joinInfo = QgsVectorJoinInfo()
            joinInfo.joinField = joinIdx
            joinInfo.joinLayerId = joinLayerId
            joinInfo.targetField = targetIdx
            joinInfo.memoryCache = True
            
            eopklayer.addJoin(joinInfo)


        layer = {}
        layer["type"] = "postgres"
        layer["title"] = u"BB.Symbole"
        layer["featuretype"] = "v_bodenbedeckung_boflaechesymbol"
        layer["geom"] = "pos"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "bb/bb_symbole.qml"

        vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if vlayer <> False:
            self.iface.legendInterface().setLayerVisible(vlayer, True)    

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = u"EO.Symbole"
        layer["featuretype"] = "t_eo_symbole"
        layer["geom"] = "pos"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "eo/eo_symbole.qml"

        vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if vlayer <> False:
            self.iface.legendInterface().setLayerVisible(vlayer, True)  

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = u"LI.Liegenschaft"
        layer["featuretype"] = "liegenschaften_liegenschaft"
        layer["geom"] = "geometrie"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "li/liegenschaft_ortho.qml"

        vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if vlayer <> False:
            self.iface.legendInterface().setLayerVisible(vlayer, False)    

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = u"BB.Objektname"
        layer["featuretype"] = "v_bb_objektnamen"
        layer["geom"] = "pos"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "bb/bb_objektnamen.qml"

        vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if vlayer <> False:
            self.iface.legendInterface().setLayerVisible(vlayer, True)  

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = u"EO.Objektname"
        layer["featuretype"] = "v_eo_objektnamen"
        layer["geom"] = "pos"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "eo/eo_objektnamen.qml"

        vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if vlayer <> False:
            self.iface.legendInterface().setLayerVisible(vlayer, True)  

        if gemgrelayer <> False:
            rect = gemgrelayer.extent()
            rect.scale(1.2)
            self.iface.mapCanvas().setExtent(rect)        
            self.iface.mapCanvas().refresh() 


#        except:            
#            QApplication.restoreOverrideCursor()        
        QApplication.restoreOverrideCursor()        

        self.canvas.setMapUnits(0)		
Ejemplo n.º 13
0
class ComplexCheck(QObject):

    def __init__(self, iface):
        self.iface = iface
        self.canvas = self.iface.mapCanvas()
    
        self.qutils = QGeoAppUtils()

    def run(self):        
        self.settings = QSettings("CatAIS","QGeoApp")
        projectId = str(self.settings.value("project/active/id").toString())
        
        QApplication.setOverrideCursor(Qt.WaitCursor)
#        try:
        group = u"Checklayer - Gewässer" + " (" + str(projectId) + ")"
        
        layer = {}
        layer["type"] = "postgres"
        layer["title"] = "BB.stehendes_Gewaesser < 100 m2"
        layer["featuretype"] = "t_gewaesser_100"
        layer["geom"] = "the_geom"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "checks/checklayer_punkt.qml"

        vlayer = self.qutils.loadProjectLayer(self.iface, layer) 
        if vlayer <> False:
            self.iface.legendInterface().setLayerVisible(vlayer, True) 
            # featureCount funktioniert nicht. Workaround:
            vlayer.removeSelection()
            vlayer.invertSelection()  
            anz_gewaesser_100 = vlayer.selectedFeatureCount()
            vlayer.removeSelection()
 
        layer = {}
        layer["type"] = "postgres"
        layer["title"] = u"EO.eingedoltes_Gewaesser auf BB.Gewaesser"
        layer["featuretype"] = "t_einged_fliessend"
        layer["geom"] = "the_geom"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "checks/checklayer_punkt.qml"

        vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if vlayer <> False:
            self.iface.legendInterface().setLayerVisible(vlayer, True)    

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = "EO.Quelle"
        layer["featuretype"] = "t_eo_quellen"
        layer["geom"] = "the_geom"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "checks/checklayer_punkt.qml"

        vlayer = self.qutils.loadProjectLayer(self.iface, layer) 
        if vlayer <> False:
            self.iface.legendInterface().setLayerVisible(vlayer, True)     
            # featureCount funktioniert nicht. Workaround:
            vlayer.removeSelection()
            vlayer.invertSelection()  
            anz_quellen = vlayer.selectedFeatureCount()
            vlayer.removeSelection()


#        QMessageBox.information( None, "Checklayer", "<b>Checklayer:</b> <br>"
#                                + "<table>"
#                                + "<tr> <td>Anzahl Quellen: </td> <td>" + str(anz_quellen) +  "</td> </tr>"
#                                + u"<tr> <td>Anzahl ste. Gewässer &lt; 100 m2: </td> <td>" + str(anz_gewaesser_100) +  "</td> </tr>"
#                                + "</table>")


#        except:            
#            QApplication.restoreOverrideCursor()        
        QApplication.restoreOverrideCursor()        

        self.canvas.setMapUnits(0)		
Ejemplo n.º 14
0
class ComplexCheck(QObject):

    def __init__(self, iface):
        self.iface = iface
        self.canvas = self.iface.mapCanvas()
    
        self.qutils = QGeoAppUtils()

    def run(self):        
        self.settings = QSettings("CatAIS","QGeoApp")
        projectId = str(self.settings.value("project/active/id").toString())
        
        QApplication.setOverrideCursor(Qt.WaitCursor)
#        try:
        group = "Checklayer - Bebautes Gebiet" + " (" + str(projectId) + ")"
        
  
        layer = {}
        layer["type"] = "postgres"
        layer["title"] = "BB.Objektname 'u.'"
        layer["featuretype"] = "t_bbobj_u"
        layer["geom"] = "the_geom"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "checks/checklayer_punkt.qml"

        vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if vlayer <> False:
            self.iface.legendInterface().setLayerVisible(vlayer, True)    

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = "EO.Objektname 'u.'"
        layer["featuretype"] = "t_eoobj_u"
        layer["geom"] = "the_geom"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "checks/checklayer_punkt.qml"

        vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if vlayer <> False:
            self.iface.legendInterface().setLayerVisible(vlayer, True)    


        layer = {}
        layer["type"] = "postgres"
        layer["title"] = "EO.Treppe nicht ein Objekt"
        layer["featuretype"] = "t_treppe_modellbildung"
        layer["geom"] = "the_geom"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "checks/checklayer_punkt.qml"

        vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if vlayer <> False:
            self.iface.legendInterface().setLayerVisible(vlayer, True)    

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = u"EO.Flächenelement 'übrig. Geb.teil' freistehend"
        layer["featuretype"] = "t_gebteil_frei"
        layer["geom"] = "the_geom"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "checks/checklayer_punkt.qml"

        vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if vlayer <> False:
            self.iface.legendInterface().setLayerVisible(vlayer, True)    

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = u"EO.Linienelement 'übrig. Geb.teil' ausserhalb Gebäude"
        layer["featuretype"] = "t_gebteil_ausserhalb"
        layer["geom"] = "the_geom"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "checks/checklayer_punkt.qml"

        vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if vlayer <> False:
            self.iface.legendInterface().setLayerVisible(vlayer, True)    

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = u"EO.Flächenelement 'übrig. Geb.teil' innerhalb Gebäude"
        layer["featuretype"] = "t_gebteil_geb"
        layer["geom"] = "the_geom"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "checks/checklayer_punkt.qml"

        vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if vlayer <> False:
            self.iface.legendInterface().setLayerVisible(vlayer, True)    

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = u"EO.Pfeiler im Gebäude"
        layer["featuretype"] = "t_pfeiler_gebaeude"
        layer["geom"] = "the_geom"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "checks/checklayer_punkt.qml"

        vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if vlayer <> False:
            self.iface.legendInterface().setLayerVisible(vlayer, True)    

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = u"EO.uebriger_Gebaeudeteil < 1.5 m2"
        layer["featuretype"] = "t_gebteil_15"
        layer["geom"] = "the_geom"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "checks/checklayer_punkt.qml"

        vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if vlayer <> False:
            self.iface.legendInterface().setLayerVisible(vlayer, True)    

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = u"Ein EO.Objekt pro Element"
        layer["featuretype"] = "t_eo_modellbildung"
        layer["geom"] = "the_geom"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "checks/checklayer_punkt.qml"

        vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if vlayer <> False:
            self.iface.legendInterface().setLayerVisible(vlayer, True)    


        layer = {}
        layer["type"] = "postgres"
        layer["title"] = u"BB.Wasserbecken mit EO.Mauer"
        layer["featuretype"] = "t_mauer_wasserbecken"
        layer["geom"] = "the_geom"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "checks/checklayer_punkt.qml"

        vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if vlayer <> False:
            self.iface.legendInterface().setLayerVisible(vlayer, True)    

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = u"EO.Linienelement Mauer"
        layer["featuretype"] = "t_mauer_linien"
        layer["geom"] = "the_geom"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "checks/checklayer_punkt.qml"

        vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if vlayer <> False:
            self.iface.legendInterface().setLayerVisible(vlayer, True)    

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = u"EO.Linienelement Mauer ausserhalb EO.Flächenelement Mauer"
        layer["featuretype"] = "t_mauer_ausserhalb"
        layer["geom"] = "the_geom"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "checks/checklayer_punkt.qml"

        vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if vlayer <> False:
            self.iface.legendInterface().setLayerVisible(vlayer, True)    
            
        layer = {}
        layer["type"] = "postgres"
        layer["title"] = u"EO.Mauer freistehend"
        layer["featuretype"] = "t_mauer_freistehend"
        layer["geom"] = "the_geom"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "checks/checklayer_punkt.qml"

        vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if vlayer <> False:
            self.iface.legendInterface().setLayerVisible(vlayer, True)              

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = "EO.Mauer nicht ein Objekt"
        layer["featuretype"] = "t_mauer_modellbildung"
        layer["geom"] = "the_geom"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "checks/checklayer_punkt.qml"

        vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if vlayer <> False:
            self.iface.legendInterface().setLayerVisible(vlayer, True)    

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = u"BB.Gebaeude ohne Gartenanlage"
        layer["featuretype"] = "t_abgrenzung_gartenanlage"
        layer["geom"] = "the_geom"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "checks/checklayer_punkt.qml"

        vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if vlayer <> False:
            self.iface.legendInterface().setLayerVisible(vlayer, True)            
          
        layer = {}
        layer["type"] = "postgres"
        layer["title"] = u"BB.Gebaeude ohne Erschliessung"
        layer["featuretype"] = "t_geb_ohne_ersch"
        layer["geom"] = "the_geom"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "checks/checklayer_punkt.qml"

        vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if vlayer <> False:
            self.iface.legendInterface().setLayerVisible(vlayer, True)               
          
        layer = {}
        layer["type"] = "postgres"
        layer["title"] = u"BB.Parkplatz < 100 m2"
        layer["featuretype"] = "t_pp_kleiner_100"
        layer["geom"] = "the_geom"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "checks/checklayer_punkt.qml"

        vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if vlayer <> False:
            self.iface.legendInterface().setLayerVisible(vlayer, True)              
          
        layer = {}
        layer["type"] = "postgres"
        layer["title"] = u"BB.Gebaeude mit mehreren Adressen"
        layer["featuretype"] = "t_2_gebein"
        layer["geom"] = "the_geom"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "checks/checklayer_punkt.qml"

        vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if vlayer <> False:
            self.iface.legendInterface().setLayerVisible(vlayer, True)              

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = u"BB.Gebaeude < 6 m2"
        layer["featuretype"] = "t_gebaeude_kleiner_6"
        layer["geom"] = "the_geom"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "checks/checklayer_punkt.qml"

        vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if vlayer <> False:
            self.iface.legendInterface().setLayerVisible(vlayer, True)              

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = u"EO.Linienelement unterird. Gebaeude"
        layer["featuretype"] = "t_u_geb_linien"
        layer["geom"] = "the_geom"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "checks/checklayer_punkt.qml"

        vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if vlayer <> False:
            self.iface.legendInterface().setLayerVisible(vlayer, True)              


        layer = {}
        layer["type"] = "postgres"
        layer["title"] = u"EO.Unterstand auf Gebäude"
        layer["featuretype"] = "t_unterstand_auf_geb"
        layer["geom"] = "the_geom"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "checks/checklayer_punkt.qml"

        vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if vlayer <> False:
            self.iface.legendInterface().setLayerVisible(vlayer, True)     

 


#        except:            
#            QApplication.restoreOverrideCursor()        
        QApplication.restoreOverrideCursor()        

        self.canvas.setMapUnits(0)		
class ComplexCheck(QObject):

    def __init__(self, iface):
        self.iface = iface
        self.canvas = self.iface.mapCanvas()
    
        self.qutils = QGeoAppUtils()

    def run(self):        
        settings = QSettings("CatAIS","QGeoApp")
        projectId = str(settings.value("project/active/id").toString())
        projectdir = str(settings.value("project/active/projectdir").toString())        
        dbhost = str(settings.value("project/active/dbhost").toString())
        dbport = str(settings.value("project/active/dbport").toString())
        dbname = str(settings.value("project/active/dbname").toString())
        dbschema = str(settings.value("project/active/dbschema").toString())
        dbuser = str(settings.value("project/active/dbuser").toString())
        dbpwd = str(settings.value("project/active/dbpwd").toString())        
        
        QApplication.setOverrideCursor(Qt.WaitCursor)
#        try:
        group = u"Checklayer - Seltene Objekte" + " (" + str(projectId) + ")"
        
        layer = {}
        layer["type"] = "postgres"
        layer["title"] = "BB.BoFlaeche"
        layer["featuretype"] = "bodenbedeckung_boflaeche"
        layer["geom"] = "geometrie"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "bb/bb_bb_plan.qml"

        vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if vlayer <> False:
            self.iface.legendInterface().setLayerVisible(vlayer, True)    

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = "EO.Einzelobjekt"
        layer["featuretype"] = "einzelobjekte_einzelobjekt"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group

        eoeolayer = self.qutils.loadProjectLayer(self.iface, layer)    

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = u"EO.Flaechenelement"
        layer["featuretype"] = "einzelobjekte_flaechenelement"
        layer["geom"] = "geometrie"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "eo/eo_fl_bb_plan.qml"

        eoflayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if eoflayer <> False:
            self.iface.legendInterface().setLayerVisible(eoflayer, True)    
            
        if eoeolayer <> False and eoflayer <> False:
            joinLayerId = eoeolayer.id()
            joinProvider = eoeolayer.dataProvider()
            joinProvider.select(joinProvider.attributeIndexes())
            joinIdx = joinProvider.fieldNameIndex("tid")
            
            targetProvider = eoflayer.dataProvider()
            targetProvider.select(targetProvider.attributeIndexes())
            targetIdx = targetProvider.fieldNameIndex("flaechenelement_von")

            joinInfo = QgsVectorJoinInfo()
            joinInfo.joinField = joinIdx
            joinInfo.joinLayerId = joinLayerId
            joinInfo.targetField = targetIdx
            joinInfo.memoryCache = True
            
            eoflayer.addJoin(joinInfo)

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = u"EO.Linienelement"
        layer["featuretype"] = "einzelobjekte_linienelement"
        layer["geom"] = "geometrie"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "eo/eo_li_bb_plan.qml"

        eolilayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if eolilayer <> False:
            self.iface.legendInterface().setLayerVisible(eolilayer, True)    

        if eoeolayer <> False and eolilayer <> False:
            joinLayerId = eoeolayer.id()
            joinProvider = eoeolayer.dataProvider()
            joinProvider.select(joinProvider.attributeIndexes())
            joinIdx = joinProvider.fieldNameIndex("tid")
            
            targetProvider = eolilayer.dataProvider()
            targetProvider.select(targetProvider.attributeIndexes())
            targetIdx = targetProvider.fieldNameIndex("linienelement_von")

            joinInfo = QgsVectorJoinInfo()
            joinInfo.joinField = joinIdx
            joinInfo.joinLayerId = joinLayerId
            joinInfo.targetField = targetIdx
            joinInfo.memoryCache = True
            
            eolilayer.addJoin(joinInfo)

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = u"LI.Liegenschaft"
        layer["featuretype"] = "liegenschaften_liegenschaft"
        layer["geom"] = "geometrie"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "li/liegenschaft_ortho.qml"

        vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if vlayer <> False:
            self.iface.legendInterface().setLayerVisible(vlayer, False)    

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = "BB.Boeschungsbauwerk"
        layer["featuretype"] = "t_boeschungbwerke"
        layer["geom"] = "the_geom"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "checks/checklayer_punkt.qml"

        vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if vlayer <> False:
            self.iface.legendInterface().setLayerVisible(vlayer, True)    
            
        layer = {}
        layer["type"] = "postgres"
        layer["title"] = "EO.Brunnen"
        layer["featuretype"] = "t_brunnen"
        layer["geom"] = "the_geom"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "checks/checklayer_punkt.qml"

        vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if vlayer <> False:
            self.iface.legendInterface().setLayerVisible(vlayer, True)    
        

#        except:            
#            QApplication.restoreOverrideCursor()        
        QApplication.restoreOverrideCursor()        

        # Export feature count in excel file.
        try:
            db = QSqlDatabase.addDatabase("QPSQL", "SelteneObjekte")
            db.setDatabaseName(dbname)
            db.setHostName(dbhost)
            db.setUserName(dbuser)
            db.setPassword(dbpwd)
            
            if  db.open() == False:
                QMessageBox.critical(None,  "QGeoApp", QCoreApplication.translate("QGeoApp", "Could not open database:\n") + str(db.lastError().driverText()))            
                return 

            # Create excel file.
            wb = pycel.Workbook(encoding='utf-8')
            wb.country_code = 41
            
            style1 = pycel.easyxf('font: bold on;');
            style2 = pycel.easyxf('font: italic on;');

            # Bodenbedeckung            
            sql = """SELECT CASE WHEN anz IS NULL THEN 0 ELSE anz END, bb_art.code as art, bb_art.code_txt as art_txt
FROM
(
 SELECT count(art) as anz, art_txt, art
 FROM """+dbschema+""".bodenbedeckung_boflaeche
 WHERE art IN (7, 9, 19, 20, 21, 22, 30, 33, 35, 36, 37, 38, 39, 40)
 GROUP BY art, art_txt
) bb
FULL JOIN """+dbschema+""".enum__bodenbedeckung_bbart bb_art ON bb_art.code = bb.art
WHERE bb_art.code IN (7, 9, 19, 20, 21, 22, 30, 33, 35, 36, 37, 38, 39, 40)
ORDER BY bb_art.code;"""

            query = db.exec_(sql)
            
            if query.isActive() == False:
                QMessageBox.critical(None,  "QGeoApp", QCoreApplication.translate("QGeoApp", "Error occured while fetching data informations."))            
                return 
                        
            ws = wb.add_sheet(u'BB seltene Objekte')
            ws.paper_size_code = 8
            ws.print_centered_vert = False
            ws.print_centered_horz = False
            ws.top_margin = 1.0
            ws.left_margin = 1.0 
            ws.bottom_margin = 1.0
            ws.portrait = True
            
            ws.write(0, 0,  str("BB seltene Objekte: "), style1 )
            ws.write(0, 1,  projectId)        

            ws.write(2, 0, str("Art"))
            ws.write(2, 1, str("Art-Text"))
            ws.write(2, 2, str("Anzahl"))

            i = 0
            record = query.record()
            while query.next():
                anz = str(query.value(record.indexOf("anz")).toString())
                art = str(query.value(record.indexOf("art")).toString())
                art_txt = str(query.value(record.indexOf("art_txt")).toString())
                
                ws.write(3+i, 0, art)
                ws.write(3+i, 1, art_txt)
                ws.write(3+i, 2, anz)
                
                i += 1

            # Einzelobjekte
            sql = """SELECT CASE WHEN anz IS NULL THEN 0 ELSE anz END, eo_art.code as art, eo_art.code_txt as art_txt
FROM
(
 SELECT count(art) as anz, art_txt, art
 FROM """+dbschema+""".einzelobjekte_einzelobjekt
 WHERE art IN (9, 14, 15, 16, 17, 18, 23, 30, 31, 35, 36, 37, 38, 40, 42)
 GROUP BY art, art_txt
) eo
FULL JOIN """+dbschema+""".enum__einzelobjekte_eoart eo_art ON eo_art.code = eo.art
WHERE eo_art.code IN (9, 14, 15, 16, 17, 18, 23, 30, 31, 35, 36, 37, 38, 40, 42)
ORDER BY eo_art.code"""

            query = db.exec_(sql)
            
            if query.isActive() == False:
                QMessageBox.critical(None,  "QGeoApp", QCoreApplication.translate("QGeoApp", "Error occured while fetching data informations."))            
                return 

            ws = wb.add_sheet(u'EO seltene Objekte')
            ws.paper_size_code = 8
            ws.print_centered_vert = False
            ws.print_centered_horz = False
            ws.top_margin = 1.0
            ws.left_margin = 1.0 
            ws.bottom_margin = 1.0
            ws.portrait = True
            
            ws.write(0, 0,  str("EO seltene Objekte: "), style1)
            ws.write(0, 1,  projectId)        

            ws.write(2, 0, str("Art"))
            ws.write(2, 1, str("Art-Text"))
            ws.write(2, 2, str("Anzahl"))

            i = 0
            record = query.record()
            while query.next():
                anz = str(query.value(record.indexOf("anz")).toString())
                art = str(query.value(record.indexOf("art")).toString())
                art_txt = str(query.value(record.indexOf("art_txt")).toString())
                
                ws.write(3+i, 0, art)
                ws.write(3+i, 1, art_txt)
                if int(anz) > 0:
                    ws.write(3+i, 2, anz, style1)
                else:
                    ws.write(3+i, 2, anz)
                
                i += 1

            file = QDir.convertSeparators(QDir.cleanPath(projectdir + os.sep + "seltene_objekte.xls"))
            try:
                wb.save(file)
                QMessageBox.information( None, "", QCoreApplication.translate("QGeoAppModule.PNF", "File written:\n") + file)
            except IOError:
                QMessageBox.warning( None, "", QCoreApplication.translate("QGeoAppModule.PNF", "File <b>not</b> written!<br>")+ file)
                return

            db.close()
    
        except:
            QMessageBox.critical(None,  "QGeoApp", QCoreApplication.translate("QGeoApp", "Error exporting data from database to excel."))            

        self.canvas.setMapUnits(0)		
 def __init__(self, iface):
     self.iface = iface
     self.canvas = self.iface.mapCanvas()
 
     self.qutils = QGeoAppUtils()
Ejemplo n.º 17
0
class ComplexCheck(QObject):

    def __init__(self, iface):
        self.iface = iface
        self.canvas = self.iface.mapCanvas()
        self.qutils = QGeoAppUtils()

    def run(self):        
        self.settings = QSettings("CatAIS","QGeoApp")
        projectId = str(self.settings.value("project/active/id").toString())
        
        QApplication.setOverrideCursor(Qt.WaitCursor)
        try:            
            layer = {}
            layer["type"] = "postgres"
            layer["title"] = "Fehlerarten"
            layer["featuretype"] = "t_maengel_fehler"
            layer["key"] = "ogc_fid"            
            layer["sql"] = ""
            layer["readonly"] = "true"
            layer["group"] = u"Mängel - Perimeterrand" + " (" + projectId + ")"

            lyr_fehlerarten = self.qutils.loadProjectLayer(self.iface, layer)    
            if lyr_fehlerarten <> False:
                lyr_fehlerarten.setLayerName(u"Fehlerarten")

            layer = {}
            layer["type"] = "postgres"
            layer["title"] = "Maengelarten"
            layer["featuretype"] = "t_maengel_art"
            layer["key"] = "ogc_fid"            
            layer["sql"] = "gruppe = 'Perimeterrand'"
            layer["readonly"] = "true"
            layer["group"] = u"Mängel - Perimeterrand" + " (" + projectId + ")"

            lyr_maengelarten = self.qutils.loadProjectLayer(self.iface, layer)    
            if lyr_maengelarten <> False:
                lyr_maengelarten.setLayerName(u"Mängelarten")

            layer = {}
            layer["type"] = "postgres"
            layer["title"] = u"Maengelliste (Punkte)"
            layer["featuretype"] = "t_maengel"
            layer["geom"] = "the_geom"
            layer["key"] = "ogc_fid"
            layer["readonly"] = "false"
            layer["sql"] = "gruppe = 'Perimeterrand'"                        
            layer["group"] = u"Mängel - Perimeterrand" + " (" + projectId + ")"
            layer["style"] = "maengel/maengel.qml"

            vlayer = self.qutils.loadProjectLayer(self.iface, layer)  
            if vlayer <> False:
                self.iface.legendInterface().setLayerVisible(vlayer, True) 
                vlayer.setLayerName(u"Mängelliste (Punkte)")
                #vlayer.saveDefaultStyle()            

                provider = vlayer.dataProvider()
                provider.select(provider.attributeIndexes())
                ogc_fid_idx = provider.fieldNameIndex("ogc_fid")
                gruppe_idx = provider.fieldNameIndex("gruppe")
                art_idx = provider.fieldNameIndex("art")
                fehler_idx = provider.fieldNameIndex("fehler")
                feld_idx = provider.fieldNameIndex("feldkontrolle")
                lnf_idx = provider.fieldNameIndex("lnf")
                terr_idx = provider.fieldNameIndex("terrestrisch")
                bemerkung_idx = provider.fieldNameIndex("bemerkung")
                datum_idx = provider.fieldNameIndex("datum")  

                vlayer.addAttributeAlias(gruppe_idx, "Gruppe:")
                vlayer.addAttributeAlias(art_idx, "Art:")
                vlayer.addAttributeAlias(fehler_idx, "Fehler:")
                vlayer.addAttributeAlias(feld_idx, "Feldkontrolle:")
                vlayer.addAttributeAlias(lnf_idx, u"Laufende Nachführung:")
                vlayer.addAttributeAlias(terr_idx, "Terrestrische Aufnahme:")
                vlayer.addAttributeAlias(bemerkung_idx, "Bemerkung:")
      
                vlayer.setEditType(ogc_fid_idx, 11)
                vlayer.setEditType(gruppe_idx, 15)
                vlayer.setEditType(art_idx, 15)
                vlayer.setEditType(fehler_idx, 15)
                vlayer.setEditType(feld_idx, 7)
                vlayer.setEditType(lnf_idx, 7)
                vlayer.setEditType(terr_idx, 7)
                vlayer.setEditType(bemerkung_idx, 12)            
                vlayer.setEditType(datum_idx, 11)            
                
                vlayer.setCheckedState(feld_idx, 't', 'f')
                vlayer.setCheckedState(lnf_idx, 't', 'f')
                vlayer.setCheckedState(terr_idx, 't', 'f')
                
                gruppe_valrel = vlayer.valueRelation(gruppe_idx)
                gruppe_valrel.mLayer = lyr_maengelarten.id()
                gruppe_valrel.mKey = "gruppe"
                gruppe_valrel.mValue = "gruppe"
                #gruppe_valrel.mFilterExpression = "\"gruppe\" = 'Perimeterrand'"
                gruppe_valrel.mOrderByValue = True
                gruppe_valrel.mAllowNull = False
                gruppe_valrel.mAllowMulti = False
                
                art_valrel = vlayer.valueRelation(art_idx)
                art_valrel.mLayer = lyr_maengelarten.id()
                art_valrel.mKey = "art_txt"
                art_valrel.mValue = "art_txt"
                art_valrel.mOrderByValue = True
                art_valrel.mAllowNull = True
                art_valrel.mAllowMulti = False
                
                fehler_valrel = vlayer.valueRelation(fehler_idx)
                fehler_valrel.mLayer = lyr_fehlerarten.id()
                fehler_valrel.mKey = "fehler_txt"
                fehler_valrel.mValue = "fehler_txt"
                fehler_valrel.mOrderByValue = True
                fehler_valrel.mAllowNull = True
                fehler_valrel.mAllowMulti = False            


            layer = {}
            layer["type"] = "postgres"
            layer["title"] = u"Maengelliste (Linien)"
            layer["featuretype"] = "t_maengel_linie"
            layer["geom"] = "the_geom"
            layer["key"] = "ogc_fid"
            layer["readonly"] = "false"
            layer["sql"] = "gruppe = 'Perimeterrand'"                        
            layer["group"] = u"Mängel - Perimeterrand" + " (" + projectId + ")"
            layer["style"] = "maengel/maengel_linie.qml"

            vlayer = self.qutils.loadProjectLayer(self.iface, layer)  
            if vlayer <> False:
                self.iface.legendInterface().setLayerVisible(vlayer, True) 
                vlayer.setLayerName(u"Mängelliste (Linie)")
                #vlayer.saveDefaultStyle()                
                    
                provider = vlayer.dataProvider()
                provider.select(provider.attributeIndexes())
                ogc_fid_idx = provider.fieldNameIndex("ogc_fid")
                gruppe_idx = provider.fieldNameIndex("gruppe")
                art_idx = provider.fieldNameIndex("art")
                fehler_idx = provider.fieldNameIndex("fehler")
                feld_idx = provider.fieldNameIndex("feldkontrolle")
                lnf_idx = provider.fieldNameIndex("lnf")
                terr_idx = provider.fieldNameIndex("terrestrisch")                
                bemerkung_idx = provider.fieldNameIndex("bemerkung")
                datum_idx = provider.fieldNameIndex("datum")  

                vlayer.addAttributeAlias(gruppe_idx, "Gruppe:")
                vlayer.addAttributeAlias(art_idx, "Art:")
                vlayer.addAttributeAlias(fehler_idx, "Fehler:")
                vlayer.addAttributeAlias(feld_idx, "Feldkontrolle:")
                vlayer.addAttributeAlias(lnf_idx, u"Laufende Nachführung:")
                vlayer.addAttributeAlias(terr_idx, "Terrestrische Aufnahme:")                
                vlayer.addAttributeAlias(bemerkung_idx, "Bemerkung:")
      
                vlayer.setEditType(ogc_fid_idx, 11)
                vlayer.setEditType(gruppe_idx, 15)
                vlayer.setEditType(art_idx, 15)
                vlayer.setEditType(fehler_idx, 15)
                vlayer.setEditType(feld_idx, 7)
                vlayer.setEditType(lnf_idx, 7)
                vlayer.setEditType(terr_idx, 7)                
                vlayer.setEditType(bemerkung_idx, 12)            
                vlayer.setEditType(datum_idx, 11)            
                
                vlayer.setCheckedState(feld_idx, 't', 'f')
                vlayer.setCheckedState(lnf_idx, 't', 'f')
                vlayer.setCheckedState(terr_idx, 't', 'f')                
                
                gruppe_valrel = vlayer.valueRelation(gruppe_idx)
                gruppe_valrel.mLayer = lyr_maengelarten.id()
                gruppe_valrel.mKey = "gruppe"
                gruppe_valrel.mValue = "gruppe"
                gruppe_valrel.mOrderByValue = True
                gruppe_valrel.mAllowNull = False
                gruppe_valrel.mAllowMulti = False
                
                art_valrel = vlayer.valueRelation(art_idx)
                art_valrel.mLayer = lyr_maengelarten.id()
                art_valrel.mKey = "art_txt"
                art_valrel.mValue = "art_txt"
                art_valrel.mOrderByValue = True
                art_valrel.mAllowNull = True
                art_valrel.mAllowMulti = False
                
                fehler_valrel = vlayer.valueRelation(fehler_idx)
                fehler_valrel.mLayer = lyr_fehlerarten.id()
                fehler_valrel.mKey = "fehler_txt"
                fehler_valrel.mValue = "fehler_txt"
                fehler_valrel.mOrderByValue = True
                fehler_valrel.mAllowNull = True
                fehler_valrel.mAllowMulti = False     
            
        except:            
            QApplication.restoreOverrideCursor()        
        QApplication.restoreOverrideCursor()        

        self.canvas.setMapUnits(0)		
Ejemplo n.º 18
0
class ComplexCheck(QObject):

    def __init__(self, iface):
        self.iface = iface
        self.canvas = self.iface.mapCanvas()
    
        self.qutils = QGeoAppUtils()

    def run(self):        
        QApplication.setOverrideCursor(Qt.WaitCursor)
#        try:        
        
        settings = QSettings("CatAIS","QGeoApp")
        dbhost = str(settings.value("project/active/dbhost").toString())
        dbport = str(settings.value("project/active/dbport").toString())
        dbname = str(settings.value("project/active/dbname").toString())
        dbschema = str(settings.value("project/active/dbschema").toString())
        dbuser = str(settings.value("project/active/dbuser").toString())
        dbpwd = str(settings.value("project/active/dbpwd").toString())        
        projectId = str(settings.value("project/active/id").toString())
    
        group = u"Gemeinde - Perimeterrand" + " (" + str(projectId) + ")"
            
        layer = {}
        layer["type"] = "wms"
        layer["title"] = "Orthofoto CIR"
        layer["url"] = "http://www.sogis1.so.ch/cgi-bin/sogis/sogis_orthofoto.wms"
        layer["layers"] = "Orthofoto_CIR_SO"
        layer["format"] = "image/jpeg"
        layer["crs"] = "EPSG:21781"
        layer["group"] = group
        rlayer = self.qutils.loadLayer(self.iface, layer, None, None)                     
            
        layer = {}
        layer["type"] = "wms"
        layer["title"] = "Orthofoto RGB"
        layer["url"] = "http://www.sogis1.so.ch/cgi-bin/sogis/sogis_orthofoto.wms"
        layer["layers"] = "Orthofoto_SO"
        layer["format"] = "image/jpeg"
        layer["crs"] = "EPSG:21781"
        layer["group"] = group
        rlayer = self.qutils.loadLayer(self.iface, layer, None, None) 
        if rlayer <> False:
            self.iface.legendInterface().setLayerVisible(rlayer, False)                 
            
        layer = {}
        layer["type"] = "wms"
        layer["title"] = "AV-WMS (V+D)"
        layer["url"] = "http://*****:*****@geodata01.admin.ch/SWMS"
        layer["layers"] = "av_wms"
        layer["format"] = "image/jpeg"
        layer["crs"] = "EPSG:21781"
        layer["group"] = group
        rlayer = self.qutils.loadLayer(self.iface, layer, None, None)        
        if rlayer <> False:
            self.iface.legendInterface().setLayerVisible(rlayer, True)     
    
        layer = {}
        layer["type"] = "postgres"
        layer["title"] = "BB.BoFlaeche"
        layer["featuretype"] = "bodenbedeckung_boflaeche"
        layer["geom"] = "geometrie"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "bb/bb_bb_plan.qml"

        vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if vlayer <> False:
            self.iface.legendInterface().setLayerVisible(vlayer, True)    

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = "EO.Einzelobjekt"
        layer["featuretype"] = "einzelobjekte_einzelobjekt"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group

        eoeolayer = self.qutils.loadProjectLayer(self.iface, layer)    

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = u"EO.Flaechenelement"
        layer["featuretype"] = "einzelobjekte_flaechenelement"
        layer["geom"] = "geometrie"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "eo/eo_fl_bb_plan.qml"

        eoflayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if eoflayer <> False:
            self.iface.legendInterface().setLayerVisible(eoflayer, True)    
            
        if eoeolayer <> False and eoflayer <> False:
            joinLayerId = eoeolayer.id()
            joinProvider = eoeolayer.dataProvider()
            joinProvider.select(joinProvider.attributeIndexes())
            joinIdx = joinProvider.fieldNameIndex("tid")
            
            targetProvider = eoflayer.dataProvider()
            targetProvider.select(targetProvider.attributeIndexes())
            targetIdx = targetProvider.fieldNameIndex("flaechenelement_von")

            joinInfo = QgsVectorJoinInfo()
            joinInfo.joinField = joinIdx
            joinInfo.joinLayerId = joinLayerId
            joinInfo.targetField = targetIdx
            joinInfo.memoryCache = True
            
            eoflayer.addJoin(joinInfo)

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = u"EO.Linienelement"
        layer["featuretype"] = "einzelobjekte_linienelement"
        layer["geom"] = "geometrie"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "eo/eo_li_bb_plan.qml"

        eolilayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if eolilayer <> False:
            self.iface.legendInterface().setLayerVisible(eolilayer, True)    

        if eoeolayer <> False and eolilayer <> False:
            joinLayerId = eoeolayer.id()
            joinProvider = eoeolayer.dataProvider()
            joinProvider.select(joinProvider.attributeIndexes())
            joinIdx = joinProvider.fieldNameIndex("tid")
            
            targetProvider = eolilayer.dataProvider()
            targetProvider.select(targetProvider.attributeIndexes())
            targetIdx = targetProvider.fieldNameIndex("linienelement_von")

            joinInfo = QgsVectorJoinInfo()
            joinInfo.joinField = joinIdx
            joinInfo.joinLayerId = joinLayerId
            joinInfo.targetField = targetIdx
            joinInfo.memoryCache = True
            
            eolilayer.addJoin(joinInfo)

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = u"LI.Liegenschaft"
        layer["featuretype"] = "liegenschaften_liegenschaft"
        layer["geom"] = "geometrie"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "li/liegenschaft_ortho.qml"

        vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
        if vlayer <> False:
            self.iface.legendInterface().setLayerVisible(vlayer, False)    

        layer = {}
        layer["type"] = "postgres"
        layer["title"] = "Gemeindegrenze"
        layer["featuretype"] = "gemeindegrenzen_gemeindegrenze"
        layer["geom"] = "geometrie"
        layer["key"] = "ogc_fid"            
        layer["sql"] = ""
        layer["readonly"] = "true"
        layer["group"] = group
        layer["style"] = "gemeindegrenze/gemgre_strichliert.qml"

        gemgrelayer = self.qutils.loadProjectLayer(self.iface, layer) 
        if gemgrelayer <> False:
            self.iface.legendInterface().setLayerVisible(gemgrelayer, True)     

        if gemgrelayer <> False:
            rect = gemgrelayer.extent()
            rect.scale(1.2)
            self.iface.mapCanvas().setExtent(rect)        
            self.iface.mapCanvas().refresh() 


#        except:            
#            QApplication.restoreOverrideCursor()        
        QApplication.restoreOverrideCursor()        

        self.canvas.setMapUnits(0)		
Ejemplo n.º 19
0
class ComplexCheck(QObject):

    def __init__(self, iface):
        self.iface = iface
        self.canvas = self.iface.mapCanvas()
    
        self.qutils = QGeoAppUtils()
    
    def run(self):        
        self.settings = QSettings("CatAIS","QGeoApp")
        project_id = str(self.settings.value("project/active/id").toString())
#        epsg = str(self.settings.value("project/active/epgs").toString())
        

        if not project_id:
#            self.iface.messageBar().pushMessage("Error",  QCoreApplication.translate("QcadastreModule", "project_id not set"), level=QgsMessageBar.CRITICAL, duration=5)                                
            return
        
        QApplication.setOverrideCursor(Qt.WaitCursor)
        try:
            group = "Differenzlayer " + " (" + str(project_id) + ")"
            
            layer = {}
            layer["type"] = "postgres"
            layer["title"] = "BB vorher NICHT in nachher"
            layer["featuretype"] = "t_bb_before_except_after"
            layer["geom"] = "the_geom"
            layer["key"] = "ogc_fid"            
            layer["sql"] = ""
            layer["readonly"] = True
            layer["group"] = group
            layer["style"] = "bb/bb_before_except_after.qml"

            vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
            if vlayer:
                self.iface.legendInterface().setLayerVisible(vlayer, True)    

            layer = {}
            layer["type"] = "postgres"
            layer["title"] = "BB nachher NICHT in vorher"
            layer["featuretype"] = "t_bb_after_except_before"
            layer["geom"] = "the_geom"
            layer["key"] = "ogc_fid"            
            layer["sql"] = ""
            layer["readonly"] = True
            layer["group"] = group
            layer["style"] = "bb/bb_after_except_before.qml"

            vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
            if vlayer:
                self.iface.legendInterface().setLayerVisible(vlayer, True)    

            layer = {}
            layer["type"] = "postgres"
            layer["title"] = "EO.Flaeche vorher NICHT in nachher"
            layer["featuretype"] = "t_eo_fl_before_except_after"
            layer["geom"] = "the_geom"
            layer["key"] = "ogc_fid"            
            layer["sql"] = ""
            layer["readonly"] = True
            layer["group"] = group
            layer["style"] = "eo/eo_fl_before_except_after.qml"

            vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
            if vlayer:
                self.iface.legendInterface().setLayerVisible(vlayer, True)    

            layer = {}
            layer["type"] = "postgres"
            layer["title"] = "EO.Flaeche nachher NICHT in vorher"
            layer["featuretype"] = "t_eo_fl_after_except_before"
            layer["geom"] = "the_geom"
            layer["key"] = "ogc_fid"            
            layer["sql"] = ""
            layer["readonly"] = True
            layer["group"] = group
            layer["style"] = "eo/eo_fl_after_except_before.qml"

            vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
            if vlayer:
                self.iface.legendInterface().setLayerVisible(vlayer, True)    

            layer = {}
            layer["type"] = "postgres"
            layer["title"] = "EO.Linie vorher NICHT in nachher"
            layer["featuretype"] = "t_eo_li_before_except_after"
            layer["geom"] = "the_geom"
            layer["key"] = "ogc_fid"            
            layer["sql"] = ""
            layer["readonly"] = True
            layer["group"] = group
            layer["style"] = "eo/eo_li_before_except_after.qml"

            vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
            if vlayer:
                self.iface.legendInterface().setLayerVisible(vlayer, True)    

            layer = {}
            layer["type"] = "postgres"
            layer["title"] = "EO.Linie nachher NICHT in vorher"
            layer["featuretype"] = "t_eo_li_after_except_before"
            layer["geom"] = "the_geom"
            layer["key"] = "ogc_fid"            
            layer["sql"] = ""
            layer["readonly"] = True
            layer["group"] = group
            layer["style"] = "eo/eo_li_after_except_before.qml"

            vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
            if vlayer:
                self.iface.legendInterface().setLayerVisible(vlayer, True)    

            layer = {}
            layer["type"] = "postgres"
            layer["title"] = "EO.Punkt vorher NICHT in nachher"
            layer["featuretype"] = "t_eo_pt_before_except_after"
            layer["geom"] = "the_geom"
            layer["key"] = "ogc_fid"            
            layer["sql"] = ""
            layer["readonly"] = True
            layer["group"] = group
            layer["style"] = "eo/eo_pt_before_except_after.qml"

            vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
            if vlayer:
                self.iface.legendInterface().setLayerVisible(vlayer, True)    

            layer = {}
            layer["type"] = "postgres"
            layer["title"] = "EO.Punkt nachher NICHT in vorher"
            layer["featuretype"] = "t_eo_pt_after_except_before"
            layer["geom"] = "the_geom"
            layer["key"] = "ogc_fid"            
            layer["sql"] = ""
            layer["readonly"] = True
            layer["group"] = group
            layer["style"] = "eo/eo_pt_after_except_before.qml"

            vlayer = self.qutils.loadProjectLayer(self.iface, layer)    
            if vlayer:
                self.iface.legendInterface().setLayerVisible(vlayer, True)    


        except Exception, e:
            QApplication.restoreOverrideCursor()            
            print "Couldn't do it: %s" % e            
            QMessageBox.warning(None, "QGeoAppModule.PNF",  str(e))                                                                
#            self.iface.messageBar().pushMessage("Error",  QCoreApplication.translate("QcadastreModule", str(e)), level=QgsMessageBar.CRITICAL, duration=5)                    
        QApplication.restoreOverrideCursor()        

        # Workaround for geometryless-tables-wgs84-bug.
        try:
            self.canvas.setMapUnits(0)		
            srs = QgsCoordinateReferenceSystem()
            srs.createFromSrid(int(21781))
            renderer = self.canvas.mapRenderer()
            renderer.setDestinationCrs(srs)
        except Exception, e:
            print "Couldn't do it: %s" % e            
            QMessageBox.warning(None, "QGeoAppModule.PNF",  str(e))