本文整理汇总了Java中com.amazonaws.geo.model.GeoPoint类的典型用法代码示例。如果您正苦于以下问题:Java GeoPoint类的具体用法?Java GeoPoint怎么用?Java GeoPoint使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GeoPoint类属于com.amazonaws.geo.model包,在下文中一共展示了GeoPoint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPointsWithinRadius
import com.amazonaws.geo.model.GeoPoint; //导入依赖的package包/类
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;
}
示例2: extractPointData
import com.amazonaws.geo.model.GeoPoint; //导入依赖的package包/类
private PointData extractPointData(Map<String, AttributeValue> item, String... fetchAttributes) {
PointData pd = new PointData();
try {
String geoJsonString = item.get(config().getGeoJsonAttributeName()).getS();
GeoPoint geoPoint = GeoJsonMapper.geoPointFromString(geoJsonString);
pd.setLatitude(geoPoint.getLatitude());
pd.setLongitude(geoPoint.getLongitude());
pd.setRangeKey(item.get(config().getRangeKeyAttributeName()).getS());
for (String fa : fetchAttributes) {
pd.getData().put(fa, item.get(fa).getS());
}
}
catch (Exception e) {
throw new RuntimeException(e);
}
return pd;
}
示例3: queryRectangle
import com.amazonaws.geo.model.GeoPoint; //导入依赖的package包/类
private void queryRectangle(JSONObject requestObject, PrintWriter out) throws IOException, JSONException {
GeoPoint minPoint = new GeoPoint(requestObject.getDouble("minLat"), requestObject.getDouble("minLng"));
GeoPoint maxPoint = new GeoPoint(requestObject.getDouble("maxLat"), requestObject.getDouble("maxLng"));
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");
QueryRectangleRequest queryRectangleRequest = new QueryRectangleRequest(minPoint, maxPoint);
queryRectangleRequest.getQueryRequest().setAttributesToGet(attributesToGet);
QueryRectangleResult queryRectangleResult = geoDataManager.queryRectangle(queryRectangleRequest);
printGeoQueryResult(queryRectangleResult, out, filterUserId);
}
示例4: queryRadius
import com.amazonaws.geo.model.GeoPoint; //导入依赖的package包/类
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);
}
示例5: putPoint
import com.amazonaws.geo.model.GeoPoint; //导入依赖的package包/类
public void putPoint(PointData pd) {
GeoPoint geoPoint = new GeoPoint(pd.getLatitude(), pd.getLongitude());
AttributeValue rangeKeyValue = new AttributeValue().withS(pd.getRangeKey());
PutPointRequest putPointRequest = new PutPointRequest(geoPoint, rangeKeyValue);
for (Entry<String, String> e : pd.getData().entrySet()) {
AttributeValue value = new AttributeValue().withS(e.getValue());
putPointRequest.getPutItemRequest().getItem().put(e.getKey(), value);
}
geoDataManager.putPoint(putPointRequest);
}
示例6: putPoint
import com.amazonaws.geo.model.GeoPoint; //导入依赖的package包/类
private void putPoint(JSONObject requestObject, PrintWriter out) throws IOException, JSONException {
GeoPoint geoPoint = new GeoPoint(requestObject.getDouble("lat"), requestObject.getDouble("lng"));
AttributeValue rangeKeyAttributeValue = new AttributeValue().withS(requestObject.getString("s3-photo-url"));
AttributeValue titleAttributeValue = new AttributeValue().withS(requestObject.getString("title"));
AttributeValue userIdAttributeValue = new AttributeValue().withS(requestObject.getString("userId"));
PutPointRequest putPointRequest = new PutPointRequest(geoPoint, rangeKeyAttributeValue);
putPointRequest.getPutItemRequest().addItemEntry("title", titleAttributeValue);
putPointRequest.getPutItemRequest().addItemEntry("userId", userIdAttributeValue);
PutPointResult putPointResult = geoDataManager.putPoint(putPointRequest);
printPutPointResult(putPointResult, out);
}
示例7: getPoint
import com.amazonaws.geo.model.GeoPoint; //导入依赖的package包/类
private void getPoint(JSONObject requestObject, PrintWriter out) throws IOException, JSONException {
GeoPoint geoPoint = new GeoPoint(requestObject.getDouble("lat"), requestObject.getDouble("lng"));
AttributeValue rangeKeyAttributeValue = new AttributeValue().withS(requestObject.getString("rangeKey"));
GetPointRequest getPointRequest = new GetPointRequest(geoPoint, rangeKeyAttributeValue);
GetPointResult getPointResult = geoDataManager.getPoint(getPointRequest);
printGetPointRequest(getPointResult, out);
}
示例8: deletePoint
import com.amazonaws.geo.model.GeoPoint; //导入依赖的package包/类
private void deletePoint(JSONObject requestObject, PrintWriter out) throws IOException, JSONException {
GeoPoint geoPoint = new GeoPoint(requestObject.getDouble("lat"), requestObject.getDouble("lng"));
AttributeValue rangeKeyAttributeValue = new AttributeValue().withS(requestObject.getString("rangeKey"));
DeletePointRequest deletePointRequest = new DeletePointRequest(geoPoint, rangeKeyAttributeValue);
DeletePointResult deletePointResult = geoDataManager.deletePoint(deletePointRequest);
printDeletePointResult(deletePointResult, out);
}
示例9: filter
import com.amazonaws.geo.model.GeoPoint; //导入依赖的package包/类
/**
* Filter out any points outside of the queried area from the input list.
*
* @param list
* List of items return by Amazon DynamoDB. It may contains points outside of the actual area queried.
*
* @param latLngRect
* Queried area. Any points outside of this area need to be discarded.
*
* @return List of items within the queried area.
*/
private List<Map<String, AttributeValue>> filter(List<Map<String, AttributeValue>> list,
GeoQueryRequest geoQueryRequest) {
List<Map<String, AttributeValue>> result = new ArrayList<Map<String, AttributeValue>>();
S2LatLngRect latLngRect = null;
S2LatLng centerLatLng = null;
double radiusInMeter = 0;
if (geoQueryRequest instanceof QueryRectangleRequest) {
latLngRect = S2Util.getBoundingLatLngRect(geoQueryRequest);
} else if (geoQueryRequest instanceof QueryRadiusRequest) {
GeoPoint centerPoint = ((QueryRadiusRequest) geoQueryRequest).getCenterPoint();
centerLatLng = S2LatLng.fromDegrees(centerPoint.getLatitude(), centerPoint.getLongitude());
radiusInMeter = ((QueryRadiusRequest) geoQueryRequest).getRadiusInMeter();
}
for (Map<String, AttributeValue> item : list) {
String geoJson = item.get(config.getGeoJsonAttributeName()).getS();
GeoPoint geoPoint = GeoJsonMapper.geoPointFromString(geoJson);
S2LatLng latLng = S2LatLng.fromDegrees(geoPoint.getLatitude(), geoPoint.getLongitude());
if (latLngRect != null && latLngRect.contains(latLng)) {
result.add(item);
} else if (centerLatLng != null && radiusInMeter > 0
&& centerLatLng.getEarthDistance(latLng) <= radiusInMeter) {
result.add(item);
}
}
return result;
}
示例10: generateGeohash
import com.amazonaws.geo.model.GeoPoint; //导入依赖的package包/类
public static long generateGeohash(GeoPoint geoPoint) {
S2LatLng latLng = S2LatLng.fromDegrees(geoPoint.getLatitude(), geoPoint.getLongitude());
S2Cell cell = new S2Cell(latLng);
S2CellId cellId = cell.id();
return cellId.id();
}
示例11: geoPointFromString
import com.amazonaws.geo.model.GeoPoint; //导入依赖的package包/类
public static GeoPoint geoPointFromString(String jsonString) {
try {
return mapper.readValue(jsonString, GeoPoint.class);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
示例12: putPoint
import com.amazonaws.geo.model.GeoPoint; //导入依赖的package包/类
private void putPoint(JSONObject requestObject, PrintWriter out) throws IOException, JSONException {
GeoPoint geoPoint = new GeoPoint(requestObject.getDouble("lat"), requestObject.getDouble("lng"));
AttributeValue rangeKeyAttributeValue = new AttributeValue().withS(UUID.randomUUID().toString());
AttributeValue schoolNameKeyAttributeValue = new AttributeValue().withS(requestObject.getString("schoolName"));
PutPointRequest putPointRequest = new PutPointRequest(geoPoint, rangeKeyAttributeValue);
putPointRequest.getPutItemRequest().addItemEntry("schoolName", schoolNameKeyAttributeValue);
PutPointResult putPointResult = geoDataManager.putPoint(putPointRequest);
printPutPointResult(putPointResult, out);
}
示例13: updatePoint
import com.amazonaws.geo.model.GeoPoint; //导入依赖的package包/类
private void updatePoint(JSONObject requestObject, PrintWriter out) throws IOException, JSONException {
GeoPoint geoPoint = new GeoPoint(requestObject.getDouble("lat"), requestObject.getDouble("lng"));
AttributeValue rangeKeyAttributeValue = new AttributeValue().withS(requestObject.getString("rangeKey"));
String schoolName = requestObject.getString("schoolName");
AttributeValueUpdate schoolNameValueUpdate = null;
String memo = requestObject.getString("memo");
AttributeValueUpdate memoValueUpdate = null;
if (schoolName == null || schoolName.equalsIgnoreCase("")) {
schoolNameValueUpdate = new AttributeValueUpdate().withAction(AttributeAction.DELETE);
} else {
AttributeValue schoolNameAttributeValue = new AttributeValue().withS(schoolName);
schoolNameValueUpdate = new AttributeValueUpdate().withAction(AttributeAction.PUT).withValue(
schoolNameAttributeValue);
}
if (memo == null || memo.equalsIgnoreCase("")) {
memoValueUpdate = new AttributeValueUpdate().withAction(AttributeAction.DELETE);
} else {
AttributeValue memoAttributeValue = new AttributeValue().withS(memo);
memoValueUpdate = new AttributeValueUpdate().withAction(AttributeAction.PUT).withValue(memoAttributeValue);
}
UpdatePointRequest updatePointRequest = new UpdatePointRequest(geoPoint, rangeKeyAttributeValue);
updatePointRequest.getUpdateItemRequest().addAttributeUpdatesEntry("schoolName", schoolNameValueUpdate);
updatePointRequest.getUpdateItemRequest().addAttributeUpdatesEntry("memo", memoValueUpdate);
UpdatePointResult updatePointResult = geoDataManager.updatePoint(updatePointRequest);
printUpdatePointResult(updatePointResult, out);
}
示例14: queryRectangle
import com.amazonaws.geo.model.GeoPoint; //导入依赖的package包/类
private void queryRectangle(JSONObject requestObject, PrintWriter out) throws IOException, JSONException {
GeoPoint minPoint = new GeoPoint(requestObject.getDouble("minLat"), requestObject.getDouble("minLng"));
GeoPoint maxPoint = new GeoPoint(requestObject.getDouble("maxLat"), requestObject.getDouble("maxLng"));
List<String> attributesToGet = new ArrayList<String>();
attributesToGet.add(config.getRangeKeyAttributeName());
attributesToGet.add(config.getGeoJsonAttributeName());
attributesToGet.add("schoolName");
QueryRectangleRequest queryRectangleRequest = new QueryRectangleRequest(minPoint, maxPoint);
queryRectangleRequest.getQueryRequest().setAttributesToGet(attributesToGet);
QueryRectangleResult queryRectangleResult = geoDataManager.queryRectangle(queryRectangleRequest);
printGeoQueryResult(queryRectangleResult, out);
}
示例15: queryRadius
import com.amazonaws.geo.model.GeoPoint; //导入依赖的package包/类
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);
}