Exemplo n.º 1
0
  /**
   * Method handling HTTP GET requests. The returned object will be sent to the client as
   * "text/plain" media type.
   *
   * @return String that will be returned as a text/plain response.
   */
  @GET
  @Path("/events/{lat}/{lon}")
  @Produces(MediaType.APPLICATION_JSON)
  public String getResultsProximity(
      @PathParam("lat") double latitude, @PathParam("lon") double longitude) {
    FacadeGeoData facadeGeoData = new FacadeGeoDataImpl();
    List<JsonObject> results = new ArrayList<JsonObject>();
    Location location = new Location();
    location.setType("Point");
    double[] coord = {longitude, latitude};
    location.setCoordinates(coord);
    try {
      results = facadeGeoData.getGeoDataProximity(location);

    } catch (Exception e) {
      e.printStackTrace();
    }
    System.out.println(results.toString());
    return results.toString();
  }
Exemplo n.º 2
0
  @GET
  @Path("/events/area/{id_area}")
  @Produces(MediaType.APPLICATION_JSON)
  public List<GeoData> getResultsWithinArea(@PathParam("id_area") String id_area) {
    FacadeAdministrativeArea facadeAdminArea = new FacadeAdministrativeAreaImpl();
    FacadeGeoData facadeGeoData = new FacadeGeoDataImpl();
    List<GeoData> results = new ArrayList<GeoData>();

    try {
      AdministrativeArea adminArea = facadeAdminArea.getAdministrativeArea(id_area);
      Geometry geometry = new Geometry();
      geometry.setType("MultiPoint");
      geometry.setCoordinates(adminArea.getGeometry().getCoordinates());
      results = facadeGeoData.getGeoDataWithinArea(geometry);

    } catch (Exception e) {
      e.printStackTrace();
    }
    System.out.println(results);
    return results;
  }