Skip to content

Instantly share code, notes, and snippets.

@stuartlynn
Created June 17, 2016 22:11
Show Gist options
  • Select an option

  • Save stuartlynn/3e681b81802e30deb8fdf9d27c9ffd31 to your computer and use it in GitHub Desktop.

Select an option

Save stuartlynn/3e681b81802e30deb8fdf9d27c9ffd31 to your computer and use it in GitHub Desktop.
Inter_linepoint
create or replace function CDB_INTERP_LINEPOINT_test3(geom geometry, start_date timestamp with time zone, end_date timestamp with time zone, points int)
RETURNS TABLE (the_geom geometry, d timestamp with time zone) as $$
DECLARE
t_step numeric;
d_temp timestamp;
line geometry;
BEGIN
-- t_step = (end_date - start_date)/points;
line = st_makeline(st_linemerge(geom));
for i in 0..points loop
RETURN select start_date + i*(end_date - start_date)/(1.0*points), ST_Line_Interpolate_Point(line, (i*1.0/points)))::INTERP_DATE_POINT ;
end loop;
END
$$
LANGUAGE plpgsql
create or replace function CDB_INTERP_LINEPOINT_test2(geom geometry, start_date timestamp with time zone, end_date timestamp with time zone, points int)
returns setof INTERP_DATE_POINT_2 as $$
DECLARE
t_step numeric;
d_temp timestamp;
line geometry;
BEGIN
-- t_step = (end_date - start_date)/points;
line = st_makeline(st_linemerge(geom));
for i in 0..points loop
RETURN NEXT ROW( start_date + i*(end_date - start_date)/(1.0*points), ST_Line_Interpolate_Point(line, (i*1.0/points)))::INTERP_DATE_POINT_2 ;
end loop;
END
$$
LANGUAGE plpgsql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment