-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Streamlined site assessment process #50
Changes from 38 commits
0ccae6f
7bf05a8
e535981
8a75fb8
1bd14e6
4e1d793
42f6dc3
c74f64c
924d4b8
9b06ce1
e3e3323
639e99c
e72850f
5e7408f
504a0a6
a48dfff
ac110d2
0d63007
d0bcf51
b93e816
46e6eed
e0d7c39
dcc61bc
08edb7e
61383c4
c55d572
3a45fe8
ed96ef4
9b0f927
3aafc4b
2681105
9b45820
2687dbf
19bf133
2cc7a44
7a9f277
c1d2707
ddaf69f
062ebad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,6 +111,19 @@ function _write_cog(file_path::String, data::Raster, config::Dict)::Nothing | |
return nothing | ||
end | ||
|
||
function _write_tiff(file_path::String, data::Raster, config::Dict)::Nothing | ||
Rasters.write( | ||
file_path, | ||
data; | ||
ext=".tiff", | ||
source="gdal", | ||
driver="gtiff", | ||
force=true | ||
) | ||
|
||
return nothing | ||
end | ||
|
||
""" | ||
criteria_middleware(handle) | ||
|
||
|
@@ -161,18 +174,19 @@ function setup_region_routes(config, auth) | |
) | ||
# somewhere:8000/suitability/assess/region-name/reeftype?criteria_names=Depth,Slope&lb=-9.0,0.0&ub=-2.0,40 | ||
# 127.0.0.1:8000/suitability/assess/Cairns-Cooktown/slopes?Depth=-4.0:-2.0&Slope=0.0:40.0&Rugosity=0.0:6.0 | ||
# 127.0.0.1:8000/suitability/assess/Cairns-Cooktown/slopes?Depth=-4.0:-2.0&Slope=0.0:40.0&Rugosity=0.0:6.0&SuitabilityThreshold=95 | ||
|
||
qp = queryparams(req) | ||
assessed_fn = cache_filename(qp, config, "$(reg)_suitable", "tiff") | ||
if isfile(assessed_fn) | ||
return file(assessed_fn; headers=COG_HEADERS) | ||
end | ||
|
||
@debug "$(now()) : Assessing region $(reg)" | ||
assessed = assess_region(reg_assess_data, reg, qp, rtype) | ||
|
||
@debug "$(now()) : Running on thread $(threadid())" | ||
@debug "Writing to $(assessed_fn)" | ||
_write_cog(assessed_fn, assessed, config) | ||
@debug "$(now()) : Writing to $(assessed_fn)" | ||
_write_tiff(assessed_fn, assessed, config) | ||
|
||
return file(assessed_fn; headers=COG_HEADERS) | ||
end | ||
|
@@ -195,7 +209,7 @@ function setup_region_routes(config, auth) | |
assessed = Raster(assessed_fn) | ||
else | ||
assessed = assess_region(reg_assess_data, reg, qp, rtype) | ||
_write_cog(assessed_fn, assessed, config) | ||
_write_tiff(assessed_fn, assessed, config) | ||
end | ||
|
||
# Extract criteria and assessment | ||
|
@@ -211,6 +225,9 @@ function setup_region_routes(config, auth) | |
) | ||
) | ||
|
||
# Specifically clear from memory to invoke garbage collector | ||
assessed = nothing | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldn't be necessary, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, yes it does make a difference. Triggers the GC to run a bit earlier, making space for the next big dataset. Otherwise you're more likely to hit an out-of-memory error. |
||
|
||
output_geojson(suitable_sites_fn, best_sites) | ||
return file(suitable_sites_fn) | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
config
not used?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I think because we went from writing out a COG (which used the defined options) to writing out a geotiff...
I'll fix it up, thanks for catching.