org.da.protoframework.jena.common.sparql.SparqlRequest
class allows to create SPARQL requests easily without having to write the request "by hand". This class is available in the JenaCommon.jar
jar file. SparqlRequest
class has the following specific API for GeoSparql requests:public class org.da.protoframework.jena.common.sparql.SparqlRequest |
---|
Modifier and Type | Method and Description |
---|---|
boolean | addTime(String var, String varTime, boolean isDateTime)
Get the time for an individual
|
addOptionalConstruct()
method allows to create an OPTIONAL construct withih the Sparql request. This construct can contain several expressions. The API SparqlRequest.Optional
result is:public class org.da.protoframework.jena.common.SparqlRequest.Optional |
---|
Modifier and Type | Method and Description |
---|---|
boolean | addDistance(String var, String fromVar, String varDist, short unit, boolean isExact)
Specifies a GeoSparql function to get the distance between two individuals
|
boolean | addGeometry(String var, String varLat, String varLon, boolean isExact)
Specifies a GeoSparql function to get the latitude and longitude of an individual
|
Waypoint
class. We want to create a request getting the list of Waypoints and their latitude and longitude.SparqlRequest request = new SparqlRequest("sitac"); request.addSelect("wpt"); request.addSelect("lat"); request.addSelect("lon"); request.addType("wpt", "Waypoint"); request.addGeometry("wpt", "lat", "lon", true); String query = request.getSPARQL();We will generate the following query:
SELECT ?wpt lat ?lon WHERE { ?wpt rdf:type sitac:Waypoint . ?wpt sitac:hasExactGeometry ?auto_1 . ?auto_1 sitac:asWKT ?auto_2 . BIND (xs:decimal(replace( str(?auto_2), "^[^0-9\\.-]*([-]?[0-9\\.]+) .*$", "$1" )) as ?lon) BIND (xs:decimal(replace( str(?auto_2), "^.* ([-]?[0-9\\.]+)[^0-9\\.]*$", "$1" )) as ?lat) }
Aircraft
individual, and we want to get the distance between each Waypoint and our Aircraft.SparqlRequest request = new SparqlRequest("sitac"); request.addSelect("wpt"); request.addSelect("dist"); request.addType("wpt", "Waypoint"); request.addAdditionalVariable("ac"); request.addType("ac", "Aircraft"); request.addPropertyValue("ac", "Label", "MyAircraft"); request.addDistance("wpt", "ac", "dist", SparqlRequest.DISTANCE_M, true); String query = request.getSPARQL();
SELECT ?wpt ?dist WHERE { ?wpt rdf:type sitac:Waypoint . ?wpt sitac:hasExactGeometry ?auto_1 . ?auto_1 sitac:asWKT ?auto_2 . ?ac rdf:type sitac:Aircraft . ?ac sitac:Label "MyAircraft" . ?ac sitac:hasExactGeometry ?auto_3 . ?auto_3 sitac:asWKT ?auto_4 . BIND (geof:distance(?auto_2, ?auto_4, <http://www.opengis.net/def/uom/OGC/1.0/meter>) as ?dist) }
Copyright 2017-2020 Dassault Aviation. All Rights Reserved. Documentation and source under the LGPL v3 licence