Wikipedia:ProyekWiki Bahasa/pemeliharaan/peta/rawdata
Tampilan
function makeSPARQLQuery( endpointUrl, sparqlQuery, doneCallback ) {
var settings = {
headers: { Accept: 'application/sparql-results+json' },
data: { query: sparqlQuery }
};
return $.ajax( endpointUrl, settings ).then( doneCallback );
}
var endpointUrl = 'https://query.wikidata.org/sparql',
sparqlQuery = "#defaultView:Map\n" +
" SELECT ?id ?idLabel ?head\n" +
" (SAMPLE(?pop) AS ?populasi)\n" +
" (SAMPLE(?ison) AS ?iso)\n" +
" (SAMPLE(?glotton) AS ?glotto)\n" +
" (SAMPLE(?img) AS ?img_)\n" +
" (SAMPLE(?gmbr) AS ?gmbr_)\n" +
" (MIN(?partyId) AS ?geo)\n" +
" (CONCAT('[[:id:', SUBSTR(STR(?link2), 31), '{{!}}', ?idLabel, ']]') AS ?title)\n" +
" (IF (BOUND(?populasi), \n" +
" IF (BOUND(?glotto),\n" +
" IF (BOUND(?iso),\n" +
" IF (BOUND(?gmbr_),\n" +
" CONCAT('[[:id:', SUBSTR(STR(?link), 31), '{{!}}', ?headLabel, ']]',\n" +
" '[[File:', SUBSTR(STR(?gmbr_), 52, 400), '{{!}}200px]]',\n" +
" '<small><hr>Populasi:',?populasi, '<hr>Informasi kode bahasa:<br>[[ISO639-3:', ?iso, '{{!}}', ?iso, ']] {{*}} ',\n" +
" '[https://glottolog.org/resource/languoid/id/', ?glotto, ' ', ?glotto, ']</small>'),\n" +
" IF (BOUND(?img_),\n" +
" CONCAT('[[:id:', SUBSTR(STR(?link), 31), '{{!}}', ?headLabel, ']]',\n" +
" '[[File:', SUBSTR(STR(?img_), 52, 400), '{{!}}200px]]',\n" +
" '<small><hr>Populasi:',?populasi, '<hr>Informasi kode bahasa:<br>[[ISO639-3:', ?iso, '{{!}}', ?iso, ']] {{*}} ',\n" +
" '[https://glottolog.org/resource/languoid/id/', ?glotto, ' ', ?glotto, ']</small>'),\n" +
" CONCAT('[[:id:', SUBSTR(STR(?link), 31), '{{!}}', ?headLabel, ']]',\n" +
" '<small><hr>Populasi:',?populasi, '<hr>Informasi kode bahasa:<br>[[ISO639-3:', ?iso, '{{!}}', ?iso, ']] {{*}} ',\n" +
" '[https://glottolog.org/resource/languoid/id/', ?glotto, ' ', ?glotto, ']</small>')\n" +
" )),\n" +
" IF (BOUND(?gmbr_),\n" +
" CONCAT('[[:id:', SUBSTR(STR(?link), 31), '{{!}}', ?headLabel, ']]',\n" +
" '[[File:', SUBSTR(STR(?gmbr_), 52, 400), '{{!}}200px]]',\n" +
" '<small><hr>Populasi:',?populasi, '<hr>Informasi kode bahasa:<br>[[ISO639-3:xx{{!}}Belum tersedia]] {{*}} ',\n" +
" '[https://glottolog.org/resource/languoid/id/', ?glotto, ' ', ?glotto, ']</small>'),\n" +
" IF (BOUND(?img_),\n" +
" CONCAT('[[:id:', SUBSTR(STR(?link), 31), '{{!}}', ?headLabel, ']]',\n" +
" '[[File:', SUBSTR(STR(?img_), 52, 400), '{{!}}200px]]',\n" +
" '<small><hr>Populasi:',?populasi, '<hr>Informasi kode bahasa:<br>[[ISO639-3:xx{{!}}Belum tersedia]] {{*}} ',\n" +
" '[https://glottolog.org/resource/languoid/id/', ?glotto, ' ', ?glotto, ']</small>'),\n" +
" CONCAT('[[:id:', SUBSTR(STR(?link), 31), '{{!}}', ?headLabel, ']]',\n" +
" '<small><hr>Populasi:',?populasi, '<hr>Informasi kode bahasa:<br>[[ISO639-3:xx{{!}}Belum tersedia]] {{*}} ',\n" +
" '[https://glottolog.org/resource/languoid/id/', ?glotto, ' ', ?glotto, ']</small>')\n" +
" ))),\n" +
" IF (BOUND(?gmbr_),\n" +
" CONCAT('[[:id:', SUBSTR(STR(?link), 31), '{{!}}', ?headLabel, ']]',\n" +
" '[[File:', SUBSTR(STR(?gmbr_), 52, 400), '{{!}}200px]]',\n" +
" '<small><hr>Populasi:',?populasi, '<hr>Informasi kode bahasa:<br><i>Tidak tersedia</i></small>'),\n" +
" IF (BOUND(?img_),\n" +
" CONCAT('[[:id:', SUBSTR(STR(?link), 31), '{{!}}', ?headLabel, ']]',\n" +
" '[[File:', SUBSTR(STR(?img_), 52, 400), '{{!}}200px]]',\n" +
" '<small><hr>Populasi:',?populasi, '<hr>Informasi kode bahasa:<br><i>Tidak tersedia</i></small>'),\n" +
" CONCAT('[[:id:', SUBSTR(STR(?link), 31), '{{!}}', ?headLabel, ']]',\n" +
" '<small><hr>Populasi:',?populasi, '<hr>Informasi kode bahasa:<br><i>Tidak tersedia</i></small>')\n" +
" )\n" +
" )\n" +
" ), \n" +
" IF (BOUND(?glotto),\n" +
" IF (BOUND(?iso),\n" +
" IF (BOUND(?gmbr_),\n" +
" CONCAT('[[:id:', SUBSTR(STR(?link), 31), '{{!}}', ?headLabel, ']]',\n" +
" '[[File:', SUBSTR(STR(?gmbr_), 52, 400), '{{!}}200px]]',\n" +
" '<small><hr>Informasi kode bahasa:<br>[[ISO639-3:', ?iso, '{{!}}', ?iso, ']] {{*}} ',\n" +
" '[https://glottolog.org/resource/languoid/id/', ?glotto, ' ', ?glotto, ']</small>'),\n" +
" IF (BOUND(?img_),\n" +
" CONCAT('[[:id:', SUBSTR(STR(?link), 31), '{{!}}', ?headLabel, ']]',\n" +
" '[[File:', SUBSTR(STR(?img_), 52, 400), '{{!}}200px]]',\n" +
" '<small><hr>Informasi kode bahasa:<br>[[ISO639-3:', ?iso, '{{!}}', ?iso, ']] {{*}} ',\n" +
" '[https://glottolog.org/resource/languoid/id/', ?glotto, ' ', ?glotto, ']</small>'),\n" +
" CONCAT('[[:id:', SUBSTR(STR(?link), 31), '{{!}}', ?headLabel, ']]',\n" +
" '<small><hr>Informasi kode bahasa:<br>[[ISO639-3:', ?iso, '{{!}}', ?iso, ']] {{*}} ',\n" +
" '[https://glottolog.org/resource/languoid/id/', ?glotto, ' ', ?glotto, ']</small>')\n" +
" )),\n" +
" IF (BOUND(?gmbr_),\n" +
" CONCAT('[[:id:', SUBSTR(STR(?link), 31), '{{!}}', ?headLabel, ']]',\n" +
" '[[File:', SUBSTR(STR(?gmbr_), 52, 400), '{{!}}200px]]',\n" +
" '<small><hr>Informasi kode bahasa:<br>[[ISO639-3:xx{{!}}Belum tersedia]] {{*}} ',\n" +
" '[https://glottolog.org/resource/languoid/id/', ?glotto, ' ', ?glotto, ']</small>'),\n" +
" IF (BOUND(?img_),\n" +
" CONCAT('[[:id:', SUBSTR(STR(?link), 31), '{{!}}', ?headLabel, ']]',\n" +
" '[[File:', SUBSTR(STR(?img_), 52, 400), '{{!}}200px]]',\n" +
" '<small><hr>Informasi kode bahasa:<br>[[ISO639-3:xx{{!}}Belum tersedia]] {{*}} ',\n" +
" '[https://glottolog.org/resource/languoid/id/', ?glotto, ' ', ?glotto, ']</small>'),\n" +
" CONCAT('[[:id:', SUBSTR(STR(?link), 31), '{{!}}', ?headLabel, ']]',\n" +
" '<small><hr>Informasi kode bahasa:<br>[[ISO639-3:xx{{!}}Belum tersedia]] {{*}} ',\n" +
" '[https://glottolog.org/resource/languoid/id/', ?glotto, ' ', ?glotto, ']</small>')\n" +
" ))),\n" +
" IF (BOUND(?gmbr_),\n" +
" CONCAT('[[:id:', SUBSTR(STR(?link), 31), '{{!}}', ?headLabel, ']]',\n" +
" '[[File:', SUBSTR(STR(?gmbr_), 52, 400), '{{!}}200px]]',\n" +
" '<small><hr>Informasi kode bahasa:<br><i>Tidak tersedia</i></small>'),\n" +
" IF (BOUND(?img_),\n" +
" CONCAT('[[:id:', SUBSTR(STR(?link), 31), '{{!}}', ?headLabel, ']]',\n" +
" '[[File:', SUBSTR(STR(?img_), 52, 400), '{{!}}200px]]',\n" +
" '<small><hr>Informasi kode bahasa:<br><i>Tidak tersedia</i></small>'),\n" +
" CONCAT('[[:id:', SUBSTR(STR(?link), 31), '{{!}}', ?headLabel, ']]',\n" +
" '<small><hr>Informasi kode bahasa:<br><i>Tidak tersedia</i></small>')\n" +
" )\n" +
" ) \n" +
" )) AS ?description)\n" +
" WHERE {\n" +
" ?id wdt:P31 wd:Q34770 .\n" +
" ?id wdt:P279 ?head .\n" +
" ?id wdt:P625 ?geo .\n" +
" SERVICE wikibase:label {\n" +
" bd:serviceParam wikibase:language 'id' .\n" +
" ?head rdfs:label ?headLabel .\n" +
" ?id rdfs:label ?idLabel .\n" +
" }\n" +
" OPTIONAL { ?id wdt:P220 ?ison . }\n" +
" OPTIONAL { ?id wdt:P1394 ?glotton . }\n" +
" OPTIONAL { ?id wdt:P18 ?img . }\n" +
" OPTIONAL { ?id wdt:P1098 ?pop . }\n" +
" OPTIONAL { ?id wdt:P1846 ?gmbr . }\n" +
" ?link schema:about ?head .\n" +
" ?link schema:isPartOf <https://id.wikipedia.org/> .\n" +
" ?link2 schema:about ?id .\n" +
" ?link2 schema:isPartOf <https://id.wikipedia.org/> .\n" +
" }\n" +
" GROUP BY ?id ?idLabel ?head ?headLabel ?link2 ?link ?geo\n" +
" \n" +
"";
makeSPARQLQuery( endpointUrl, sparqlQuery, function( data ) {
$( 'body' ).append( $( '<pre>' ).text( JSON.stringify( data ) ) );
console.log( data );
}
);