Skip to content
This repository has been archived by the owner on Sep 26, 2022. It is now read-only.
/ SPARQLMap Public archive

LinkedDataHub's Google Maps layout for SPARQL RDF results

Notifications You must be signed in to change notification settings

AtomGraph/SPARQLMap

Repository files navigation

SPARQLMap

Interactive map layout for SPARQL RDF results.

It uses a SPARQL query to load RDF resources with coordinates within the bounds of the map, and renders each as a marker, which shows an info window with HTML representation of the resource when clicked.

Setup

SPARQLMap can be constructed with the following arguments:

map
google.maps.Map
Instance of Google Maps map
endpoint
URL
URL of the SPARQL endpoint
select
string
SPARQL select query string
focusVarName
string
Variable which will be bound to resources that represent markers
graphVarName?
string
Optional graph name variable name, in case marker resources are contained in named graphs

Usage

window.SPARQLMap.geo = new SPARQLMap.Geo(window.SPARQLMap.map, new URL('http://dbpedia.org/sparql'), `SELECT ?s { ?s ?p ?o }`, 's', 'g'); // construct object
window.LinkedDataHub.map.addListener('idle', function() { window.SPARQLMap.geo.loadMarkers(window.SPARQLMap.geo.addMarkers); }); // binds a handler for the 'idle' event

The library can be built using the webpack command; a browser-ready distribution will be created in the dist folder.

Query building

SPARQLMap will take the initial SELECT query, append a pattern that selects and filters the coordinates using the current viewport bounds (from the specified default and optionally named graph), and wraps it into a DESCRIBE.

Example

Initial SELECT:

SELECT ?s
{
    ?s ?p ?o
}

Default graph

Given focusVarName = 's' and current viewport bounds ((51.067080526460764, -2.8555919369506944), (51.905101013931514, 0.07458193695067283)), the final query executed on the endpoint will look like this:

PREFIX  geo:  <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX  xsd:  <http://www.w3.org/2001/XMLSchema#>

DESCRIBE ?s
WHERE
  { SELECT  ?s
    WHERE
      { ?s  ?p  ?o
        { ?s  geo:lat   ?lat ;
              geo:long  ?long
          FILTER ( ?long < 56.882781982421875 )
          FILTER ( ?lat < 66.28570153405012 )
          FILTER ( ?lat > 42.00247670093502 )
          FILTER ( ?long > -36.88278198242187 )
        }
      }
  }

Named graph

Given focusVarName = 's', graphVarName = 'g' and current viewport bounds ((51.067080526460764, -2.8555919369506944), (51.905101013931514, 0.07458193695067283)), the final query executed on the endpoint will look like this:

PREFIX  geo:  <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX  xsd:  <http://www.w3.org/2001/XMLSchema#>

DESCRIBE ?s
WHERE
  { SELECT  ?s
    WHERE
      { ?s  ?p  ?o
          { ?s  geo:lat   ?lat ;
                geo:long  ?long
            FILTER ( ?long < 56.882781982421875 )
            FILTER ( ?lat < 66.28570153405012 )
            FILTER ( ?lat > 42.00247670093502 )
            FILTER ( ?long > -36.88278198242187 )
          }
        UNION
          { GRAPH ?g
              { { ?s  geo:lat   ?lat ;
                      geo:long  ?long
                  FILTER ( ?long < 56.882781982421875 )
                  FILTER ( ?lat < 66.28570153405012 )
                  FILTER ( ?lat > 42.00247670093502 )
                  FILTER ( ?long > -36.88278198242187 )
                }
              }
          }
      }
  }

RDF data conventions

SPARQLMap will currently

  • only recognize geo:lat and geo:long (from the WGS84 Geo vocabulary) properties as coordinates.
  • use foaf:isPrimaryTopicOf and, as a fallback, foaf:page values as URLs to load info window HTML from when a marker is clicked. Absent these properties, the info window will not be available for that resource.

About

LinkedDataHub's Google Maps layout for SPARQL RDF results

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published