Commit e9a62503 authored by Jonas Waeber's avatar Jonas Waeber

Remove town labels from list.

parent bbef1653
......@@ -26,28 +26,56 @@ WHERE
https://query.wikidata.org/
```sparql
SELECT ?item (GROUP_CONCAT(DISTINCT ?postalCode; SEPARATOR=",") as ?groupedPostalCode) ?adminUnit ?labelDE ?labelFR ?labelIT (GROUP_CONCAT(DISTINCT ?coordinates; SEPARATOR=",") as ?groupedCoordinates)
```sql
SELECT ?item (GROUP_CONCAT(DISTINCT ?postalCode; SEPARATOR=",") as ?groupedPostalCode) ?canton (GROUP_CONCAT(DISTINCT ?coordinates; SEPARATOR=",") as ?groupedCoordinates)
WHERE
{
?item wdt:P31 wd:Q70208. # swiss municipalities
?item wdt:P281 ?postalCode .
?item wdt:P625 ?coordinates .
?item wdt:P131 ?adminUnit .
?adminUnit wdt:P31 wd:Q23058 . # adminUnit is canton of switzerland
?item wdt:P131 ?canton .
?canton wdt:P31 wd:Q23058 . # adminUnit is canton of switzerland
?item rdfs:label ?labelDE .
FILTER(LANG(?labelDE) = "de")
MINUS {
?item wdt:P31 wd:Q685309 # removes former municipalities
}
?item rdfs:label ?labelFR .
FILTER(LANG(?labelFR) = "fr")
}
GROUP BY ?item ?canton
```
### More Complete Query
```sql
SELECT ?item (GROUP_CONCAT(DISTINCT ?postalCode; SEPARATOR=",") as ?groupedPostalCode) ?canton ?labelDE ?labelFR ?labelIT (GROUP_CONCAT(DISTINCT ?coordinates; SEPARATOR=",") as ?groupedCoordinates)
WHERE
{
?item wdt:P31 wd:Q70208. # swiss municipalities
OPTIONAL { ?item wdt:P281 ?postalCode . }
?item wdt:P625 ?coordinates .
OPTIONAL {
?item wdt:P131 ?canton .
?canton wdt:P31 wd:Q23058 . # adminUnit is canton of switzerland
}
?item rdfs:label ?labelIT .
FILTER(LANG(?labelIT) = "it")
OPTIONAL {
?item rdfs:label ?labelDE .
FILTER(LANG(?labelDE) = "de")
}
OPTIONAL {
?item rdfs:label ?labelFR .
FILTER(LANG(?labelFR) = "fr")
}
OPTIONAL {
?item rdfs:label ?labelIT .
FILTER(LANG(?labelIT) = "it")
}
MINUS {
?item wdt:P31 wd:Q685309 # removes former municipalities
}
}
GROUP BY ?item ?adminUnit ?labelDE ?labelFR ?labelIT
GROUP BY ?item ?canton ?labelDE ?labelFR ?labelIT
```
\ No newline at end of file
......@@ -20,9 +20,6 @@ object Helpers {
values[1].trim('"').split(",").map { code -> code.trim() },
values[2].trim('<', '>'),
values[0].trim('<', '>'),
values[3].replace("@de", "").trim('"'),
values[4].replace("@fr", "").trim('"'),
values[5].replace("@it", "").trim('"'),
values[6].split(",")
)
}.map { municipality ->
......
......@@ -4,8 +4,5 @@ data class Municipality(
val postalCodes: List<String>,
val canton: String,
val id: String,
val de: String,
val fr: String,
val it: String,
val coordinates: List<String>
)
\ No newline at end of file
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment