ProjectMirador / mirador

An open-source, web-based 'multi-up' viewer that supports zoom-pan-rotate functionality, ability to display/compare simple images, and images with annotations.
https://projectmirador.org
Apache License 2.0
558 stars 255 forks source link

SAS missing OA scope causing null value #767

Closed glenrobson closed 8 years ago

glenrobson commented 8 years ago

Just trying to update the SimpleAnnotationServer to work with the latest version of Mirador and found a problem when I tried to edit an annotation. Mirador sends the following Annotation:

{
  "@context" : "file:///Users/gmr/development/mvn/SAS/master/SimpleAnnotationServer/src/main/webapp/contexts/iiif-2.0.json",
  "@type" : "oa:Annotation",
  "motivation" : [ "oa:commenting" ],
  "resource" : [ {
    "@type" : "dctypes:Text",
    "format" : "text/html",
    "chars" : "<p>jones</p>"
  } ],
  "on" : {
    "@type" : "oa:SpecificResource",
    "selector" : {
      "@type" : "oa:FragmentSelector",
      "value" : "xywh=800,111,526,422"
    },
    "scope" : {
      "@context" : "http://www.harvard.edu/catch/oa.json",
      "@type" : "catch:Viewport",
      "value" : "xywh=-2809,0,8168,1662"
    },
    "full" : "http://oculus-dev.harvardx.harvard.edu/manifests/huam:320567/canvas/canvas-20434940.json"
  },
  "@id" : "http://dev.llgc.org.uk/annotation/1456528993897"
}

but as the scope isn't in the context.json when it gets loaded to the RDF store the scope section is lost. Now when I try and edit an annotation the scope is missing so setting scope.value below in osd-canvas-renderer.js fails as the scope is missing.

439  var scope = _this.osdViewer.viewport.viewportToImageRectangle(bounds);
440        //bounds is giving negative values?
441        //update scope
442        oaAnno.on.scope.value = "xywh="+Math.round(scope.x)+","+Math.round(scope.y)+","+Math.round(scope.width)+","+Math.round(scope.height); //osd bounds

Would it be possible to add a test to see if scope is missing and if it is add an empty scope (if scope is required).

rsinghal commented 8 years ago

@glenrobson I will take a look