Пример #1
0
    def show_study_area(self, zoom_to=True):
        '''
        add layers with communities selectable to be in the study area
        '''
        group_name = f'{self.layer_group}/{self.study_group}'
        output = ProjectLayer.from_table(self.centers.table,
                                         groupname=group_name)
        self.communities_selected_layer = output.draw(
            label='Ausgewählte Gemeinden/Verw.gemeinschaften im '
            'Betrachtungsraum',
            style_file='standortkonkurrenz_gemeinden_ausgewaehlt.qml',
            filter='auswahl!=0 AND nutzerdefiniert=-1',
            redraw=False,
            checked=self.ui.select_communities_button.isChecked())
        self.community_picker.set_layer(self.communities_selected_layer)

        output = ProjectLayer.from_table(self.centers.table,
                                         groupname=group_name)
        self.communities_not_selected_layer = output.draw(
            label='Nicht ausgewählte Gemeinden/Verw.gemeinschaften',
            style_file='standortkonkurrenz_gemeinden_nicht_ausgewaehlt.qml',
            filter='auswahl=0 AND nutzerdefiniert=-1',
            redraw=False,
            checked=self.ui.select_communities_button.isChecked())
        self.community_picker.add_layer(self.communities_not_selected_layer)
        if zoom_to:
            output.zoom_to()
Пример #2
0
    def load_content(self):
        '''
        load data
        '''
        super().load_content()
        areas = Teilflaechen.features()
        self.area = None
        for area in areas:
            if not self.area:
                self.area = area.geom
            else:
                self.area = self.area.combine(area.geom)
        self.boden_nullfall = BodenbedeckungNullfall.features(create=True)
        self.boden_planfall = BodenbedeckungPlanfall.features(create=True)
        self.anteile = BodenbedeckungAnteile.features(create=True)
        self.bb_types = self.basedata.get_table('Bodenbedeckung',
                                                'Flaeche_und_Oekologie')
        self.faktoren = self.basedata.get_table('Faktoren',
                                                'Flaeche_und_Oekologie')

        self.output_nullfall = ProjectLayer.from_table(
            self.boden_nullfall.table,
            groupname=self.layer_group,
            prepend=True)
        self.output_planfall = ProjectLayer.from_table(
            self.boden_planfall.table,
            groupname=self.layer_group,
            prepend=True)
        self.setup_params()
Пример #3
0
 def show_outputs(self, zoom=False):
     '''
     show the definition layers (planning areas with type of use)
     '''
     table = Teilflaechen.get_table()
     self.tou_output = ProjectLayer.from_table(
         table, groupname=self.layer_group)
     self.tou_output.draw(label='Nutzungen des Plangebiets',
                         style_file='definitions.qml', redraw=False)
     if zoom:
         self.tou_output.zoom_to()
     output = ProjectLayer.from_table(table, groupname='Hintergrund',
                                      prepend=False)
     output.draw(label='Umriss des Plangebiets', style_file='areas.qml')
     self.connector_setter.show_connectors()
 def load_content(self):
     self.netzelemente = self.project.basedata.get_table(
         'Netze_und_Netzelemente', 'Kosten'
     ).features()
     self.drawn_lines = ErschliessungsnetzLinienZeichnung.features(
         create=True)
     self.line_elements = ErschliessungsnetzLinien.features(
         create=True)
     self.points = ErschliessungsnetzPunkte.features(create=True)
     self.output_lines = ProjectLayer.from_table(
         self.drawn_lines.table, groupname=self.layer_group,
         prepend=True)
     self.output_points = ProjectLayer.from_table(
         self.points.table, groupname=self.layer_group,
         prepend=True)
     self.fill_points_combo()
     self.setup_line_params()
Пример #5
0
 def remove_results(cls):
     '''
     remove result layers
     '''
     # ToDo: remove results from database (?)
     group = ProjectLayer.find(cls.results_group, groupname=cls.layer_group)
     if group:
         group[0].removeAllChildren()
Пример #6
0
 def show_connectors(self):
     '''
     add layer showing the connectors
     '''
     self.output = ProjectLayer.from_table(
         Connectors.get_table(), groupname=self.layer_group)
     self.output.draw(
         label='Anbindungspunkte',
         style_file='verkehr_anbindungspunkte.qml', prepend=True)
Пример #7
0
 def add_border_output(self):
     '''
     add layer to visualize drawn border
     '''
     self.output_border = ProjectLayer.from_table(
         self.borders.table, groupname=self.layer_group,
         prepend=True)
     self.output_border.draw(
         label='Grenze Siedlunskörper',
         style_file='flaeche_oekologie_grenze_siedlungskoerper.qml'
     )
Пример #8
0
 def add_gesamt_layer(self):
     '''
     show layer with total changes in tax revenues
     '''
     self.output = ProjectLayer.from_table(self.gemeinden.table,
                                           groupname=self.layer_group)
     self.output.draw(label='Gesamtsumme Einnahmen',
                      style_file='einnahmen_summe_einnahmen.qml',
                      filter="summe_einnahmen != 'NULL'",
                      uncheck_siblings=True,
                      redraw=False)
     self.output.zoom_to()
Пример #9
0
 def draw_itineraries(self, zoom_to=False):
     '''
     show layer visualizing the itineraries used for determining the
     transfer nodes
     '''
     self.itinerary_output = ProjectLayer.from_table(
         self.itineraries.table, groupname=self.layer_group)
     self.itinerary_output.draw(label='Zulaufstrecken',
                                expanded=False,
                                style_file='verkehr_kuerzeste_Wege.qml')
     if zoom_to:
         self.itinerary_output.zoom_to()
Пример #10
0
 def add_layer(self):
     '''
     show business tax layer
     '''
     self.output = ProjectLayer.from_table(self.gemeinden.table,
                                           groupname=self.layer_group)
     self.output.draw(label='Gewerbesteuer',
                      style_file='einnahmen_gewerbesteuer.qml',
                      filter="gewerbesteuer != 'NULL'",
                      uncheck_siblings=True,
                      redraw=False)
     self.output.zoom_to()
Пример #11
0
 def add_est_layer(self):
     '''
     show income tax layer
     '''
     self.output = ProjectLayer.from_table(self.gemeinden.table,
                                           groupname=self.layer_group)
     self.output.draw(label='Einkommensteuer',
                      style_file='einnahmen_einkommensteuer.qml',
                      filter="einkommensteuer != 'NULL'",
                      uncheck_siblings=True,
                      redraw=False)
     self.output.zoom_to()
Пример #12
0
 def add_layer(self, toggle_if_exists=False):
     '''
     show the centers in a layer
     '''
     self.output = ProjectLayer.from_table(self.centers.table,
                                           groupname=self.layer_group)
     self.output.draw(label='Zentren',
                      style_file='standortkonkurrenz_zentren.qml',
                      filter='nutzerdefiniert=1',
                      redraw=not toggle_if_exists,
                      toggle_if_exists=toggle_if_exists)
     self.select_tool.set_layer(self.output.layer)
Пример #13
0
 def add_fla_layer(self):
     '''
     show family compensation layer
     '''
     self.output = ProjectLayer.from_table(self.gemeinden.table,
                                           groupname=self.layer_group)
     self.output.draw(label='Familienleistungsausgleich',
                      style_file='einnahmen_fam_leistungs_ausgleich.qml',
                      filter="fam_leistungs_ausgleich != 'NULL'",
                      uncheck_siblings=True,
                      redraw=False)
     self.output.zoom_to()
Пример #14
0
 def add_ust_layer(self):
     '''
     show value added tax layer
     '''
     self.output = ProjectLayer.from_table(self.gemeinden.table,
                                           groupname=self.layer_group)
     self.output.draw(label='Umsatzsteuer',
                      style_file='einnahmen_umsatzsteuer.qml',
                      filter="umsatzsteuer != 'NULL'",
                      uncheck_siblings=True,
                      redraw=False)
     self.output.zoom_to()
Пример #15
0
 def draw_nodes(self, zoom_to=False):
     '''
     show layer visualizing the transfer nodes
     '''
     self.node_output = ProjectLayer.from_table(self.transfer_nodes.table,
                                                groupname=self.layer_group)
     self.node_output.draw(label='Herkunfts-/Zielpunkte',
                           style_file='verkehr_zielpunkte.qml',
                           prepend=True)
     self.select_tool.set_layer(self.node_output.layer)
     self.drag_tool.set_layer(self.node_output.layer)
     if zoom_to:
         self.node_output.zoom_to()
    def jobs_table(self):
        '''
        show job development in a table a dialog
        '''
        areas = self.get_job_areas()
        if not areas:
            return
        output = ProjectLayer.from_table(
            ApProJahr.get_table(), groupname=self.layer_group)
        layer = output.draw(label='Arbeitsplätze insgesamt nach Jahr')
        table_config = layer.attributeTableConfig()
        table_config.setSortExpression('"id_teilflaeche" || "jahr"')
        layer.setAttributeTableConfig(table_config)
        utils.iface.showAttributeTable(layer)

        output = ProjectLayer.from_table(
            Gewerbeanteile.get_table(), groupname=self.layer_group)
        layer = output.draw(label='Branchenanteile')
        table_config = layer.attributeTableConfig()
        table_config.setSortExpression('"id_teilflaeche" || "id_branche"')
        layer.setAttributeTableConfig(table_config)
        utils.iface.showAttributeTable(layer)
Пример #17
0
 def close(self):
     '''
     close parameters and drawing tools
     '''
     # ToDo: implement this in project (collecting all used workscpaces)
     output = ProjectLayer.find('Umriss des Plangebiets')
     if output:
         layer = output[0].layer()
         layer.removeSelection()
     if hasattr(self, 'params'):
         self.params.close()
     self.bordertool.set_active(False)
     super().close()
Пример #18
0
 def add_layer(self, toggle_if_exists=False):
     '''
     show layer with migration of jobs
     '''
     self.output = ProjectLayer.from_table(self.wanderung.table,
                                           groupname=self.layer_group)
     self.output.draw(label='Wanderungssalden Beschäftigte',
                      style_file='einnahmen_beschaeftigtenwanderung.qml',
                      uncheck_siblings=True,
                      redraw=not toggle_if_exists,
                      toggle_if_exists=toggle_if_exists)
     if self.output.tree_layer.isVisible():
         self.output.zoom_to()
Пример #19
0
 def show_dockwidget(self, widget):
     '''
     Show a dock-widget (domain or definition). Only one can be active at a
     time
     '''
     if self.active_dockwidget:
         self.active_dockwidget.close()
     else:
         tree_layer = ProjectLayer.find(ProjectDefinitions.layer_group)
         if tree_layer:
             tree_layer[0].setItemVisibilityChecked(False)
     self.active_dockwidget = widget
     widget.show()
Пример #20
0
 def add_layer(self, zoom_to=False, toggle_if_exists=False):
     '''
     add output layer showing markets
     '''
     self.output = ProjectLayer.from_table(self.markets.table,
                                           groupname=self.layer_group)
     self.output.draw(label=self.market_label,
                      style_file=self.layer_style,
                      filter=self.layer_filter,
                      redraw=not toggle_if_exists,
                      toggle_if_exists=toggle_if_exists)
     self.select_tool.set_layer(self.output.layer)
     if zoom_to and self.output.tree_layer.isVisible():
         self.output.zoom_to()
Пример #21
0
    def load_content(self):
        super().load_content()
        # add layer-groups in specific order
        for group_name in [
                self.nullfall_group, self.planfall_group, self.results_group,
                self.study_group
        ]:
            ProjectLayer.add_group(f'{self.layer_group}/{group_name}',
                                   prepend=False)

        self.centers = Centers.features()
        if len(self.centers.filter(nutzerdefiniert=0)) == 0:
            QMessageBox.warning(
                self.ui, 'Hinweis',
                'Das Projekt wurde scheinbar mit einer alten '
                'Projekt-Check-Version erstellt. Bitte legen Sie eine neues '
                'Projekt an, um die Standortkonkurrenz dort nutzen zu können.')
        self.markets = Markets.features(create=True)
        self.relations = MarketCellRelations.features(create=True)
        self.nullfall_edit.load_content()
        self.planfall_edit.load_content()
        self.changed_edit.load_content()
        self.center_edit.load_content()
Пример #22
0
    def draw_traffic(self, zoom_to=False, toggle_if_exists=False):
        '''
        show layer visualizing the additional traffic load
        '''

        output = ProjectLayer.from_table(self.traffic_load.table,
                                         groupname=self.layer_group)
        output.draw(label='Zusätzliche PKW-Fahrten',
                    style_file='verkehr_links_zusaetzliche_PKW-Fahrten.qml',
                    filter=f'trips > 0',
                    toggle_if_exists=toggle_if_exists,
                    redraw=not toggle_if_exists)
        if zoom_to and output.tree_layer.isVisible():
            output.zoom_to()
 def inhabitants_table(self):
     '''
     show population development in a table a dialog
     '''
     areas = self.get_residential_areas()
     if not areas:
         return
     output = ProjectLayer.from_table(
         WohnenProJahr.get_table(), groupname=self.layer_group)
     layer = output.draw(label='Bewohnerschätzung nach Alter und Jahr')
     table_config = layer.attributeTableConfig()
     table_config.setSortExpression(
         '"id_teilflaeche" || "jahr" || "id_altersklasse"')
     layer.setAttributeTableConfig(table_config)
     utils.iface.showAttributeTable(layer)
Пример #24
0
    def change_area(self):
        '''
        set currently selected area as active area
        '''
        self.area = self.ui.area_combo.itemData(
            self.ui.area_combo.currentIndex())
        if not self.area:
            return

        output = ProjectLayer.find('Umriss des Plangebiets')
        if output:
            layer = output[0].layer()
            layer.removeSelection()
            layer.select(self.area.id)

        self.setup_params()
Пример #25
0
    def load_content(self):
        super().load_content()
        output = ProjectLayer.find('Projektdefinition')
        if output:
            output[0].setItemVisibilityChecked(True)
        self.areas = Teilflaechen.features(project=self.project)
        self.links = RouteLinks.features(project=self.project, create=True)
        self.traffic_load = TrafficLoadLinks.features(project=self.project,
                                                      create=True)
        self.transfer_nodes = TransferNodes.features(project=self.project,
                                                     create=True)
        self.itineraries = Itineraries.features(project=self.project,
                                                create=True)
        self.ways = Ways.features(project=self.project, create=True)
        self.connectors = Connectors.features(project=self.project,
                                              create=True)

        self.draw_nodes()
        self.fill_node_combo()
        self.setup_ways()
        self.setup_weights()
Пример #26
0
    def show_results(self):
        '''
        show the results from "Projektwirkung" as layers
        '''
        # hide layers messing up the readability of the results
        study_output = ProjectLayer.find(self.study_group)
        if study_output:
            study_output[0].setItemVisibilityChecked(False)
        nullfall_output = ProjectLayer.find(self.nullfall_group)
        if nullfall_output:
            nullfall_output[0].setItemVisibilityChecked(False)

        group_name = f'{self.layer_group}/{self.results_group}'
        planfall_markets = self.markets.filter(id_betriebstyp_planfall__gt=0)
        # check first one only
        checked = True
        for market in planfall_markets:
            if market.id_betriebstyp_nullfall == market.id_betriebstyp_planfall:
                continue
            output = ProjectLayer.from_table(self.relations.table,
                                             groupname=group_name)
            layer_name = f'Kaufkraftbindung {market.name} ({market.id})'
            output.draw(label=layer_name,
                        style_file='standortkonkurrenz_kk_bindung_2.qml',
                        filter=f'id_markt={market.id}',
                        expanded=False,
                        checked=checked)
            # zoom to first layer
            if checked:
                output.zoom_to()
            checked = False
        self.markets.filter()

        output = ProjectLayer.from_table(self.centers.table,
                                         groupname=group_name)
        output.draw(
            label='Umsatzveränderung der Bestandsmärke nach Zentren',
            style_file='standortkonkurrenz_umsatzveraenderung_zentren.qml',
            filter='nutzerdefiniert=1',
            expanded=False,
            checked=checked)
        checked = False
        output = ProjectLayer.from_table(self.centers.table,
                                         groupname=group_name)
        output.draw(
            label='Umsatzveränderung der Bestandsmärke nach Gemeinde/Verw-Gem.',
            style_file='standortkonkurrenz_umsatzveraenderung_vwg.qml',
            filter='nutzerdefiniert=-1 and auswahl!=0',
            expanded=False,
            checked=checked)
        output = ProjectLayer.from_table(self.centers.table,
                                         groupname=group_name)
        output.draw(label='Zentralität im Nullfall nach Gemeinde/Verw-Gem.',
                    style_file='standortkonkurrenz_zentralitaet_nullfall.qml',
                    filter='nutzerdefiniert=-1 and auswahl!=0',
                    expanded=False,
                    checked=checked)
        output = ProjectLayer.from_table(self.centers.table,
                                         groupname=group_name)
        output.draw(label='Zentralität im Planfall nach Gemeinde/Verw-Gem.',
                    style_file='standortkonkurrenz_zentralitaet_planfall.qml',
                    filter='nutzerdefiniert=-1 and auswahl!=0',
                    expanded=False,
                    checked=checked)
        output = ProjectLayer.from_table(self.centers.table,
                                         groupname=group_name)
        output.draw(
            label='Veränderung der Zentralität im Planfall gegenüber Nullfall',
            style_file='standortkonkurrenz_entwicklung_zentralitaet.qml',
            filter='nutzerdefiniert=-1 and auswahl!=0',
            expanded=False,
            checked=checked)
        output = ProjectLayer.from_table(self.centers.table,
                                         groupname=group_name)
        output.draw(
            label='Verkaufsflächendichte im Nullfall',
            style_file='standortkonkurrenz_verkaufsflaechendichte_nullfall.qml',
            filter='nutzerdefiniert=-1 and auswahl!=0',
            expanded=False,
            checked=checked)
        output = ProjectLayer.from_table(self.centers.table,
                                         groupname=group_name)
        output.draw(
            label='Verkaufsflächendichte im Planfall',
            style_file='standortkonkurrenz_verkaufsflaechendichte_planfall.qml',
            filter='nutzerdefiniert=-1 and auswahl!=0',
            expanded=False,
            checked=checked)
        output = ProjectLayer.from_table(self.centers.table,
                                         groupname=group_name)
        output.draw(label='Veränderung der Verkaufsflächendichte im Planfall '
                    'gegenüber Nullfall',
                    style_file='standortkonkurrenz_entwicklung_'
                    'verkaufsflaechendichte.qml',
                    filter='nutzerdefiniert=-1 and auswahl!=0',
                    expanded=False,
                    checked=checked)
Пример #27
0
    def change_project(self, project):
        '''
        set given project as the active project. Only one project can be active
        at a time. Reloads the definition and domain widgets.
        '''
        if not project:
            self.ui.domain_button.setEnabled(False)
            self.ui.definition_button.setEnabled(False)
            return
        projektrahmendaten = Projektrahmendaten.features(project=project)[0]
        version = projektrahmendaten.basisdaten_version
        success = self.project_manager.load_basedata(version=version)
        # check the availability of the base data the project was created with
        if not success:
            server_versions = self.project_manager.server_versions
            available = [v['version'] for v in server_versions]
            v_repr = f' (v{version})' if version else ''
            if version not in available:
                QMessageBox.warning(
                    self.ui, 'Fehler',
                    f'Die Basisdaten{v_repr}, mit denen das Projekt erstellt '
                    'wurde sind nicht mehr online verfügbar.\n\n'
                    'Sie können das Projekt leider nicht weiterverwenden. '
                    'Bitte erstellen Sie ein neues Projekt.')
            else:
                reply = QMessageBox.question(
                    self.ui, 'Basisdaten herunterladen',
                    f'Die Basisdaten{v_repr}, mit denen das Projekt erstellt '
                    'wurde, wurden lokal nicht gefunden.\n\n'
                    'Möchten Sie diese Daten jetzt herunterladen? ',
                    QMessageBox.Yes, QMessageBox.No)
                if reply == QMessageBox.Yes:
                    settings = SettingsDialog(self)
                    settings.download_basedata(version=version)
            self.ui.project_combo.setCurrentIndex(0)
            return
        try:
            if getattr(self, 'project_definitions', None):
                self.project_definitions.unload()
                del (self.project_definitions)
            for domain in self.domains:
                domain.unload()
                del (domain)
            # ToDo: put that in project.close() and get
            # workspaces of this project only
            for ws in Workspace.get_instances():
                if not ws.database.read_only:
                    ws.close()

            self.project_manager.active_project = project

            self.setup_definitions()
            self.setup_domains()

            # append groups to force initial order of layers
            ProjectLayer.add_group(self.project_definitions.layer_group,
                                   prepend=True)
            for domain in self.domains:
                group = ProjectLayer.add_group(domain.layer_group,
                                               prepend=False)
                group.setItemVisibilityChecked(False)
                parent = group.parent()
                # in case parent is sub-group of project group, hide as well
                if parent.name() != self.project.groupname:
                    parent.setItemVisibilityChecked(False)

            # check active project, uncheck other projects
            layer_root = QgsProject.instance().layerTreeRoot()
            for p in self.project_manager.projects:
                group = layer_root.findGroup(p.groupname)
                if group:
                    group.setItemVisibilityChecked(
                        p.groupname == project.groupname)

            # show area layers
            self.project_definitions.show_outputs(zoom=True)

            backgroundOSM = OSMBackgroundLayer(groupname='Hintergrundkarten')
            backgroundOSM.draw(checked=False)
            backgroundGrey = TerrestrisBackgroundLayer(
                groupname='Hintergrundkarten')
            backgroundGrey.draw()
            self.ui.domain_button.setEnabled(True)
            self.ui.definition_button.setEnabled(True)
            # ToDo: show last active widget
        except FileNotFoundError as e:
            message = QMessageBox()
            message.setIcon(QMessageBox.Warning)
            message.setText(f'Das Projekt "{project.name}" ist beschädigt.')
            message.setInformativeText('Bitte löschen Sie das Projekt oder '
                                       'wenden Sie sich an den Administrator')
            message.setWindowTitle('Fehler')
            message.setDetailedText(str(e))
            message.exec_()
 def load_content(self):
     super().load_content()
     output = ProjectLayer.find('Projektdefinition')
     if output:
         output[0].setItemVisibilityChecked(True)