protected Map<String, Object> convertGeoCircle(GeoCircle geoCircle) { Map<String, Object> propertyValueMap = new HashMap<>(); propertyValueMap.put(FIELD_TYPE, "circle"); List<Double> coordinates = new ArrayList<>(); coordinates.add(geoCircle.getLongitude()); coordinates.add(geoCircle.getLatitude()); propertyValueMap.put(FIELD_COORDINATES, coordinates); propertyValueMap.put(CircleBuilder.FIELD_RADIUS, geoCircle.getRadius() + "km"); return propertyValueMap; }
protected Map<String, Object> convertGeoCircle(GeoCircle geoCircle) { Map<String, Object> propertyValueMap = new HashMap<>(); propertyValueMap.put(FIELD_TYPE, "circle"); List<Double> coordinates = new ArrayList<>(); coordinates.add(geoCircle.getLongitude()); coordinates.add(geoCircle.getLatitude()); propertyValueMap.put(FIELD_COORDINATES, coordinates); propertyValueMap.put(CircleBuilder.FIELD_RADIUS, geoCircle.getRadius() + "km"); return propertyValueMap; }
@Override public String toString() { return "GeoCircle[" + getLatitude() + ", " + getLongitude() + ", " + getRadius() + "]"; } }
protected void convertGeoCircle(Map<String, Object> propertiesMap, String deflatedPropertyName, GeoCircle geoCircle) { Map<String, Object> propertyValueMap = new HashMap<>(); propertyValueMap.put("type", "circle"); List<Double> coordinates = new ArrayList<>(); coordinates.add(geoCircle.getLongitude()); coordinates.add(geoCircle.getLatitude()); propertyValueMap.put("coordinates", coordinates); propertyValueMap.put("radius", geoCircle.getRadius() + "km"); addPropertyValueToPropertiesMap(propertiesMap, deflatedPropertyName + GEO_PROPERTY_NAME_SUFFIX, propertyValueMap); if (geoCircle.getDescription() != null) { addPropertyValueToPropertiesMap(propertiesMap, deflatedPropertyName, geoCircle.getDescription()); } }
@Override public String toString() { return "GeoCircle[" + getLatitude() + ", " + getLongitude() + ", " + getRadius() + "]"; } }
protected void convertGeoCircle(Graph graph, Map<String, Object> propertiesMap, String deflatedPropertyName, GeoCircle geoCircle) { Map<String, Object> propertyValueMap = new HashMap<>(); propertyValueMap.put("type", "circle"); List<Double> coordinates = new ArrayList<>(); coordinates.add(geoCircle.getLongitude()); coordinates.add(geoCircle.getLatitude()); propertyValueMap.put("coordinates", coordinates); propertyValueMap.put("radius", geoCircle.getRadius() + "km"); addPropertyValueToPropertiesMap(propertiesMap, deflatedPropertyName + GEO_PROPERTY_NAME_SUFFIX, propertyValueMap); if (geoCircle.getDescription() != null) { addPropertyValueToPropertiesMap(propertiesMap, deflatedPropertyName, geoCircle.getDescription()); } }
protected void convertGeoCircle(Graph graph, XContentBuilder jsonBuilder, Property property, GeoCircle geoCircle) throws IOException { Map<String, Object> propertyValueMap = new HashMap<>(); propertyValueMap.put("type", "circle"); List<Double> coordinates = new ArrayList<>(); coordinates.add(geoCircle.getLongitude()); coordinates.add(geoCircle.getLatitude()); propertyValueMap.put("coordinates", coordinates); propertyValueMap.put("radius", geoCircle.getRadius() + "km"); jsonBuilder.field(addVisibilityToPropertyName(graph, property) + GEO_PROPERTY_NAME_SUFFIX, propertyValueMap); if (geoCircle.getDescription() != null) { jsonBuilder.field(addVisibilityToPropertyName(graph, property), geoCircle.getDescription()); } }
private CircleBuilder getCircleBuilder(GeoCircle geoCircle) { return ShapeBuilders.newCircleBuilder() .center(geoCircle.getLongitude(), geoCircle.getLatitude()) .radius(geoCircle.getRadius(), DistanceUnit.KILOMETERS); }
@Override public boolean within(GeoShape geoShape) { if (geoShape instanceof GeoPoint) { GeoPoint pt = (GeoPoint) geoShape; return distanceBetween(getLatitude(), getLongitude(), pt.getLatitude(), pt.getLongitude()) <= getRadius(); } else if (geoShape instanceof GeoCircle) { GeoCircle circle = (GeoCircle) geoShape; double distance = distanceBetween(getLatitude(), getLongitude(), circle.getLatitude(), circle.getLongitude()); return distance <= getRadius() + circle.getRadius(); } else if (geoShape instanceof GeoRect) { GeoRect rect = (GeoRect) geoShape; return within(rect.getNorthWest()) && within(rect.getSouthEast()); } else if (geoShape instanceof GeoHash) { return within(((GeoHash) geoShape).toGeoRect()); } else if (geoShape instanceof GeoLine) { return ((GeoLine) geoShape).getGeoPoints().stream().allMatch(this::within); } throw new VertexiumException("Not implemented for argument type " + geoShape.getClass().getName()); }
@Override public boolean within(GeoShape geoShape) { if (geoShape instanceof GeoPoint) { GeoPoint pt = (GeoPoint) geoShape; return distanceBetween(getLatitude(), getLongitude(), pt.getLatitude(), pt.getLongitude()) <= getRadius(); } else if (geoShape instanceof GeoCircle) { GeoCircle circle = (GeoCircle) geoShape; double distance = distanceBetween(getLatitude(), getLongitude(), circle.getLatitude(), circle.getLongitude()); return distance <= getRadius() + circle.getRadius(); } else if (geoShape instanceof GeoRect) { GeoRect rect = (GeoRect) geoShape; return within(rect.getNorthWest()) && within(rect.getSouthEast()); } else if (geoShape instanceof GeoHash) { return within(((GeoHash) geoShape).toGeoRect()); } else if (geoShape instanceof GeoLine) { return ((GeoLine) geoShape).getGeoPoints().stream().allMatch(this::within); } throw new VertexiumException("Not implemented for argument type " + geoShape.getClass().getName()); }
private CircleBuilder getCircleBuilder(GeoCircle geoCircle) { return ShapeBuilders.newCircleBuilder() .center(geoCircle.getLongitude(), geoCircle.getLatitude()) .radius(geoCircle.getRadius(), DistanceUnit.KILOMETERS); }
@Test public void testGeoCircle() { GeoCircle geoCircle = new GeoCircle(12.123, 23.234, 34.345, "Geo circle with description"); testValue( geoCircle, getGeoCircleBytes(), (givenValue, deserializedValue) -> { assertNotNull(deserializedValue); assertEquals(givenValue.getLatitude(), deserializedValue.getLatitude(), 0.001); assertEquals(givenValue.getLongitude(), deserializedValue.getLongitude(), 0.001); assertEquals(givenValue.getRadius(), deserializedValue.getRadius(), 0.001); assertEquals(givenValue.getDescription(), deserializedValue.getDescription()); } ); }
@Test public void testGeoCircle() { GeoCircle geoCircle = new GeoCircle(12.123, 23.234, 34.345, "Geo circle with description"); testValue( geoCircle, getGeoCircleBytes(), (givenValue, deserializedValue) -> { assertNotNull(deserializedValue); assertEquals(givenValue.getLatitude(), deserializedValue.getLatitude(), 0.001); assertEquals(givenValue.getLongitude(), deserializedValue.getLongitude(), 0.001); assertEquals(givenValue.getRadius(), deserializedValue.getRadius(), 0.001); assertEquals(givenValue.getDescription(), deserializedValue.getDescription()); } ); }
GeoCircle geoCircle = (GeoCircle) value; double lat = geoCircle.getLatitude(); double lon = geoCircle.getLongitude(); double distance = geoCircle.getRadius();
GeoCircle geoCircle = (GeoCircle) value; double lat = geoCircle.getLatitude(); double lon = geoCircle.getLongitude(); double distance = geoCircle.getRadius();