Skip to content
Snippets Groups Projects

Resolve "Create a rule that gets the construction date from cadaster data for Tabula dataset."

Compare and Show latest version
1 file
+ 7
26
Compare changes
  • Side-by-side
  • Inline
@@ -33,16 +33,9 @@ class OccupancyRule(AbstractRule):
extended_tags = [tags] + osm_spots + osm_lands
occupancies = self.occupancies_from_tags(extended_tags)
unique_occupancies_level_0 = set(
[occupancy.level_0 for occupancy in occupancies]
)
unique_occupancies_level_0 = set([occupancy.level_0 for occupancy in occupancies])
unique_occupancies_level_1 = set(
[
occupancy.detail_1
for occupancy in occupancies
if occupancy.detail_1 != ""
]
)
[occupancy.detail_1 for occupancy in occupancies if occupancy.detail_1 != ""])
# Rule no occupancies
# If there are no occupancies, return `unknown`
@@ -63,10 +56,7 @@ class OccupancyRule(AbstractRule):
# Rule two tags; same level 1
# If there is one unique level 0 and one unique level 1 (which implies that the
# unique level 1 has the same level 0 as the unique level 0), returns level 1.
if (
len(unique_occupancies_level_0) == 1
and len(unique_occupancies_level_1) <= 1
):
if len(unique_occupancies_level_0) == 1 and len(unique_occupancies_level_1) <= 1:
for occ in occupancies:
if occ.detail_1 != "" or len(unique_occupancies_level_1) == 0:
return {"occupancy": occ.level_1}
@@ -89,9 +79,7 @@ class OccupancyRule(AbstractRule):
# "COM2" and/or "COM3" and/or "COM5" and/or "COM7" and/or "COM11" and/or "ASS3".
if all(occ.level_1 in ["COM1", "COM5", "COM"] for occ in occupancies):
return {"occupancy": "COM1"}
com_1_occurance = sum(
map(lambda occ: 1 if occ.level_1 == "COM1" else 0, occupancies)
)
com_1_occurance = sum(map(lambda occ: 1 if occ.level_1 == "COM1" else 0, occupancies))
if com_1_occurance >= 2 and all(
occ.level_0 == "COM" or occ.level_1 == "ASS3" for occ in occupancies
@@ -111,10 +99,7 @@ class OccupancyRule(AbstractRule):
# commercial").
if (
"RES" in unique_occupancies_level_0
and (
"COM" in unique_occupancies_level_0
or "ASS" in unique_occupancies_level_0
)
and ("COM" in unique_occupancies_level_0 or "ASS" in unique_occupancies_level_0)
and all(
occ.level_0 == "RES"
or occ.level_1 in ["COM", "COM1", "COM3", "COM5", "ASS3"]
@@ -132,8 +117,7 @@ class OccupancyRule(AbstractRule):
and "COM" in unique_occupancies_level_0
and all(
occ.level_0 == "IND"
or occ.level_1
in ["COM", "COM1", "COM2", "COM3", "COM5", "COM7", "COM11"]
or occ.level_1 in ["COM", "COM1", "COM2", "COM3", "COM5", "COM7", "COM11"]
for occ in occupancies
)
):
@@ -456,10 +440,7 @@ class OccupancyRule(AbstractRule):
("building:type", "apartments"): "RES2",
("building:type", "barn"): "AGR1",
("building:type", "dwelling_house"): "RES1",
(
"building:type",
"garage",
): "COM7", # Add extension RES7|COM7 in next version
("building:type", "garage"): "COM7", # Add extension RES7|COM7 in next version
("building:type", "greenhouse"): "AGR3",
("building:type", "house"): "RES1",
("building:type", "residential"): "RES",
Loading