changeset 1392:266e31e20a5b

added support for legacy 'areas' annotation format.
author robcast
date Thu, 04 Jun 2015 16:10:12 +0200
parents a42721c798ef
children bb45e0404306
files webapp/src/main/webapp/jquery/jquery.digilib.annotator.js
diffstat 1 files changed, 19 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/webapp/src/main/webapp/jquery/jquery.digilib.annotator.js	Thu Jun 04 12:58:51 2015 +0200
+++ b/webapp/src/main/webapp/jquery/jquery.digilib.annotator.js	Thu Jun 04 16:10:12 2015 +0200
@@ -31,7 +31,7 @@
  */
 (function($) {
     // version of this plugin
-    var version = 'jquery.digilib.annotator.js 1.3.4';
+    var version = 'jquery.digilib.annotator.js 1.3.5';
 
     // affine geometry
     var geom = null;
@@ -384,6 +384,24 @@
         var area = null;
         var type = null;
         var shape = null;
+        if (annotation.areas != null && annotation.shapes == null) {
+            console.warn("Annotation uses legacy 'areas' format! Converting...");
+            /*
+             * convert legacy annotation areas into shapes
+             */
+            area = geom.rectangle(annotation.areas[0]);
+            annoShape = {
+                'geometry' : area,
+                'units' : 'fraction'
+            };
+            if (area.isRectangle()) {
+                annoShape['type'] = 'rectangle';
+            } else {
+                annoShape['type'] = 'point';
+            }
+            delete annotation.areas;
+            annotation.shapes = [annoShape];
+        }
         if (annotation.shapes != null) {
             // annotation shape
             annoShape = annotation.shapes[0];