Java 类com.amazonaws.geo.model.QueryRadiusResult 实例源码

项目:UnitedWayRESTBackend    文件:DynamoGeoService.java   
public List<PointData> getPointsWithinRadius(double latitude, double longitude, double radiusInMeter, String... fetchAttributes) {
    GeoPoint centerPoint = new GeoPoint(latitude, longitude);

    //System.out.println(latitude + "/" + longitude); //TODO remove DEBUG code

    List<String> attributesToGet = new ArrayList<String>();
    attributesToGet.add(config().getRangeKeyAttributeName());
    attributesToGet.add(config().getGeoJsonAttributeName());
    for (String fa : fetchAttributes) {
        attributesToGet.add(fa);
    }

    QueryRadiusRequest queryRadiusRequest = new QueryRadiusRequest(centerPoint, radiusInMeter);
    queryRadiusRequest.getQueryRequest().setAttributesToGet(attributesToGet);
    QueryRadiusResult queryRadiusResult = geoDataManager.queryRadius(queryRadiusRequest);

    List<PointData> result = new LinkedList<PointData>();
    for (Map<String, AttributeValue> item : queryRadiusResult.getItem()) {
        //System.out.println(" => " + item); //TODO remove DEBUG code

        PointData pd = extractPointData(item, fetchAttributes);
        result.add(pd);
    }

    return result;
}
项目:reinvent2013-mobile-photo-share    文件:GeoDynamoDBServlet.java   
private void queryRadius(JSONObject requestObject, PrintWriter out) throws IOException, JSONException {
    GeoPoint centerPoint = new GeoPoint(requestObject.getDouble("lat"), requestObject.getDouble("lng"));
    double radiusInMeter = requestObject.getDouble("radiusInMeter");
    String filterUserId = requestObject.getString("filterUserId");

    List<String> attributesToGet = new ArrayList<String>();
    attributesToGet.add(config.getRangeKeyAttributeName());
    attributesToGet.add(config.getGeoJsonAttributeName());
    attributesToGet.add("title");
    attributesToGet.add("userId");

    QueryRadiusRequest queryRadiusRequest = new QueryRadiusRequest(centerPoint, radiusInMeter);
    queryRadiusRequest.getQueryRequest().setAttributesToGet(attributesToGet);
    QueryRadiusResult queryRadiusResult = geoDataManager.queryRadius(queryRadiusRequest);

    printGeoQueryResult(queryRadiusResult, out, filterUserId);
}
项目:dynamodb-geo    文件:GeoDynamoDBServlet.java   
private void queryRadius(JSONObject requestObject, PrintWriter out) throws IOException, JSONException {
    GeoPoint centerPoint = new GeoPoint(requestObject.getDouble("lat"), requestObject.getDouble("lng"));
    double radiusInMeter = requestObject.getDouble("radiusInMeter");

    List<String> attributesToGet = new ArrayList<String>();
    attributesToGet.add(config.getRangeKeyAttributeName());
    attributesToGet.add(config.getGeoJsonAttributeName());
    attributesToGet.add("schoolName");

    QueryRadiusRequest queryRadiusRequest = new QueryRadiusRequest(centerPoint, radiusInMeter);
    queryRadiusRequest.getQueryRequest().setAttributesToGet(attributesToGet);
    QueryRadiusResult queryRadiusResult = geoDataManager.queryRadius(queryRadiusRequest);

    printGeoQueryResult(queryRadiusResult, out);
}
项目:dynamodb-geo    文件:GeoDataManager.java   
/**
 * <p>
 * Query a circular area constructed by a center point and its radius.
 * </p>
 * <b>Sample usage:</b>
 * 
 * <pre>
 * GeoPoint centerPoint = new GeoPoint(47.5, -122.3);
 * 
 * QueryRadiusRequest queryRadiusRequest = new QueryRadiusRequest(centerPoint, 100);
 * QueryRadiusResult queryRadiusResult = geoIndexManager.queryRadius(queryRadiusRequest);
 * 
 * for (Map&lt;String, AttributeValue&gt; item : queryRadiusResult.getItem()) {
 *  System.out.println(&quot;item: &quot; + item);
 * }
 * </pre>
 * 
 * @param queryRadiusRequest
 *            Container for the necessary parameters to execute radius query request.
 * 
 * @return Result of radius query request.
 * */
public QueryRadiusResult queryRadius(QueryRadiusRequest queryRadiusRequest) {
    S2LatLngRect latLngRect = S2Util.getBoundingLatLngRect(queryRadiusRequest);

    S2CellUnion cellUnion = S2Manager.findCellIds(latLngRect);

    List<GeohashRange> ranges = mergeCells(cellUnion);
    cellUnion = null;

    return new QueryRadiusResult(dispatchQueries(ranges, queryRadiusRequest));
}