Más contenido relacionado La actualidad más candente (20) Similar a ParliamentでGeoSPARQL (20) ParliamentでGeoSPARQL2. ダウンロード&インストール
• Parliament Webサイトにアクセス
– http://parliament.semwebcentral.org/
• [Download]をクリックし、自分の環境にあったファイル
をDL(今回はMac OS Xで行います)
CentOS→ centos
Windows→ mcvc
Mac OS X→ darwin
Ubuntu→ ubuntu
• DLしたファイルを解凍
Teppei Inaba, Nagoya University
Teppei Inaba
2013/10/18
2
/11
4. Webブラウザからクエリする
• Webブラウザからサーバのアドレスにアクセス
– デフォルト: http://localhost:8080/parliament/
– 8080ポートが使用済みな場合、parliamentconfjetty.xmlで変更
できます
• [Indexes]→[Create All]で、インデックスを構築
– 追加するデータやクエリでSpatial Indexが利用可能に
• [Insert Data]でデータの追加、[Query]でクエリなど、
様々な機能が使用できるようになります
Teppei Inaba, Nagoya University
Teppei Inaba
2013/10/18
4
/11
5. 論文で紹介されているクエリを実行する
• 「GeoSPARQL: Enabling a Geospatial Semantic Web 」
で紹介されているクエリを実行します
– 論文URL: http://www.semantic-webjournal.net/sites/default/files/swj176_0.pdf
• 論文中のPrefixや述語の一部は、Parliamentの実装と異
なっていることに注意しながら実行
– geo: <http://www.opengis.net/ont/OGC-GeoSPARQL/1.0/>.
→ geo: <http://www.opengis.net/ont/geosparql#>.
– WKTLiteral → wktLiteral
Teppei Inaba, Nagoya University
Teppei Inaba
2013/10/18
5
/11
6. RDFを追加(1/2)
• [Insert Data]でListing 2: Example Ontologyをストア
– Turtle もしくは N3 フォーマットを選択
Listing 2: Example Ontology
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
@prefix ex: <http://example.org/PointOfInterest#>.
@prefix geo: <http://www.opengis.net/ont/geosparql#> .
ex:Restaurant a owl:Class; rdfs:subClassOf ex:Service .
ex:Park a owl:Class; rdfs:subClassOf ex:Attraction .
ex:Museum a owl:Class; rdfs:subClassOf ex:Attraction .
ex:Monument a owl:Class; rdfs:subClassOf ex:Attraction .
ex:Service a owl:Class; rdfs:subClassOf ex:PointOfInterest .
ex:Attraction a owl:Class; rdfs:subClassOf ex:PointOfInterest .
ex:PointOfInterest a owl:Class; rdfs:subClassOf geo:Feature .
Teppei Inaba, Nagoya University
Teppei Inaba
2013/10/18
6
/11
7. RDFを追加(2/2)
• 同様にListing 3: Washington Monumentをストア
Listing 3: Washington Monument
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
@prefix ex: <http://example.org/PointOfInterest#>.
@prefix geo: <http://www.opengis.net/ont/geosparql#>.
@prefix sf: <http://www.opengis.net/ont/sf#>.
ex:WashingtonMonument a ex:Monument;
rdfs:label "Washington Monument";
geo:hasGeometry ex:WMPoint .
ex:WMPoint a geo:Point;
geo:asWKT "POINT(-77.03524 38.889468)"^^sf:wktLiteral .
Teppei Inaba, Nagoya University
Teppei Inaba
2013/10/18
7
/11
8. クエリの実行
• [Query]でListing 7: Example Query 3を実行
Listing 3: Washington Monument
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#>
PREFIX ex: <http://example.org/PointOfInterest#>
SELECT ?a
WHERE {
?a geo:hasGeometry ?ageo .
?ageo geo:asWKT ?alit .
FILTER( geof:sfWithin(?alit, "Polygon((-77.089005 38.913574,-77.029953 38.913574,-77.029953
38.886321,-77.089005 38.886321,-77.089005 38.913574))"^^sf:wktLiteral))
}
– 結果のHTML出力
Teppei Inaba, Nagoya University
Teppei Inaba
2013/10/18
8
/11
10. プログラムの例
• 簡単なプログラムの例
import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.query.ResultSet;
import com.hp.hpl.jena.query.ResultSetFormatter;
public class sample1 {
public static void main(String[] args){
String sparqlSelectQuery = "PREFIX ex: <http://example.org/PointOfInterest#>" +
"SELECT ?m " +
"WHERE {" +
"?m a ex:Attraction" +
"}" ;
QueryExecution qexec = QueryExecutionFactory.sparqlService(
"http://localhost:8080/parliament/sparql",
sparqlSelectQuery);
ResultSet results = qexec.execSelect();
System.out.println(ResultSetFormatter.asText(results));
qexec.close();
}
}
WashingtonMonumentが出力される
Teppei Inaba, Nagoya University
Teppei Inaba
2013/10/18
10
/11
11. 参考文献
• Parliament User Guide, November 8, 2012
– http://parliament.semwebcentral.org/ParliamentUserGuide.pdf
• Setting up Parliament Triple Store with GeoSPARQL
– http://lodum.de/setting-up-parliament-triple-store-with-geosparql/
• OGC GeoSPARQL - A Geographic Query Language for
RDF Data
– http://www.opengeospatial.org/standards/geosparql
Teppei Inaba, Nagoya University
Teppei Inaba
2013/10/18
11
/11