LODUM Blog

News from the LODUM headquarters and all things Linked Open Data.


For those interested on getting started with GeoSPARQL (Spatial SPARQL Queries), here it is new tutorial about how to set up Parliament Triple Store with GeoSPARQL support.

This tutorial was written and successfully tested using the Parliament version 2.7.4, running on Ubuntu Linux 12.04 64-bit, Windows Server 2008 R2 64-bit and Windows 7 Home Premium 64-bit.

Note: Before you start, make sure that your Java platform matches to the parliament platform you downloaded. Ex: If you’re using a 32-bit Java Runtime Environment in a 64-bit operating system, you must use the 32-bit version of parliament. In other words, Java 32-bit + Parliament 64-bit = trouble! Once you have your appropriate Java installed, don’t forget also to properly set the JAVA_HOME variable.

Download Parliament and uncompress it to a folder and follow the instructions below according to your operating system.

Ubuntu Linux 12.04 64-bit

For the sake of this sample, let’s assume we downloaded and uncompressed the ZIP file into the path /home/jones/parliament/. After you downloaded the Parliament for Ubuntu Linux 64-bit and uncompressed it, you have to execute the /home/jones/parliament/StartParliament.sh in the terminal. After you’ve done so, you might see a message like this.

Parliament_Ubuntu

Windows Server 2008 64-bit

For the sake of this sample, let’s assume you downloaded and uncompressed the Windows 64-bit Parliament files in the directory c:\parliament. Afterwards, you must execute the following application C:\parliament\RedistributablePackages\msvc-10.0-sp1\vcredist_x64.exe, which is the Visual C Compiler (Needed only for Windows).

Once you’re done with the vcredist_x64.exe installation, you just need to start Parliament via the file C:\parliament\StartParliament.bat in the DOS console. After you execute it, you might see a message like this.

parliamentWin

Parliament starts by default in the port 8080, so you can access it in your browser under the address http://localhost:8080/parliament/. If you already have a service running in this port, you can fix it by changing the Jetty XML file at c:\parliament\conf\jetty.xml or /home/jones/parliament/conf/jetty.xml and change the following line:

<Set name="port"><SystemProperty name="jetty.port" default="8080"/></Set>

Now that you’ve got Parliament up and running, there is one last detail for you to start making your first GeoSPARQL query, namelly create the Spatial Indexes. Go to http://localhost:8080/parliament/indexes.jsp (considering you didn’t change port and path) and click on the link “Create All”. This will enable your parliament to create spatial indexes to new incoming triples.

After you’ve done so, you’re ready to start geo-querying! To test your Parliament, insert the following triple by using the GUI under the address http://localhost:8080/parliament/insert.jsp, pasting the triples in the text field “Text Insert” and pressing “Insert Data”.

<http://www.lanuv.nrw.de/osiris/geometries/adce33b2-42c6-469a-8aac-27860d51df0b> <http://www.opengis.net/ont/geosparql#asWKT> "<http://www.opengis.net/def/crs/OGC/1.3/CRS84> POINT (8.46035239692792 51.48661096320327)"^^<http://www.opengis.net/ont/sf#wktLiteral> .

The following message should appear:

HTTP OK: 200

Insert operation successful. 1 statement added.

With your first RDF statement added, it is time to test a spatial query! Go to http://localhost:8080/parliament/query.jsp and execute the following GeoSPARQL Query:

PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
PREFIX sf: <http://www.opengis.net/ont/sf#>

SELECT DISTINCT
*
WHERE {
?bGeom geo:asWKT ?bWKT .
FILTER (geof:sfWithin(?bWKT, "Polygon((7 50, 7 53, 9 53, 9 50, 7 50))"^^sf:wktLiteral))
}

After running this query, you have to get the following result:

GeoSPARQL_Result

For shutting down Parliament, type exit in the terminal. By no means use the famous Ctrl+C to quit the server, since Parliament indexes are pretty sensible and can get very easily corrupted.

And this is it, enjoy GeoSPARQL!

This tutorial was originally published at the Linked Open Data section of the NASA World Wind SDK Tutorial.


Heads up: If you’re not into Web development, this post is going to bore the hell out of you.

While it is quite straightforward these days to load data dynamically via AJAX, everyone who has tried to augment their website with Linked Data via JavaScript has probably hit the wall of the same origin policy. While a script can be loaded from any arbitrary server, this policy allows the script to communicate exclusively with the same port on the same host through the same protocol. So you’re even lost if you want to load data from your triple store hosted on the same machine, but on port 8080, for example.

While the policy is there for very good (security) reasons, it can be quite an annoyance when you are trying to develop applications that pull in data from various sources in the Linked Data Cloud. JSON with padding, better known as JSONP, has been introduced as a creative workaround for this problem. It basically packs the results of a GET request as a JavaScript function; the result becomes a script of its own (the callback function), and these can be loaded from anywhere (see above). The only problem with this approach is that the server needs to support JSONP, as the results need to be packed into a JS function. In other words, if the SPARQL endpoint you are loading data from does not support JSONP, you are still lost and have to come up with a workaround such as a local proxy script.

And this is pretty much what our proxy service at http://jsonp.lodum.de does. Fire any GET requests with the following three parameters at it, and it will return the SPARQL results wrapped as JSONP:

  • endpoint: The URL of the SPARQL endpoint you want to query.
  • query: Your SPARQL query.
  • callback: The name for the callback function you are expecting.

If you are using jQuery, you don’t even need the callback function. jQuery takes care of that part for you; Here’s a quick example:

var endpoint = "http://data.uni-muenster.de/sparql";
var queryUrl = "http://jsonp.lodum.de/?endpoint=" + endpoint;
$.ajax({
   dataType: "jsonp",
   data: {query: "SELECT * WHERE { ?a ?b ?c . } LIMIT 10"},
   url: queryUrl,
   success: function(data) {
      // do something with the results
   }
});

jQuery takes care of assigning the callback function a name and you’re ready to use the SPARQL results in JSON notation. No need to say that this also works with other endpoints.

If you don’t want to rely on our server being up, the script is also available for download, so that you can set up your own proxy.


full_text_search

We added a FullTextIndex (Owlim/Lucene) to the Lodum store containing all literal values. The index is named “lodumLiteralIndex” and can be queried combining SPARQL and the Lucene sytanx (Sparql Example).

On top we built a small GUI with JQuery, making the search capabilities accessible to the wider public. Even though, the index contains blank notes es well (e.g. authorlists), we still working on a smart way to integrate those into the GUI.

The RDFpad got an update as well and is now working with both Etherpad versions ( Etherpad and EtherpadLite). In addition, we built a small on-the-fly SPARQL-Tool (SPARQLfly) in order to query small, remote RDF Triples using the FROM clause (e.g. written in Etherpad or static files). The RDFpad provides automatically a link to SPARQLfly, which will then read and prepare the query form containing all namespaces.


spatial_linked

It just occurred to me that we have not even mentioned the new version of spatial.linkedscience.org here yet. Completely new UI, and tons of new data.