query-7a3ddc8e6dec404dd2bb3e2d19a28b00

rq turtle/ttl

Map of all J/92 and J/92s home ports Map and list of municipalities in The NetherlandsBased on the SPARQL query example Replace Q97170629 / Q97179551 by a boat class to get a map of that boat class. Map of all J92 and J92s home ports Map and list of municipalities in The NetherlandsBased on the SPARQL query example Replace Q97170629 / Q97179551 by a boat class to get a map of that boat class.

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#Map of all J/92 (Q97170629) and J/92s (Q97179551) home ports (P504)
#boat = wikidata item id (qid)
#home_portLabel = home port name
#home_port_coord = home port coordinates
#boatLabel = wikidata item name
#boat_name (optional) = boat name
#image (optional) = picture

#defaultView:Map
SELECT DISTINCT ?boat ?boatLabel ?boat_name ?instance_ofLabel ?home_portLabel ?image ?home_port_coord WHERE {
  {
  ?boat wdt:P31/wdt:P279* wd:Q97170629; #'?boat' are 'instance of'(P31) and any number of 'subclass of' (P279*) of 'J/92'(Q97170629)
        wdt:P31 ?instance_of. #'?boat' 'instance of' (P31) are '?instance_of'
  }
  UNION
  {
  ?boat wdt:P31/wdt:P279* wd:Q97179551; #'?boat' are 'instance of'(P31) and any number of 'subclass of' (P279*) of 'J/92s'(Q97179551)
        wdt:P31 ?instance_of. #'?boat' 'instance of' (P31) are '?instance_of'
  }

  OPTIONAL {
  ?boat wdt:P504 ?home_port . #'?boat' 'home port' (P504) are '?home_port'
  #filter out home ports that are no longer current (home port (P504) with an 'end time' qualifier (P582))
  ?boat p:P504 ?statement1 .
  ?statement1 ps:P504 ?home_port .
  FILTER NOT EXISTS { ?statement1 pq:P582 ?x }
  ?home_port wdt:P625 ?home_port_coord. #'?home_port' 'coordinate location' (P625) are '?home_port_coord'
  }


  OPTIONAL { ?boat wdt:P18 ?image . } 

  #'?boat" 'short name' (P1813) are '?boat_name'
  #filter out names that are no longer current (short name (P1813) with an 'end time' qualifier (P582))
  OPTIONAL {
    ?boat wdt:P1813 ?boat_name.
    ?boat p:P1813 ?statement2 .
    ?statement2 ps:P1813 ?boat_name .
    FILTER NOT EXISTS { ?statement2 pq:P582 ?x } 
  }  

  #xxxLabel is the label for any variable called xxx
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v4("?boat"):::projected v9("?boat_name"):::projected v6("?home_port") v7("?home_port_coord"):::projected v8("?image"):::projected v5("?instance_of") v3("?statement1") v1("?statement2") v2("?x") a1((" ")) a2((" ")) c4(["wd:Q97170629"]):::iri c5(["wd:Q97179551"]):::iri c15(["bd:serviceParam"]):::iri c17(["#91;AUTO_LANGUAGE#93;,en"]):::literal subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v4 --"p:direct/P31"--> a2 a2 --"p:direct/P279"--> c5 v4 --"p:direct/P31"--> v5 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v4 --"p:direct/P31"--> a1 a1 --"p:direct/P279"--> c4 v4 --"p:direct/P31"--> v5 end union0r <== or ==> union0l end subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v4 -."p:direct/P504".-> v6 v4 --"p:P504"--> v3 v3 --"p:statement/P504"--> v6 v6 --"p:direct/P625"--> v7 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v4 -."p:direct/P18".-> v8 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v4 -."p:direct/P1813".-> v9 v4 --"p:P1813"--> v1 v1 --"p:statement/P1813"--> v9 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c15 --"wikibase:language"--> c17 end