翻译者:ginkgo
原文链接:https://iiif.io/api/cookbook/recipe/0139-geolocate-canvas-fragment/
译文:
许多现实世界的资源受益于地理数据,其中许多已经在 IIIF 数字馆藏中得到体现:新旧地图、旅游期刊、报纸、手稿、诗歌和日记等等。他们还只是具有地理特征的文化遗产文物的一个子集。这些特征为资料带来了人文背景,并为发现不同资源之间的联系提供了一个可识别的、舒适的环境。
用例
一张画布(Canvas)上有一个包含地图的兴趣区域。您希望将此地图与地理坐标相关联,以便在Leaflet和OpenLayers等Web地图客户端中使用。这可能意味着简单地在Web地图上显示非交互式形状,但出于实用目的,通常更多地是显示其他与形状相关的资源数据。下面的示例显示了单击形状时出现的弹出窗口。弹出窗口包括目标地图以及来自资源的其他元数据。
实现说明
除了IIIF展示API3.0上下文之外,还包括第三方GeoJSON-LD上下文。GeoJSON-LD上下文为注释(Annotation)主体提供词汇术语,因为IIIF展示API3.0上下文没有描述这些术语。当有多个上下文时,@context
属性可以是作为集合处理的数组。一般而言,顺序对于集合来说无关紧要。但是,当在这些数组中使用IIIF上下文时,它必须是集合中的最后一项。
GeoJSON中的properties
对象是通用的,几乎可以是任何东西。它用于传递元数据和地理坐标。这对必须分辨所使用的数据的客户端和解析器是有帮助的。例如,如果目标资源有一个label
属性而properties
对象有一个label
属性,则使用接口必须选择优先呈现的对象。在用例部分的图像中,“标签”使用 GeoJSON中的properties
对象的label
属性(第 80-83 行)而不是来自注释(Annotation)或画布(Canvas)的label
属性。这是因为 Web 地图客户端旨在查找 GeoJSON中的properties对象的元数据以进行显示。
请注意,除了多边形(Polygon),几何图形(geometry)还有其他类型取值。
限制
严格遵循关联数据(Linked Data)实践的应用程序会发现嵌套的 GeoJSON 坐标数组与 JSON-LD 1.0 的处理模型不兼容。JSON-LD 1.1 处理模型没有此限制。如果您计划将 JSON-LD 序列化为其他语义数据格式或标记语言(如 RDF),请注意这一点。
示例
清单(Manifest)中有一个带有图像(Image)的画布(Canvas) ,画布的尺寸与图像相同。画布有一个注释页(Annotation Page),其中一个注释以使用#xywh Fragment Selector 语法进行地图描述的兴趣区域为目标。注释body
是 GeoJSON-LD,它得到了许多开源地图系统的支持。客户端可以解析画布中的注释并将注释body
传递到Web地图中,从而在世界地图上呈现几何形状。通常,来自资源的数据(例如图像 URL、标签或描述)通过GeoJSON中的properties与这些形状相关联。由于使用的图像是遵循IIIF图像API3.0规范的IIIF配件(Fixture) ,您可以通过提供#xywh 选择器中用于图像 URL 的值来查看目标片段。
{
"@context": [
"http://geojson.org/geojson-ld/geojson-context.jsonld",
"http://iiif.io/api/presentation/3/context.json"
],
"id": "https://iiif.io/api/cookbook/recipe/0139-geolocate-canvas-fragment/manifest.json",
"type": "Manifest",
"label": {
"en": [
"Recipe Manifest for #139"
]
},
"summary": {
"en": [
"A IIIF Presentation API 3.0 Manifest containing a GeoJSON-LD Web Annotation which targets a Canvas fragment."
]
},
"items": [
{
"id": "https://iiif.io/api/cookbook/recipe/0139-geolocate-canvas-fragment/canvas.json",
"type": "Canvas",
"label": {
"en": [
"Chesapeake and Ohio Canal Pamphlet"
]
},
"width": 5212,
"height": 7072,
"items": [
{
"id": "https://iiif.io/api/cookbook/recipe/0139-geolocate-canvas-fragment/contentPage.json",
"type": "AnnotationPage",
"items": [
{
"id": "https://iiif.io/api/cookbook/recipe/0139-geolocate-canvas-fragment/content.json",
"type": "Annotation",
"motivation": "painting",
"label": {
"en": [
"Pamphlet Cover"
]
},
"body": {
"id": "https://iiif.io/api/image/3.0/example/reference/43153e2ec7531f14dd1c9b2fc401678a-88695674/full/max/0/default.jpg",
"type": "Image",
"format": "image/jpeg",
"service": [
{
"id": "https://iiif.io/api/image/3.0/example/reference/43153e2ec7531f14dd1c9b2fc401678a-88695674",
"type": "ImageService3",
"profile": "level1"
}
],
"width": 5212,
"height": 7072
},
"target": "https://iiif.io/api/cookbook/recipe/0139-geolocate-canvas-fragment/canvas.json"
}
]
}
],
"annotations": [
{
"id": "https://iiif.io/api/cookbook/recipe/0139-geolocate-canvas-fragment/supplementingPage.json",
"type": "AnnotationPage",
"items": [
{
"id": "https://iiif.io/api/cookbook/recipe/0139-geolocate-canvas-fragment/geoAnno.json",
"type": "Annotation",
"motivation": "tagging",
"label": {
"en": [
"Annotation containing GeoJSON-LD coordinates that place the map depiction onto a Leaflet web map."
]
},
"body": {
"id": "https://iiif.io/api/cookbook/recipe/0139-geolocate-canvas-fragment/geo.json",
"type": "Feature",
"properties": {
"label": {
"en": [
"Targeted Map from Chesapeake and Ohio Canal Pamphlet"
]
}
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-77.097847,
38.901359
],
[
-77.02694,
38.901359
],
[
-77.02694,
39.03404
],
[
-77.097847,
39.03404
]
]
]
}
},
"target": "https://iiif.io/api/cookbook/recipe/0139-geolocate-canvas-fragment/canvas.json#xywh=920,3600,1510,3000"
}
]
}
]
}
]
}
相关专题
- [片段选择器][0020]
- [标签注释][0021]