Modify entity asset selection within a bounding box in import of exposure data from PostGIS
I was trying to import both the reference and building-wise exposure data within the bounding box:
bounding_box = { "lon_min": 23.551940918, "lon_max": 23.553314211, "lat_min": 38.236022777, "lat_max": 38.237101468, }
The bounding box is slightly bigger than one tile (1 tile is fully in the bounding box and 3 other tile's boundaries are slightly cut by the bounding box boundaries.
Below is a zoomed in image of the bounding box. As you can see the box is slightly bigger than one tile.
Now looking at the entities included in the imported reference and building-wise exposure data:
Below you can see the entities included in the reference exposure:
It covers all 4 tiles in the box
The Asset
table of the reference exposure data includes assets for the 4 tiles shown above.
Now, looking into the building-wise imported exposure data:
There are 4 tiles and one building in the Entity
table, and the Asset
table includes data only on the building.
The reason is that is you look at the first image, these tiles are all complete tiles, thus in the case of the reference model, all the 4 tiles and their assets are included in the Entity
and Asset
tables, but in the building-wise exposure, the tile entities have no asset and the only building entity that falls within the boundary is the one in the Asset
table.
So, we could modify the import_from_postgis
function to pick all the entities that fall not within the bounding box, but fall within the quadkeys that appear in the Entity
table even partially. This way, when importing the building-wise exposure model, the Asset
table will include all the other buildings that are in the other 3 quadkeys too.