@allmaps/注释
剖析和生成地理参考说明.
如何运作
此模块可以生成和剖析 地理参考说明。 。 。 .
A 类 地理参考注释 是一个 网络注释 存储所需的元数据 地理参考 (单位:千美元) IIIF 图像。看看这个 实例。 。 。 .
地理参考注释包含以下数据:
- 这个 IIIF 图像的 URI,以及其像素中的维度.
- 一个多边形资源掩码,它定义了图像的制图部分.
- 地控点列表(GCP),定义了资源坐标和地理空间坐标之间的映射.
多张地图可以在 注释页 (见 光谱) (中文(简体) ).
Allmaps提供应用软件和软件包,用于与GeoReference June合作. 全部地图查看器 能够 比如说 在浏览器中扭曲 IIIF 映射, 只需装入一个 GeoReference 注释 .
A 类 地理参考地图 是Allmaps内部使用的格式来描述一个地图,并在函数和软件包之间传递。 它以更实际的形式载有同样的信息。 看这个 实例。 。 。 .
此模块允许 解析 地理参考地图和 生成 地理参考说明取自地理参考地图.
这个模块被写入TypeScript并使用Zod来构建.
安装
这是一个只在浏览器和Node.js中工作的无害环境管理模块.
节点.js:
用 pnpm 安装 :
pnpm install @allmaps/annotation
浏览器 :
<script type="module">
import { Annotation } from 'https://unpkg.com/@allmaps/annotation?module'
</script>
使用量
import { parseAnnotation, generateAnnotation } from '@allmaps/annotation'
// Fetch an annotation
const annotation = await fetch(annoationUrl).then((response) => response.json())
// Create a georeferencedMap from the annotation
const georeferencedMaps = parseAnnotation(annotation)
const georeferencedMap = georeferencedMaps[0]
// Use or modify the georeferencedMap(s)
// ...
// Generate Georeference Annotation
// Note: returns an annotation or annotation page based on input
const georeferenceAnnotation = generateAnnotation(georeferencedMap)
const georeferenceAnnotationPage = generateAnnotation(georeferencedMaps)
详见下文API.
许可证
麻省理工学院
API 密码
Annotation
类型
{ id?: string | undefined; type: "Annotation"; '@context'?: string | Array<string> | undefined; motivation?: string | undefined; created?: string | undefined; modified?: string | undefined; target: { ...; }; body: { ...; }; }
AnnotationPage
类型
{ id?: string | undefined; type: "AnnotationPage"; '@context'?: string | Array<string> | undefined; items: Array<{ id?: string | undefined; type: "Annotation"; '@context'?: string | Array<string> | undefined; motivation?: string | undefined; created?: string | undefined; modified?: string | undefined; target: { ...;...
AnnotationPageSchema
类型
AnnotationPage1Schema
AnnotationSchema
类型
Annotation1Schema
FeaturePropertiesSchema
类型
Annotation1FeaturePropertiesSchema
GCPSchema
类型
GeoreferencedMap2GCPSchema
GeoreferencedMap
类型
{ '@context'?: "https://schemas.allmaps.org/map/2/context.json" | undefined; type: "GeoreferencedMap"; id?: string | undefined; created?: string | undefined; modified?: string | undefined; ... 5 more ...; _allmaps?: unknown; }
GeoreferencedMapSchema
类型
GeoreferencedMap2Schema
GeoreferencedMapsSchema
类型
GeoreferencedMaps2Schema
PartOf
类型
Array<PartOfItemType>
PartOfItem
类型
{
id: string
type: string
label?: z.infer<typeof LanguageValueSchema>
partOf?: PartOfItemType[]
}
ResourceSchema
类型
GeoreferencedMap2ResourceSchema
SvgSelectorSchema
类型
SvgSelector1Schema
generateAnnotation(mapOrMaps)
从单一的地理参考地图生成地理参考注释或 a 注释页,包含多个地理参考说明,来自一系列地理参考地图.
参数
mapOrMaps(单位:千美元)unknown(中文(简体) )- 单一地理参考地图, 或一系列地理参考地图
回返
地理参考注释或注释页({ id?: string | undefined; type: "Annotation"; '@context'?: string | Array<string> | undefined; motivation?: string | undefined; created?: string | undefined; modified?: string | undefined; target: { ...; }; body: { ...; }; } | { ...; }) (中文(简体) ).
实例
import fs from 'fs'
import { generateAnnotation } from '@allmaps/annotation'
const map = JSON.parse(fs.readFileSync('./examples/map.example.json'))
const annotation = generateAnnotation(map)
parseAnnotation(annotation)
分析一个地理参考注释或包含多个地理参考说明的注释页 并返回一系列地理参考地图.
参数
annotation(单位:千美元)unknown(中文(简体) )- 地理参考注释或注释页,包含多个地理参考说明
回返
地图阵列Array<{ '@context'?: "https://schemas.allmaps.org/map/2/context.json" | undefined; type: "GeoreferencedMap"; id?: string | undefined; created?: string | undefined; modified?: string | undefined; ... 5 more ...; _allmaps?: unknown; }>) (中文(简体) ).
实例
import fs from 'fs'
import { parseAnnotation } from '@allmaps/annotation'
const annotation = JSON.parse(fs.readFileSync('./examples/annotation.example.json'))
const maps = parseAnnotation(annotation)
validateAnnotation(annotation)
参数
annotation(单位:千美元)unknown(中文(简体) )
回返
{ id?: string | undefined; type: "Annotation"; '@context'?: string | Array<string> | undefined; motivation?: string | undefined; created?: string | undefined; modified?: string | undefined; target: { ...; }; body: { ...; }; } | { ...; }。 。 。 .
validateGeoreferencedMap(mapOrMaps)
参数
mapOrMaps(单位:千美元)unknown(中文(简体) )
回返
Array<{ '@context'?: "https://schemas.allmaps.org/map/2/context.json" | undefined; type: "GeoreferencedMap"; id?: string | undefined; created?: string | undefined; modified?: string | undefined; ... 5 more ...; _allmaps?: unknown; }> | { '@context'?: "https://schemas.allmaps.org/map/2/context.json" | undefined; type...。 。 。 .