2 -- File ID: 24babc2a-fafb-11dd-96fe-000475e441b9
4 -- siste_aar: List all places from last year, DISTINCT ON name and every week
5 CREATE OR REPLACE VIEW siste_aar -- {{{
8 name, date_trunc('week', date)
11 WHERE date > now() + interval '1 year ago'
15 -- siste_halvaar: List all places from last six months, DISTINCT ON name and every week
16 CREATE OR REPLACE VIEW siste_halvaar -- {{{
19 name, date_trunc('week', date)
22 WHERE date > now() + interval '0.5 year ago'
26 -- siste_maaned: List all places from last month, DISTINCT ON name and every hour
27 CREATE OR REPLACE VIEW siste_maaned -- {{{
30 name, date_trunc('hour', date)
33 WHERE date > now() + interval '1 month ago'
37 -- siste_uke: List all places from last week, DISTINCT ON name and every hour
38 CREATE OR REPLACE VIEW siste_uke -- {{{
41 name, date_trunc('hour', date)
44 WHERE date > now()+interval '1 week ago'
48 -- siste_dogn: List all places from the last 24 hours, DISTINCT ON name and every minute
49 CREATE OR REPLACE VIEW siste_dogn -- {{{
52 name, date_trunc('minute', date)
55 WHERE date > now()+interval '1 day ago'
61 CREATE OR REPLACE VIEW minutt -- {{{
64 date_trunc('minute', date)
69 CREATE OR REPLACE VIEW minuttname -- {{{
72 date_trunc('minute', date),
78 CREATE OR REPLACE VIEW hourname -- {{{
81 date_trunc('hour', date),
90 CREATE OR REPLACE VIEW closest AS -- {{{
92 SELECT DISTINCT ON (name) * FROM (
96 WHERE name IS NOT NULL
100 CREATE OR REPLACE VIEW gpx AS -- {{{
101 SELECT '<trkpt lat="' || coor[0] || '" lon="' || coor[1] || '"> ' ||
102 '<ele>' || ele || '</ele> ' ||
103 '<time>' || date || '</time> ' ||
106 date, coor, ele, name, dist, description
109 CREATE OR REPLACE VIEW gpst AS -- {{{
110 SELECT date, coor, ele, name, dist,
111 '<tp> <time>' || date || 'Z' || '</time> <lat>' || coor[0] || '</lat> <lon>' || coor[1] || '</lon> </tp>'
115 -- ev: List events and the log
116 CREATE OR REPLACE VIEW ev AS -- {{{
118 SELECT 'gps' AS flag, date, coor, name || ' (' || dist || ')' AS name, ele::numeric(8,1), NULL AS descr
121 SELECT 'event' AS flag, date, coor, NULL, NULL, descr AS descr
124 SELECT 'pic' AS flag, date, coor, filename, NULL, NULL
127 SELECT 'film' AS flag, date, coor, filename, NULL, descr
130 SELECT 'lyd' AS flag, date, coor, filename, NULL, descr
133 ORDER BY date; -- }}}
135 CREATE OR REPLACE VIEW media AS -- {{{
136 SELECT 'film' AS what,
139 clname(coor) AS name,
140 cldist(coor) AS dist,
144 SELECT 'pic', date, filename, clname(coor), cldist(coor), coor
147 SELECT 'lyd', date, filename, clname(coor), cldist(coor), coor
149 ORDER BY date; -- }}}
151 -- wp: List all waypoints, sorted north → south, west → east
152 CREATE OR REPLACE VIEW wp AS -- {{{
161 ORDER BY coor[0] DESC, coor[1]; -- }}}