use of com.vividsolutions.jts.geom.LinearRing in project incubator-rya by apache.
the class GeoWaveIndexerTest method testDcSearchWithSubjectAndContext.
@Test
public void testDcSearchWithSubjectAndContext() 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[] {});
// query with correct context subject
Assert.assertEquals(Sets.newHashSet(statement), getSet(f.queryWithin(p1, new StatementConstraints().setContext(context).setSubject(subject))));
// query with wrong context
Assert.assertEquals(Sets.newHashSet(), getSet(f.queryWithin(p1, new StatementConstraints().setContext(vf.createURI("foo:context2")))));
// query with wrong subject
Assert.assertEquals(Sets.newHashSet(), getSet(f.queryWithin(p1, new StatementConstraints().setSubject(vf.createURI("foo:subj2")))));
}
}
use of com.vividsolutions.jts.geom.LinearRing in project incubator-rya by apache.
the class GeoWaveIndexerTest method testDcSearchWithPredicate.
@Test
public void testDcSearchWithPredicate() 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[] {});
// query with correct Predicate
Assert.assertEquals(Sets.newHashSet(statement), getSet(f.queryWithin(p1, new StatementConstraints().setPredicates(Collections.singleton(predicate)))));
// query with wrong predicate
Assert.assertEquals(Sets.newHashSet(), getSet(f.queryWithin(p1, new StatementConstraints().setPredicates(Collections.singleton(vf.createURI("other:pred"))))));
}
}
use of com.vividsolutions.jts.geom.LinearRing in project incubator-rya by apache.
the class MongoGeoIndexerIT method testDeleteSearch.
@Test
public void testDeleteSearch() throws Exception {
// test a ring around dc
try (final MongoGeoIndexer f = new MongoGeoIndexer()) {
f.setConf(conf);
f.init();
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[] {});
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[] {});
assertEquals(Sets.newHashSet(), getSet(f.queryWithin(pOut, EMPTY_CONSTRAINTS)));
// test a ring for the whole world and make sure the point is gone
// Geomesa is a little sensitive around lon 180, so we only go to 179
final double[] world = { -180, 90, 179, 90, 179, -90, -180, -90, -180, 90 };
final LinearRing rWorld = gf.createLinearRing(new PackedCoordinateSequence.Double(world, 2));
final Polygon pWorld = gf.createPolygon(rWorld, new LinearRing[] {});
assertEquals(Sets.newHashSet(), getSet(f.queryWithin(pWorld, EMPTY_CONSTRAINTS)));
}
}
use of com.vividsolutions.jts.geom.LinearRing in project incubator-rya by apache.
the class MongoGeoIndexerIT method testDcSearchWithContext.
@Test
public void testDcSearchWithContext() throws Exception {
// test a ring around dc
try (final MongoGeoIndexer f = new MongoGeoIndexer()) {
f.setConf(conf);
f.init();
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[] {});
// query with correct context
assertEquals(Sets.newHashSet(statement), getSet(f.queryWithin(p1, new StatementConstraints().setContext(context))));
// query with wrong context
assertEquals(Sets.newHashSet(), getSet(f.queryWithin(p1, new StatementConstraints().setContext(vf.createURI("foo:context2")))));
}
}
use of com.vividsolutions.jts.geom.LinearRing in project incubator-rya by apache.
the class MongoGeoIndexerIT method testAntiMeridianSearch.
// @Test
public void testAntiMeridianSearch() throws Exception {
// verify that a search works if the bounding box crosses the anti meridian
try (final MongoGeoIndexer f = new MongoGeoIndexer()) {
f.setConf(conf);
f.init();
final ValueFactory vf = new ValueFactoryImpl();
final Resource context = vf.createURI("foo:context");
final Resource subjectEast = vf.createURI("foo:subj:east");
final URI predicateEast = GeoConstants.GEO_AS_WKT;
final Value objectEast = vf.createLiteral("Point(179 0)", GeoConstants.XMLSCHEMA_OGC_WKT);
final Statement statementEast = new ContextStatementImpl(subjectEast, predicateEast, objectEast, context);
f.storeStatement(convertStatement(statementEast));
final Resource subjectWest = vf.createURI("foo:subj:west");
final URI predicateWest = GeoConstants.GEO_AS_WKT;
final Value objectWest = vf.createLiteral("Point(-179 0)", GeoConstants.XMLSCHEMA_OGC_WKT);
final Statement statementWest = new ContextStatementImpl(subjectWest, predicateWest, objectWest, context);
f.storeStatement(convertStatement(statementWest));
f.flush();
final double[] ONE = { 178.1, 1, -178, 1, -178, -1, 178.1, -1, 178.1, 1 };
final LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(ONE, 2));
final Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});
assertEquals(Sets.newHashSet(statementEast, statementWest), getSet(f.queryWithin(p1, EMPTY_CONSTRAINTS)));
}
}
Aggregations