From cdb92ac50f03307d655cc6f844e7b8ed59910751 Mon Sep 17 00:00:00 2001 From: mmaurostoffel <166130318+mmaurostoffel@users.noreply.github.com> Date: Sun, 19 Jan 2025 11:54:22 +0100 Subject: [PATCH] =?UTF-8?q?Aufr=C3=A4umen=20des=20etl=5Fproperty=5Fneighbo?= =?UTF-8?q?urs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Kommentare gelöscht und haversineFormel angepasst, dass sie gleich wie in der Quelle ist --- etl/src/data/etl_property_neighbours.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/etl/src/data/etl_property_neighbours.py b/etl/src/data/etl_property_neighbours.py index b861232..02806f2 100644 --- a/etl/src/data/etl_property_neighbours.py +++ b/etl/src/data/etl_property_neighbours.py @@ -19,11 +19,12 @@ def calcHaversinDistance(latMain, lonMain, lat, lon): dlat = latMain - lat a = sin(dlat / 2) ** 2 + cos(lat) * cos(latMain) * sin(dlon / 2) ** 2 - c = 2 * asin(sqrt(a)) # 2 * atan2(sqrt(a), sqrt(1-a)) + c = 2 * atan2(sqrt(a), sqrt(1-a)) d = R * c return d + def property_neighbours(id: int): file = f"etl_property_neighbours_{id}.obj" @@ -46,7 +47,6 @@ def property_neighbours(id: int): extractions = extractions.filter(pl.col('id') != str(id)) # Split coordinate into lat and lon - #extractions = extractions.with_columns((pl.col('coordinates').str.split(','))[0].alias("coordinates")).unnest("fields") extractions = extractions.with_columns(pl.col("coordinates").str.split_exact(",", 1).struct.rename_fields(["lat", "lon"]).alias("lat/lon")).unnest("lat/lon") extractions = extractions.drop('coordinates') extractions = extractions.with_columns(pl.col("lat").cast(pl.Float32)) @@ -67,7 +67,6 @@ def property_neighbours(id: int): extractions = extractions.sort("distances").head(10) extractions = extractions.drop('distances') - #result = {"ids": extractions['id'].to_list(), "lat": extractions['lat'].to_list(), "lon": extractions['lon'].to_list()} result = extractions.to_dicts() etl_cache.saveObj(file, result)