Skip to content

Commit

Permalink
Merge pull request #519 from IIIF/issue-518
Browse files Browse the repository at this point in the history
Checking for Annotations with label
  • Loading branch information
glenrobson authored Aug 15, 2024
2 parents c14ec01 + 36bf7ac commit 702014b
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 21 deletions.
2 changes: 1 addition & 1 deletion recipe/0135-annotating-point-in-canvas/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ This example uses a leaflet with a map and a guide supplied by the Library of Co

{% include manifest_links.html viewers="Glycerine Viewer" manifest="manifest.json" %}

{% include jsonviewer.html src="manifest.json" config='data-line="74-82"' %}
{% include jsonviewer.html src="manifest.json" config='data-line="69-76"' %}

# Related recipes

Expand Down
5 changes: 0 additions & 5 deletions recipe/0135-annotating-point-in-canvas/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,6 @@
{
"id": "{{ id.path }}/annotation/p0002-tag",
"type": "Annotation",
"label": {
"en": [
"Annotation containing the name of the place annotated using the PointSelector."
]
},
"motivation": "tagging",
"body": {
"type": "TextualBody",
Expand Down
4 changes: 2 additions & 2 deletions recipe/0139-geolocate-canvas-fragment/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ A Canvas has a region of interest that contains a map. You would like to associa
### Implementation Notes
The third party [GeoJSON-LD](https://geojson.org/geojson-ld/) context is included in addition to the IIIF Presentation API 3.0 context. The GeoJSON-LD context supplies the vocabulary terms for the Annotation bodies since the IIIF Presentation API 3.0 context does not describe those terms. When there are multiple contexts, the `@context` property can be an array which is processed as a set. Typically order does not matter for a set. However, when the IIIF context is used in these arrays it must be the last item in the set.

The GeoJSON `properties` object is generic and [can be nearly anything](https://tools.ietf.org/html/rfc7946#section-3.2). It is used to pass metadata along with the geocoordinates. This has implications on clients and parsers that must discern what data to use. For example, if the targeted resource has a `label` property and the `properties` object has a `label` property, the consuming interface must make a choice on which to prioritize for presentation purposes. In the image from the Use Case section, the "Label" uses the GeoJSON `properties` object's `label` property (lines 80-83) instead of the `label` property from the Annotation or Canvas. This is because web mapping clients are designed to look for metadata in GeoJSON `properties` for display.
The GeoJSON `properties` object is generic and [can be nearly anything](https://tools.ietf.org/html/rfc7946#section-3.2). It is used to pass metadata along with the geocoordinates. This has implications on clients and parsers that must discern what data to use. For example, if the targeted resource had a `label` property and the `properties` object has a `label` property, the consuming interface must make a choice on which to prioritize for presentation purposes. In the image from the Use Case section, the "Label" uses the GeoJSON `properties` object's `label` property (lines 69-75) instead of the `label` property from the Annotation or Canvas. This is because web mapping clients are designed to look for metadata in GeoJSON `properties` for display.

Note that [`geometry` has more types besides `Polygon`.](https://tools.ietf.org/html/rfc7946#section-3.1)

Expand All @@ -34,7 +34,7 @@ The Manifest has one Canvas with one Image, and the Canvas has the same size dim

{% include manifest_links.html viewers="Annona" manifest="manifest.json" %}

{% include jsonviewer.html src="manifest.json" config='data-line="2-5, 67-111"' %}
{% include jsonviewer.html src="manifest.json" config='data-line="2-5, 62-101"' %}

## Related Recipes
* [Fragment Selectors][0020]
Expand Down
10 changes: 0 additions & 10 deletions recipe/0139-geolocate-canvas-fragment/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@
"id":"{{ id.path }}/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",
Expand Down Expand Up @@ -68,11 +63,6 @@
"id":"{{ id.path }}/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":"{{ id.path }}/geo.json",
"type":"Feature",
Expand Down
43 changes: 40 additions & 3 deletions scripts/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,43 @@ def validateIIIF(jsonData, filepath):
else:
return True

def checkForNonValidationIssues(data, filename):
type = data["type"]
# Look for label in annotation
if type == 'Manifest':
anyFailed = False
if 'items' in data:
for canvas in data['items']:
if 'items' in canvas:
for page in canvas['items']:
result = checkAnnotationPage(page)
if result:
anyFailed = True
print (f'Manifest {filename} contains a painting annotation in canvas {canvas['id']} which has a label in the annotation')
if 'annotations' in canvas:
for page in canvas['annotations']:
result = checkAnnotationPage(page)
if result:
anyFailed = True
print (f'Manifest {filename} contains an annotation in canvas {canvas['id']} which has a label in the annotation')

if anyFailed:
return False

elif type == 'AnnotationPage':
result = checkAnnotationPage(data)
if result:
print (f'AnnotationPage {filename} has a label in the annotation')
return False
return True

def checkAnnotationPage(page):
if 'items' in page:
for annotation in page['items']:
if 'label' in annotation:
return True
return False

def loadYAML(location):
with open(location, "r") as stream:
try:
Expand Down Expand Up @@ -94,9 +131,6 @@ def loadYAML(location):
if not ignoreViewer:
print ('Recipe {} is missing a `viewers` entry either add it or add the name of the recipe to _data.viewer_ignore.yml'.format(recipepath))
allPassed = False




files = findFilesToValidate("../_site", ".json")
# Get JSON Schema
Expand All @@ -116,6 +150,9 @@ def loadYAML(location):
if not passed:
allPassed = False
# else it passed
passed = checkForNonValidationIssues(jsonData, jsonFilename)
if not passed:
allPassed = False
else:
print ('{}: Do not know how to validate JSON with type: {}'.format(errorJsonFilename, jsonData['type']))
else:
Expand Down

0 comments on commit 702014b

Please sign in to comment.