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
+ 6
5
Compare changes
  • Side-by-side
  • Inline
# Copyright (c) 2023-2024:
# Copyright (c) 2024:
# Helmholtz-Zentrum Potsdam Deutsches GeoForschungsZentrum GFZ
#
# This program is free software: you can redistribute it and/or modify it
@@ -13,11 +13,12 @@
#
# 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 databaselib import PostGISDatabase
from rulelib import AbstractRule
class DateFromValencianCadasterRule(AbstractRule):
from databaselib import PostGISDatabase
def __call__(self, database: PostGISDatabase, geometry: str, *args, **kwargs):
"""
@@ -34,17 +35,17 @@ class DateFromValencianCadasterRule(AbstractRule):
tables `parcels` and `cadaster_buildings`.
geometry (str):
Geometry of the building being currently processed. The geometry is a WKT
formatted string wrapped in th `ST_GeomFromText()` function.
formatted string wrapped in the `ST_GeomFromText()` function.
Returns:
Integer that represents the building's construction year.
Integer that represents the building's year of construction.
"""
sql_statement = f"""
SELECT construction_year
FROM Parcels
INNER JOIN cadaster_buildings USING parcel_id
INNER JOIN cadaster_buildings USING(parcel_id)
WHERE ST_Intersects({geometry}, Parcels.geom)
"""
database.cursor.execute(sql_statement)
Loading