PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
PREFIX unit: <http://www.opengis.net/def/uom/OGC/1.0/>

SELECT DISTINCT ?Resource1 ?Resource2 ?distance
FROM <http://www.sdi4apps.eu/poi/czech>
WHERE {
  ?Resource1 a ?type1 .
  ?Resource1 rdfs:label ?label1 .
  ?Resource1 geo:asWKT ?geo1 .
  ?Resource2 a ?type2 .
  ?Resource2 rdfs:label ?label2 .
  ?Resource2 geo:asWKT ?geo2 .
  FILTER (lcase(str(?label1)) = lcase(str(?label2) )) .
  FILTER ( ?Resource1 != ?Resource2 && ?Resource1 < ?Resource2)
  FILTER (NOT EXISTS {?x a ?Resource1} && NOT EXISTS {?y a ?Resource2}) .
  BIND (geof:distance ( ?geo1 , ?geo2 , unit:metre ) as ?distance) .
  FILTER ( ?distance < 100 )
}
LIMIT 1000
OFFSET 0
