forked from EPERLab/dn_corrector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DN_Corrector.py.bak
1498 lines (1256 loc) · 71.2 KB
/
DN_Corrector.py.bak
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# -*- coding: utf-8 -*-
"""
/***************************************************************************
DN_Corrector
A QGIS plugin
This plugin identifies and correct errors of connection on radial electrical distribution networks
-------------------
begin : 2017-02-28
git sha : $Format:%H$
copyright : (C) 2017 by Abdenago Guzman L.
email : [email protected]
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
"""
from __future__ import print_function
from __future__ import absolute_import
from builtins import str
from builtins import range
from builtins import object
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from qgis.core import * #QgsMapLayerRegistry, QgsVectorDataProvider, QgsField
from qgis.gui import QgsMessageBar
import time
from qgis.PyQt.QtWidgets import QProgressBar
from PyQt5 import QtCore
from PyQt5 import QtGui #Paquetes requeridos para crear ventanas de diálogo e interfaz gráfica.
from PyQt5 import QtWidgets
from PyQt5.QtWidgets import QApplication, QWidget, QInputDialog, QLineEdit, QFileDialog, QMessageBox, QDialog, QStyleFactory, QAction
import traceback
#from qgis2opendss_progress import Ui_Progress
# Initialize Qt resources from file resources.py
from . import resources
# Import the code for the dialog
from .DN_Corrector_dialog import DN_CorrectorDialog
import os.path
from . import func_connector
from random import randint
import networkx as nx
import numpy as np
import matplotlib.pyplot as plt
import time
import math
class DN_Corrector(object):
"""QGIS Plugin Implementation."""
def __init__(self, iface):
"""Constructor.
:param iface: An interface instance that will be passed to this class
which provides the hook by which you can manipulate the QGIS
application at run time.
:type iface: QgsInterface
"""
# Save reference to the QGIS interface
self.iface = iface
# initialize plugin directory
self.plugin_dir = os.path.dirname(__file__)
# initialize locale
locale = QSettings().value('locale/userLocale')[0:2]
locale_path = os.path.join(
self.plugin_dir,
'i18n',
'DN_Corrector_{}.qm'.format(locale))
if os.path.exists(locale_path):
self.translator = QTranslator()
self.translator.load(locale_path)
if qVersion() > '4.3.3':
QCoreApplication.installTranslator(self.translator)
# Declare instance attributes
self.actions = []
self.menu = self.tr(u'&DN Corrector')
# Create the dialog (after translation) and keep reference
self.dlg = DN_CorrectorDialog()
#self.progress = Ui_Progress()
# TODO: We are going to let the user set this up in a future iteration
self.toolbar = self.iface.addToolBar(u'DN_Corrector')
self.toolbar.setObjectName(u'DN_Corrector')
self.dlg.pushButton_incons_BT.clicked.connect(self.reporteInconsis)
self.dlg.pushButton_incons_MT.clicked.connect(self.inconsistencias_MT)
self.dlg.pushButton_traf.clicked.connect(self.trafConec)
self.dlg.pushButton_cargas.clicked.connect(self.loadConec)
self.dlg.pushButton_lines.clicked.connect(self.lineConec)
self.dlg.pushButton_split.clicked.connect(self.split_iteration)
self.dlg.button_box.helpRequested.connect(self.show_help)
self.tolerance = 0.1
# noinspection PyMethodMayBeStatic
def tr(self, message):
"""Get the translation for a string using Qt translation API.
We implement this ourselves since we do not inherit QObject.
:param message: String for translation.
:type message: str, QString
:returns: Translated version of message.
:rtype: QString
"""
# noinspection PyTypeChecker,PyArgumentList,PyCallByClass
return QCoreApplication.translate('DN_Corrector', message)
def add_action(
self,
icon_path,
text,
callback,
enabled_flag=True,
add_to_menu=True,
add_to_toolbar=True,
status_tip=None,
whats_this=None,
parent=None):
"""Add a toolbar icon to the toolbar.
:param icon_path: Path to the icon for this action. Can be a resource
path (e.g. ':/plugins/foo/bar.png') or a normal file system path.
:type icon_path: str
:param text: Text that should be shown in menu items for this action.
:type text: str
:param callback: Function to be called when the action is triggered.
:type callback: function
:param enabled_flag: A flag indicating if the action should be enabled
by default. Defaults to True.
:type enabled_flag: bool
:param add_to_menu: Flag indicating whether the action should also
be added to the menu. Defaults to True.
:type add_to_menu: bool
:param add_to_toolbar: Flag indicating whether the action should also
be added to the toolbar. Defaults to True.
:type add_to_toolbar: bool
:param status_tip: Optional text to show in a popup when mouse pointer
hovers over the action.
:type status_tip: str
:param parent: Parent widget for the new action. Defaults None.
:type parent: QWidget
:param whats_this: Optional text to show in the status bar when the
mouse pointer hovers over the action.
:returns: The action that was created. Note that the action is also
added to self.actions list.
:rtype: QAction
"""
icon = QIcon(icon_path)
action = QAction(icon, text, parent)
action.triggered.connect(callback)
action.setEnabled(enabled_flag)
if status_tip is not None:
action.setStatusTip(status_tip)
if whats_this is not None:
action.setWhatsThis(whats_this)
if add_to_toolbar:
self.toolbar.addAction(action)
if add_to_menu:
self.iface.addPluginToMenu(
self.menu,
action)
self.actions.append(action)
return action
def initGui(self):
"""Create the menu entries and toolbar icons inside the QGIS GUI."""
icon_path = ':/plugins/DN_Corrector/icon.png'
self.add_action(
icon_path,
text=self.tr(u'Connection of distribution network elements'),
callback=self.run,
parent=self.iface.mainWindow())
def unload(self):
"""Removes the plugin menu item and icon from QGIS GUI."""
for action in self.actions:
self.iface.removePluginMenu(
self.tr(u'&DN Corrector'),
action)
self.iface.removeToolBarIcon(action)
# remove the toolbar
del self.toolbar
def show_help(self):
"""Display application help to the user."""
help_file = 'file:///%s/help/Manual_DNCorrector_ESP.pdf' % self.plugin_dir
QDesktopServices.openUrl(QUrl(help_file))
"""Get a list of all the layers.
:returns: A list of the layers
:rtype: list
"""
def readerLayers(self):
Index_line_MT_1 = self.dlg.layerComboBox_aerea_MT_1.currentIndex()
Index_line_MT_2 = self.dlg.layerComboBox_aerea_MT_2.currentIndex()
Index_line_MT_3 = self.dlg.layerComboBox_aerea_MT_3.currentIndex()
Index_carga_MT_1 = self.dlg.layerComboBox_carga_MT_1.currentIndex()
Index_carga_MT_2 = self.dlg.layerComboBox_carga_MT_2.currentIndex()
Index_carga_MT_3 = self.dlg.layerComboBox_carga_MT_3.currentIndex()
Index_trafo_1 = self.dlg.layerComboBox_trafo_1.currentIndex()
Index_trafo_2 = self.dlg.layerComboBox_trafo_2.currentIndex()
Index_trafo_3 = self.dlg.layerComboBox_trafo_3.currentIndex()
Index_line_BT_1 = self.dlg.layerComboBox_aer_1.currentIndex()
Index_line_BT_2 = self.dlg.layerComboBox_aer_2.currentIndex()
Index_line_BT_3 = self.dlg.layerComboBox_aer_3.currentIndex()
Index_Carga_1 = self.dlg.layerComboBox_Carga_1.currentIndex()
Index_Carga_2 = self.dlg.layerComboBox_Carga_2.currentIndex()
Index_Carga_3 = self.dlg.layerComboBox_Carga_3.currentIndex()
Index_acometida_1 = self.dlg.layerComboBox_acometida_1.currentIndex()
Index_acometida_2 = self.dlg.layerComboBox_acometida_2.currentIndex()
Index_acometida_3 = self.dlg.layerComboBox_acometida_3.currentIndex()
######
layers_line_MT = []
if Index_line_MT_1 != 0:
Name_line_MT_1 = self.dlg.layerComboBox_aerea_MT_1.currentText()
#print( "Name_line_MT_1 = ", Name_line_MT_1 )
layers_line_MT.append(QgsProject.instance().mapLayersByName(Name_line_MT_1))#[0]
if Index_line_MT_2 != 0:
Name_line_MT_2 = self.dlg.layerComboBox_aerea_MT_2.currentText()
layers_line_MT.append(QgsProject.instance().mapLayersByName(Name_line_MT_2))#[0]
if Index_line_MT_3 != 0:
Name_line_MT_3 = self.dlg.layerComboBox_aerea_MT_3.currentText()
layers_line_MT.append(QgsProject.instance().mapLayersByName(Name_line_MT_3))#[0]
layers_carga_MT=[]
if Index_carga_MT_1 != 0:
Name_carga_MT_1 = self.dlg.layerComboBox_carga_MT_1.currentText()
layers_carga_MT.append(QgsProject.instance().mapLayersByName(Name_carga_MT_1))#[0]
if Index_carga_MT_2 != 0:
Name_carga_MT_2 = self.dlg.layerComboBox_carga_MT_2.currentText()
layers_carga_MT.append(QgsProject.instance().mapLayersByName(Name_carga_MT_2))#[0]
if Index_carga_MT_3 != 0:
Name_carga_MT_3 = self.dlg.layerComboBox_carga_MT_3.currentText()
layers_carga_MT.append(QgsProject.instance().mapLayersByName(Name_carga_MT_3))#[0]
layers_trafo=[]
if Index_trafo_1 != 0:
Name_trafo_1 = self.dlg.layerComboBox_trafo_1.currentText()
layers_trafo.append(QgsProject.instance().mapLayersByName(Name_trafo_1))#[0]
if Index_trafo_2 != 0:
Name_trafo_2 = self.dlg.layerComboBox_trafo_2.currentText()
layers_trafo.append(QgsProject.instance().mapLayersByName(Name_trafo_2))#[0]
if Index_trafo_3 != 0:
Name_trafo_3 = self.dlg.layerComboBox_trafo_3.currentText()
layers_trafo.append(QgsProject.instance().mapLayersByName(Name_trafo_3))#[0]
layers_line_BT=[]
if Index_line_BT_1 != 0:
Name_line_BT_1 = self.dlg.layerComboBox_aer_1.currentText()
layers_line_BT.append(QgsProject.instance().mapLayersByName(Name_line_BT_1))#[0]
if Index_line_BT_2 != 0:
Name_line_BT_2 = self.dlg.layerComboBox_aer_2.currentText()
layers_line_BT.append(QgsProject.instance().mapLayersByName(Name_line_BT_2))#[0]
if Index_line_BT_3 != 0:
Name_line_BT_3 = self.dlg.layerComboBox_aer_3.currentText()
layers_line_BT.append(QgsProject.instance().mapLayersByName(Name_line_BT_3))#[0]
layers_acometida=[]
if Index_acometida_1 != 0:
Name_acometida_1 = self.dlg.layerComboBox_acometida_1.currentText()
layers_acometida.append(QgsProject.instance().mapLayersByName(Name_acometida_1))#[0]
if Index_acometida_2 != 0:
Name_acometida_2 = self.dlg.layerComboBox_acometida_2.currentText()
layers_acometida.append(QgsProject.instance().mapLayersByName(Name_acometida_2))#[0]
if Index_acometida_3 != 0:
Name_acometida_3 = self.dlg.layerComboBox_acometida_3.currentText()
layers_acometida.append(QgsProject.instance().mapLayersByName(Name_acometida_3))#[0]
layers_Carga=[]
if Index_Carga_1 != 0:
Name_Carga_1 = self.dlg.layerComboBox_Carga_1.currentText()
layers_Carga.append(QgsProject.instance().mapLayersByName(Name_Carga_1))#[0]
if Index_Carga_2 != 0:
Name_Carga_2 = self.dlg.layerComboBox_Carga_2.currentText()
layers_Carga.append(QgsProject.instance().mapLayersByName(Name_Carga_2))#[0]
if Index_Carga_3 != 0:
Name_Carga_3 = self.dlg.layerComboBox_Carga_3.currentText()
layers_Carga.append(QgsProject.instance().mapLayersByName(Name_Carga_3))#[0]
inputLayers = {"MT_lines":layers_line_MT,"carga_MT":layers_carga_MT, "trafos": layers_trafo, "BT_lines":layers_line_BT,"acometida": layers_acometida, "carga_BT":layers_Carga}
return inputLayers
def attributeUpdateLines(self, layer):
layer.startEditing()
X1Index = layer.fields().indexFromName("X1")
Y1Index = layer.fields().indexFromName("Y1")
X2Index = layer.fields().indexFromName("X2")
Y2Index = layer.fields().indexFromName("Y2")
for obj in layer.getFeatures():
geom = obj.geometry()
line = self.MultiStringToMatrix(geom)
n = len(line)
x1= line[0][0]
y1=line[0][1]
x2=line[n-1][0]
y2=line[n-1][1]
layer.changeAttributeValue(obj.id(), X1Index, x1)
layer.changeAttributeValue(obj.id(), Y1Index, y1)
layer.changeAttributeValue(obj.id(), X2Index, x2)
layer.changeAttributeValue(obj.id(), Y2Index, Y2)
def attributeUpdatePoints(self, layer):
layer.startEditing()
XIndex = layer.fields().indexFromName("X1")
YIndex = layer.fields().indexFromName("Y1")
for feat in layer.getFeatures():
point = feat.geometry().asPoint()
x = point[0]
y = point[1]
layer.changeAttributeValue(feat.id(), XIndex, x)
layer.changeAttributeValue(feat.id(), YIndex, y)
def getAttributeIndex(self, aLayer, attrName): # Crea el atributo y obtiene el ID
"""Find the attribute index, adding a new Int column, if necessary"""
"""
if len(attrName) > 10 and aLayer.storageType() == 'ESRI Shapefile':
self.iface.messageBar().pushCritical("Error", "For ESRI Shapefiles, the maximum length of any attribute name is 10. Please choose a shorter attribute name.")
return -3
"""
AttrIdx = aLayer.dataProvider().fieldNameIndex(attrName)
if AttrIdx == -1: # attribute doesn't exist, so create it
caps = aLayer.dataProvider().capabilities()
if caps & QgsVectorDataProvider.AddAttributes:
res = aLayer.dataProvider().addAttributes([QgsField(attrName, QVariant.Int)])
AttrIdx = aLayer.dataProvider().fieldNameIndex(attrName)
aLayer.updateFields()
if AttrIdx == -1:
self.iface.messageBar().pushCritical("Error", "Failed to create attribute!")
return -1
else:
self.iface.messageBar().pushCritical("Error", "Failed to add attribute!")
return -1
else:
pass
return AttrIdx
def changeGroupValue(self, layerlist, islandList):
for LayerX in layerlist:
layer = LayerX[0]
layer.startEditing()
for (data1, data2) in list(islandList.items()):
idx = data1[0]
idlayer = data1[1]
attId = data2["attIndx"]
group = data2["GROUP"]
donea = layerlist[idlayer][0].changeAttributeValue(idx, attId, group)
for LayerX in layerlist:
layer = LayerX[0]
layer.commitChanges()
def ringRender(self, layerList):
for layerX in layerList:
layer = layerX[0]
layer.beginEditCommand("Update layer styling")
categories = []
firstCat = True
idx = layer.fields().indexFromName('RING')
values = layer.uniqueValues(idx)
for cat in values:
if cat == -1:
color = QColor(10, 44, 236)
widthLineMult=1
else:
color = QColor(236, 10, 10)
widthLineMult=3
symbol = QgsSymbol.defaultSymbol(layer.geometryType())
symbol.setColor(color)
symbol.setWidth(symbol.width()*widthLineMult)
category = QgsRendererCategory(cat, symbol, str(cat))#"%d" %
categories.append(category)
field = 'RING'
renderer = QgsCategorizedSymbolRenderer(field, categories)
layer.setRenderer(renderer)
layer.triggerRepaint()
layer.endEditCommand()
def inconsistencias_MT(self):
inputLayers = self.readerLayers()
line_MT_Layers = inputLayers["MT_lines"]
carga_MT_Layers = inputLayers["carga_MT"]
trafo_MT_Layers = inputLayers["trafos"]
if len(line_MT_Layers) == 0:
QMessageBox.critical(None,"DN Corrector","Debe seleccionar al menos una capa de lineas de MT")
else:
##### Establece la tolerancia para reconocer uniones entre segmentos
tolerance = self.dlg.toleranceSpinBox.value()
if tolerance == 0:
tolerance = self.tolerance
GrafoMT = nx.Graph()
GrafoLMT = nx.Graph()
GrafoTrafosMT = nx.Graph()
GrafoLoadMT = nx.Graph()
indexLayer=0
for aereaMTLayerX in line_MT_Layers: #Si la lista de capas esta vacia no entra al ciclo, por lo que no es necesario un IF
aereaMTLayer = aereaMTLayerX[0]
aereaMTLayer.startEditing()
MTAerAttrIdx = self.getAttributeIndex(aereaMTLayer, 'RING')
MTAerAttrIdxConnect = self.getAttributeIndex(aereaMTLayer, 'GROUP_MT')
for feat in aereaMTLayer.getFeatures():
done = aereaMTLayer.changeAttributeValue(feat.id(), MTAerAttrIdx, -1)
done = aereaMTLayer.changeAttributeValue(feat.id(), MTAerAttrIdxConnect, -1)
#try:
geom = feat.geometry()
line = self.MultiStringToMatrix(geom)
if line == []:
message = "Error al leer la geometrìa. Se ha finalizado el programa."
QMessageBox.warning(None, QCoreApplication.translate('dialog', u'REGISTRO DE INCONSISTENCIAS'), message)
return
n= len(line)
if self.dlg.checkBox_intNodes.isChecked():
for i in range(len(line)-1):
GrafoMT.add_edges_from([((int(line[i][0]/tolerance), int(line[i][1]/tolerance)), (int(line[i+1][0]/tolerance), int(line[i+1][1]/tolerance)),
{"attIndexGroup":MTAerAttrIdxConnect, "ringAttIndex":MTAerAttrIdx, 'fid': feat.id(), 'element': 'lineMT', "FEAT":feat, "idLAYER": indexLayer})]) # first scale by tolerance, then convert to int. Before doing this, there were problems with floats not equating, thus creating disconnects that weren't there.
GrafoLMT.add_edges_from([((int(line[i][0]/tolerance), int(line[i][1]/tolerance)), (int(line[i+1][0]/tolerance), int(line[i+1][1]/tolerance)),
{"attIndexGroup":MTAerAttrIdxConnect, "ringAttIndex":MTAerAttrIdx, 'fid': feat.id(), 'element': 'lineMT', "FEAT":feat, "idLAYER": indexLayer})])
else:
GrafoMT.add_edges_from([((int(line[0][0]/tolerance), int(line[0][1]/tolerance)), (int(line[n-1][0]/tolerance), int(line[n-1][1]/tolerance)),
{"attIndexGroup":MTAerAttrIdxConnect, "ringAttIndex":MTAerAttrIdx, 'fid': feat.id(), 'element': 'lineMT', "FEAT":feat, "idLAYER": indexLayer})]) # first scale by tolerance, then convert to int. Before doing this, there were problems with floats not equating, thus creating disconnects that weren't there.
GrafoLMT.add_edges_from([((int(line[0][0]/tolerance), int(line[0][1]/tolerance)), (int(line[n-1][0]/tolerance), int(line[n-1][1]/tolerance)),
{"attIndexGroup":MTAerAttrIdxConnect, "ringAttIndex":MTAerAttrIdx, 'fid': feat.id(), 'element': 'lineMT', "FEAT":feat, "idLAYER": indexLayer})])
indexLayer +=1
aereaMTLayer.endEditCommand()
indexLayer = 0
for cargaMTLayerX in carga_MT_Layers:
cargaMTLayer = cargaMTLayerX[0]
cargaMTLayer.startEditing()
MTCargaAttrIdxConnect = self.getAttributeIndex(cargaMTLayer, 'GROUP_MT')
for feat in cargaMTLayer.getFeatures():
done = cargaMTLayer.changeAttributeValue(feat.id(), MTCargaAttrIdxConnect, -1)
point = feat.geometry().asPoint()
x = int(point[0]/tolerance)
y = int(point[1]/tolerance)
p = (x, y)
GrafoMT.add_node(p)
GrafoMT.nodes[p].update( {'fid': feat.id(), 'element': 'cargaMT', "FEAT":feat, "LAYER": indexLayer, "attIndexGroup":MTCargaAttrIdxConnect} )
GrafoLoadMT.add_node(p)
GrafoLoadMT.nodes[p].update( {'fid': feat.id(), "FEAT":feat, "LAYER": indexLayer, "attIndexGroup":MTCargaAttrIdxConnect} )
indexLayer +=1
cargaMTLayer.endEditCommand()
indexLayer = 0
for trafoLayerX in trafo_MT_Layers:
trafoLayer = trafoLayerX[0]
trafoLayer.startEditing()
trafoLayer.beginEditCommand("Update group attribute")
TrafLayerEditingMode = True
trafoAttrIdxConnect = self.getAttributeIndex(trafoLayer, 'GROUP_MV')
for feat in trafoLayer.getFeatures():
done = trafoLayer.changeAttributeValue(feat.id(), trafoAttrIdxConnect, -1)
point = feat.geometry().asPoint()
x = int(point[0]/tolerance)
y = int(point[1]/tolerance)
p = (x, y)
GrafoMT.add_node(p)
GrafoMT.nodes[p].update( {'fid': feat.id(), 'element': 'trafo', "FEAT":feat, "LAYER": indexLayer, "attIndexGroup":trafoAttrIdxConnect} )
GrafoTrafosMT.add_node(p)
GrafoTrafosMT.nodes[p].update( {'fid': feat.id(), 'element': 'trafo', "FEAT":feat, "LAYER": indexLayer, "attIndexGroup":trafoAttrIdxConnect} )
indexLayer +=1
trafoLayer.endEditCommand()
anillos = nx.cycle_basis(GrafoMT)
if len(anillos)==0:
message = "No existen anillos en la red de MT"
else:
message = "Existen "+ str(len(anillos))+ " anillos en la red de MT"
N=0
for anillo in anillos:
idlayer = GrafoMT[anillo[0]][anillo[len(anillo)-1]]["idLAYER"]
AttrIdx = GrafoMT[anillo[0]][anillo[len(anillo)-1]]["ringAttIndex"]
idMTline= GrafoMT[anillo[0]][anillo[len(anillo)-1]]["fid"]
done = line_MT_Layers[idlayer][0].changeAttributeValue(idMTline, AttrIdx, N)
for i in range(len(anillo)-1):
idlayer = GrafoMT[anillo[i]][anillo[i+1]]["idLAYER"]
AttrIdx = GrafoMT[anillo[i]][anillo[i+1]]["ringAttIndex"]
idMTline= GrafoMT[anillo[i]][anillo[i+1]]["fid"]
done = line_MT_Layers[idlayer][0].changeAttributeValue(idMTline, AttrIdx, N)
N+=1
###RENDER MT LINES
if self.dlg.checkBox_anillos.isChecked() :
self.ringRender(line_MT_Layers)
self.iface.mapCanvas().refresh()
Lines_Islands = {}
trafos_Islands = {}
cargas_Islands ={}
Lines_Groups = {0:[], 1:[], 2:[]}
trafos_Groups = []
cargas_Groups = []
connected_components_MT = list(nx.connected_component_subgraphs(GrafoMT)) # Determina cuales son los componentes conectados en baja tension
i=0
for graph in connected_components_MT:
for edge in list( graph.edges(data=True) ):
#Lines_Islands[edge[2].get('fid', None)] = i
Lines_Islands[(edge[2]["fid"], edge[2]["idLAYER"])] = {"GROUP":i,"attIndx":edge[2]["attIndexGroup"]}# {(id, layer):{group, idGroup],....,}
if i not in Lines_Groups[edge[2]["idLAYER"]]:
Lines_Groups[edge[2]["idLAYER"]].append(i)
for node in list( graph.nodes(data=True) ):
if len(node[1])!=0 and node[1]['element']=='trafo':
#trafos_Islands[node[1].get('fid', None)] = i
trafos_Islands[(node[1]["fid"],node[1]["LAYER"])] = {"GROUP":i ,"attIndx": node[1]["attIndexGroup"]} # {(id, layer):{group, idGroup],....,}
if i not in trafos_Groups:
trafos_Groups.append(i)
if len(node[1])!=0 and node[1]['element']== 'cargaMT':
#cargas_Islands[node[1].get('fid', None)] = i
cargas_Islands[(node[1]["fid"],node[1]["LAYER"])] = {"GROUP":i , "attIndx": node[1]["attIndexGroup"]} # {(id, layer):{group, idGroup],....,}
if i not in cargas_Groups:
cargas_Groups.append(i)
i+=1
###### Actualiza los atributos por el valor de su grupo respectivo
self.changeGroupValue(line_MT_Layers, Lines_Islands)
self.changeGroupValue(carga_MT_Layers, cargas_Islands)
self.changeGroupValue(trafo_MT_Layers, trafos_Islands)
### islands render
if self.dlg.colorCheckBox.isChecked() :
for i in range(len(line_MT_Layers)):
layer = line_MT_Layers[i][0]
groupsLines = Lines_Groups[i]
self.render(layer, groupsLines, "GROUP_MT")
####Reporte de inconsistencias
MTLinesDesc =[]
for line in Lines_Groups[0]+Lines_Groups[1]+Lines_Groups[2]:
if (line not in trafos_Groups) and (line not in MTLinesDesc):
MTLinesDesc.append(line)
trafoDesc =[]
for trafo in trafos_Groups:
if (trafo not in Lines_Groups[0]) and (trafo not in Lines_Groups[1]) and (trafo not in Lines_Groups[2]) and (trafo not in trafoDesc):
trafoDesc.append(trafo)
cargaMTDesc =[]
for cargas in cargas_Groups:
if (cargas not in Lines_Groups[0])and (cargas not in Lines_Groups[1]) and (cargas not in Lines_Groups[2]) and (cargas not in cargaMTDesc):
cargaMTDesc.append(cargas)
# #######################################
if len(MTLinesDesc) > 0 :
repLines = u"\nLas lineas de MT desconectadas son: "+str(MTLinesDesc)
else:
repLines = u'\nNo existen lineas de media tension desconectadas.'
if len(trafoDesc) > 0 :
repTraf = "\nLos transformadores desconectados son: " + str(trafoDesc)
else:
repTraf = '\nNo existen transformadores desconectados de media tension.'
if len(cargaMTDesc) > 0 :
repLoad = u"\nLas cargas de MT desconectadas son: " + str(cargaMTDesc)
else:
repLoad = '\nNo existen cargas de media tension desconectadas.'
msg = message+repLines+repTraf+repLoad
QMessageBox.warning(None, QCoreApplication.translate('dialog', u'Registro de incosistencias'), msg)
QgsApplication.instance().messageLog().logMessage(msg, tag="REGISTRO DE INCONSISTENCIAS",level=Qgis.MessageLevel(1))
self.iface.messageBar().pushMessage("DN_Corrector", QCoreApplication.translate('dialog', u"Se ha analizado la red de media tension, vea los mensajes de registro para ver los errores") )
def inconsistencias_BT(self):
inputLayers = self.readerLayers()
trafo_Layers = inputLayers["trafos"]
line_BT_Layers = inputLayers["BT_lines"]
acomet_Layers = inputLayers["acometida"]
carga_BT_Layers = inputLayers["carga_BT"]
NOGEOMETRY = False
##### Establece la tolerancia para reconocer uniones entre segmentos
tolerance = self.dlg.toleranceSpinBox.value()
if tolerance == 0:
tolerance = self.tolerance
##### Crea un grafo vacio y le añade las lineas y nodos
GrafoBT = nx.Graph()
indexLayer = 0
for trafoLayerX in trafo_Layers:
trafoLayer = trafoLayerX[0]
trafoLayer.startEditing()
trafoLayer.beginEditCommand("Update group attribute")
trafoAttrIdx = self.getAttributeIndex(trafoLayer, 'GROUP_LV')
for feat in trafoLayer.getFeatures():
done = trafoLayer.changeAttributeValue(feat.id(), trafoAttrIdx, -1)
try:
point = feat.geometry().asPoint()
x = int(point[0]/tolerance)
y = int(point[1]/tolerance)
p = (x, y)
GrafoBT.add_node(p)
GrafoBT.nodes[p].update( {'fid': feat.id(), 'element': 'trafo', "FEAT":feat,"idLAYER": indexLayer, "attIndexGroup":trafoAttrIdx} )
except:
Geom_Idx = self.getAttributeIndex(trafoLayer, 'NO_GEOMETRY')
done = trafoLayer.changeAttributeValue(feat.id(), Geom_Idx, 1)
NOGEOMETRY = True
trafoLayer.endEditCommand()
indexLayer +=1
indexLayer=0
for BTLinesLayerX in line_BT_Layers: #Si la lista de capas esta vacia no entra al ciclo, por lo que no es necesario un IF
BTLayer = BTLinesLayerX[0]
BTLayer.startEditing()
BTLayer.beginEditCommand("Update group attribute")
groupAttrIdx = self.getAttributeIndex(BTLayer, 'GROUP_LV')
ringAttrIdx = self.getAttributeIndex(BTLayer, 'RING')
for feat in BTLayer.getFeatures():
done = BTLayer.changeAttributeValue(feat.id(), groupAttrIdx, -1)
done = BTLayer.changeAttributeValue(feat.id(), ringAttrIdx, -1)
try:
geom = feat.geometry()
line = self.MultiStringToMatrix(geom)
n= len(line)
if self.dlg.checkBox_intNodes.isChecked():
for i in range(len(line)-1):
GrafoBT.add_edges_from([((int(line[i][0]/tolerance), int(line[i][1]/tolerance)), (int(line[i+1][0]/tolerance), int(line[i+1][1]/tolerance)),
{"attIndexGroup":groupAttrIdx, "ringAttIndex":ringAttrIdx, 'fid': feat.id(), 'element': 'BTLine', "FEAT":feat, "idLAYER": indexLayer})]) # first scale by tolerance, then convert to int. Before doing this, there were problems with floats not equating, thus creating disconnects that weren't there.
else:
GrafoBT.add_edges_from([((int(line[0][0]/tolerance), int(line[0][1]/tolerance)), (int(line[n-1][0]/tolerance), int(line[n-1][1]/tolerance)),
{"attIndexGroup":groupAttrIdx, "ringAttIndex":ringAttrIdx, 'fid': feat.id(), 'element': 'BTLine', "FEAT":feat, "idLAYER": indexLayer})]) # first scale by tolerance, then convert to int. Before doing this, there were problems with floats not equating, thus creating disconnects that weren't there.
except:
Geom_Idx = self.getAttributeIndex(BTLayer, 'NO_GEOMETRY')
done = BTLayer.changeAttributeValue(feat.id(), Geom_Idx, 1)
NOGEOMETRY = True
BTLayer.endEditCommand()
indexLayer +=1
indexLayer=0
for acomLinesLayerX in acomet_Layers: #Si la lista de capas esta vacia no entra al ciclo, por lo que no es necesario un IF
acomLayer = acomLinesLayerX[0]
acomLayer.startEditing()
acomLayer.beginEditCommand("Update group attribute")
groupAttrIdx = self.getAttributeIndex(acomLayer, 'GROUP_LV')
ringAttrIdx = self.getAttributeIndex(acomLayer, 'RING')
for feat in acomLayer.getFeatures():
done = acomLayer.changeAttributeValue(feat.id(), groupAttrIdx, -1)
done = acomLayer.changeAttributeValue(feat.id(), ringAttrIdx, -1)
try:
geom = feat.geometry()
line = self.MultiStringToMatrix(geom)
n= len(line)
if self.dlg.checkBox_intNodes.isChecked():
for i in range(len(line)-1):
GrafoBT.add_edges_from([((int(line[i][0]/tolerance), int(line[i][1]/tolerance)), (int(line[i+1][0]/tolerance), int(line[i+1][1]/tolerance)),
{"attIndexGroup":groupAttrIdx, "ringAttIndex":ringAttrIdx, 'fid': feat.id(), 'element': 'acom', "FEAT":feat, "idLAYER": indexLayer})]) # first scale by tolerance, then convert to int. Before doing this, there were problems with floats not equating, thus creating disconnects that weren't there.
else:
GrafoBT.add_edges_from([((int(line[0][0]/tolerance), int(line[0][1]/tolerance)), (int(line[n-1][0]/tolerance), int(line[n-1][1]/tolerance)),
{"attIndexGroup":groupAttrIdx, "ringAttIndex":ringAttrIdx, 'fid': feat.id(), 'element': 'acom', "FEAT":feat, "idLAYER": indexLayer})]) # first scale by tolerance, then convert to int. Before doing this, there were problems with floats not equating, thus creating disconnects that weren't there.
except:
Geom_Idx = self.getAttributeIndex(acomLayer, 'NO_GEOMETRY')
done = acomLayer.changeAttributeValue(feat.id(), Geom_Idx, 1)
NOGEOMETRY = True
acomLayer.endEditCommand()
indexLayer +=1
indexLayer = 0
for cargaLayerX in carga_BT_Layers:
cargaLayer = cargaLayerX[0]
cargaLayer.startEditing()
cargaLayer.beginEditCommand("Update group attribute")
groupAttrIdx = self.getAttributeIndex(cargaLayer, 'GROUP_LV')
for feat in cargaLayer.getFeatures():
done = cargaLayer.changeAttributeValue(feat.id(), groupAttrIdx, -1)
try:
point = feat.geometry().asPoint()
x = int(point[0]/tolerance)
y = int(point[1]/tolerance)
p = (x, y)
GrafoBT.add_node(p)
GrafoBT.nodes[p].update( {"attIndexGroup":groupAttrIdx, 'fid': feat.id(), 'element': 'carga', "FEAT":feat, "idLAYER": indexLayer} )
except:
Geom_Idx = self.getAttributeIndex(cargaLayer, 'NO_GEOMETRY')
done = cargaLayer.changeAttributeValue(feat.id(), Geom_Idx, 1)
NOGEOMETRY = True
cargaLayer.endEditCommand()
indexLayer +=1
############################################################################
connected_components_BT = list(nx.connected_component_subgraphs(GrafoBT)) # Determina cuales son los componentes conectados en baja tension
trafo_group = {0:[], 1:[], 2:[]}
BT_lines_group = {0:[], 1:[], 2:[]}
aco_group = {0:[], 1:[], 2:[]}
carga_group = {0:[], 1:[], 2:[]}
lines_BT_Islands = {} #{(id, layer):{group, idGroup],....,}
lines_acom_Islands = {} #{(id, layer):{group, idGroup],....,}
trafos_islands = {} #{(id, layer):{group, idGroup],....,}
loads_islands ={} #{(id, layer):{group, idGroup],....,}
trafoCount = []
i = 0
for graph in connected_components_BT:
for edge in list( graph.edges(data=True) ):
if edge[2]['element'] == 'BTLine':
lines_BT_Islands[(edge[2]["fid"], edge[2]["idLAYER"])] = {"GROUP":i,"attIndx":edge[2]["attIndexGroup"]}
if i not in BT_lines_group[edge[2]["idLAYER"]]:
BT_lines_group[edge[2]["idLAYER"]].append(i)
if edge[2]['element']== 'acom':
lines_acom_Islands[(edge[2]["fid"], edge[2]["idLAYER"])] = {"GROUP":i,"attIndx":edge[2]["attIndexGroup"]}
if i not in aco_group[edge[2]["idLAYER"]]:
aco_group[edge[2]["idLAYER"]].append(i)
for node in list( graph.nodes(data=True) ):
if len(node[1])!=0 and node[1]['element']=='trafo':
trafos_islands[(node[1]["fid"],node[1]["idLAYER"])] = {"GROUP":i ,"attIndx": node[1]["attIndexGroup"]}
trafoCount.append(i)
if i not in trafo_group[node[1]["idLAYER"]]:
trafo_group[node[1]["idLAYER"]].append(i)
if len(node[1])!=0 and node[1]['element']== 'carga':
loads_islands[(node[1]["fid"],node[1]["idLAYER"])] = {"GROUP":i ,"attIndx": node[1]["attIndexGroup"]}
if i not in carga_group[node[1]["idLAYER"]]:
carga_group[node[1]["idLAYER"]].append(i)
i += 1
################################################################## Actualiza los atributos por el valor de su grupo respectivo
self.changeGroupValue(trafo_Layers, trafos_islands)
self.changeGroupValue(line_BT_Layers, lines_BT_Islands)
self.changeGroupValue(acomet_Layers, lines_acom_Islands)
self.changeGroupValue(carga_BT_Layers, loads_islands)
#####################################Reporte de inconsistencias
linesGroupTotalList = BT_lines_group[0]+BT_lines_group[1]+BT_lines_group[2]+aco_group[0]+aco_group[1]+aco_group[2]
trafodGroupTotalList = trafo_group[0] + trafo_group[1] + trafo_group[2]
cargaDesc = {0:[], 1:[], 2:[]}
for i in range(len(carga_BT_Layers)):
for group in carga_group[i]:
if (group not in linesGroupTotalList):
cargaDesc[i].append(group)
trafoDesc = {0:[], 1:[], 2:[]}
for i in range(len(trafo_Layers)):
for group in trafo_group[i]:
if (group not in linesGroupTotalList):
trafoDesc[i].append(group)
BTDesc = {0:[], 1:[], 2:[]}
for i in range(len(line_BT_Layers)):
for group in BT_lines_group[i]:
if (group not in trafodGroupTotalList):
BTDesc[i].append(group)
acoDesc = {0:[], 1:[], 2:[]}
for i in range(len(acomet_Layers)):
for group in aco_group[i]:
if (group not in trafodGroupTotalList):
acoDesc[i].append(group)
trafParalelo = []
for trafo in trafoCount:
if (trafoCount.count(trafo) > 1) and (trafo not in trafParalelo):
trafParalelo.append(trafo)
toReport = [trafoDesc, BTDesc, acoDesc,cargaDesc, trafParalelo, BT_lines_group, aco_group]
return lines_BT_Islands, toReport, GrafoBT, NOGEOMETRY
def reporteInconsis(self):
starTime = time.time()
inputLayers = self.readerLayers()
line_BT_Layers = inputLayers["BT_lines"]
acomet_Layers = inputLayers["acometida"]
fid_comp_aerea, toReport, GrafoBT, NOGEOMETRY = self.inconsistencias_BT()
trafoDesc = toReport[0][0] + toReport[0][1] + toReport[0][2]
BTDesc = toReport[1][0] + toReport[1][1] + toReport[1][2]
acoDesc = toReport[2][0] + toReport[2][1] + toReport[2][2]
cargaDesc = toReport[3][0] + toReport[3][1] + toReport[3][2]
trafParalelo = toReport[4]
BT_lines_groups = toReport[5]
aco_groups = toReport[6]
anillos = nx.cycle_basis(GrafoBT)
if len(anillos)==0:
message = "No existen anillos en las redes secundarias"
else:
message = "Existen "+ str(len(anillos))+ " anillos en las redes secundarias"
N=0
for LayerX in line_BT_Layers + acomet_Layers:
layer = LayerX[0]
layer.startEditing()
for anillo in anillos:
idlayer = GrafoBT[anillo[0]][anillo[len(anillo)-1]]["idLAYER"]
AttrIdx = GrafoBT[anillo[0]][anillo[len(anillo)-1]]["ringAttIndex"]
idBTline= GrafoBT[anillo[0]][anillo[len(anillo)-1]]["fid"]
element = GrafoBT[anillo[0]][anillo[len(anillo)-1]]["element"]
if element== "BTLine":
layer = line_BT_Layers[idlayer][0]
else:
layer = acomet_Layers[idlayer][0]
done = layer.changeAttributeValue(idBTline, AttrIdx, N)
for i in range(len(anillo)-1):
idlayer = GrafoBT[anillo[i]][anillo[i+1]]["idLAYER"]
AttrIdx = GrafoBT[anillo[i]][anillo[i+1]]["ringAttIndex"]
idBTline= GrafoBT[anillo[i]][anillo[i+1]]["fid"]
element = GrafoBT[anillo[i]][anillo[i+1]]["element"]
if element== "BTLine":
layer = line_BT_Layers[idlayer][0]
else:
layer = acomet_Layers[idlayer][0]
done = layer.changeAttributeValue(idBTline, AttrIdx, N)
N+=1
###RENDER MT LINES
if self.dlg.checkBox_anillos.isChecked() :
self.ringRender(line_BT_Layers)
self.ringRender(acomet_Layers)
self.iface.mapCanvas().refresh()
for LayerX in line_BT_Layers + acomet_Layers:
layer = LayerX[0]
layer.commitChanges()
if self.dlg.colorCheckBox.isChecked() :
for i in range(len(line_BT_Layers)):
layer = line_BT_Layers[i][0]
groupsLines = BT_lines_groups[i]
self.render(layer, groupsLines, "GROUP_LV")
for i in range(len(acomet_Layers)):
layer = acomet_Layers[i][0]
groupsLines = aco_groups[i]
self.render(layer, groupsLines, "GROUP_LV")
if len(trafoDesc) > 0 :
repTraf = "\n Hay "+str(len(trafoDesc))+" transformadores desconectados en BT, estos son: "+ str(trafoDesc)
else:
repTraf = '\nNo existen transformadores desconectados de BT.'
if len(BTDesc) > 0 :
repLines = "\n Hay "+str(len(BTDesc))+" lineas de BT desconectadas, estas son: "+str(BTDesc)
else:
repLines = '\nNo existen lineas de BT desconectadas.'
if len(acoDesc) > 0 :
repAco = "\n Hay "+str(len(acoDesc))+" acometidas desconectadas, estas son: "+str(acoDesc)
else:
repAco = '\nNo existen acometidas desconectadas.'
if len(cargaDesc) > 0 :
repLoad = "\n Hay "+str(len(cargaDesc))+" cargas de BT desconectadas, estas son: " + str(cargaDesc)
else:
repLoad = '\nNo existen cargas de BT desconectadas.'
if len(trafParalelo) > 0 :
repParalel = "\n Hay "+str(len(trafParalelo))+" secundarios con más de un transformador, estos son: " + str(trafParalelo)
else:
repParalel = '\nNo existen secundarios con mas de 1 transformador.'
if NOGEOMETRY:
repGeome = '\nExisten elementos en el SIG sin geometria, estos elementos tienen un 1 en el atributo NO_GEOMETRY.'
else:
repGeome=''
message = message+repParalel+repTraf+repLines+repAco+repLoad+repGeome
QgsApplication.instance().messageLog().logMessage(message, tag="REGISTRO DE INCONSISTENCIAS",level=Qgis.MessageLevel(1))
QMessageBox.warning(None, QCoreApplication.translate('dialog', u'REGISTRO DE INCONSISTENCIAS'), message)
self.iface.messageBar().pushMessage("DN_Corrector", QCoreApplication.translate('dialog', "Se ha analizado la red de baja tension, vea los mensajes de registro para ver las inconsistencias"))
def render(self, aereaLayer, groups, field):
################################################################################ Colorea los grupos de LBT aerea con colores distintos
aereaLayer.beginEditCommand("Update layer styling")
categories = []
firstCat = True
for cat in groups:
symbol = QgsSymbol.defaultSymbol(aereaLayer.geometryType())
symbol.setColor(QColor(randint(0,255), randint(0,255), randint(0,255)))
if firstCat:
firstCat = False
else:
symbol.setWidth(symbol.width())
category = QgsRendererCategory(cat, symbol, "%d" % cat)
categories.append(category)
renderer = QgsCategorizedSymbolRenderer(field, categories)
aereaLayer.setRenderer(renderer)
aereaLayer.triggerRepaint()
aereaLayer.endEditCommand()
def trafConec(self):
inputLayers = self.readerLayers()
line_MT_Layers = inputLayers["MT_lines"]
trafo_Layers = inputLayers["trafos"]
line_BT_Layers = inputLayers["BT_lines"]
acomet_Layers = inputLayers["acometida"]
tolerance = self.dlg.toleranceSpinBox.value()
if tolerance == 0:
tolerance = self.tolerance
fid_comp_aerea, toReport, GrafoBT, NOGEOMETRY = self.inconsistencias_BT()
trafoDesc, linesBTDesc, ACODesc, loadDesc, trafParalelo, BT_lines_group, aco_group = toReport
func_connector.trafConnectMain(line_BT_Layers, acomet_Layers, trafo_Layers, linesBTDesc, ACODesc, trafoDesc, GrafoBT, tolerance)
self.iface.messageBar().pushSuccess("Finalizado", "Se ha finalizado el proceso de conexion transformadores")
self.iface.mapCanvas().refresh()
def loadConec(self):
inputLayers = self.readerLayers()
line_BT_Layers = inputLayers["BT_lines"]
acomet_Layers = inputLayers["acometida"]
carga_BT_Layers = inputLayers["carga_BT"]
fid_comp_aerea, toReport, GrafoBT, NOGEOMETRY = self.inconsistencias_BT()
trafoDesc, linesBTDesc, ACODesc, loadDesc, trafParalelo, BT_lines_group, aco_group = toReport
func_connector.loadConnectMain(carga_BT_Layers, line_BT_Layers, acomet_Layers, loadDesc)
self.iface.mapCanvas().refresh()
self.iface.messageBar().pushSuccess("Finalizado", u"Se ha finalizado el proceso de conexion cargas de BT")
def lineConec(self):
inputLayers = self.readerLayers()
trafo_Layers = inputLayers["trafos"]
line_BT_Layers = inputLayers["BT_lines"]
acomet_Layers = inputLayers["acometida"]