@Override public GeoRect getGeoCell() { org.elasticsearch.common.geo.GeoPoint northWest = new org.elasticsearch.common.geo.GeoPoint(); org.elasticsearch.common.geo.GeoPoint southEast = new org.elasticsearch.common.geo.GeoPoint(); GeohashUtils.decodeCell(getKey(), northWest, southEast); return new GeoRect(new GeoPoint(northWest.getLat(), northWest.getLon()), new GeoPoint(southEast.getLat(), southEast.getLon())); } };
@Override public GeoRect getGeoCell() { org.elasticsearch.common.geo.GeoPoint northWest = new org.elasticsearch.common.geo.GeoPoint(); org.elasticsearch.common.geo.GeoPoint southEast = new org.elasticsearch.common.geo.GeoPoint(); GeohashUtils.decodeCell(getKey(), northWest, southEast); return new GeoRect(new GeoPoint(northWest.getLat(), northWest.getLon()), new GeoPoint(southEast.getLat(), southEast.getLon())); } };
@Override public GeohashResult getGeohashResults(String name) { List<GeohashBucket> buckets = new ArrayList<GeohashBucket>(); Aggregation agg = this.searchResponse.getAggregations().get(name); if (agg == null) { return null; } if (agg instanceof GeoHashGrid) { GeoHashGrid h = (GeoHashGrid) agg; for (GeoHashGrid.Bucket b : h.getBuckets()) { org.elasticsearch.common.geo.GeoPoint g = b.getKeyAsGeoPoint(); GeohashBucket geohashBucket = new GeohashBucket(b.getKey(), b.getDocCount(), new GeoPoint(g.getLat(), g.getLon())) { @Override public GeoRect getGeoCell() { org.elasticsearch.common.geo.GeoPoint northWest = new org.elasticsearch.common.geo.GeoPoint(); org.elasticsearch.common.geo.GeoPoint southEast = new org.elasticsearch.common.geo.GeoPoint(); GeohashUtils.decodeCell(getKey(), northWest, southEast); return new GeoRect(new GeoPoint(northWest.getLat(), northWest.getLon()), new GeoPoint(southEast.getLat(), southEast.getLon())); } }; buckets.add(geohashBucket); } } else { throw new SecureGraphException("Aggregation is not a geohash: " + agg.getClass().getName()); } return new GeohashResult(buckets); } }
@Override public GeohashResult getGeohashResults(String name) { List<GeohashBucket> buckets = new ArrayList<GeohashBucket>(); Aggregation agg = this.searchResponse.getAggregations().get(name); if (agg == null) { return null; } if (agg instanceof GeoHashGrid) { GeoHashGrid h = (GeoHashGrid) agg; for (GeoHashGrid.Bucket b : h.getBuckets()) { org.elasticsearch.common.geo.GeoPoint g = b.getKeyAsGeoPoint(); GeohashBucket geohashBucket = new GeohashBucket(b.getKey(), b.getDocCount(), new GeoPoint(g.getLat(), g.getLon())) { @Override public GeoRect getGeoCell() { org.elasticsearch.common.geo.GeoPoint northWest = new org.elasticsearch.common.geo.GeoPoint(); org.elasticsearch.common.geo.GeoPoint southEast = new org.elasticsearch.common.geo.GeoPoint(); GeohashUtils.decodeCell(getKey(), northWest, southEast); return new GeoRect(new GeoPoint(northWest.getLat(), northWest.getLon()), new GeoPoint(southEast.getLat(), southEast.getLon())); } }; buckets.add(geohashBucket); } } else { throw new SecureGraphException("Aggregation is not a geohash: " + agg.getClass().getName()); } return new GeohashResult(buckets); } }
.setProperty("alternateNames", alternateNames, visibility) .setProperty("population", population, visibility) .setProperty("geoLocation", new GeoPoint(latitude, longitude), visibility) .save(authorizations); i++;
@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)); }
.setProperty("long", (long) 5, VISIBILITY_A) .setProperty("boolean", true, VISIBILITY_A) .setProperty("geopoint", new GeoPoint(77, -33), VISIBILITY_A) .setProperty("short", (short) 5, VISIBILITY_A) .setProperty("date", date, VISIBILITY_A)