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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Changelog

## 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
18 changes: 17 additions & 1 deletion jedeschule/spiders/hamburg.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,29 @@ class HamburgSpider(SchoolSpider):
name = "hamburg"

start_urls = [
"https://geodienste.hamburg.de/HH_WFS_Schulen?SERVICE=WFS&VERSION=1.1.0&REQUEST=GetFeature&typename=de.hh.up:nicht_staatliche_schulen,de.hh.up:staatliche_schulen"
"https://geodienste.hamburg.de/HH_WFS_Schulen?SERVICE=WFS&VERSION=1.1.0&REQUEST=GetFeature&typename=de.hh.up:nicht_staatliche_schulen,de.hh.up:staatliche_schulen&srsname=EPSG:4326"
]


def parse(self, response):
namespaces = {
"gml": "http://www.opengis.net/gml",
}

elem = ET.fromstring(response.body)

for member in elem:
data_elem = {}
for attr in member[0]:
if attr.tag == "{https://registry.gdi-de.org/id/de.hh.up}the_geom":
# This nested entry contains the coordinates that we would like to expand
lon, lat = attr.findtext(
"gml:Point/gml:pos", namespaces=namespaces
).split(" ")
data_elem["lat"] = lat
data_elem["lon"] = lon
continue
# strip the namespace before returning
data_elem[attr.tag.split("}", 1)[1]] = attr.text
yield data_elem

Expand All @@ -39,4 +53,6 @@ def normalize(item: Item) -> School:
fax=item.get("fax"),
phone=item.get("schul_telefonnr"),
director=item.get("name_schulleiter"),
latitude=item.get("lat"),
longitude=item.get("lon"),
)