Skip to content

Instantly share code, notes, and snippets.

@strk
Last active August 29, 2015 13:55
Show Gist options
  • Save strk/8704942 to your computer and use it in GitHub Desktop.
Save strk/8704942 to your computer and use it in GitHub Desktop.
WITH trip AS (
SELECT ST_MakeLine(the_geom_webmercator ORDER BY cartodb_id ASC) as g
FROM jackerouak
),
params AS (
SELECT
greatest(st_xmax(g)-st_xmin(g), st_ymax(g)-st_ymin(g))/20 as maxlen_old,
CDB_XYZ_Resolution(4)*10 as maxlen
FROM trip
),
dump AS (
SELECT (ST_DumpPoints(ST_Segmentize(t.g, p.maxlen))).*
FROM trip t, params p
)
SELECT path as cartodb_id, geom as the_geom_webmercator
FROM dump
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment