use of org.openrdf.model.impl.StatementImpl in project incubator-rya by apache.
the class MongoGeoIndexerFilterIT method statement.
private static RyaStatement statement(final Geometry geo) {
final ValueFactory vf = new ValueFactoryImpl();
final Resource subject = vf.createURI("urn:geo");
final URI predicate = GeoConstants.GEO_AS_WKT;
final WKTWriter w = new WKTWriter();
final Value object = vf.createLiteral(w.write(geo), GeoConstants.XMLSCHEMA_OGC_WKT);
return RdfToRyaConversions.convertStatement(new StatementImpl(subject, predicate, object));
}
use of org.openrdf.model.impl.StatementImpl in project incubator-rya by apache.
the class GeoIndexerSfTest method genericStatementGml.
private static Statement genericStatementGml(final Geometry geo, final URI encodingMethod) {
final ValueFactory vf = new ValueFactoryImpl();
final Resource subject = vf.createURI("uri:" + NAMES.get(geo));
final URI predicate = GeoConstants.GEO_AS_GML;
final String gml;
if (encodingMethod == USE_JTS_LIB_ENCODING) {
gml = geoToGmlUseJtsLib(geo);
} else if (encodingMethod == USE_ROUGH_ENCODING) {
gml = geoToGmlRough(geo);
} else {
throw new Error("invalid encoding method: " + encodingMethod);
// System.out.println("===created GML====");
// System.out.println(gml);
// System.out.println("========== GML====");
}
final Value object = vf.createLiteral(gml, GeoConstants.XMLSCHEMA_OGC_GML);
return new StatementImpl(subject, predicate, object);
}
use of org.openrdf.model.impl.StatementImpl in project incubator-rya by apache.
the class GeoWaveIndexerTest method testRestrictPredicatesSearch.
@Test
public void testRestrictPredicatesSearch() throws Exception {
conf.setStrings(ConfigUtils.GEO_PREDICATES_LIST, "pred:1,pred:2");
try (final GeoWaveGeoIndexer f = new GeoWaveGeoIndexer()) {
f.setConf(conf);
f.purge(conf);
final ValueFactory vf = new ValueFactoryImpl();
final Point point = gf.createPoint(new Coordinate(10, 10));
final Value pointValue = vf.createLiteral("Point(10 10)", GeoConstants.XMLSCHEMA_OGC_WKT);
final URI invalidPredicate = GeoConstants.GEO_AS_WKT;
// These should not be stored because they are not in the predicate list
f.storeStatement(convertStatement(new StatementImpl(vf.createURI("foo:subj1"), invalidPredicate, pointValue)));
f.storeStatement(convertStatement(new StatementImpl(vf.createURI("foo:subj2"), invalidPredicate, pointValue)));
final URI pred1 = vf.createURI("pred:1");
final URI pred2 = vf.createURI("pred:2");
// These should be stored because they are in the predicate list
final Statement s3 = new StatementImpl(vf.createURI("foo:subj3"), pred1, pointValue);
final Statement s4 = new StatementImpl(vf.createURI("foo:subj4"), pred2, pointValue);
f.storeStatement(convertStatement(s3));
f.storeStatement(convertStatement(s4));
// This should not be stored because the object is not valid wkt
f.storeStatement(convertStatement(new StatementImpl(vf.createURI("foo:subj5"), pred1, vf.createLiteral("soint(10 10)"))));
// This should not be stored because the object is not a literal
f.storeStatement(convertStatement(new StatementImpl(vf.createURI("foo:subj6"), pred1, vf.createURI("p:Point(10 10)"))));
f.flush();
final Set<Statement> actual = getSet(f.queryEquals(point, EMPTY_CONSTRAINTS));
Assert.assertEquals(2, actual.size());
Assert.assertTrue(actual.contains(s3));
Assert.assertTrue(actual.contains(s4));
}
}
use of org.openrdf.model.impl.StatementImpl in project incubator-rya by apache.
the class MongoGeoTemporalIndexerIT method statement.
private static RyaStatement statement(final Geometry geo) {
final ValueFactory vf = new ValueFactoryImpl();
final Resource subject = vf.createURI("uri:test");
final URI predicate = GeoConstants.GEO_AS_WKT;
final Value object = vf.createLiteral(geo.toString(), GeoConstants.XMLSCHEMA_OGC_WKT);
return RdfToRyaConversions.convertStatement(new StatementImpl(subject, predicate, object));
}
use of org.openrdf.model.impl.StatementImpl in project incubator-rya by apache.
the class MongoGeoIndexerIT method testRestrictPredicatesSearch.
@Test
public void testRestrictPredicatesSearch() throws Exception {
try (final MongoGeoIndexer f = new MongoGeoIndexer()) {
conf.setStrings(ConfigUtils.GEO_PREDICATES_LIST, "pred:1,pred:2");
f.setConf(conf);
f.init();
final ValueFactory vf = new ValueFactoryImpl();
final Point point = gf.createPoint(new Coordinate(10, 10));
final Value pointValue = vf.createLiteral("Point(10 10)", GeoConstants.XMLSCHEMA_OGC_WKT);
final URI invalidPredicate = GeoConstants.GEO_AS_WKT;
// These should not be stored because they are not in the predicate list
f.storeStatement(convertStatement(new StatementImpl(vf.createURI("foo:subj1"), invalidPredicate, pointValue)));
f.storeStatement(convertStatement(new StatementImpl(vf.createURI("foo:subj2"), invalidPredicate, pointValue)));
final URI pred1 = vf.createURI("pred:1");
final URI pred2 = vf.createURI("pred:2");
// These should be stored because they are in the predicate list
final Statement s3 = new StatementImpl(vf.createURI("foo:subj3"), pred1, pointValue);
final Statement s4 = new StatementImpl(vf.createURI("foo:subj4"), pred2, pointValue);
f.storeStatement(convertStatement(s3));
f.storeStatement(convertStatement(s4));
// This should not be stored because the object is not valid wkt
f.storeStatement(convertStatement(new StatementImpl(vf.createURI("foo:subj5"), pred1, vf.createLiteral("soint(10 10)"))));
// This should not be stored because the object is not a literal
f.storeStatement(convertStatement(new StatementImpl(vf.createURI("foo:subj6"), pred1, vf.createURI("p:Point(10 10)"))));
f.flush();
final Set<Statement> actual = getSet(f.queryEquals(point, EMPTY_CONSTRAINTS));
assertEquals(2, actual.size());
assertTrue(actual.contains(s3));
assertTrue(actual.contains(s4));
}
}
Aggregations