SELECT DISTINCT ?city ?cityLabel
(GROUP_CONCAT(DISTINCT ?decodedImage; separator="; ") AS ?images)
(GROUP_CONCAT(DISTINCT ?decodedCapitalTitle; separator="; ") AS ?capitals)
(GROUP_CONCAT(DISTINCT ?decodedLocationTitle; separator="; ") AS ?locations)
(GROUP_CONCAT(DISTINCT ?decodedContainsTitle; separator="; ") AS ?containedPlaces)
(GROUP_CONCAT(DISTINCT ?decodedMap; separator="; ") AS ?maps)
(GROUP_CONCAT(DISTINCT ?households; separator="; ") AS ?numberOfHouseholds)
WHERE {
?city wdt:P31 wd:Q137535 . # county of Iran
OPTIONAL {
?article_ckb schema:about ?city.
?article_ckb schema:inLanguage "ckb".
?article_ckb schema:isPartOf <https://ckb.wikipedia.org/>.
}
OPTIONAL {
?city wdt:P18 ?image.
BIND(REPLACE(wikibase:decodeUri(SUBSTR(STR(?image), STRLEN("http://commons.wikimedia.org/wiki/Special:FilePath/") + 1)), "_", " ") AS ?decodedImage)
}
OPTIONAL {
?city wdt:P242 ?map.
BIND(REPLACE(wikibase:decodeUri(SUBSTR(STR(?map), STRLEN("http://commons.wikimedia.org/wiki/Special:FilePath/") + 1)), "_", " ") AS ?decodedMap)
}
OPTIONAL {
?city wdt:P36 ?capital.
OPTIONAL {
?article_fa_capital schema:about ?capital;
schema:isPartOf <https://fa.wikipedia.org/>.
BIND(REPLACE(wikibase:decodeUri(STRAFTER(STR(?article_fa_capital), "https://fa.wikipedia.org/wiki/")), "_", " ") AS ?decodedCapitalTitle)
}
}
OPTIONAL {
?city wdt:P131 ?location.
OPTIONAL {
?article_fa_location schema:about ?location;
schema:isPartOf <https://fa.wikipedia.org/>.
BIND(REPLACE(wikibase:decodeUri(STRAFTER(STR(?article_fa_location), "https://fa.wikipedia.org/wiki/")), "_", " ") AS ?decodedLocationTitle)
}
}
OPTIONAL {
?city wdt:P150 ?contains.
OPTIONAL {
?article_fa_contains schema:about ?contains;
schema:isPartOf <https://fa.wikipedia.org/>.
BIND(REPLACE(wikibase:decodeUri(STRAFTER(STR(?article_fa_contains), "https://fa.wikipedia.org/wiki/")), "_", " ") AS ?decodedContainsTitle)
}
}
OPTIONAL {
?city wdt:P1538 ?households.
}
FILTER(!BOUND(?article_ckb)) # Exclude cities with articles in ckb Wikipedia
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
GROUP BY ?city ?cityLabel
ORDER BY ?cityLabel