Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
exposure-initializer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Global Dynamic Exposure
exposure-initializer
Commits
0eee3873
Commit
0eee3873
authored
1 year ago
by
Danijel Schorlemmer
Browse files
Options
Downloads
Patches
Plain Diff
[Hotfix] - Correct wrong call to function in processing gaps of small countries
parent
2a88004a
No related branches found
Branches containing commit
Tags
v2.2.1
Tags containing commit
1 merge request
!34
Resolve "[Hotfix] - Processing countries without the `large-country` flag fails"
Pipeline
#68066
passed
1 year ago
Stage: tests
Stage: release
Changes
1
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
exposureinitializer/exposureinitializer.py
+11
-11
11 additions, 11 deletions
exposureinitializer/exposureinitializer.py
with
11 additions
and
11 deletions
exposureinitializer/exposureinitializer.py
+
11
−
11
View file @
0eee3873
...
...
@@ -489,7 +489,7 @@ class ExposureInitializer:
self
.
exposure_db
.
cursor
.
execute
(
sql_statement
)
self
.
exposure_db
.
connection
.
commit
()
def
process_gaps_in_exposure
(
self
,
country_iso_code
,
is_large_country
=
False
):
def
process_gaps_in_exposure
(
self
,
country_iso_code
,
low_memory_usage
=
False
):
"""
In the case of missing exposure data for districts in the country, tiles containing
built area will not be covered with assets. Also, tiles at the border with the centroid
...
...
@@ -506,9 +506,9 @@ class ExposureInitializer:
Args:
country_iso_code (str):
ISO 3166-1 alpha-3 code of the country.
is_large_country
(bool, optional, default: False):
Switch
for processing large countries
in case of memory problems. If set to
`True`, a slower but less
memory-consuming process is used.
low_memory_usage
(bool, optional, default: False):
Switch in case of memory problems. If set to
`True`, a slower but less
memory-consuming process is used.
"""
# Get the assets of the average building in the country
...
...
@@ -523,19 +523,19 @@ class ExposureInitializer:
# Calculate the total built area in the country
logger
.
info
(
f
"
Calculating the total built area in country
{
country_iso_code
}
.
"
)
quadkeys
=
[]
if
is_large_country
:
if
low_memory_usage
:
# To avoid a query over the full country, first retrieve all quadkeys of the country
# and then compute the total built area stepwise in batches of quadkeys
quadkeys
=
self
.
exposure_db
.
get_country_tiles
(
country_iso_code
)
total_built_area
=
self
.
exposure_db
.
get_built_area_from_quadkeys
(
quadkeys
)
else
:
# For small countries the query can be directly executed
total_built_area
=
self
.
exposure_db
.
cursor
.
get_country_built_area
(
country_iso_code
)
total_built_area
=
self
.
exposure_db
.
get_country_built_area
(
country_iso_code
)
logger
.
info
(
f
"
Total built area in country
{
country_iso_code
}
:
{
total_built_area
}
.
"
)
# Select all tiles within the country (and with built area) without reference entities.
logger
.
info
(
"
Retrieving all tiles with built area but without reference entities.
"
)
if
is_large_country
:
if
low_memory_usage
:
tiles
=
self
.
exposure_db
.
get_tiles_without_reference_entities
(
quadkeys
=
quadkeys
)
else
:
tiles
=
self
.
exposure_db
.
get_tiles_without_reference_entities
(
...
...
@@ -713,10 +713,10 @@ def command_line_interface():
)
parser_postgis
.
add_argument
(
"
-l
"
,
"
--l
arge-country
"
,
"
--l
ow-memory-usage
"
,
required
=
False
,
action
=
"
store_true
"
,
help
=
"
Switch
for processing large countries
in case of memory problems
"
,
help
=
"
Switch in case of memory problems
"
,
)
# Read arguments from command line
...
...
@@ -725,7 +725,7 @@ def command_line_interface():
exposure_model
=
args
.
exposure_model
country_iso_code
=
args
.
country_iso_code
postgis_config_file
=
args
.
config_file
is_large_country
=
args
.
large_country
low_memory_usage
=
args
.
low_memory_usage
# Create dictionary from INI-style config file
postgis_config
=
configparser
.
ConfigParser
()
...
...
@@ -759,7 +759,7 @@ def command_line_interface():
initializer
.
exposure_db
.
remove_asset_country
(
country_iso_code
)
initializer
.
import_exposure
(
exposure_model
,
country_iso_code
,
num_processors
)
initializer
.
process_gaps_in_exposure
(
country_iso_code
,
is_large_country
=
is_large_country
country_iso_code
,
low_memory_usage
=
low_memory_usage
)
initializer
.
exposure_db
.
commit_and_close
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment