1.0.0-beta.26 • Published 2 months ago

@allmaps/annotation v1.0.0-beta.26

Weekly downloads
52
License
GPL-3.0-or-later
Repository
github
Last release
2 months ago

@allmaps/annotation

@allmaps/annotation is a JavaScript module that can generate and parse Georeference Annotations.

A Georeference Annotation is a Web Annotation that stores the metadata needed to georeference a IIIF image.

A Georeference Annotation contains the following data:

  • The URI of an IIIF Image, as well as its dimensions in pixels.
  • A list of ground control points (GCPs) that define the mapping between resource coordinates and geospatial coordinates.
  • A polygonal resource mask that defines the cartographic part of the image.

Georeference Annotations are a core part of Allmaps. For example, Allmaps Viewer can warp maps IIIF maps in the browser, just by loading a georeference annotation.

Installation & usage

This is an ESM-only module that works in browsers and Node.js.

Node.js:

First, run npm install @allmaps/annotation to add this module to your project.

import { parseAnnotation, generateAnnotation } from '@allmaps/annotation'

Browser:

<script type="module">
  import {
    parseAnnotation,
    generateAnnotation
  } from 'https://unpkg.com/@allmaps/annotation?module'
</script>

API

Table of Contents

Generating & parsing Georeference Annotations

parseAnnotation

Parses a Georeference Annotation or an AnnotationPage containing multiple Georeference Annotations and returns an array of maps.

Parameters
  • annotation (Annotation | AnnotationPage) Georeference Annotation or AnnotationPage containing multiple Georeference Annotations
Examples
import fs from 'fs'
import { parseAnnotation } from '@allmaps/annotation'

const annotation = JSON.parse(fs.readFileSync('./examples/annotation.example.json'))
const maps = parseAnnotation(annotation)

Returns Array<Map> Array of maps

generateAnnotation

Generates a Georeference Annotation from a single map or an AnnotationPage containing multiple Georeference Annotations from an array of maps.

Parameters
  • mapOrMaps (Map | Array<Map>) Single map object, or array of maps
Examples
import fs from 'fs'
import { generateAnnotation } from '@allmaps/annotation'

const map = JSON.parse(fs.readFileSync('./examples/map.example.json'))
const annotation = generateAnnotation(map)

Returns (Annotation | AnnotationPage) Georeference Annotation

Types

The two types this module converts between, Annotation, AnnotationPage and Map, are described below.

Map

Object that contains the data needed to georeference a IIIF resource in the format that is used by Allmaps internally.

Type: Object

Annotation

Web Annotation that contains a single Georeference Annotation.

Type: Object

AnnotationPage

An Annotation Page that contains multiple Georeference Annotations.

Type: Object

1.0.0-beta.26

2 months ago

1.0.0-beta.25

2 months ago

1.0.0-beta.22

3 months ago

1.0.0-beta.21

3 months ago

1.0.0-beta.20

4 months ago

1.0.0-beta.19

6 months ago

1.0.0-beta.18

6 months ago

1.0.0-beta.17

7 months ago

1.0.0-beta.15

9 months ago

1.0.0-beta.16

8 months ago

1.0.0-beta.14

9 months ago

1.0.0-beta.13

11 months ago

1.0.0-beta.11

1 year ago

1.0.0-beta.12

1 year ago

1.0.0-beta.10

1 year ago

1.0.0-beta.9

2 years ago

1.0.0-beta.8

2 years ago

1.0.0-beta.3

2 years ago

1.0.0-beta.4

2 years ago

1.0.0-beta.5

2 years ago

1.0.0-beta.6

2 years ago

1.0.0-beta.2

2 years ago

1.0.0-beta.0

2 years ago

1.0.0-beta.1

2 years ago

1.0.0-alpha.18

3 years ago

1.0.0-alpha.17

3 years ago

1.0.0-alpha.16

3 years ago

1.0.0-alpha.15

3 years ago

1.0.0-alpha.14

3 years ago

1.0.0-alpha.13

3 years ago

1.0.0-alpha.12

3 years ago

1.0.0-alpha.11

3 years ago

1.0.0-alpha.10

3 years ago

1.0.0-alpha.9

3 years ago

1.0.0-alpha.8

3 years ago

1.0.0-alpha.7

3 years ago

1.0.0-alpha.6

3 years ago

1.0.0-alpha.5

3 years ago

1.0.0-alpha.4

3 years ago

1.0.0-alpha.3

3 years ago

1.0.0-alpha.2

3 years ago

1.0.0-alpha.1

3 years ago