use of org.apache.jena.query.QuerySolution in project jena by apache.
the class WestGeomPFTest method testExecEvaluated.
/**
* Test of execEvaluated method, of class WestGeomPF.
*/
@Test
public void testExecEvaluated() {
Dataset dataset = SpatialIndexTestData.createTestDataset();
String query = "PREFIX spatial: <http://jena.apache.org/spatial#>\n" + "\n" + "SELECT ?subj\n" + "WHERE{\n" + " BIND( \"<http://www.opengis.net/def/crs/EPSG/0/4326> POINT(48.857487 2.373047)\"^^<http://www.opengis.net/ont/geosparql#wktLiteral> AS ?geom)" + " ?subj spatial:westGeom(?geom) .\n" + "}ORDER by ?subj";
List<Resource> result = new ArrayList<>();
try (QueryExecution qe = QueryExecutionFactory.create(query, dataset)) {
ResultSet rs = qe.execSelect();
while (rs.hasNext()) {
QuerySolution qs = rs.nextSolution();
Resource feature = qs.getResource("subj");
result.add(feature);
}
}
List<Resource> expResult = Arrays.asList(SpatialIndexTestData.HONOLULU_FEATURE, SpatialIndexTestData.LONDON_FEATURE, SpatialIndexTestData.NEW_YORK_FEATURE);
assertEquals(expResult, result);
}
use of org.apache.jena.query.QuerySolution in project jena by apache.
the class NearbyGeomPFTest method testExecEvaluated.
/**
* Test of execEvaluated method, of class NearbyGeomPF.
*/
@Test
public void testExecEvaluated() {
Dataset dataset = SpatialIndexTestData.createTestDataset();
String query = "PREFIX spatial: <http://jena.apache.org/spatial#>\n" + "\n" + "SELECT ?subj\n" + "WHERE{\n" + " BIND( \"<http://www.opengis.net/def/crs/EPSG/0/4326> POINT(48.857487 2.373047)\"^^<http://www.opengis.net/ont/geosparql#wktLiteral> AS ?geom)" + " ?subj spatial:nearbyGeom(?geom 350) .\n" + "}ORDER by ?subj";
List<Resource> result = new ArrayList<>();
try (QueryExecution qe = QueryExecutionFactory.create(query, dataset)) {
ResultSet rs = qe.execSelect();
while (rs.hasNext()) {
QuerySolution qs = rs.nextSolution();
Resource feature = qs.getResource("subj");
result.add(feature);
}
}
List<Resource> expResult = Arrays.asList(SpatialIndexTestData.LONDON_FEATURE);
assertEquals(expResult, result);
}
use of org.apache.jena.query.QuerySolution in project jena by apache.
the class NearbyGeomPFTest method testExecEvaluated_fail.
/**
* Test of execEvaluated method, of class NearbyGeomPF.<br>
* Close enough for first filter but rejected by second filter.
*/
@Test
public void testExecEvaluated_fail() {
Dataset dataset = SpatialIndexTestData.createTestDataset();
String query = "PREFIX spatial: <http://jena.apache.org/spatial#>\n" + "\n" + "SELECT ?subj\n" + "WHERE{\n" + " BIND( \"<http://www.opengis.net/def/crs/EPSG/0/4326> POINT(48.857487 2.373047)\"^^<http://www.opengis.net/ont/geosparql#wktLiteral> AS ?geom)" + " ?subj spatial:nearbyGeom(?geom 340) .\n" + "}ORDER by ?subj";
List<Resource> result = new ArrayList<>();
try (QueryExecution qe = QueryExecutionFactory.create(query, dataset)) {
ResultSet rs = qe.execSelect();
while (rs.hasNext()) {
QuerySolution qs = rs.nextSolution();
Resource feature = qs.getResource("subj");
result.add(feature);
}
}
List<Resource> expResult = new ArrayList<>();
assertEquals(expResult, result);
}
use of org.apache.jena.query.QuerySolution in project jena by apache.
the class IntersectBoxGeomPFTest method testExecEvaluated.
/**
* Test of execEvaluated method, of class IntersectBoxGeom.
*/
@Test
public void testExecEvaluated() {
Dataset dataset = SpatialIndexTestData.createTestDataset();
String query = "PREFIX spatial: <http://jena.apache.org/spatial#>\n" + "\n" + "SELECT ?subj\n" + "WHERE{\n" + " BIND( \"<http://www.opengis.net/def/crs/EPSG/0/4326> POLYGON((51.4 -0.13, 51.6 -0.13, 51.6 -0.12, 51.4 -0.12, 51.4 -0.13))\"^^<http://www.opengis.net/ont/geosparql#wktLiteral> AS ?geom)" + " ?subj spatial:intersectBoxGeom(?geom) .\n" + "}ORDER by ?subj";
List<Resource> result = new ArrayList<>();
try (QueryExecution qe = QueryExecutionFactory.create(query, dataset)) {
ResultSet rs = qe.execSelect();
while (rs.hasNext()) {
QuerySolution qs = rs.nextSolution();
Resource feature = qs.getResource("subj");
result.add(feature);
}
}
List<Resource> expResult = Arrays.asList(SpatialIndexTestData.LONDON_FEATURE);
assertEquals(expResult, result);
}
use of org.apache.jena.query.QuerySolution in project jena by apache.
the class WithinBoxGeomPFTest method testExecEvaluated.
/**
* Test of execEvaluated method, of class WithinBoxGeom.
*/
@Test
public void testExecEvaluated() {
Dataset dataset = SpatialIndexTestData.createTestDataset();
String query = "PREFIX spatial: <http://jena.apache.org/spatial#>\n" + "\n" + "SELECT ?subj\n" + "WHERE{\n" + " BIND( \"<http://www.opengis.net/def/crs/EPSG/0/4326> POLYGON((51.4 -0.13, 51.6 -0.13, 51.6 -0.12, 51.4 -0.12, 51.4 -0.13))\"^^<http://www.opengis.net/ont/geosparql#wktLiteral> AS ?geom)" + " ?subj spatial:withinBoxGeom(?geom) .\n" + "}ORDER by ?subj";
List<Resource> result = new ArrayList<>();
try (QueryExecution qe = QueryExecutionFactory.create(query, dataset)) {
ResultSet rs = qe.execSelect();
while (rs.hasNext()) {
QuerySolution qs = rs.nextSolution();
Resource feature = qs.getResource("subj");
result.add(feature);
}
}
List<Resource> expResult = Arrays.asList(SpatialIndexTestData.LONDON_FEATURE);
assertEquals(expResult, result);
}
Aggregations