mirror of
https://github.com/ANL-CEEESA/RELOG.git
synced 2025-12-05 23:38:52 -06:00
Fix GeoDB download
This commit is contained in:
@@ -42,7 +42,7 @@ function centroid(geom::Shapefile.Polygon)::GeoPoint
|
|||||||
return GeoPoint(round(y_center, digits = 5), round(x_center, digits = 5))
|
return GeoPoint(round(y_center, digits = 5), round(x_center, digits = 5))
|
||||||
end
|
end
|
||||||
|
|
||||||
function _download(url, output, expected_crc32)::Nothing
|
function _download_file(url, output, expected_crc32)::Nothing
|
||||||
if isfile(output)
|
if isfile(output)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -55,13 +55,13 @@ function _download(url, output, expected_crc32)::Nothing
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
function _download_zip(url, outputdir, expected_crc32)::Nothing
|
function _download_zip(url, outputdir, expected_output_file, expected_crc32)::Nothing
|
||||||
if isdir(outputdir)
|
if isfile(expected_output_file)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
mkpath(outputdir)
|
mkpath(outputdir)
|
||||||
@info "Downloading: $url"
|
@info "Downloading: $url"
|
||||||
zip_filename = _download(url)
|
zip_filename = download(url)
|
||||||
actual_crc32 = open(crc32, zip_filename)
|
actual_crc32 = open(crc32, zip_filename)
|
||||||
expected_crc32 == actual_crc32 || error("CRC32 mismatch")
|
expected_crc32 == actual_crc32 || error("CRC32 mismatch")
|
||||||
open(zip_filename) do zip_file
|
open(zip_filename) do zip_file
|
||||||
@@ -91,8 +91,8 @@ function _geodb_load_gov_census(;
|
|||||||
csv_filename = "$basedir/locations.csv"
|
csv_filename = "$basedir/locations.csv"
|
||||||
if !isfile(csv_filename)
|
if !isfile(csv_filename)
|
||||||
# Download required files
|
# Download required files
|
||||||
_download(population_url, "$basedir/population.csv", population_crc32)
|
_download_zip(shp_url, basedir, joinpath(basedir, shp_filename), shp_crc32)
|
||||||
_download_zip(shp_url, basedir, shp_crc32)
|
_download_file(population_url, "$basedir/population.csv", population_crc32)
|
||||||
|
|
||||||
# Read shapefile
|
# Read shapefile
|
||||||
@info "Processing: $shp_filename"
|
@info "Processing: $shp_filename"
|
||||||
|
|||||||
Reference in New Issue
Block a user