Example #1
0
 private void buildLocations() {
   guiLogger.info("Building Locations from ERDDAP Dataset: " + this.getTitle());
   try {
     ClientConfig clientConfig = new DefaultClientConfig();
     clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
     Client c = Client.create(clientConfig);
     guiLogger.info(
         "Request: "
             + this.getTabledap()
             + ".json?"
             + this.getX().getName()
             + ","
             + this.getY().getName()
             + "&distinct()");
     WebResource wr =
         c.resource(
             this.getTabledap()
                 + ".json?"
                 + this.getX().getName()
                 + ","
                 + this.getY().getName()
                 + "&distinct()");
     JSONObject result = wr.get(JSONObject.class);
     JSONArray ar = result.getJSONObject("table").getJSONArray("rows");
     locations = new ArrayList<SensorContainer>(ar.length());
     SensorContainer senc;
     double[] loc = new double[4];
     for (int i = 0; i < ar.length(); i++) {
       senc = new SensorContainer();
       loc[0] = ar.getJSONArray(i).getDouble(1);
       loc[1] = ar.getJSONArray(i).getDouble(0);
       loc[2] = ar.getJSONArray(i).getDouble(1);
       loc[3] = ar.getJSONArray(i).getDouble(0);
       senc.setNESW(loc.clone());
       senc.setName("");
       locations.add(senc);
     }
   } catch (Exception e) {
     guiLogger.error("Exception", e);
   }
 }