Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate GeoJSON-LD context in Web Annotation #1

Open
LvanWissen opened this issue Jun 23, 2022 · 3 comments
Open

Integrate GeoJSON-LD context in Web Annotation #1

LvanWissen opened this issue Jun 23, 2022 · 3 comments

Comments

@LvanWissen
Copy link

An example of an annotation in JSON-LD:

{
    "type": "Annotation",
    "body": [
        {
            "purpose": "geotagging",
            "type": "Feature",
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            26.2361715,
                            39.9572062
                        ],
                        [
                            26.2362076,
                            39.9569925
                        ],
                        [
                            26.2362569,
                            39.9568602
                        ],
                        [
                            26.2365809,
                            39.9567601
                        ],
                        [
                            26.2366667,
                            39.9567173
                        ],
                        [
                            26.2367423,
                            39.956777
                        ],
                        [
                            26.2368898,
                            39.9567997
                        ],
                        [
                            26.2370684,
                            39.9567577
                        ],
                        [
                            26.2372566,
                            39.9567609
                        ],
                        [
                            26.2378104,
                            39.9564934
                        ],
                        [
                            26.2378769,
                            39.956405
                        ],
                        [
                            26.238294,
                            39.9561932
                        ],
                        [
                            26.2385285,
                            39.956323
                        ],
                        [
                            26.2388346,
                            39.9564428
                        ],
                        [
                            26.2396683,
                            39.9565477
                        ],
                        [
                            26.2398442,
                            39.9574015
                        ],
                        [
                            26.2398507,
                            39.9578508
                        ],
                        [
                            26.2396879,
                            39.9581753
                        ],
                        [
                            26.239284,
                            39.9584699
                        ],
                        [
                            26.2386783,
                            39.9585298
                        ],
                        [
                            26.2379162,
                            39.9584299
                        ],
                        [
                            26.2373821,
                            39.9582252
                        ],
                        [
                            26.2367496,
                            39.957804
                        ],
                        [
                            26.23628,
                            39.9575255
                        ],
                        [
                            26.2361812,
                            39.9573464
                        ],
                        [
                            26.2361715,
                            39.9572062
                        ]
                    ]
                ]
            },
            "source": "https://www.openstreetmap.org/way/423938794"
        }
    ],
    "target": {
        "selector": [
            {
                "type": "TextQuoteSelector",
                "exact": "Troy"
            },
            {
                "type": "TextPositionSelector",
                "start": 124,
                "end": 128
            }
        ]
    },
    "@context": "http://www.w3.org/ns/anno.jsonld",
    "id": "#db10a813-a3a9-41b6-bff7-71f794267c8b"
}

Serialized to RDF/Turtle (through the nquads of the JSON-LD Playground):

@prefix oa: <http://www.w3.org/ns/oa#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<https://json-ld.org/playground/#db10a813-a3a9-41b6-bff7-71f794267c8b>
  a oa:Annotation ;
  oa:hasBody [
    a <https://json-ld.org/playground/Feature> ;
    oa:hasPurpose <https://json-ld.org/playground/geotagging> ;
    oa:hasSource <https://www.openstreetmap.org/way/423938794>
  ] ;
  oa:hasTarget [ oa:hasSelector [
      a oa:TextQuoteSelector ;
      oa:exact "Troy"
    ], [
      a oa:TextPositionSelector ;
      oa:end "128"^^xsd:nonNegativeInteger ;
      oa:start "124"^^xsd:nonNegativeInteger
    ] ] .

Problem: The specific geo contents of the body are missing, because these properties are not defined in the open annotation context.

The solution is to integrate (parts of) the JSON-LD context (https://geojson.org/geojson-ld/) in the @context of the annotation serialization. Then we can store all of this information in valid RDF.

@rsimon
Copy link
Member

rsimon commented Jun 24, 2022

Thanks, do I assume correctly that this would mean the @context would have to become an array?

 "@context": [
  "http://www.w3.org/ns/anno.jsonld",
  "https://geojson.org/geojson-ld/"
]

Just an advance warning: it's currently not possible for widgets/plugins to modify the annotation context. That will require a small bit of additional plumbing in the recogito-client-core base library. Which means it will only be possible in the next releases of Annotorious and RecogitoJS.

If it's urgent, you'd need to patch the context yourself for the time being, e.g. by modifying the annotation object in the createAnnotation and updateAnnotation handlers.

@LvanWissen
Copy link
Author

Yes, the @context can be an array! But in this case that would be:

 "@context": [
  "http://www.w3.org/ns/anno.jsonld",
  "https://geojson.org/geojson-ld/geojson-context.jsonld"
]

The values in the @context are not necessarily prefixes (like those in rdf/turtle), but need to return a valid json-ld object itself. With the context above, my example above will expand correctly in the json-ld playground.

It's not urgent in my case. If this needs to be modified in the recogito-client-core, then I can imagine that a user possibly wants to integrate another custom context when the body of an annotation contains something else than a geometry. Maybe a dedicated/generic method for this can be worth implementing, if the createAnnotation and updateAnnotation handlers are not the way to go.

Thank you very much for your great work in developing these recogito-js tools. I really value them for their usability (both from a developer's perspective as from the annotator's side) and for their implementation of W3C standards!

@rsimon
Copy link
Member

rsimon commented Jul 24, 2022

That's now implemented in the main branch of recogito-client-core. Plugins can use the new args.addContext(uri) method to attach an additional context namespace to the annotation.

This will go live with the next releases of Annotorious, Annotorious OpenSeadragon and RecogitoJS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants