当前位置: 首页>>代码示例>>Python>>正文


Python Library.proses_sb方法代码示例

本文整理汇总了Python中library.Library.proses_sb方法的典型用法代码示例。如果您正苦于以下问题:Python Library.proses_sb方法的具体用法?Python Library.proses_sb怎么用?Python Library.proses_sb使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在library.Library的用法示例。


在下文中一共展示了Library.proses_sb方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from library import Library [as 别名]
# 或者: from library.Library import proses_sb [as 别名]

#.........这里部分代码省略.........

    def update_poi_info_b(self):
        self.layer_ttk_b = self.lib.konversi_garis_ke_titik(self.list_feat_garis_b, "B")
        self.list_feat_ttk_b = [feat for feat in self.layer_ttk_b.getFeatures()]
        jml_ttk_b = len(self.list_feat_ttk_b)
        self.dlg.labelTitikB.setText(str(jml_ttk_b) + " points")

    # --- eksekusi algoritma
    def hdp_deploy(self):
        list_geom_a = [feat.geometry() for feat in self.list_feat_garis_a]
        list_geom_b = [feat.geometry() for feat in self.list_feat_garis_b]
        list_ft = self.list_feat_ttk_a + self.list_feat_ttk_b
        # pendefinisian titik awal
        t_awal_a = self.lib.titik_pada_garis(self.dlg.start_a, list_geom_a)
        t_akhr_a = self.lib.titik_pada_garis(self.dlg.end_a, list_geom_a)
        t_awal_b = self.lib.titik_pada_garis(self.dlg.start_b, list_geom_b)
        t_akhr_b = self.lib.titik_pada_garis(self.dlg.end_b, list_geom_b)
        # iterasi
        list_g_eq, list_g_cc, list_g_grs_k = self.lib.proses_hdp(t_awal_a,
                                                                 t_awal_b,
                                                                 t_akhr_a,
                                                                 t_akhr_b,
                                                                 list_ft)
        self.lib.konversi_titik_ke_garis(list_g_cc)
        if self.dlg.checkBox_cLine.isChecked():
            self.lib.buat_layer_garis_k(list_g_grs_k)
        if self.dlg.checkBox_titikEq.isChecked():
            self.lib.buat_layer_titik(list_g_cc)

    def sblh_deploy(self):
        list_geom_a = [feat.geometry() for feat in self.list_feat_garis_a]
        list_geom_b = [feat.geometry() for feat in self.list_feat_garis_b]
        list_feat = self.list_feat_ttk_a + self.list_feat_ttk_b
        t_awal_a = self.lib.titik_pada_garis(self.dlg.adj_start_a, list_geom_a)
        t_awal_b = self.lib.titik_pada_garis(self.dlg.adj_start_b, list_geom_b)
        list_t_akhir = []
        for a in list_geom_a:
            for b in list_geom_b:
                if a.intersects(b):
                    t_akhir = a.intersection(b)
                    list_t_akhir.append(t_akhir)
                else:
                    pass
        if len(list_t_akhir) == 0:
            raise ValueError("No end point detected")
        elif len(list_t_akhir) > 1:
            raise ValueError("More than one end point detected")
        else:
            g_akhir = list_t_akhir[0]
            ttk_akhir = g_akhir.asPoint()
        jarak_klaim = int(self.dlg.adj_claim_dist.text())*1852
        self.adj_lib = Library(self.layer_a, self.layer_b, 10, jarak_klaim)
        list_g_eq, list_g_cc, list_g_gk = self.adj_lib.proses_sb(t_awal_a,
                                                                 t_awal_b,
                                                                 ttk_akhir,
                                                                 list_feat)
        self.adj_lib.konversi_titik_ke_garis(list_g_cc)
        if self.dlg.checkBox_cLine.isChecked():
            self.lib.buat_layer_garis_k(list_g_gk)
        if self.dlg.checkBox_titikEq.isChecked():
            self.lib.buat_layer_titik(list_g_cc)

    def run(self):
        # Kosongkan input pada combo box
        self.dlg.layerInputA.clear()
        self.dlg.layerInputB.clear()
        # baca informasi layer yang termuat pada TOC QGIS
        toc_layers = QgsMapLayerRegistry.instance().mapLayers().values()
        layer_polyline = []
        for lay in toc_layers:
            if lay.type() == QgsMapLayer.VectorLayer and lay.geometryType() == 1:
                layer_polyline.append(lay)
        # cek nilai input
        self.dlg.lineEdit_sa.textChanged.connect(self.cek_proses)
        self.dlg.lineEdit_ea.textChanged.connect(self.cek_proses)
        self.dlg.lineEdit_sb.textChanged.connect(self.cek_proses)
        self.dlg.lineEdit_eb.textChanged.connect(self.cek_proses)
        # -
        self.dlg.adj_lineEditA.textChanged.connect(self.cek_proses)
        self.dlg.adj_lineEditB.textChanged.connect(self.cek_proses)
        self.dlg.adj_claim_dist.textChanged.connect(self.cek_proses)
        # connect function
        self.dlg.opp_btnRun.pressed.connect(self.hdp_deploy)
        self.dlg.adj_btnRun.pressed.connect(self.sblh_deploy)
        # tampilkan dialog jika dua layer polyline telah termuat dalam TOC
        if len(layer_polyline) < 2:
            self.iface.messageBar().pushMessage('Oops!!',
                                                'Please add at least two line layers',
                                                level=QgsMessageBar.CRITICAL,
                                                duration=2)
        else:
            # tampilkan dialog
            self.dlg.show()
            # tambahkan line layer pada TOC
            for layer in layer_polyline:
                self.dlg.layerInputA.addItem(layer.name(), layer)
                self.dlg.layerInputB.addItem(layer.name(), layer)
            self.cek_layer_input()
            self.dlg.layerInputA.currentIndexChanged.connect(self.cek_layer_input)
            self.dlg.layerInputB.currentIndexChanged.connect(self.cek_layer_input)
开发者ID:ivanbusthomi,项目名称:EqDistant,代码行数:104,代码来源:eq_distant.py


注:本文中的library.Library.proses_sb方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。