@Test public void testContainsIndex() { OrientGraphNoTx graph = new OrientGraphNoTx("memory:functionsTestWithIndex"); try { ODatabaseDocumentTx db = graph.getRawGraph(); db.command(new OCommandSQL("create class Polygon extends v")).execute(); db.command(new OCommandSQL("create property Polygon.geometry EMBEDDED OPolygon")).execute(); db.command( new OCommandSQL( "insert into Polygon set geometry = ST_Buffer(ST_GeomFromText('POINT(50 50)'), 20)")) .execute(); db.command( new OCommandSQL( "insert into Polygon set geometry = ST_Buffer(ST_GeomFromText('POINT(50 50)'), 40)")) .execute(); db.command( new OCommandSQL("create index Polygon.g on Polygon (geometry) SPATIAL engine lucene")) .execute(); List<ODocument> execute = db.command( new OCommandSQL( "SELECT from Polygon where ST_Contains(geometry, 'POINT(50 50)') = true")) .execute(); Assert.assertEquals(execute.size(), 2); execute = db.command( new OCommandSQL( "SELECT from Polygon where ST_Contains(geometry, ST_Buffer(ST_GeomFromText('POINT(50 50)'), 30)) = true")) .execute(); Assert.assertEquals(execute.size(), 1); } finally { graph.drop(); } }
@Test public void testContainsNoIndex() { OrientGraphNoTx graph = new OrientGraphNoTx("memory:functionsTestNoIndex"); try { ODatabaseDocumentTx db = graph.getRawGraph(); List<ODocument> execute = db.command( new OCommandSQL( "select ST_Contains(smallc,smallc) as smallinsmall,ST_Contains(smallc, bigc) As smallinbig, ST_Contains(bigc,smallc) As biginsmall from (SELECT ST_Buffer(ST_GeomFromText('POINT(50 50)'), 20) As smallc,ST_Buffer(ST_GeomFromText('POINT(50 50)'), 40) As bigc)")) .execute(); ODocument next = execute.iterator().next(); Assert.assertEquals(next.field("smallinsmall"), true); Assert.assertEquals(next.field("smallinbig"), false); Assert.assertEquals(next.field("biginsmall"), true); } finally { graph.drop(); } }