You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following query should yield five rows, but results in 10 instead:
WITH
line as (
SELECT
ST_SetSRID(ST_MakeLine(ARRAY[
ST_MakePoint(10, 80),
ST_MakePoint(50, 80),
ST_MakePoint(10, 30),
ST_MakePoint(90, 30)
]), 28992) as geom
),
points AS (
SELECT
t.id,
ST_SetSRID(t.geom, 28992) as geom
FROM
(VALUES
(1, ST_MakePoint(40, 60)),
-- (2, ST_MakePoint(50, 50)),
(3, ST_MakePoint(60, 40))
) AS t (id, geom)
),
circles AS (
SELECT
p.id as point_id,
p.geom as point_geom,
ST_Buffer(p.geom, 40) as circle_geom
FROM
points p
),
intersections_as_sets AS (
SELECT
c.*,
ST_Dump(ST_Intersection(c.circle_geom, l.geom)) as intersection
FROM
circles c,
line l
),
intersections_as_lines AS (
SELECT
i.point_id,
i.point_geom,
i.point_id::text || ':' || (i.intersection).path::text || ':' || s.index::text as id,
ST_SetSRID(ST_MakeLine(
ST_PointN((i.intersection).geom, s.index),
ST_PointN((i.intersection).geom, s.index + 1)
), 28992) as intersection_geom
FROM
intersections_as_sets i,
LATERAL (
SELECT
generate_series(1, ST_NPoints((i.intersection).geom) - 1) as index
) s
),
intersections_as_rows AS (
SELECT
i.*,
ST_LineLocatePoint(l.geom, i.point_geom) as pos,
ST_LineLocatePoint(l.geom, ST_StartPoint(i.intersection_geom)) as pos_start,
ST_LineLocatePoint(l.geom, ST_EndPoint(i.intersection_geom)) as pos_end,
ST_Distance(l.geom, i.point_geom) as distance
FROM
intersections_as_lines i,
line l
)
SELECT * FROM intersections_as_rows
The text was updated successfully, but these errors were encountered:
The following query should yield five rows, but results in 10 instead:
The text was updated successfully, but these errors were encountered: