Skip to content
GitLab
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
212b25cf
Commit
212b25cf
authored
Oct 18, 2021
by
Marius Kriegerowski
Browse files
include csv in package
parent
b6484603
Changes
4
Hide whitespace changes
Inline
Side-by-side
MANIFEST.in
0 → 100644
View file @
212b25cf
include rules/gem_occupancy/data/*.csv
include LICENSE
rabotnikobm/instance.py
View file @
212b25cf
...
...
@@ -24,7 +24,7 @@ import argparse
from
rabotnik
import
Rabotnik
,
Assembly
from
rabotnik.bus
import
MessageBus
from
rabotnikobm.rules.gem_occupancy.
mapping
import
Occupancy
Mapper
from
rabotnikobm.rules.gem_occupancy.
get_building_occupancy
import
GetBuilding
Occupancy
from
.rules
import
GetBuilding
from
.rules
import
GetFloorspace
...
...
@@ -62,15 +62,10 @@ async def start_rabotnik_obm(message_bus):
await
message_bus
.
subscribe
(
"building"
,
rules
.
run
)
async
def
start_rabotnik_gem_occupancy
(
message_bus
,
storage_consumer
,
storage_contributor
,
n_processes_max
):
fn_mapping
=
"building_and_PoIs_tags.csv"
occupancy_mapper
=
OccupancyMapper
.
from_csv
(
fn
=
fn_mapping
)
async
def
start_rabotnik_gem_occupancy
(
message_bus
,
storage_consumer
,
_
,
n_processes_max
):
rules
=
[
GetBuildingOccupancy
(
storage_consumer
,
occupancy_mapper
=
occupancy_mapper
),
GetBuildingOccupancy
(
storage_consumer
),
]
rules
=
Assembly
(
rules
=
rules
,
n_processes_max
=
n_processes_max
)
...
...
@@ -82,9 +77,13 @@ async def start_rabotnik(args):
message_bus
=
await
connected_message_bus
(
args
.
config_message_bus
)
# await start_rabotnik_obm(
# message_bus, storage_consumer, storage_contributor, args.n_processes_max
# )
rabotnik_args
=
(
message_bus
,
storage_consumer
,
storage_contributor
,
args
.
n_processes_max
)
if
args
.
target
in
(
"all"
,
"obm"
):
asyncio
.
create_task
(
start_rabotnik_obm
(
*
rabotnik_args
))
if
args
.
target
in
(
"all"
,
"gem"
):
asyncio
.
create_task
(
start_rabotnik_gem_occupancy
(
*
rabotnik_args
))
def
main
():
...
...
@@ -108,6 +107,15 @@ def main():
"--start-celery-worker"
,
action
=
"store_true"
,
)
parser
.
add_argument
(
"-t"
,
"--target"
,
default
=
"all"
,
type
=
str
,
help
=
"Process to start (defaults to 'all')"
,
)
args
=
parser
.
parse_args
()
default_log_level
=
logging
.
WARNING
...
...
rabotnikobm/rules/gem_occupancy/get_building_occupancy.py
View file @
212b25cf
...
...
@@ -109,12 +109,12 @@ class RulesOneUniqueSubGroup:
class
GetBuildingOccupancy
(
Rule
):
"""A rule to map OSM tags to building occupancies."""
def
__init__
(
self
,
storage
:
StorageBase
,
occupancy_mapper
:
OccupancyMapper
):
def
__init__
(
self
,
storage
:
StorageBase
):
self
.
storage
=
storage
self
.
mappers
=
[
o
ccupancy
_m
apper
.
landuse_mapper
(),
o
ccupancy
_m
apper
.
building_poi_mapper
(),
O
ccupancy
M
apper
.
landuse_mapper
(),
O
ccupancy
M
apper
.
building_poi_mapper
(),
]
self
.
candidates
=
[
...
...
@@ -130,14 +130,15 @@ class GetBuildingOccupancy(Rule):
f
"SELECT tags FROM osm_building_relations WHERE osm_id=
{
building_id
}
AND index=0"
)
# Mapping to GEM taxonom
ie
s
# Mapping to GEM taxonom
y string
s
occupancies
=
[]
for
mapper
in
self
.
mappers
:
occupancies
.
extend
(
mapper
.
apply
(
tags
))
# Convert derived occupancies to GEMTags
occupancies
=
TagStatistics
.
from_strings
(
occupancies
)
# Apply rules to find
ultimate
taxonomy
# Apply rules to find
final
taxonomy
occupancy
=
apply_rules
(
self
.
candidates
,
occupancies
)
logger
.
debug
(
"occupancies %s: %s"
,
building_id
,
occupancy
)
...
...
setup.py
View file @
212b25cf
...
...
@@ -33,7 +33,8 @@ setup(
"tests"
:
tests_require
,
"linters"
:
linters_require
,
},
packages
=
find_packages
(),
entry_points
=
{
"console_scripts"
:
[
"rabotnikobm = rabotnikobm.instance:main"
]},
python_requires
=
">=3.6"
,
packages
=
find_packages
(),
include_package_data
=
True
,
)
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment