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 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); } }
private static HashMap<String, Double> checkVisibility( String spatialcontext, GeoFeature feature, Database db, String viewpoint) throws SQLException, ClassNotFoundException, IOException { double tolerance; if (viewpoint == null || viewpoint.isEmpty()) { tolerance = POINTCLOUD_TOLERANCE; } else { ResultSet startViewpoint = db.getViewpoint(spatialcontext, viewpoint); if (startViewpoint.next()) { String filename = Config.getProperty("pointcloudpath") + startViewpoint.getString("filename"); Transformation t = new Transformation(startViewpoint.getString("pointcloud_trans")); t.transform(new Transformation(startViewpoint.getString("viewpoint_trans"))); feature.transform(t.inverse()); tolerance = feature.getPointTol(filename); feature.transform(t); if (tolerance < POINTCLOUD_TOLERANCE) { tolerance = POINTCLOUD_TOLERANCE; } } else { tolerance = POINTCLOUD_TOLERANCE; } } // result.last(); // int size = result.getRow(); // result.beforeFirst(); ResultSet result = db.getViewpoints(spatialcontext); HashMap<String, Double> visibility = new HashMap<>(); while (result.next()) { // user.setStatus(result.getRow() * 90 / size); String filename = Config.getProperty("pointcloudpath") + result.getString("filename"); Transformation t = new Transformation(result.getString("pointcloud_trans")); t.transform(new Transformation(result.getString("viewpoint_trans"))); feature.transform(t.inverse()); visibility.put(result.getString("name"), feature.visible(tolerance, filename)); feature.transform(t); } return visibility; }