public static Response editFeature(
     int fid,
     String spatialcontext,
     String viewpoint,
     InputXML input,
     String img,
     int width,
     int height) {
   try (Database db = new Database()) {
     Point[] points = anglesToFeature(spatialcontext, viewpoint, input.getAngles(), db);
     GeoFeature feature =
         Util.pointsToFeature(points, input.getAngles(), input.getType(), false, 0);
     db.setFeature(fid, spatialcontext, feature.toWkt(), "wkt", 0);
     db.addMeasurement(fid, spatialcontext, viewpoint, input);
     /*HashMap<String, Double> visibility = checkVisibility(spatialcontext, feature, db);
     for (String vp : visibility.keySet()) {
     db.setVisibility(spatialcontext, fid, vp, visibility.get(vp) > VISIBILITY_TOLERANCE);
     }*/
     db.setVisibility(spatialcontext, fid, viewpoint, true);
     db.close();
     // insertImage(img, fid, width, height);
     return FeatureXML.getFeature(spatialcontext, fid);
   } catch (ClientException e) {
     return Config.getResult(e);
   } catch (Exception e) {
     return Config.getResult(e);
   }
 }
  public static Response importFeatures(
      String spatialcontext,
      String data,
      String format,
      String srid,
      String creator,
      String license) {
    try (Database db = new Database()) {
      String[] split = data.split("\\r?\\n");
      for (String content : split) {
        int fid = db.addFeature(spatialcontext, content, format, Integer.parseInt(srid));
        db.addImport(fid, creator, license);

        // TODO: Visibility Analysis
        GeoFeature feature = db.getFeature(spatialcontext, fid);
        HashMap<String, Double> visibility = checkVisibility(spatialcontext, feature, db, null);
        for (String vp : visibility.keySet()) {
          db.setVisibility(spatialcontext, fid, vp, visibility.get(vp) > VISIBILITY_TOLERANCE);
        }
      }
      db.close();
      return Config.getResult();
      // return
      // Response.seeOther(URI.create(Config.getProperty("gv_viewer"))).header("Access-Control-Allow-Origin", "*").build();
    } catch (ClientException e) {
      return Config.getResult(e);
    } catch (Exception e) {
      return Config.getResult(e);
    }
  }
 public static Response deleteFeature(String spatialcontext, int fid) {
   try (Database db = new Database()) {
     db.removeFeature(fid, spatialcontext);
     File file = new File(Config.getProperty("screenshotpath") + fid + ".png");
     file.delete();
     return Config.getResult();
   } catch (ClientException e) {
     return Config.getResult(e);
   } catch (Exception e) {
     return Config.getResult(e);
   }
 }
 public static Response getFeature(String spatialcontext, InputXML input) {
   try (Database db = new Database()) {
     Point[] points = anglesToFeature(spatialcontext, input.getViewpoint(), input.getAngles(), db);
     GeoFeature feature =
         Util.pointsToFeature(points, input.getAngles(), input.getType(), false, 0);
     String message = Config.xml + "<feature>";
     message += "<geom>" + feature.toWkt() + "</geom>";
     return Config.getResult(message + "</feature>");
   } catch (ClientException e) {
     return Config.getResult(e);
   } catch (Exception e) {
     return Config.getResult(e);
   }
 }
 public static Response setScreenshot(
     String spatialcontext, int fid, String img, int width, int height) {
   try {
     insertImage(img, fid, width, height);
     return FeatureXML.getFeature(spatialcontext, fid);
   } catch (Exception e) {
     return Config.getResult(e);
   }
 }
 public static Response setVisibility(
     String spatialcontext, String viewpoint, int fid, boolean visible) {
   try (Database db = new Database()) {
     db.setVisibility(spatialcontext, fid, viewpoint, visible);
     db.close();
     return FeatureXML.getFeature(spatialcontext, fid);
   } catch (Exception e) {
     return Config.getResult(e);
   }
 }
 public static Response setVisibility(String spatialcontext, int fid, String viewpoint) {
   try (Database db = new Database()) {
     GeoFeature feature = db.getFeature(spatialcontext, fid);
     HashMap<String, Double> visibility = checkVisibility(spatialcontext, feature, db, viewpoint);
     for (String vp : visibility.keySet()) {
       db.setVisibility(spatialcontext, fid, vp, visibility.get(vp) > VISIBILITY_TOLERANCE);
     }
     db.close();
     return FeatureXML.getFeature(spatialcontext, fid);
   } catch (Exception e) {
     return Config.getResult(e);
   }
 }