Setting up Parliament Triple Store with GeoSPARQL

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.

This is a post
on the LODUM blog.


2 comments

Thanks alot for this
i have tried and it worked just fine. However, if i try to change the value of the point to get it outside the Polygon, Parliament keeps records of the previous value and it keeps coming up in the results, i could not get rid of it , do you have any idea what to do about that

Alia
September 3, 2013
12:06
Permalink

Hello I want to ask some points belong to installation. Do we have to install tomcat before setting up parliament?

Can Ayd?n
October 9, 2013
19:40
Permalink

Add a comment

Required

Required, but won't be shown

Optional