mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 21:03:54 +01:00
* Try to get the localized version of the wikipedia article before defaulting to the English version. Tested with Spanish on physical Android device. Other notes: Difficulties building with gradle due to dexcount plugin: https://github.com/KeepSafe/dexcount-gradle-plugin/issues/234. In testing, disabled the plugin. * Update article fetch to not include unnecessary SERVICE line
60 lines
No EOL
2.5 KiB
SPARQL
60 lines
No EOL
2.5 KiB
SPARQL
SELECT
|
|
(SAMPLE(?location) as ?location)
|
|
?item
|
|
(SAMPLE(COALESCE(?item_label_preferred_language, ?item_label_any_language)) as ?label)
|
|
(SAMPLE(?classId) as ?class)
|
|
(SAMPLE(COALESCE(?class_label_preferred_language, ?class_label_any_language, "?")) as ?class_label)
|
|
(SAMPLE(COALESCE(?icon0, ?icon1)) as ?icon)
|
|
(SAMPLE(COALESCE(?emoji0, ?emoji1)) as ?emoji)
|
|
?wikipediaArticle
|
|
?commonsArticle
|
|
(SAMPLE(?Commons_category) as ?Commons_category)
|
|
WHERE {
|
|
# Around given location...
|
|
SERVICE wikibase:around {
|
|
?item wdt:P625 ?location.
|
|
bd:serviceParam wikibase:center "Point(${LONG} ${LAT})"^^geo:wktLiteral.
|
|
bd:serviceParam wikibase:radius "${RAD}" . # Radius in kilometers.
|
|
}
|
|
|
|
# ... and without an image.
|
|
MINUS {?item wdt:P18 []}
|
|
|
|
# Get the label in the preferred language of the user, or any other language if no label is available in that language.
|
|
OPTIONAL {?item rdfs:label ?item_label_preferred_language. FILTER (lang(?item_label_preferred_language) = "${LANG}")}
|
|
OPTIONAL {?item rdfs:label ?item_label_any_language}
|
|
|
|
# Get Commons category (P373)
|
|
OPTIONAL { ?item wdt:P373 ?Commons_category. }
|
|
|
|
# Get the class label in the preferred language of the user, or any other language if no label is available in that language.
|
|
OPTIONAL {
|
|
?item p:P31/ps:P31 ?classId.
|
|
OPTIONAL {?classId rdfs:label ?class_label_preferred_language. FILTER (lang(?class_label_preferred_language) = "${LANG}")}
|
|
OPTIONAL {?classId rdfs:label ?class_label_any_language}
|
|
|
|
# Get icon
|
|
OPTIONAL { ?classId wdt:P2910 ?icon0. }
|
|
OPTIONAL { ?classId wdt:P279*/wdt:P2910 ?icon1. }
|
|
# Get emoji
|
|
OPTIONAL { ?classId wdt:P487 ?emoji0. }
|
|
OPTIONAL { ?classId wdt:P279*/wdt:P487 ?emoji1. }
|
|
|
|
OPTIONAL {
|
|
?wikipediaArticle schema:about ?item ;
|
|
schema:isPartOf <https://${LANG}.wikipedia.org/> .
|
|
}
|
|
OPTIONAL {
|
|
?wikipediaArticle schema:about ?item ;
|
|
schema:isPartOf <https://en.wikipedia.org/> .
|
|
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
|
|
}
|
|
|
|
OPTIONAL {
|
|
?commonsArticle schema:about ?item ;
|
|
schema:isPartOf <https://commons.wikimedia.org/> .
|
|
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
|
|
}
|
|
}
|
|
}
|
|
GROUP BY ?item ?wikipediaArticle ?commonsArticle |