Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
rabotnik-obm
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Global Dynamic Exposure
rabotnik
rabotnik-obm
Commits
8014b816
Commit
8014b816
authored
4 years ago
by
Marius Kriegerowski
Browse files
Options
Downloads
Patches
Plain Diff
Added building to retrieve land use of buildings
parent
ba438333
No related branches found
No related tags found
Loading
Pipeline
#23805
passed
4 years ago
Stage: test
Changes
2
Pipelines
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
rabotnikobm/rules/get_building_land_use.py
+41
-0
41 additions, 0 deletions
rabotnikobm/rules/get_building_land_use.py
tests/test_get_building_land_use.py
+33
-0
33 additions, 0 deletions
tests/test_get_building_land_use.py
with
74 additions
and
0 deletions
rabotnikobm/rules/get_building_land_use.py
0 → 100644
+
41
−
0
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
This diff is collapsed.
Click to expand it.
tests/test_get_building_land_use.py
0 → 100644
+
33
−
0
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
"
,)]
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