Search in sources :

Example 1 with DistanceFromNativePoint

use of org.neo4j.ogm.cypher.function.DistanceFromNativePoint in project neo4j-ogm by neo4j.

the class DistanceComparisonTestBase method filterForCartesianPoint3d.

@Test
public void filterForCartesianPoint3d() {
    Session session = sessionFactory.openSession();
    SomethingSpatial spatial = new SomethingSpatial();
    CartesianPoint3d point = new CartesianPoint3d(1, 2, 3);
    spatial.setCartesianPoint3d(point);
    session.save(spatial);
    DistanceFromNativePoint distanceFromNativePoint = new DistanceFromNativePoint(new CartesianPoint3d(2, 2, 3), 2);
    Filter filter = new Filter("cartesianPoint3d", distanceComparisonFor(distanceFromNativePoint));
    filter.setOwnerEntityType(SomethingSpatial.class);
    Collection<SomethingSpatial> somethingSpatials = session.loadAll(SomethingSpatial.class, filter);
    assertThat(somethingSpatials).hasSize(1);
}
Also used : CartesianPoint3d(org.neo4j.ogm.types.spatial.CartesianPoint3d) Filter(org.neo4j.ogm.cypher.Filter) SomethingSpatial(org.neo4j.ogm.persistence.types.nativetypes.SomethingSpatial) DistanceFromNativePoint(org.neo4j.ogm.cypher.function.DistanceFromNativePoint) Session(org.neo4j.ogm.session.Session) Test(org.junit.Test)

Example 2 with DistanceFromNativePoint

use of org.neo4j.ogm.cypher.function.DistanceFromNativePoint in project neo4j-ogm by neo4j.

the class DistanceComparisonTestBase method filterForGeographicPoint3d.

@Test
public void filterForGeographicPoint3d() {
    Session session = sessionFactory.openSession();
    SomethingSpatial spatial = new SomethingSpatial();
    GeographicPoint3d centralStationLocation = new GeographicPoint3d(55.6093093, 13.0004377, -5);
    spatial.setGeographicPoint3d(centralStationLocation);
    session.save(spatial);
    GeographicPoint3d office = new GeographicPoint3d(55.611851, 12.9949028, 15);
    DistanceFromNativePoint distanceFromNativePoint = new DistanceFromNativePoint(office, 448.9591);
    Filter filter = new Filter("geographicPoint3d", distanceComparisonFor(distanceFromNativePoint));
    filter.setOwnerEntityType(SomethingSpatial.class);
    Collection<SomethingSpatial> somethingSpatials = session.loadAll(SomethingSpatial.class, filter);
    assertThat(somethingSpatials).hasSize(1);
}
Also used : Filter(org.neo4j.ogm.cypher.Filter) GeographicPoint3d(org.neo4j.ogm.types.spatial.GeographicPoint3d) SomethingSpatial(org.neo4j.ogm.persistence.types.nativetypes.SomethingSpatial) DistanceFromNativePoint(org.neo4j.ogm.cypher.function.DistanceFromNativePoint) Session(org.neo4j.ogm.session.Session) Test(org.junit.Test)

Example 3 with DistanceFromNativePoint

use of org.neo4j.ogm.cypher.function.DistanceFromNativePoint in project neo4j-ogm by neo4j.

the class DistanceComparisonTestBase method filterForGeographicPoint2d.

@Test
public void filterForGeographicPoint2d() {
    Session session = sessionFactory.openSession();
    SomethingSpatial spatial = new SomethingSpatial();
    GeographicPoint2d centralStationLocation = new GeographicPoint2d(55.6093093, 13.0004377);
    spatial.setGeographicPoint2d(centralStationLocation);
    session.save(spatial);
    GeographicPoint2d office = new GeographicPoint2d(55.611851, 12.9949028);
    DistanceFromNativePoint distanceFromNativePoint = new DistanceFromNativePoint(office, 449);
    Filter filter = new Filter("geographicPoint2d", distanceComparisonFor(distanceFromNativePoint));
    filter.setOwnerEntityType(SomethingSpatial.class);
    Collection<SomethingSpatial> somethingSpatials = session.loadAll(SomethingSpatial.class, filter);
    assertThat(somethingSpatials).hasSize(1);
}
Also used : Filter(org.neo4j.ogm.cypher.Filter) GeographicPoint2d(org.neo4j.ogm.types.spatial.GeographicPoint2d) SomethingSpatial(org.neo4j.ogm.persistence.types.nativetypes.SomethingSpatial) DistanceFromNativePoint(org.neo4j.ogm.cypher.function.DistanceFromNativePoint) Session(org.neo4j.ogm.session.Session) Test(org.junit.Test)

Example 4 with DistanceFromNativePoint

use of org.neo4j.ogm.cypher.function.DistanceFromNativePoint in project neo4j-ogm by neo4j.

the class DistanceComparisonTestBase method filterForGeographicPoint3dNoMatch.

@Test
public void filterForGeographicPoint3dNoMatch() {
    Session session = sessionFactory.openSession();
    SomethingSpatial spatial = new SomethingSpatial();
    GeographicPoint3d centralStationLocation = new GeographicPoint3d(55.6093093, 13.0004377, -5);
    spatial.setGeographicPoint3d(centralStationLocation);
    session.save(spatial);
    GeographicPoint3d office = new GeographicPoint3d(55.611851, 12.9949028, 15);
    DistanceFromNativePoint distanceFromNativePoint = new DistanceFromNativePoint(office, 448.950);
    Filter filter = new Filter("geographicPoint3d", distanceComparisonFor(distanceFromNativePoint));
    filter.setOwnerEntityType(SomethingSpatial.class);
    Collection<SomethingSpatial> somethingSpatials = session.loadAll(SomethingSpatial.class, filter);
    assertThat(somethingSpatials).hasSize(0);
}
Also used : Filter(org.neo4j.ogm.cypher.Filter) GeographicPoint3d(org.neo4j.ogm.types.spatial.GeographicPoint3d) SomethingSpatial(org.neo4j.ogm.persistence.types.nativetypes.SomethingSpatial) DistanceFromNativePoint(org.neo4j.ogm.cypher.function.DistanceFromNativePoint) Session(org.neo4j.ogm.session.Session) Test(org.junit.Test)

Example 5 with DistanceFromNativePoint

use of org.neo4j.ogm.cypher.function.DistanceFromNativePoint in project neo4j-ogm by neo4j.

the class DistanceComparisonTestBase method filterForCartesianPoint2dNoMatch.

@Test
public void filterForCartesianPoint2dNoMatch() {
    Session session = sessionFactory.openSession();
    SomethingSpatial spatial = new SomethingSpatial();
    CartesianPoint2d point = new CartesianPoint2d(1, 2);
    spatial.setCartesianPoint2d(point);
    session.save(spatial);
    DistanceFromNativePoint distanceFromNativePoint = new DistanceFromNativePoint(new CartesianPoint2d(2, 2), 1);
    Filter filter = new Filter("cartesianPoint2d", distanceComparisonFor(distanceFromNativePoint));
    filter.setOwnerEntityType(SomethingSpatial.class);
    Collection<SomethingSpatial> somethingSpatials = session.loadAll(SomethingSpatial.class, filter);
    assertThat(somethingSpatials).hasSize(0);
}
Also used : Filter(org.neo4j.ogm.cypher.Filter) CartesianPoint2d(org.neo4j.ogm.types.spatial.CartesianPoint2d) SomethingSpatial(org.neo4j.ogm.persistence.types.nativetypes.SomethingSpatial) DistanceFromNativePoint(org.neo4j.ogm.cypher.function.DistanceFromNativePoint) Session(org.neo4j.ogm.session.Session) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)8 Filter (org.neo4j.ogm.cypher.Filter)8 DistanceFromNativePoint (org.neo4j.ogm.cypher.function.DistanceFromNativePoint)8 SomethingSpatial (org.neo4j.ogm.persistence.types.nativetypes.SomethingSpatial)8 Session (org.neo4j.ogm.session.Session)8 CartesianPoint2d (org.neo4j.ogm.types.spatial.CartesianPoint2d)2 CartesianPoint3d (org.neo4j.ogm.types.spatial.CartesianPoint3d)2 GeographicPoint2d (org.neo4j.ogm.types.spatial.GeographicPoint2d)2 GeographicPoint3d (org.neo4j.ogm.types.spatial.GeographicPoint3d)2