--
You received this message because you are subscribed to the Google Groups "SpatiaLite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spatialite-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/spatialite-users/dbd8a51f-fa48-4d22-8e6e-9a051d1d2fc0n%40googlegroups.com.
Hi,I am not sure if it is practically impossible. Tricky it may be, but I think that the followind approuch might work:1. Create an offset line with desired distanse with OffsetCurve.2. Dissolve segments with DissolveSegments.3. Find centroids of original and dissolved segments with ST_Centroid.4. Join the centroids of the original segments and corresponding offset segments.However, I do not know if the lines that connect the centroids are guaranteed to be perpendicular to the original segments.-Jukka Rahkonen-
with
--PARAMETERS
para ("key", "value") as (
values(
'offset_left', 500
),(
'offset_right', 2500
),(
'epsg', 25832
)
)
--01> Linienmittelpunkt
--- ST_Line_Interpolate_Point( line Curve , fraction Double precision ) : Point
, cte1 as (
select pk, ST_Line_Interpolate_Point(geom, 0.5) as g_ln_midpt
from st_line
)
--02> Linienteil: Start - Mitte
--- ST_Line_Substring( line Curve , start_fraction Double precision , end_fraction Double precision ) : Curve
, cte2 as (
select pk, ST_Line_Substring(geom, 0.0, 0.5) as g_ln_sub1
from st_line
)
--- Segmente
, cte2b as (
select pk, st_dissolveSegments(g_ln_sub1) as g_segs_sub1
from cte2
)
--03> Linienteil: Mitte - Ende
--- ST_Line_Substring( line Curve , start_fraction Double precision , end_fraction Double precision ) : Curve
, cte3 as (
select pk, ST_Line_Substring(geom, 0.5, 1.0) as g_ln_sub2
from st_line
)
--- Segmente
, cte3b as (
select pk, st_dissolveSegments(g_ln_sub2) as g_segs_sub2
from cte3
)
--04> Nachbar-Segmente Linienmittelpunkt
, cte4 as (
select a.pk
-- letztes Segment der ersten Linienhälfte
, st_GeometryN(a.g_segs_sub1, st_numGeometries(a.g_segs_sub1)) as g_seg1
-- erstes Segment der zweiten Linienhälfte
, st_GeometryN(b.g_segs_sub2, 1) as g_seg2
from cte2b as a
join cte3b as b
using(pk)
)
--05> Azimuth: Segmente
--- ST_Azimuth( pt1 Geometry , pt2 Geometry ) : Double precision
, cte5 as (
select pk, ST_Azimuth(st_startpoint(g_seg1), st_endpoint(g_seg2)) as azi
from cte4
)
--06> Mittelsenkrechte
--- ST_Project( start_point Geometry, distance Double precision, azimuth Double precision ) : Point(EPSG:4326)
--- st_Project() verlangt nach WGS84 (EPSG:4326)
, cte6 as (
-- rechtes Segment
select a.pk, 'right' as off_dir
, st_x(a.g_ln_midpt) as x0, st_y(a.g_ln_midpt) as y0
, sin(azi + pi()/2) * c."value" as x1, cos(azi + pi()/2) * c."value" as y1
, ST_Project(
st_transform(g_ln_midpt,4326)
, c."value"
, b.azi + pi()/2 -- = +radians(90)
) as geom
from cte1 as a
join cte5 as b
using (pk)
join para as c
where c."key" = 'offset_right'
union
-- linkes Segment
select a.pk, 'left'
, st_x(a.g_ln_midpt) as x0, st_y(a.g_ln_midpt) as y0
, sin(azi - pi()/2) * c."value" as x1, cos(azi - pi()/2) * c."value" as y1
, ST_Project(
st_transform(g_ln_midpt,4326)
, c."value"
, b.azi - pi()/2
)
from cte1 as a
join cte5 as b
using (pk)
join para as c
where c."key" = 'offset_left'
)
select a.pk, off_dir, makeLine(makePoint(x0, y0, c."value"), makePoint(x0 + x1, y0 + y1, c."value")) as g_trig
, st_transform(makeLine(st_transform(a.g_ln_midpt,4326), b.geom), c."value") as g_proj
from cte1 as a
join cte6 as b
using (pk)
join para as c
where c."key" = 'epsg'
;
Greatings
Bernd