Skip to content

Commit

Permalink
fix buffer overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
nicokant committed Jan 17, 2025
1 parent 25e2d7b commit 16b98de
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion queries/join-elevation.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
LOAD spatial;
copy (
with elevation as (
select try_cast(column0 as double) as elevation, (row_number() over ()) as row_number from read_csv('/dev/stdin', header = false)
select try_cast(column2 as double) as elevation, (row_number() over ()) as row_number from read_csv('$hogl_csv', header = false)
), points as (
select
*,
Expand All @@ -16,6 +16,7 @@ copy (
WHEN e.elevation is null THEN null
ELSE (st_z(p.geom) - e.elevation)
END as hogl,
e.elevation as elevation,
'$elevation_model_path' as computed_from_path,
now() as created_at
from points as p
Expand Down
4 changes: 3 additions & 1 deletion scripts/compute-coords.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
export parquet_source_path=$1
export elevation_model_path=$2
export destination_path=$3
export hogl_csv=$4

duckdb -csv -noheader -separator " " ":memory:" "$(envsubst <queries/get-row-coordinates.sql)" |
gdallocationinfo -wgs84 -b 1 -valonly $2 |
gdallocationinfo -wgs84 -b 1 -valonly -E -field_sep , $2 > $4
duckdb ":memory:" "$(envsubst <queries/join-elevation.sql)"
rm $4
3 changes: 2 additions & 1 deletion taskfiles/Track.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ tasks:
parquet_source: '{{.OUTPUT_DIR}}/track/radar_name={{.RADAR_NAME}}/location={{.LOCATION_NAME}}/year={{.YEAR}}/month={{.MONTH}}/track.parquet'
output_path: '{{.OUTPUT_DIR}}/track_point/radar_name={{.RADAR_NAME}}/location={{.LOCATION_NAME}}/year={{.YEAR}}/month={{.MONTH}}/'
- 'mkdir -p {{.output_path}}'
- 'ls {{.input_path}} | parallel --bar --joblog {{.joblog}} --resume --resume-failed ./scripts/compute-coords.sh {{.input_path}}{1} {{.ELEVATION_MODEL_PATH}} {{.output_path}}{1}'
- 'ls {{.input_path}} | parallel --bar --joblog {{.joblog}} --resume --resume-failed ./scripts/compute-coords.sh {{.input_path}}{1} {{.ELEVATION_MODEL_PATH}} {{.output_path}}{1} {{.hogl_csv}}{1}'
vars:
joblog: '{{.TEMP_DIR}}/track_{{.LOCATION_NAME}}_{{.YEAR}}_{{.MONTH}}-hogl.log'
input_path: '{{.OUTPUT_DIR}}/track_point/radar_name={{.RADAR_NAME}}/location={{.LOCATION_NAME}}/year={{.YEAR}}/month={{.MONTH}}/'
output_path: '{{.OUTPUT_DIR}}/track_point_hogl/radar_name={{.RADAR_NAME}}/location={{.LOCATION_NAME}}/year={{.YEAR}}/month={{.MONTH}}/'
hogl_csv: '{{.TEMP_DIR}}/track_{{.LOCATION_NAME}}_{{.YEAR}}_{{.MONTH}}_{{.CHUNKS}}-hogl-'
requires:
vars: [RADAR_NAME, YEAR, LOCATION_NAME, MONTH, ELEVATION_MODEL_PATH]
sources:
Expand Down

0 comments on commit 16b98de

Please sign in to comment.