@Override public String toString() { return "GeoCircle[" + getLatitude() + ", " + getLongitude() + ", " + getRadius() + "]"; } }
@Test public void testGraphQueryGeoPoint() { graph.prepareVertex("v1", VISIBILITY_A) .setProperty("location", new GeoPoint(38.9186, -77.2297, "Reston, VA"), VISIBILITY_A) .save(AUTHORIZATIONS_A_AND_B); graph.prepareVertex("v2", VISIBILITY_A) .setProperty("location", new GeoPoint(38.9544, -77.3464, "Reston, VA"), VISIBILITY_A) .save(AUTHORIZATIONS_A_AND_B); List<Vertex> vertices = toList(graph.query(AUTHORIZATIONS_A) .has("location", GeoCompare.WITHIN, new GeoCircle(38.9186, -77.2297, 1)) .vertices()); assertEquals(1, count(vertices)); GeoPoint geoPoint = (GeoPoint) vertices.get(0).getPropertyValue("location"); assertEquals(38.9186, geoPoint.getLatitude(), 0.001); assertEquals(-77.2297, geoPoint.getLongitude(), 0.001); assertEquals("Reston, VA", geoPoint.getDescription()); vertices = toList(graph.query(AUTHORIZATIONS_A) .has("location", GeoCompare.WITHIN, new GeoCircle(38.9186, -77.2297, 25)) .vertices()); assertEquals(2, count(vertices)); vertices = toList(graph.query(AUTHORIZATIONS_A) .has("location", TextPredicate.CONTAINS, "Reston") .vertices()); assertEquals(2, count(vertices)); }
@Test public void testGraphQueryGeoPoint() { graph.prepareVertex("v1", VISIBILITY_A) .setProperty("location", new GeoPoint(38.9186, -77.2297, "Reston, VA"), VISIBILITY_A) .save(AUTHORIZATIONS_A_AND_B); graph.prepareVertex("v2", VISIBILITY_A) .setProperty("location", new GeoPoint(38.9544, -77.3464, "Reston, VA"), VISIBILITY_A) .save(AUTHORIZATIONS_A_AND_B); List<Vertex> vertices = toList(graph.query(AUTHORIZATIONS_A) .has("location", GeoCompare.WITHIN, new GeoCircle(38.9186, -77.2297, 1)) .vertices()); assertEquals(1, count(vertices)); GeoPoint geoPoint = (GeoPoint) vertices.get(0).getPropertyValue("location"); assertEquals(38.9186, geoPoint.getLatitude(), 0.001); assertEquals(-77.2297, geoPoint.getLongitude(), 0.001); assertEquals("Reston, VA", geoPoint.getDescription()); vertices = toList(graph.query(AUTHORIZATIONS_A) .has("location", GeoCompare.WITHIN, new GeoCircle(38.9186, -77.2297, 25)) .vertices()); assertEquals(2, count(vertices)); vertices = toList(graph.query(AUTHORIZATIONS_A) .has("location", TextPredicate.CONTAINS, "Reston") .vertices()); assertEquals(2, count(vertices)); }
@Override public String toString() { return "GeoCircle[" + getLatitude() + ", " + getLongitude() + ", " + getRadius() + "]"; } }
assertEquals(1, count(graph.query(AUTHORIZATIONS_A).has("bigDecimal", BigDecimal.valueOf(1.1)).vertices())); assertEquals(1, count(graph.query(AUTHORIZATIONS_A).has("bigDecimal", 1.1).vertices())); assertEquals(1, count(graph.query(AUTHORIZATIONS_A).has("geopoint", GeoCompare.WITHIN, new GeoCircle(77, -33, 1)).vertices()));
@Override public boolean within(GeoShape geoShape) { if (geoShape instanceof GeoPoint) { GeoPoint pt = (GeoPoint) geoShape; return GeoPoint.distanceBetween(getLatitude(), getLongitude(), pt.getLatitude(), pt.getLongitude()) <= getRadius(); } throw new SecureGraphException("Not implemented for argument type " + geoShape.getClass().getName()); }
assertEquals(1, count(graph.query(AUTHORIZATIONS_A).has("bigDecimal", BigDecimal.valueOf(1.1)).vertices())); assertEquals(1, count(graph.query(AUTHORIZATIONS_A).has("bigDecimal", 1.1).vertices())); assertEquals(1, count(graph.query(AUTHORIZATIONS_A).has("geopoint", GeoCompare.WITHIN, new GeoCircle(77, -33, 1)).vertices()));
@Override public boolean within(GeoShape geoShape) { if (geoShape instanceof GeoPoint) { GeoPoint pt = (GeoPoint) geoShape; return GeoPoint.distanceBetween(getLatitude(), getLongitude(), pt.getLatitude(), pt.getLongitude()) <= getRadius(); } throw new SecureGraphException("Not implemented for argument type " + geoShape.getClass().getName()); }
if (has.value instanceof GeoCircle) { GeoCircle geoCircle = (GeoCircle) has.value; double lat = geoCircle.getLatitude(); double lon = geoCircle.getLongitude(); double distance = geoCircle.getRadius(); filters .add(FilterBuilders
if (has.value instanceof GeoCircle) { GeoCircle geoCircle = (GeoCircle) has.value; double lat = geoCircle.getLatitude(); double lon = geoCircle.getLongitude(); double distance = geoCircle.getRadius(); filters .add(FilterBuilders