Search in sources :

Example 41 with QuerySolution

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);
}
Also used : QuerySolution(org.apache.jena.query.QuerySolution) Dataset(org.apache.jena.query.Dataset) Resource(org.apache.jena.rdf.model.Resource) ArrayList(java.util.ArrayList) ResultSet(org.apache.jena.query.ResultSet) QueryExecution(org.apache.jena.query.QueryExecution) Test(org.junit.Test)

Example 42 with QuerySolution

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);
}
Also used : QuerySolution(org.apache.jena.query.QuerySolution) Dataset(org.apache.jena.query.Dataset) Resource(org.apache.jena.rdf.model.Resource) ArrayList(java.util.ArrayList) ResultSet(org.apache.jena.query.ResultSet) QueryExecution(org.apache.jena.query.QueryExecution) Test(org.junit.Test)

Example 43 with QuerySolution

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);
}
Also used : QuerySolution(org.apache.jena.query.QuerySolution) Dataset(org.apache.jena.query.Dataset) Resource(org.apache.jena.rdf.model.Resource) ArrayList(java.util.ArrayList) ResultSet(org.apache.jena.query.ResultSet) QueryExecution(org.apache.jena.query.QueryExecution) Test(org.junit.Test)

Example 44 with QuerySolution

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);
}
Also used : QuerySolution(org.apache.jena.query.QuerySolution) Dataset(org.apache.jena.query.Dataset) Resource(org.apache.jena.rdf.model.Resource) ArrayList(java.util.ArrayList) ResultSet(org.apache.jena.query.ResultSet) QueryExecution(org.apache.jena.query.QueryExecution) Test(org.junit.Test)

Example 45 with QuerySolution

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);
}
Also used : QuerySolution(org.apache.jena.query.QuerySolution) Dataset(org.apache.jena.query.Dataset) Resource(org.apache.jena.rdf.model.Resource) ArrayList(java.util.ArrayList) ResultSet(org.apache.jena.query.ResultSet) QueryExecution(org.apache.jena.query.QueryExecution) Test(org.junit.Test)

Aggregations

QuerySolution (org.apache.jena.query.QuerySolution)129 ResultSet (org.apache.jena.query.ResultSet)106 QueryExecution (org.apache.jena.query.QueryExecution)99 Test (org.junit.Test)71 ArrayList (java.util.ArrayList)70 Query (org.apache.jena.query.Query)47 Dataset (org.apache.jena.query.Dataset)44 Resource (org.apache.jena.rdf.model.Resource)43 Literal (org.apache.jena.rdf.model.Literal)22 RDFNode (org.apache.jena.rdf.model.RDFNode)21 Model (org.apache.jena.rdf.model.Model)15 HashMap (java.util.HashMap)7 ResultSetRewindable (org.apache.jena.query.ResultSetRewindable)6 Extractor (infoeval.main.WikiData.Extractor)4 IOException (java.io.IOException)4 Node (org.apache.jena.graph.Node)4 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)4 Date (java.sql.Date)3 SimpleDateFormat (java.text.SimpleDateFormat)3 LinkedList (java.util.LinkedList)3