Aufräumen des etl_property_neighbours

Kommentare gelöscht und haversineFormel angepasst, dass sie gleich wie in der Quelle ist
main
mmaurostoffel 2025-01-19 11:54:22 +01:00
parent 41f8c89178
commit cdb92ac50f
1 changed files with 2 additions and 3 deletions

View File

@ -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)