Package com.amazonaws.geo.model

Examples of com.amazonaws.geo.model.GeoPoint


          String schoolId = columns[0];
          String schoolName = columns[1];
          double latitude = Double.parseDouble(columns[2]);
          double longitude = Double.parseDouble(columns[3]);

          GeoPoint geoPoint = new GeoPoint(latitude, longitude);
          AttributeValue rangeKeyValue = new AttributeValue().withS(schoolId);
          AttributeValue schoolNameValue = new AttributeValue().withS(schoolName);

          PutPointRequest putPointRequest = new PutPointRequest(geoPoint, rangeKeyValue);
          putPointRequest.getPutItemRequest().getItem().put("schoolName", schoolNameValue);
View Full Code Here


      log(sw.toString());
    }
  }

  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);
View Full Code Here

    out.println(mapper.writeValueAsString(jsonMap));
    out.flush();
  }

  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);
View Full Code Here

    out.println(mapper.writeValueAsString(jsonMap));
    out.flush();
  }

  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;
View Full Code Here

    out.println(mapper.writeValueAsString(jsonMap));
    out.flush();
  }

  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");
View Full Code Here

    printGeoQueryResult(queryRectangleResult, out);
  }

  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());
View Full Code Here

    out.println(mapper.writeValueAsString(jsonMap));
    out.flush();
  }

  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);
View Full Code Here

    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);
View Full Code Here

   * */
  public static S2LatLngRect getBoundingLatLngRect(GeoQueryRequest geoQueryRequest) {
    if (geoQueryRequest instanceof QueryRectangleRequest) {
      QueryRectangleRequest queryRectangleRequest = (QueryRectangleRequest) geoQueryRequest;

      GeoPoint minPoint = queryRectangleRequest.getMinPoint();
      GeoPoint maxPoint = queryRectangleRequest.getMaxPoint();

      S2LatLngRect latLngRect = null;

      if (minPoint != null && maxPoint != null) {
        S2LatLng minLatLng = S2LatLng.fromDegrees(minPoint.getLatitude(), minPoint.getLongitude());
        S2LatLng maxLatLng = S2LatLng.fromDegrees(maxPoint.getLatitude(), maxPoint.getLongitude());

        latLngRect = new S2LatLngRect(minLatLng, maxLatLng);
      }

      return latLngRect;
    } else if (geoQueryRequest instanceof QueryRadiusRequest) {
      QueryRadiusRequest queryRadiusRequest = (QueryRadiusRequest) geoQueryRequest;

      GeoPoint centerPoint = queryRadiusRequest.getCenterPoint();
      double radiusInMeter = queryRadiusRequest.getRadiusInMeter();

      S2LatLng centerLatLng = S2LatLng.fromDegrees(centerPoint.getLatitude(), centerPoint.getLongitude());

      double latReferenceUnit = centerPoint.getLatitude() > 0.0 ? -1.0 : 1.0;
      S2LatLng latReferenceLatLng = S2LatLng.fromDegrees(centerPoint.getLatitude() + latReferenceUnit,
          centerPoint.getLongitude());
      double lngReferenceUnit = centerPoint.getLongitude() > 0.0 ? -1.0 : 1.0;
      S2LatLng lngReferenceLatLng = S2LatLng.fromDegrees(centerPoint.getLatitude(), centerPoint.getLongitude()
          + lngReferenceUnit);

      double latForRadius = radiusInMeter / centerLatLng.getEarthDistance(latReferenceLatLng);
      double lngForRadius = radiusInMeter / centerLatLng.getEarthDistance(lngReferenceLatLng);

      S2LatLng minLatLng = S2LatLng.fromDegrees(centerPoint.getLatitude() - latForRadius,
          centerPoint.getLongitude() - lngForRadius);
      S2LatLng maxLatLng = S2LatLng.fromDegrees(centerPoint.getLatitude() + latForRadius,
          centerPoint.getLongitude() + lngForRadius);

      return new S2LatLngRect(minLatLng, maxLatLng);
    }

    return null;
View Full Code Here

TOP

Related Classes of com.amazonaws.geo.model.GeoPoint

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.