diff --git a/config/migrations/2026/20260417120000-feat--add-vlaams-gewest-werkingsgebied/20260417120002-link-flemish-werkingsgebieden-to-vlaams-gewest.sparql b/config/migrations/2026/20260417120000-feat--add-vlaams-gewest-werkingsgebied/20260417120002-link-flemish-werkingsgebieden-to-vlaams-gewest.sparql new file mode 100644 index 0000000..d485b6c --- /dev/null +++ b/config/migrations/2026/20260417120000-feat--add-vlaams-gewest-werkingsgebied/20260417120002-link-flemish-werkingsgebieden-to-vlaams-gewest.sparql @@ -0,0 +1,85 @@ +PREFIX prov: +PREFIX geo: +PREFIX ext: +PREFIX rdfs: +PREFIX org: +PREFIX besluit: + +# 1) Link the 5 Flemish province werkingsgebieden themselves to Vlaams Gewest +INSERT { + GRAPH { + ?provWg geo:sfWithin ?vlaamsGewest . + } +} WHERE { + GRAPH { + ?vlaamsGewest a prov:Location ; + ext:werkingsgebiedNiveau "Gewest" ; + rdfs:label "Vlaams Gewest" . + } + GRAPH { + ?province a besluit:Bestuurseenheid ; + org:classification . + } + GRAPH { + ?province besluit:werkingsgebied ?provWg . + } + FILTER NOT EXISTS { + GRAPH { + ?provWg geo:sfWithin ?vlaamsGewest . + } + } +} ; + +# 2) Link Flemish municipality werkingsgebieden to Vlaams Gewest +# Selector: any Gemeente-level location whose sfWithin is a werkingsgebied +# belonging to a Bestuurseenheid classified as Provincie (i.e. a Flemish province). +# Brussels has no provinces, and there are no Waals-Gewest provinces in OP, +# so "classified as Provincie" == "Flemish province". +INSERT { + GRAPH { + ?munWg geo:sfWithin ?vlaamsGewest . + } +} WHERE { + GRAPH { + ?vlaamsGewest a prov:Location ; + ext:werkingsgebiedNiveau "Gewest" ; + rdfs:label "Vlaams Gewest" . + ?munWg a prov:Location ; + ext:werkingsgebiedNiveau "Gemeente" ; + geo:sfWithin ?provWg . + } + GRAPH { + ?province a besluit:Bestuurseenheid ; + org:classification . + } + GRAPH { + ?province besluit:werkingsgebied ?provWg . + } + FILTER NOT EXISTS { + GRAPH { + ?munWg geo:sfWithin ?vlaamsGewest . + } + } +} ; + +# 3) Link all District and Referentieregio werkingsgebieden to Vlaams Gewest +# All districts and referentieregios in the data are Flemish by scope; +# no further filtering required. +INSERT { + GRAPH { + ?wg geo:sfWithin ?vlaamsGewest . + } +} WHERE { + GRAPH { + ?vlaamsGewest a prov:Location ; + ext:werkingsgebiedNiveau "Gewest" ; + rdfs:label "Vlaams Gewest" . + ?wg a prov:Location ; ext:werkingsgebiedNiveau ?niveau . + VALUES ?niveau { "District" "Referentieregio" } + } + FILTER NOT EXISTS { + GRAPH { + ?wg geo:sfWithin ?vlaamsGewest . + } + } +}