Advertisement
Guest User

Untitled

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