-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tide data to operations_stats #110
* Add tide data to operations_stats * Add maree_categorie column
- Loading branch information
1 parent
3623e10
commit d26d698
Showing
7 changed files
with
98 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
update operations_stats set | ||
maree_port = t.maree_port, | ||
maree_coefficient = t.maree_coefficient, | ||
maree_categorie = t.maree_categorie | ||
from ( | ||
select | ||
operation_id, | ||
t.port as maree_port, | ||
coefficient as maree_coefficient, | ||
case | ||
when coefficient between 20 and 45 then '20-45' | ||
when coefficient between 46 and 70 then '46-70' | ||
when coefficient between 71 and 95 then '71-95' | ||
when coefficient between 95 and 120 then '96-120' | ||
else null | ||
end maree_categorie | ||
from ( | ||
select distinct | ||
operation_id, | ||
date, | ||
first_value(port) over (partition by operation_id order by distance_km asc) port, | ||
first_value(port_code) over (partition by operation_id order by distance_km asc) code | ||
from ( | ||
SELECT | ||
op.operation_id, | ||
op.date, | ||
p.code as port_code, | ||
p.name as port, | ||
ST_Distance( | ||
p.point, | ||
op.point | ||
)/1000 distance_km | ||
FROM ports p | ||
join ( | ||
select | ||
op.operation_id, | ||
op.point, | ||
stats.date | ||
from operations_points op | ||
join operations_stats stats on stats.operation_id = op.operation_id | ||
join operations o on o.operation_id = op.operation_id | ||
where op.point is not null | ||
and coalesce(stats.distance_cote_metres, 0) < 20000 | ||
and o."cross" not in ('Antilles-Guyane', 'Corse', 'Guadeloupe', 'Guyane', 'La Garde', 'La Réunion', 'Martinique', 'Mayotte', 'Nouvelle-Calédonie', 'Polynésie') | ||
) op on true | ||
) t | ||
) t | ||
join tide_data td on td.date = t.date and td.port = t.code | ||
) t | ||
where operations_stats.operation_id = t.operation_id; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters