0

I have 3 tables, a linear table of sections, a non geometric table of bus lines, and a intermediate table between both, with relations N:M. In the intermediate table I have the ID of sections table and bus line table

I need to get the geometry of bus lines. but some of the sections belongs to many bus lines, so I need to "duplicate" some of the sections. I can do it with a Joint feature by field value, in the way to do a One to Many match. but the problem it's I need a dynamic way to do, that's mean, when a new link it's stablished in the intermediate table between a section and a bus line, I need to see this new entity in the geometry of bus line.

Any idea of how to do it?

1 Answer 1

1

You can achieve this using a virtual layer to join the 3 tables.

Go to the menu Layer > Add Layer > Add/Edit Virtual Layer..., enter the following query and adjust for your layer/table name.

SELECT *
FROM
 bus_line_table bl
 JOIN line_segment_relation rel ON bl.line_id = rel.line_id
 JOIN road_segments seg ON rel.segment_id = seg.segment_id
1
  • thanks @JGH, it's works fine! I have the bus line geometry and its update if I change the sections linked. The only problem it's the virtual layer, take to much time to draw. Every time I pan or zoom, QGIS redraws all lines, even sometimes QGIS crach or not responding. I found the "search_frame ", maybe can help, but Im not sure how to include in the query. Have you any idea how to manage this problem? Commented Sep 29, 2023 at 6:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.