Commit 3764cebf authored by Mathias Goebel's avatar Mathias Goebel 🎠
Browse files

restructured and refined

parent a99b9471
......@@ -21,7 +21,7 @@ import module namespace rest="http://exquery.org/ns/restxq";
import module namespace fontaneTransfo="http://fontane-nb.dariah.eu/Transfo" at "transform.xqm";
(:~
: retreives parameters via REST, queries the link and returns the corresponding
: retreives parameters via REST and returns the corresponding
: image. Resolution is always 1000px in height.
:
: @param $uri – A valid TextGrid Base-URI without prefix
......@@ -35,22 +35,7 @@ declare
%output:method("binary")
function tbleapi:stream-image($uri as xs:string, $xmlid as xs:string, $format as xs:string)
{
let $link := fontaneTransfo:newestTBLELink($uri, $xmlid)
let $shape := $link/@targets => substring-after('#') => substring-before(' ')
let $svgg := $link/root()//svg:g[@id = $link/parent::tei:linkGrp/substring-after(@facs, '#')]
let $image := substring-before($svgg//svg:image/@xlink:href, ".") || ".1"
let $rect := $svgg//svg:rect[@id = $shape]
let $x := $rect/@x => substring-before('%') => number()
let $y := $rect/@y => substring-before('%') => number()
let $w := $rect/@width => substring-before('%') => number()
let $h := $rect/@height => substring-before('%') => number()
let $rotation := 0
let $url := "https://textgridlab.org/1.0/digilib/rest/IIIF/"
|| $image || '/pct:' || $x || ',' || $y || ',' || $w || ',' || $h
|| "/,1000/" || $rotation || "/default." || $format
let $url := tbleapi:get-url($uri, $xmlid, $format)
let $request := httpclient:get($url, false(), ())
let $data := $request/httpclient:body/text()
let $binary-data :=
......@@ -58,10 +43,39 @@ let $binary-data :=
catch * {
error(
QName("err", "load1"),
string-join(("
Could not load data from TextGrid: ",$data,$err:code,$err:description), "
"))
string-join(("
Could not load data from TextGrid: ", $data, $err:code, $err:description), "
"))
}
let $mime := string($request/httpclient:body/@mimetype)
return
$binary-data
};
(:~
: retreives the URL to a clipping generated with Text-Image-Link-Editor
:
: @param $uri – A valid TextGrid Base-URI without prefix
: @param $xmlid – Any xml:id used inside the document specified by $uri
: @param $format – the return format (IIIF: http://iiif.io/api/image/2.0/#format)
: @return the URL to the image as xs:string
:)
declate function tbleapi:get-url($uri as xs:string, $xmlid as xs:string, $format as xs:string)
as xs:string {
let $link := fontaneTransfo:newestTBLELink($uri, $xmlid) (: TODO: move this function here :)
let $shape := $link/@targets => substring-after('#') => substring-before(' ')
let $svgg := $link/root()//svg:g[@id = $link/parent::tei:linkGrp/substring-after(@facs, '#')]
let $image := substring-before($svgg//svg:image/@xlink:href, ".")
let $rect := $svgg//svg:rect[@id = $shape]
let $x := $rect/@x => substring-before('%')
let $y := $rect/@y => substring-before('%')
let $w := $rect/@width => substring-before('%')
let $h := $rect/@height => substring-before('%')
let $rotation := 0
let $url := "https://textgridlab.org/1.0/digilib/rest/IIIF/"
|| $image || '/pct:' || $x || ',' || $y || ',' || $w || ',' || $h
|| "/,1000/" || $rotation || "/default." || $format
return
$url
};
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment