Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Divide an input geometry into equal-length portions of the specified length.
- -- The final segment will contain the "unused" portion of the line and will be
- -- shorter than the others.
- CREATE OR REPLACE FUNCTION pg_temp.DivideLine(g geometry, segment_length double precision)
- RETURNS SETOF geometry AS $$
- SELECT ST_LineSubstring($1,
- i*$2/length_m,
- LEAST(1.0, (i+1)*$2/length_m))
- FROM (SELECT $1, ST_Length($1) AS length_m) sq
- CROSS JOIN LATERAL generate_series(0, floor(length_m / $2)::int) AS i
- $$ LANGUAGE SQL;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement