I need to get MBR from table with multiple rows from lineString
type column.
Using envelope I could get MBR from single row because envelope
is not aggregate function.
How to get one MBR of lineString column including multiple rows?
I need to get MBR from table with multiple rows from lineString
type column.
Using envelope I could get MBR from single row because envelope
is not aggregate function.
How to get one MBR of lineString column including multiple rows?
Complicated query. Last row would has result.
SELECT
@id := id,
@geometry := Envelope(if(isNull(@geometry), `line`, GeometryCollection( `line` , geomFromText(AsText(@geometry))))),
AsText(@geometry)
FROM `table_line`
JOIN (SELECT @id :=0, @geometry := NULL) `tmp`
WHERE id > @id
ORDER BY id ASC
Using this answer
geomFromText(AsText(@geometry))
-- this is necessary because GeometryCollection does not work with direct variables.
P.S. but it's very complicated, do not use it in production.