@allmaps/analyze
This module analyzes warpedMaps: it checks them for possible error and computes accuracy measures.
A Warped Map is an object used in @allmaps/render to store information about a georeferencedMap (which in turn are parsed Georeference Annotations) as it is warped by a transformer in order to be rendered. Hence, these objects have a lot of information that can e used to infer the quality and accuracy of a map’s warping.
In a WebGL2Renderer a map is warped and triangulated, so the TriangulatedWarpedMaps is used, which extends WarpedMaps.
How it works
This packages analyzes maps to return information, warning and error items. These items are objects with a code and text attribute, and possible additional information.
- Infos are notable but not problematic informations on a warping.
- Code
maskequalsfullmask
: The mask contains the full image.
- Code
- Warnings are possibly problematic findings, but don’t invalidate the map.
- Code
gcpincompleteresource
: A GCP has incomplete source coordinates. - Code
gcpincompleteregeo
: A GCP has incomplete source coordinates. - Code
gcpoutsidemask
: A GCP is outside the mask. - Code
maskpointoutsidefullmask
: A mask point is outside the full mask. - Code
triangulationfoldsover
: The map folds over itself, for the selected transformation type. - Code
polynomialsheartoohigh
: A polynomial transformation shows a shear higher then a set maximum.
- Code
- Errors are problematic findings that invalidate the map.
- Code
gcpamounttoolow
: There are less then 3 GCPs. - Code
gcpresourcerepeatedpoint
: GCP resource coordinates are repeated. - Code
gcpgeorepeatedpoint
: GCP geo coordinates are repeated. - Code
masknotring
: The mask is not a valid ring (an array of points). - Code
maskrepeatedpoint
: Mask resource coordinates are repeated. - Code
maskselfintersection
: The mask self-intersects.
- Code
An analyzer can also compute the following Measures:
- About the current transformation type:
rmse
: The root-mean-square error of GCPs in projected geo coordinatesdestinationErrors
: for each GCP, the error in projected geo coordinatesresourceErrors
: for each GCP, the error in projected geo coordinates, scaled to resource spaceresourceRelativeErrors
: for each GCP, the error in projected resource coordinates, relative to the resource mask BBox diameter.
- About the Helmert transformation type:
helmertRmse
: The root-mean-square error of GCPs in projected geo coordinateshelmertParameters
: The Helmert parameters. See @allmaps/transform.helmertScale
: The scalehelmertRotation
: The rotationhelmertTranslation
: The translation
- About the polynomial transformation type:
polynomialRmse
: The root-mean-square error of GCPs in projected geo coordinatespolynomialParameters
: The polynomial parameters. See @allmaps/transform.polynomialScale
: The scalepolynomialRotation
: The rotationpolynomialShear
: The shearpolynomialTranslation
: The translation
An analyzer can also compute the following Distortion information:
- About the current transformation type:
meanDistortions
: For each computed distortion measure, the mean distortion over all triangulation points.
Installation
This is an ESM-only module that works in browsers and Node.js.
Install using npm:
npm install @allmaps/analyze
Usage
First, get a warpedMap, either by making it from an annotation, or by getting it from a renderer’s warpedMapList. Then analyze it using this library.
import { parseAnnotation } from '@allmaps/annotation'import { TriangulatedWarpedMap } from '@allmaps/render'import { Analyzer } from '@allmaps/analyze'
// Fetch an annotationconst annotation = await fetch(annoationUrl).then((response) => response.json())
// Create a warpedMap from the annotationconst georeferencedMaps = parseAnnotation(annotation)const georeferencedMap = georeferencedMaps[0]const triangualtedWarpedMap = new TriangulatedWarpedMap( georeferencedMap.id, georeferencedMap)
// Or add the annotation the a renderer and extract a warpedMap// ... create a webGL2Renderer, see the render packageawait renderer.addGeoreferenceAnnotation(annotation)const triangulatedWarpedMap = renderer.warpedMapList.getWarpedMaps()[0]
// Create Analyzer for the warpedMapconst analyzer = new Analyzer(triangulatedWarpedMap)
// Analyze to get all infos, warnings and errorsconst infos = analyzer.getInfos()const warnings = analyzer.getWarnings()const errors = analyzer.getErrors()
// Or quickly check e.g. if there are any errorsconst hasErrors = analyzer.hasErrors()
// Analyze measures and distortionsconst measures = analyzer.getMeasures()const distortions = analyzer.getDistortions()
API
Table of Contents
Analyzer
Class for Analyzer. This class describes how a georeferenced map is warped using a specific transformation.
Parameters
warpedMap
A Warped MapmapId
ID of the map
hasInfos
Check if analysis has infos.
Returns boolean
hasWarnings
Check if analysis has warnings.
Returns boolean
hasErrors
Check if analysis has errors.
Returns boolean
getInfos
Get analysis informations.
Returns Array<AnalysisItem>
getWarnings
Get zis warnings.
Returns Array<AnalysisItem>
getErrors
Get analysis errors.
getMeasures
Get analysis measures.
getDistortions
Get distortions.
Returns Distortions
fromWarpedMap
Creates an instance of Analyzer from a Warped Map.
Parameters
warpedMap
A Warped Map