Skip to content
Snippets Groups Projects
Commit b439011e authored by Piotr Gawron's avatar Piotr Gawron
Browse files

polygon of overview image is returned as an array

parent 5628b347
No related branches found
No related tags found
1 merge request!286Resolve "Remove View objects from service"
......@@ -179,8 +179,9 @@ public class ProjectRestImpl extends BaseRestImpl {
}
private Map<String, Object> imageToMap(OverviewImage image) {
Map<String, Object> result = new TreeMap<>();
result.put("filename", image.getFilename());
Map<String, Object> result = new LinkedHashMap<>();
result.put("idObject", image.getId());
result.put("filename", image.getProject().getDirectory() + "/" + image.getFilename());
result.put("width", image.getWidth());
result.put("height", image.getHeight());
List<Map<String, Object>> links = new ArrayList<>();
......@@ -192,13 +193,14 @@ public class ProjectRestImpl extends BaseRestImpl {
}
private Map<String, Object> overviewLinkToMap(OverviewLink link) {
Map<String, Object> result = new TreeMap<>();
result.put("polygon", link.getPolygon());
Map<String, Object> result = new LinkedHashMap<>();
result.put("idObject", link.getId());
result.put("polygon", polygonToMap(link.getPolygon()));
if (link instanceof OverviewModelLink) {
OverviewModelLink modelLink = (OverviewModelLink) link;
result.put("modelLinkId", modelLink.getLinkedModel().getId());
result.put("modelPoint", new Point2D.Double(modelLink.getxCoord(), modelLink.getyCoord()));
result.put("zoomLevel", modelLink.getZoomLevel());
result.put("modelPoint", new Point2D.Double(modelLink.getxCoord(), modelLink.getyCoord()));
result.put("modelLinkId", modelLink.getLinkedModel().getId());
} else if (link instanceof OverviewImageLink) {
result.put("imageLinkId", ((OverviewImageLink) link).getLinkedOverviewImage().getId());
......@@ -211,6 +213,18 @@ public class ProjectRestImpl extends BaseRestImpl {
return result;
}
private List<Map<String, Double>> polygonToMap(String polygon) {
List<Map<String, Double>> result = new ArrayList<>();
for (String string : polygon.split(" ")) {
String tmp[] = string.split(",");
Map<String, Double> point = new TreeMap<>();
point.put("x", Double.parseDouble(tmp[0]));
point.put("y", Double.parseDouble(tmp[1]));
result.add(point);
}
return result;
}
public FileEntry getSource(String token, String projectId) throws SecurityException, QueryException {
Project project = getProjectService().getProjectByProjectId(projectId, token);
if (project == null) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment