use of org.neo4j.ogm.types.spatial.GeographicPoint2d in project neo4j-ogm by neo4j.
the class PointToBoltValueAdapter method apply.
@Override
public Point apply(AbstractPoint object) {
Value value;
if (object instanceof CartesianPoint2d) {
CartesianPoint2d point = (CartesianPoint2d) object;
value = Values.point(point.getSrid(), point.getX(), point.getY());
} else if (object instanceof CartesianPoint3d) {
CartesianPoint3d point = (CartesianPoint3d) object;
value = Values.point(point.getSrid(), point.getX(), point.getY(), point.getZ());
} else if (object instanceof GeographicPoint2d) {
GeographicPoint2d point = (GeographicPoint2d) object;
value = Values.point(point.getSrid(), point.getLongitude(), point.getLatitude());
} else if (object instanceof GeographicPoint3d) {
GeographicPoint3d point = (GeographicPoint3d) object;
value = Values.point(point.getSrid(), point.getLongitude(), point.getLatitude(), point.getHeight());
} else {
throw new IllegalArgumentException("Unsupported point implementation: " + object.getClass());
}
return value.asPoint();
}
use of org.neo4j.ogm.types.spatial.GeographicPoint2d in project neo4j-ogm by neo4j.
the class SpatialTestBase method convertPersistAndLoadGeographicPoint2dForRelationship.
@Test
public void convertPersistAndLoadGeographicPoint2dForRelationship() {
Session session = sessionFactory.openSession();
SomethingRelationship somethingRelated = new SomethingRelationship();
GeographicPoint2d point = new GeographicPoint2d(1, 2);
somethingRelated.setGeographicPoint2d(point);
session.save(somethingRelated);
session.clear();
SomethingRelationship loaded = session.load(SomethingRelationship.class, somethingRelated.getId());
assertThat(loaded.getGeographicPoint2d()).isEqualTo(point);
}
use of org.neo4j.ogm.types.spatial.GeographicPoint2d in project neo4j-ogm by neo4j.
the class SpatialTestBase method spatialObjectsInMapsShouldWork.
@Test
public void spatialObjectsInMapsShouldWork() {
Session session = sessionFactory.openSession();
SomethingSpatial spatial = new SomethingSpatial();
GeographicPoint2d geographicPoint2d = new GeographicPoint2d(1, 2);
GeographicPoint3d geographicPoint3d = new GeographicPoint3d(1, 2, 3);
CartesianPoint2d cartesianPoint2d = new CartesianPoint2d(1, 2);
CartesianPoint3d cartesianPoint3d = new CartesianPoint3d(1, 2, 3);
spatial.addProperty("geographicPoint2d", geographicPoint2d);
spatial.addProperty("geographicPoint3d", geographicPoint3d);
spatial.addProperty("cartesianPoint2d", cartesianPoint2d);
spatial.addProperty("cartesianPoint3d", cartesianPoint3d);
session.save(spatial);
session.clear();
SomethingSpatial loaded = session.load(SomethingSpatial.class, spatial.getId());
assertThat(loaded.getProperties()).containsEntry("geographicPoint2d", geographicPoint2d);
assertThat(loaded.getProperties()).containsEntry("geographicPoint3d", geographicPoint3d);
assertThat(loaded.getProperties()).containsEntry("cartesianPoint2d", cartesianPoint2d);
assertThat(loaded.getProperties()).containsEntry("cartesianPoint3d", cartesianPoint3d);
}
use of org.neo4j.ogm.types.spatial.GeographicPoint2d in project neo4j-ogm by neo4j.
the class SpatialTestBase method convertPersistAndLoadGeographicPoint2d.
@Test
public void convertPersistAndLoadGeographicPoint2d() {
Session session = sessionFactory.openSession();
SomethingSpatial spatial = new SomethingSpatial();
GeographicPoint2d point = new GeographicPoint2d(1, 2);
spatial.setGeographicPoint2d(point);
session.save(spatial);
session.clear();
SomethingSpatial loaded = session.load(SomethingSpatial.class, spatial.getId());
assertThat(loaded.getGeographicPoint2d()).isEqualTo(point);
}
use of org.neo4j.ogm.types.spatial.GeographicPoint2d 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);
}
Aggregations