Skip to content

Commit

Permalink
Merge pull request #646 from gisce/fix-a1-conta-at-tipus-tram
Browse files Browse the repository at this point in the history
A1: Mejora tipos de conexión en CONTA-AT
  • Loading branch information
ecarreras authored Apr 18, 2024
2 parents f65d799 + 675dbf1 commit c1ec91e
Showing 1 changed file with 29 additions and 52 deletions.
81 changes: 29 additions & 52 deletions libcnmc/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,62 +574,39 @@ def get_tipus_connexio(o, id_escomesa):
"""

tipus = 'A'
if 'node_id' in o.GiscedataCupsEscomesa.fields_get().keys() and 'edge_id' in o.GiscedataBtElement.fields_get().keys():
node_id = o.GiscedataCupsEscomesa.read(
id_escomesa, ['node_id']
)['node_id']
if node_id:
edge_id = o.GiscegisEdge.search(
[
'|',
('start_node', '=', node_id[0]),
('end_node', '=', node_id[0])
]
)
if edge_id:
tram_bt = o.GiscedataBtElement.search(
[('edge_id', '=', edge_id[0])]
)
if tram_bt:
tram_bt = o.GiscedataBtElement.read(
tram_bt[0], ['tipus_linia']
)
if tram_bt['tipus_linia']:
tipus = tram_bt['tipus_linia'][1][0]
else:
bloc = o.GiscegisBlocsEscomeses.search(
[('escomesa', '=', id_escomesa)]
node_id = o.GiscedataCupsEscomesa.read(
id_escomesa, ['node_id']
)['node_id']
if node_id:
edge_id = o.GiscegisEdge.search(
[
'|',
('start_node', '=', node_id[0]),
('end_node', '=', node_id[0])
]
)
if bloc:
bloc = o.GiscegisBlocsEscomeses.read(bloc[0], ['node'])
if bloc['node']:
node = bloc['node'][0]
edge_bt = o.GiscegisEdge.search(
[
'|',
('start_node', '=', node),
('end_node', '=', node),
'|',
('layer', 'ilike', self.layer),
('layer', 'ilike', 'EMBARRA%BT%')
]
if edge_id:
tram_bt = o.GiscedataBtElement.search(
[('edge_id', '=', edge_id[0])]
)
if tram_bt:
tram_bt = o.GiscedataBtElement.read(
tram_bt[0], ['tipus_linia']
)
edge = o.GiscegisEdge.read(
edge_bt[0], ['id_linktemplate']
if tram_bt['tipus_linia']:
tipus = tram_bt['tipus_linia'][1][0]
else:
tram_at = o.GiscedataAtTram.search(
[('edge_id', '=', edge_id[0])]
)
if edge['id_linktemplate']:
tram_bt = o.GiscedataBtElement.search(
[
('name', '=', edge['id_linktemplate'])
]
if tram_at:
tram_at = o.GiscedataAtTram.read(
tram_at[0], ['tipus']
)
if tram_bt:
tram_bt = o.GiscedataBtElement.read(
tram_bt[0], ['tipus_linia']
)
if tram_bt:
if tram_bt['tipus_linia']:
tipus = tram_bt['tipus_linia'][1][0]
if tram_at['tipus'] and tram_at['tipus'] == 1:
tipus = 'A'
else:
tipus = 'S'

return tipus

Expand Down

0 comments on commit c1ec91e

Please sign in to comment.