Skip to content

Commit

Permalink
include annotation data in GET media-assets/ID
Browse files Browse the repository at this point in the history
  • Loading branch information
naknomum committed Jan 21, 2025
1 parent 9589def commit 78cf601
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/main/java/org/ecocean/api/GenericObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import org.json.JSONArray;
import org.json.JSONObject;

import org.ecocean.Annotation;
import org.ecocean.media.Feature;
import org.ecocean.media.MediaAsset;
import org.ecocean.media.MediaAssetFactory;
import org.ecocean.servlet.ServletUtilities;
Expand Down Expand Up @@ -56,6 +58,27 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response)
rtn.put("url", url.toString());
rtn.put("width", ma.getWidth());
rtn.put("height", ma.getHeight());
JSONArray janns = new JSONArray();
for (Annotation ann : ma.getAnnotations()) {
JSONObject jann = new JSONObject();
if (ann.getFeatures() != null) {
for (Feature ft : ann.getFeatures()) {
if (ft.isUnity()) {
jann.put("trivial", true);
jann.put("x", 0);
jann.put("y", 0);
jann.put("width", (int)ma.getWidth());
jann.put("height", (int)ma.getHeight());
} else {
// basically if we have more than one feature, only one wins
if (ft.getParameters() != null) jann = ft.getParameters();
}
}
}
jann.put("id", ann.getId());
janns.put(jann);
}
rtn.put("annotations", janns);
}
}
break;
Expand Down

0 comments on commit 78cf601

Please sign in to comment.