28
 
1
SELECT id, year, season,
2
(year::text || '-' || season) as cartodb_id,
3
CASE WHEN season = 'spring' THEN year*10 + 1 ELSE year+10 + 2 END AS year_and_season,
4
  ST_MakeLine(
5
    ST_Transform(
6
      ST_SetSRID(
7
        ST_MakePoint(lon, lat),
8
      4326),
9
    3857)
10
    ORDER BY timestamp DESC
11
  ) as the_geom_webmercator
12
FROM
13
(
14
  SELECT *, 
15
  ST_Distance(
16
    the_geom_webmercator, 
17
    lag(the_geom_webmercator) 
18
    OVER (
19
      ORDER BY id, timestamp
1
12
 
1
#layer{
2
  line-width: 3;
3
  line-opacity: 0.8;
4
  line-join: round;
5
  [id=117181]{ line-color: ramp([year_and_season],(#9bbbd5,#8cacc6,#7d9cb6,#6e8da7,#5e7e98,#4f6f88,#406079,#315069,#22415a)); } /* Egbert */
6
  [id=117185]{ line-color: ramp([year_and_season],(#b5c88d,#9cb075,#84975d,#6b7f44,#53662c,#3a4e14)); } /* Olive */
7
  [id=117186]{ line-color: ramp([year_and_season],(#f4bb84,#e3aa74,#d19865,#c08755,#ae7646,#9d6536,#8b5327,#7a4217)); } /* Rapunzel */
8
  [id=130828]{ line-color: ramp([year_and_season],(#94c7b6,#77a997,#5b8a79,#3e6b5a,#214d3b)); } /* Helen */
9
  [id=130830]{ line-color: ramp([year_and_season],(#e38f8f,#c57372,#a75655,#893a38,#6b1d1b)); } /* Scooter */
10
  [id=130832]{ line-color: ramp([year_and_season],(#e49bc1,#c67ea3,#a86184,#894466,#6b2747)); } /* Walter */
11
  [id=139413]{ line-color: ramp([year_and_season],(#c2a8cc,#482e51)); } /* Unnamed */
12
}
Leaflet | CartoDB © 2014