I have the following sql code that intersects each linestring with a polygon. The problem is that when the linestring is wholly covered in the polygon the descriptor attribute of the polygon is put into the ra column instead of the descriptor column. When the linestrings are intersected it is correctly performed. How can I get the descriptor attribute to not be switched around.
Current Output |
|
|
|
lic_li_no |
orig_licli |
ra |
descriptor |
xxxxx |
xxxxx |
LSD-10 Sec 12 |
NULL |
Desired Output |
|
|
|
lic_li_no |
orig_licli |
ra |
descriptor |
xxxxx |
xxxxx |
NULL |
LSD-10 Sec 12 |
WITH split_lines AS (
SELECT
p.lic_li_no, p.orig_licli,l.ra,
l.descriptor,
(ST_Dump(ST_Intersection(p.geom, l.geom))).geom AS geom
FROM
public.linestring p, public.grid_concave_hull l
WHERE
ST_Intersects(p.geom, l.geom) AND NOT ST_CoveredBy(p.geom, l.geom)
UNION ALL
SELECT
p.lic_li_no, p.orig_licli,
l.descriptor, l.ra,
p.geom AS geom
FROM
public.linestring p, public.grid_concave_hull l
WHERE
ST_CoveredBy(p.geom, l.geom)
)
SELECT * FROM split_lines;
