Geographic Information Systems Asked by eclipsed_by_the_moon on March 13, 2021
I use the “Offset Point Symbol” tool and a geometry generator symbology to create dynamic leader lines. A sample file is available at http://hub.qgis.org/issues/15201 (Add snapping for ‘Offset Point Symbol’ tool).
Because I need a circle symbology without fill in some projects, I want to shorten the leader lines by the radius of the cirle symbology.
Can anyone help me with the expression? Symbology units are in meter (‘Map units’).
make_line (
make_point(
$x + regexp_substr("offset", '([^,]*)'),
$y - regexp_substr("offset", '([^,]*$)')
),
$geometry
)
Based on the answer posted by underdark I’ve created an expression that works properly:
-- radius = 2m
difference(
make_line (
make_point(
$x + regexp_substr("offset", '([^,]*)'),
$y - regexp_substr("offset", '([^,]*$)')
),
$geometry
),
buffer(make_point(
$x + regexp_substr("offset", '([^,]*)'),
$y - regexp_substr("offset", '([^,]*$)')
), 2)
)
Your requirements seem to be similar to the requirements I had for a flow map a while ago. To shorten the lines at the start and at the end, I used geometric difference functions as shown here:
difference( difference( $geometry, buffer( start_point($geometry), 10000 ) ), buffer( end_point( $geometry), 10000 ) )
Correct answer by underdark on March 13, 2021
What you need to do is find the ratio of the diagonal you need vs the one you have. You're essentially finding a similar right triangle to the one you already have so if the diagonal needs to be 78% shorter, you can multiply your x and y by 78%.
Note this diagram (sorry for hand drawn, on my phone)
So for x offset you need something like:
(sqrt("x offset"^2 + "y offset"^2) - "radius")
/sqrt("x offset"^2 + "y offset"^2) * x
You'll need to know the radius of the circle in meters. If it's set to 'map units' for its radius that's easy, if it's set to mm you'll need to multiply by your scale (convert mm to meters)
So if your circle is 5mm radius you could do something like 0.005 * @map_scale
Answered by Jesse McMillan on March 13, 2021
As an alternative you could join the values that determine the circle size to the lines and use the tool Line substring to trim the starting and/or ending points of your lines.
This was the solution I used when I faced a similar challenge to that of @underdark, but my circles were not equal in size.
Answered by Sylvia on March 13, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP