Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
subugoe
ahiqar
backend
Merge requests
!70
Develop
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Develop
develop
into
main
Overview
0
Commits
179
Pipelines
0
Changes
3
Merged
Michelle Weidling
requested to merge
develop
into
main
4 years ago
Overview
0
Commits
179
Pipelines
0
Changes
3
Expand
0
0
Merge request reports
Viewing commit
ec52c096
Prev
Next
Show latest version
3 files
+
12
−
6
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
3
Search (e.g. *.vue) (Ctrl+P)
ec52c096
Merge branch 'bugfix/
#87
-TILE-follow-up' into 'develop'
· ec52c096
Michelle Weidling
authored
4 years ago
Bugfix/
#87
tile follow up Closes
#87
See merge request
!61
exist-app/modules/tapi-img.xqm
0 → 100644
+
124
−
0
Options
xquery
version
"3.1"
;
(:
: This module handles the correct selection of an image path for an item.
:
: The Ahiqar project has both single- and double-sided images. While the former works
: without further ado, the latter needs a different URL in order to display to proper
: image section.
:)
module
namespace
tapi-img
=
"http://ahikar.sub.uni-goettingen.de/ns/tapi/images"
;
declare
namespace
tei
=
"http://www.tei-c.org/ns/1.0"
;
declare
namespace
ore
=
"http://www.openarchives.org/ore/terms/"
;
declare
namespace
rdf
=
"http://www.w3.org/1999/02/22-rdf-syntax-ns#"
;
declare
namespace
svg
=
"http://www.w3.org/2000/svg"
;
declare
namespace
tgmd
=
"http://textgrid.info/namespaces/metadata/core/2010"
;
import
module
namespace
commons
=
"http://ahikar.sub.uni-goettingen.de/ns/commons"
at
"commons.xqm"
;
declare
function
tapi-img:has-manifest-tile
(
$manifest-uri
as
xs:string
)
as
xs:boolean
{
exists
(
tapi-img:get-tile-uri
(
$manifest-uri
))
};
declare
function
tapi-img:is-resource-tile
(
$uri
as
xs:string
)
as
xs:boolean
{
let
$metadata
:=
commons:get-metadata-file
(
$uri
)
return
$metadata
//
tgmd:format
=
"text/linkeditorlinkedfile"
};
declare
function
tapi-img:is-tile-available
(
$uri
as
xs:string
)
as
xs:boolean
{
exists
(
doc
(
$commons:tile
||
$uri
||
".xml"
))
};
declare
function
tapi-img:get-tile-uri
(
$manifest-uri
as
xs:string
)
as
xs:string
*
{
let
$manifest-doc
:=
commons:get-aggregation
(
$manifest-uri
)
let
$aggregated
:=
$manifest-doc
//
ore:aggregates
for
$element
in
$aggregated
return
let
$stripped-uri
:=
substring-after
(
$element
/
@rdf:resource
/
string
()
,
"textgrid:"
)
return
if
(
tapi-img:is-tile-available
(
$stripped-uri
))
then
$stripped-uri
else
()
};
declare
function
tapi-img:get-tile
(
$manifest-uri
as
xs:string
)
as
document-node
()
?
{
tapi-img:get-tile-uri
(
$manifest-uri
)
=>
tapi-img:open-tile
()
};
declare
function
tapi-img:open-tile
(
$uri
as
xs:string
)
as
document-node
()
{
doc
(
$commons:tile
||
$uri
||
".xml"
)
};
declare
function
tapi-img:get-facsimile-uri-for-page
(
$manifest-uri
as
xs:string
,
$page
as
xs:string
)
as
xs:string
{
let
$tei-xml
:=
commons:get-tei-xml-for-manifest
(
$manifest-uri
)
return
$tei-xml
//
tei:pb
[
@n
=
$page
]
/
@facs
=>
substring-after
(
"textgrid:"
)
};
declare
function
tapi-img:get-xml-id-for-page
(
$manifest-uri
as
xs:string
,
$page
as
xs:string
)
as
xs:string
{
let
$tei-xml
:=
commons:get-tei-xml-for-manifest
(
$manifest-uri
)
return
$tei-xml
//
tei:pb
[
@n
=
$page
]
/
@xml:id
/
string
()
};
declare
function
tapi-img:get-shape-id
(
$manifest-uri
as
xs:string
,
$page-id
as
xs:string
)
as
xs:string
{
let
$tile
:=
tapi-img:get-tile
(
$manifest-uri
)
let
$link-element
:=
$tile
//
tei:link
[
ends-with
(
@targets
,
$page-id
)]
return
(:@targets has the following form:
#shape-1 textgrid:ahiqar_sample.3#a1 :)
tokenize
(
$link-element
/
@targets
,
" "
)[
1
]
=>
replace
(
"#"
,
""
)
};
declare
function
tapi-img:get-svg-rect
(
$tile
as
document-node
()
,
$shape-id
as
xs:string
)
as
element
(
svg:rect
)
{
$tile
//
svg:rect
[
@id
=
$shape-id
]
};
declare
function
tapi-img:get-svg-section-dimensions-as-string
(
$svg
as
element
(
svg:rect
))
as
xs:string
{
let
$x-offset
:=
local:round
(
$svg
/
@x
)
let
$y-offset
:=
local:round
(
$svg
/
@y
)
let
$width
:=
local:round
(
$svg
/
@width
)
let
$height
:=
local:round
(
$svg
/
@height
)
return
string-join
((
$x-offset
,
$y-offset
,
$width
,
$height
)
,
","
)
};
declare
function
local:round
(
$number-as-string
as
attribute
())
as
xs:string
{
$number-as-string
=>
substring-before
(
"%"
)
=>
xs:decimal
()
=>
format-number
(
"0.00"
)
(: will round last number; converts to string :)
};
declare
function
tapi-img:get-relevant-image-section
(
$manifest-uri
as
xs:string
,
$page-uri
as
xs:string
)
as
xs:string
{
let
$page-id
:=
tapi-img:get-xml-id-for-page
(
$manifest-uri
,
$page-uri
)
let
$shape-id
:=
tapi-img:get-shape-id
(
$manifest-uri
,
$page-id
)
let
$tile
:=
tapi-img:get-tile
(
$manifest-uri
)
let
$svg
:=
tapi-img:get-svg-rect
(
$tile
,
$shape-id
)
return
tapi-img:get-svg-section-dimensions-as-string
(
$svg
)
};
Loading