Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Dynamic Exposure
OpenBuildingMap
rabotnik-obm
Commits
8014b816
Commit
8014b816
authored
May 29, 2021
by
Marius Kriegerowski
Browse files
Added building to retrieve land use of buildings
parent
ba438333
Pipeline
#23805
passed with stage
in 2 minutes
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
rabotnikobm/rules/get_building_land_use.py
0 → 100644
View file @
8014b816
#!/usr/bin/env python3
# Copyright (C) 2021:
# Helmholtz-Zentrum Potsdam Deutsches GeoForschungsZentrum GFZ
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
# General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.
from
typing
import
Tuple
,
Iterator
from
rabotnik
import
Rule
class
GetBuildingLandUse
(
Rule
):
"""A rule to get the land use of a building."""
def
__init__
(
self
,
storage
):
self
.
storage
=
storage
async
def
evaluate
(
self
,
payload
:
dict
)
->
Iterator
[
Tuple
[
int
]]:
building_id
=
payload
[
"building_id"
]
async
for
land_use
in
self
.
storage
.
iter_results
(
f
"""SELECT land.class
FROM osm_building_relations AS building, osm_lands AS land
WHERE
{
building_id
}
= building.id
AND ST_INTERSECTS(land.geometry, building.geometry);
"""
):
yield
land_use
tests/test_get_building_land_use.py
0 → 100644
View file @
8014b816
#!/usr/bin/env python3
# Copyright (C) 2021:
# Helmholtz-Zentrum Potsdam Deutsches GeoForschungsZentrum GFZ
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
# General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.
import
pytest
from
rabotnikobm.rules.get_building_land_use
import
(
GetBuildingLandUse
,
)
@
pytest
.
mark
.
requires_storage
@
pytest
.
mark
.
asyncio
async
def
test_get_points_in_building
(
connected_storage
):
rule
=
GetBuildingLandUse
(
storage
=
connected_storage
)
payload
=
{
"building_id"
:
193799
}
result
=
[
result
async
for
result
in
rule
.
evaluate
(
payload
=
payload
)]
assert
result
==
[(
"forest"
,)]
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment