Difference between revisions of "Template:SPARQLcountry"

From Wikibase Personal data
Jump to navigation Jump to search
(Created page with "{{SPARQLhierarchy |predicate=P55 |value={{{country}}} |visualisation={{{visualisation}}} }}")
(No difference)

Revision as of 03:13, 21 May 2019

  1. defaultView:Graph

SELECT ?item1 ?item1Label ?rgb ?item2 ?item2Label ?link WITH {SELECT ?nodeType ?nodeRGB WHERE {

   pdio:{{{visualization}}} pdiop:P26 ?nodeTypeStatement.
   ?nodeTypeStatement pdiops:P26 ?nodeType.
   OPTIONAL {
     ?nodeTypeStatement pdiopq:P115 ?nodeRGB
   }
 }

} AS %nodeTypes WITH {SELECT ?edgeTypeDomain ?edgeTypeRange ?edgeType ?rgb WHERE {

   pdio:Q803 pdiop:P117 ?edgeTypeStatement.
   ?edgeTypeStatement pdiops:P117 ?edgeType.
   ?edgeTypeStatement pdiopq:P24 ?edgeTypeDomain.
   ?edgeTypeStatement pdiopq:P23 ?edgeTypeRange.
   OPTIONAL {
     ?edgeTypeStatement pdiopq:P115 ?rgb     
   }
 }

} AS %edgeTypes WITH {SELECT ?node ?nodeType ?nodeRGB WHERE {

   ?node pdiot:P55 pdio:{{{country}}}.
   ?node pdiot:P3 ?nodeType.
   INCLUDE %nodeTypes.
 }

} AS %nodes WITH {SELECT ?domain ?range ?rgb WHERE {

   INCLUDE %edgeTypes.
   ?domain pdiot:P3 ?edgeTypeDomain.
   ?range pdiot:P3 ?edgeTypeRange.
   ?edgeType pdiot:P105 ?Pid.
   BIND(URI(CONCAT("http://wiki.personaldata.io/prop/direct/", ?Pid)) AS ?link).
   ?domain ?link ?range.
   ?domain pdiot:P55 pdio:{{{country}}}.       # This is filtering for each edge twice, potentially a huge waste: |E|*|V| instead of |V|
   ?range pdiot:P55 pdio:{{{country}}}.
 }

} AS %edges WHERE {

 {  
    INCLUDE %nodeTypes.
    BIND(?nodeType AS ?item1).
    BIND(?nodeRGB AS ?rgb).
 }
 UNION
 {  
    INCLUDE %edgeTypes.
    BIND(?edgeTypeDomain AS ?item1).
    BIND(?edgeTypeRange AS ?item2).
 }
 UNION
 {  
    INCLUDE %nodes.
    BIND(?node AS ?item1).
    BIND(?nodeRGB AS ?rgb).
 }
 UNION
 {  
    INCLUDE %edges.
    BIND(?domain AS ?item1).
    BIND(?range AS ?item2).
 }
 SERVICE wikibase:label {
   bd:serviceParam wikibase:language "en" . 
 }

} LIMIT 10000