Skip to content

Commit 440bb85

Browse files
authored
Merge pull request #155 from Datenschule/hh-locations
[HH] Persist locations
2 parents 9f0e9a0 + 5d396cc commit 440bb85

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Changelog
2+
3+
## 2025-04-22
4+
- [HH]: The data now includes the location information from the WFS, filling the `location` field in the database
5+
for the city of Hamburg for the first time

jedeschule/spiders/hamburg.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,29 @@ class HamburgSpider(SchoolSpider):
1010
name = "hamburg"
1111

1212
start_urls = [
13-
"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"
13+
"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"
1414
]
1515

16+
1617
def parse(self, response):
18+
namespaces = {
19+
"gml": "http://www.opengis.net/gml",
20+
}
21+
1722
elem = ET.fromstring(response.body)
1823

1924
for member in elem:
2025
data_elem = {}
2126
for attr in member[0]:
27+
if attr.tag == "{https://registry.gdi-de.org/id/de.hh.up}the_geom":
28+
# This nested entry contains the coordinates that we would like to expand
29+
lon, lat = attr.findtext(
30+
"gml:Point/gml:pos", namespaces=namespaces
31+
).split(" ")
32+
data_elem["lat"] = lat
33+
data_elem["lon"] = lon
34+
continue
35+
# strip the namespace before returning
2236
data_elem[attr.tag.split("}", 1)[1]] = attr.text
2337
yield data_elem
2438

@@ -39,4 +53,6 @@ def normalize(item: Item) -> School:
3953
fax=item.get("fax"),
4054
phone=item.get("schul_telefonnr"),
4155
director=item.get("name_schulleiter"),
56+
latitude=item.get("lat"),
57+
longitude=item.get("lon"),
4258
)

0 commit comments

Comments
 (0)