Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 2025-04-30
- [BY]: Latitude and Longitude were swapped in the database. This has been fixed.
- [NW]: Latitude and Longitude were swapped in the database. This has been fixed.

## 2025-04-22
- [HH]: The data now includes the location information from the WFS, filling the `location` field in the database
for the city of Hamburg for the first time
2 changes: 1 addition & 1 deletion jedeschule/spiders/bayern.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def parse_resource(self, response, feature):

for entry in school:
if entry.tag == "{http://gdi.bayern/brbschul}geometry":
lat, lon = entry.findtext(
lon, lat = entry.findtext(
"gml:Point/gml:pos", namespaces=namespaces
).split(" ")
data_elem["lat"] = lat
Expand Down
2 changes: 1 addition & 1 deletion jedeschule/spiders/nordrhein_westfalen.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def normalize(item: Item) -> School:
source_crs = item.get("EPSG")
if source_crs == "null":
source_crs = "EPSG:25832"
transformer = Transformer.from_crs(source_crs, "EPSG:4326")
transformer = Transformer.from_crs(source_crs, "EPSG:4326", always_xy=True)
lon, lat = transformer.transform(right, high)

return School(
Expand Down
34 changes: 19 additions & 15 deletions test_changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,39 @@ def fetch_data(school_id):
return response.json()


def sort_dict(data):
return {key: value for key, value in sorted(data.items(), key=lambda k: k[0])}


def get_clean_item(data):
return set(
{
return {
key: value
for key, value in data.items()
if value is not None and key != "update_timestamp"
}
)


def compare_schools(new_school, old_school):
new_school = sort_dict(new_school)
old_school = sort_dict(old_school)
def dict_diff(dict1, dict2):
all_keys = set(dict1.keys()) | set(dict2.keys())

differences = {}
for key in all_keys:
val1 = dict1.get(key, None)
val2 = dict2.get(key, None)

if val1 != val2:
differences[key] = (val1, val2)

return differences


def compare_schools(new_school, old_school):
new_values = get_clean_item(new_school)
old_values = get_clean_item(old_school)

differences = new_values ^ old_values
if not differences:
differences = dict_diff(new_values, old_values)
if len(differences) == 0:
print(" no changes \n")
return

print(f"Difference: {differences}")
print(f"Old: {old_school}")
print(f"New: {new_school}")
print(f"Difference found:")
print(json.dumps(differences, indent=2))


def main():
Expand Down