Just about your "the line will update automatically" part, a virtual layer may help.
In this example I have prepared two point layers
my_From.shp
layer with a field from_id
my_To.shp
layer with a field to_id
And the actual workflow to create a line (virtual) layer is:
Layer | Add Layer | Add Virtual Layer
Embedded layers
- [Import] above two layers
- In the
Query
field, give a query (as below).
- Click on [OK], and a virtual layer with connected lines will be created.
- NB. when you add a point in a layer, please make sure you have identical ids in
from_id
and to_id
.
Query:
SELECT
my_From.from_id,
my_To.to_id,
make_line(my_From.geometry, my_To.geometry) geometry
FROM my_From CROSS JOIN my_To
WHERE my_From.from_id = my_To.to_id
[EDIT] To include a field line_length
, please use a query below. Labeling with this field is also possible.
SELECT
my_From.from_id,
my_To.to_id,
make_line(my_From.geometry, my_To.geometry) geometry,
st_distance(my_From.geometry, my_To.geometry) AS line_length
FROM my_From CROSS JOIN my_To
WHERE my_From.from_id = my_To.to_id
Lastly, when you add a new point please open the layer properties
of the virtual layer and click on [Apply] to refresh the layer. (so it is semi-automatic..., not 100% automatic... sorry).