use of org.openrdf.model.ValueFactory in project incubator-rya by apache.
the class GeoTemporalProviderTest method twoNode_test.
@Test
public void twoNode_test() throws Exception {
final ValueFactory vf = new ValueFactoryImpl();
final Value geo = vf.createLiteral("Point(0 0)", GeoConstants.XMLSCHEMA_OGC_WKT);
final Value temp = vf.createLiteral(new TemporalInstantRfc3339(2015, 12, 30, 12, 00, 0).toString());
final URI tempPred = vf.createURI(URI_PROPERTY_AT_TIME);
final String query = "PREFIX geo: <http://www.opengis.net/ont/geosparql#>" + "PREFIX geos: <http://www.opengis.net/def/function/geosparql/>" + "PREFIX time: <tag:rya-rdf.org,2015:temporal#>" + "SELECT * WHERE { " + "?subj <" + tempPred + "> ?time ." + "?subj <" + GeoConstants.GEO_AS_WKT + "> ?loc . " + "?subj2 <" + tempPred + "> ?time2 ." + "?subj2 <" + GeoConstants.GEO_AS_WKT + "> ?loc2 . " + " FILTER(geos:sfContains(?loc, " + geo + ")) . " + " FILTER(time:equals(?time, " + temp + ")) . " + " FILTER(geos:sfContains(?loc2, " + geo + ")) . " + " FILTER(time:equals(?time2, " + temp + ")) . " + "}";
final QuerySegment<EventQueryNode> node = getQueryNode(query);
final List<EventQueryNode> nodes = provider.getExternalSets(node);
assertEquals(2, nodes.size());
}
use of org.openrdf.model.ValueFactory in project incubator-rya by apache.
the class GeoTemporalMongoDBStorageStrategyTest method serializeTest.
@Test
public void serializeTest() {
final ValueFactory vf = new ValueFactoryImpl();
final Resource subject = vf.createURI("foo:subj");
final Resource context = vf.createURI("foo:context");
// GEO
URI predicate = GeoConstants.GEO_AS_WKT;
Value object = vf.createLiteral("Point(-77.03524 38.889468)", GeoConstants.XMLSCHEMA_OGC_WKT);
Statement statement = new ContextStatementImpl(subject, predicate, object, context);
DBObject actual = adapter.serialize(RdfToRyaConversions.convertStatement(statement));
String expectedString = "{ " + "\"_id\" : -852305321 , " + "\"location\" : { " + "\"coordinates\" : [ -77.03524 , 38.889468] , " + "\"type\" : \"Point\"" + "}" + "}";
DBObject expected = (DBObject) JSON.parse(expectedString);
assertEqualMongo(expected, actual);
// TIME INSTANT
predicate = new URIImpl("Property:event:time");
object = vf.createLiteral("2015-12-30T12:00:00Z");
statement = new ContextStatementImpl(subject, predicate, object, context);
actual = adapter.serialize(RdfToRyaConversions.convertStatement(statement));
expectedString = "{" + "_id : -852305321, " + "time: {" + "instant : {" + "\"$date\" : \"2015-12-30T12:00:00.000Z\"" + "}" + "}" + "}";
expected = (DBObject) JSON.parse(expectedString);
assertEqualMongo(expected, actual);
// TIME INTERVAL
predicate = new URIImpl("Property:circa");
object = vf.createLiteral("[1969-12-31T19:00:00-05:00,1969-12-31T19:00:01-05:00]");
statement = new ContextStatementImpl(subject, predicate, object, context);
actual = adapter.serialize(RdfToRyaConversions.convertStatement(statement));
expectedString = "{" + "_id : -852305321, " + "time: {" + "start : {" + "\"$date\" : \"1970-01-01T00:00:00.000Z\"" + "}," + "end : {" + "\"$date\" : \"1970-01-01T00:00:01.000Z\"" + "}" + "}" + "}";
expected = (DBObject) JSON.parse(expectedString);
assertEqualMongo(expected, actual);
}
use of org.openrdf.model.ValueFactory in project incubator-rya by apache.
the class GeoIndexerSfTest method genericStatementWkt.
private static Statement genericStatementWkt(final Geometry geo) {
final ValueFactory vf = new ValueFactoryImpl();
final Resource subject = vf.createURI("uri:" + NAMES.get(geo));
final URI predicate = GeoConstants.GEO_AS_WKT;
final Value object = vf.createLiteral(geo.toString(), GeoConstants.XMLSCHEMA_OGC_WKT);
return new StatementImpl(subject, predicate, object);
}
use of org.openrdf.model.ValueFactory in project incubator-rya by apache.
the class GeoWaveIndexerTest method testDeleteSearch.
@Test
public void testDeleteSearch() throws Exception {
// test a ring around dc
try (final GeoWaveGeoIndexer f = new GeoWaveGeoIndexer()) {
f.setConf(conf);
f.purge(conf);
final ValueFactory vf = new ValueFactoryImpl();
final Resource subject = vf.createURI("foo:subj");
final URI predicate = GeoConstants.GEO_AS_WKT;
final Value object = vf.createLiteral("Point(-77.03524 38.889468)", GeoConstants.XMLSCHEMA_OGC_WKT);
final Resource context = vf.createURI("foo:context");
final Statement statement = new ContextStatementImpl(subject, predicate, object, context);
f.storeStatement(convertStatement(statement));
f.flush();
f.deleteStatement(convertStatement(statement));
// test a ring that the point would be inside of if not deleted
final double[] in = { -78, 39, -77, 39, -77, 38, -78, 38, -78, 39 };
final LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(in, 2));
final Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});
Assert.assertEquals(Sets.newHashSet(), getSet(f.queryWithin(p1, EMPTY_CONSTRAINTS)));
// test a ring that the point would be outside of if not deleted
final double[] out = { -77, 39, -76, 39, -76, 38, -77, 38, -77, 39 };
final LinearRing rOut = gf.createLinearRing(new PackedCoordinateSequence.Double(out, 2));
final Polygon pOut = gf.createPolygon(rOut, new LinearRing[] {});
Assert.assertEquals(Sets.newHashSet(), getSet(f.queryWithin(pOut, EMPTY_CONSTRAINTS)));
// test a ring for the whole world and make sure the point is gone
final double[] world = { -180, 90, 180, 90, 180, -90, -180, -90, -180, 90 };
final LinearRing rWorld = gf.createLinearRing(new PackedCoordinateSequence.Double(world, 2));
final Polygon pWorld = gf.createPolygon(rWorld, new LinearRing[] {});
Assert.assertEquals(Sets.newHashSet(), getSet(f.queryWithin(pWorld, EMPTY_CONSTRAINTS)));
}
}
use of org.openrdf.model.ValueFactory in project incubator-rya by apache.
the class GeoWaveIndexerTest method testDcSearch.
@Test
public void testDcSearch() throws Exception {
// test a ring around dc
try (final GeoWaveGeoIndexer f = new GeoWaveGeoIndexer()) {
f.setConf(conf);
f.purge(conf);
final ValueFactory vf = new ValueFactoryImpl();
final Resource subject = vf.createURI("foo:subj");
final URI predicate = GeoConstants.GEO_AS_WKT;
final Value object = vf.createLiteral("Point(-77.03524 38.889468)", GeoConstants.XMLSCHEMA_OGC_WKT);
final Resource context = vf.createURI("foo:context");
final Statement statement = new ContextStatementImpl(subject, predicate, object, context);
f.storeStatement(convertStatement(statement));
f.flush();
final double[] IN = { -78, 39, -77, 39, -77, 38, -78, 38, -78, 39 };
final LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(IN, 2));
final Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});
Assert.assertEquals(Sets.newHashSet(statement), getSet(f.queryWithin(p1, EMPTY_CONSTRAINTS)));
// test a ring outside the point
final double[] OUT = { -77, 39, -76, 39, -76, 38, -77, 38, -77, 39 };
final LinearRing rOut = gf.createLinearRing(new PackedCoordinateSequence.Double(OUT, 2));
final Polygon pOut = gf.createPolygon(rOut, new LinearRing[] {});
Assert.assertEquals(Sets.newHashSet(), getSet(f.queryWithin(pOut, EMPTY_CONSTRAINTS)));
}
}
Aggregations