Compare commits

...

3 Commits

Author SHA1 Message Date
ddd2daf8cf monticello view 2021-09-13 13:48:23 +02:00
1b8674a6c0 removed unrelated comment 2021-09-13 11:25:54 +02:00
ca69ec961e parco_monza_classico e arcore classico views 2021-09-13 11:24:49 +02:00

View File

@ -68,4 +68,82 @@ select
on (td_start.training_id = td_end.training_id) on (td_start.training_id = td_end.training_id)
join training t on (t.id = td_start.training_id) join training t on (t.id = td_start.training_id)
order by td_start.t asc order by td_start.t asc
);
---------------------------------------------
-- trovare allenamenti usando georeference --
---------------------------------------------
-- COSTANTI
-- via mirabello (dentro al parco): st_point(45.607115, 9.283687)
-- rotatoria Tamoil (per la via del nord): st_point(45.622779, 9.276274)
-- giro del parco di monza
create or replace view parco_monza_classico as
(
select duration,
distance,
pace_kmh,
start_time,
end_time,
start_location,
end_location,
training_id
from training_info ti
where ti.training_id in (
-- trovo id allenamenti che passano sicuramente per il parco di monza
select distinct t.id
from training t
join training_data td on (t.id = td.training_id)
join training_data td2 using (training_id)
where
distance < 31 and
st_dwithin(td.geog, st_point(45.607115, 9.283687), 20) -- se passo a 20 metri da via mirabello dentro al parco
and not st_dwithin(td2.geog, st_point(45.622779, 9.276274), 20) -- e se non passo dal tamoil
)
);
-- giro di arcore
create or replace view arcore as
(
select duration,
distance,
pace_kmh,
start_time,
end_time,
start_location,
end_location,
training_id
from training_info ti
where ti.training_id in (
select td.training_id
from training_data td join training_data td2 using (training_id)
where
distance < 42 and
end_location = 'Bicocca' and
st_dwithin(td.geog, st_point(45.622779, 9.276274), 20) -- se passo a 20 metri dal Tamoil
and st_dwithin(td2.geog, st_point(45.631299, 9.308985), 30) -- e se passo a 30 metri dalla rotatoria per arcore
)
);
create or replace view monticello as
(
select duration,
distance,
pace_kmh,
start_time,
end_time,
start_location,
end_location,
training_id
from training_info ti
where ti.training_id in (
select td.training_id
from training_data td join training_data td2 on (td.training_id = td2.training_id) join training_data td3 on (td.training_id = td3.training_id)
where
distance < 61 and
end_location = 'Bicocca' and
st_dwithin(td.geog, st_point(45.622779, 9.276274), 20) -- se passo per il Tamoil
and st_dwithin(td2.geog, st_point(45.631299, 9.308985), 30) -- e se passo a 30 metri dalla rotatoria per arcore
and st_dwithin(td3.geog, st_point(45.705275, 9.305889), 20) -- e se passo a 20 metri dalla fontanella di Monticello
)
); );