@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 message attribute, and possible additional information.
- Info 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
gcpoutsidemask
: A GCP is outside the mask. - Code
maskpointoutsidefullmask
: A mask point is outside the full mask. - Code
polynomialsheartoohigh
: A polynomial transformation shows a shear higher then a set maximum.
- Code
- Errors are problematic findings that invalidate the map.
- Code
constructingwarpedmapfailed
: A warped map map could not be constructed. - Code
constructingtriangulatedwarpedmapfailed
: A triangulated warped map could not be constructed. - Code
gcpincompleteresource
: A GCP has incomplete source coordinates. - Code
gcpincompleteregeo
: A GCP has incomplete source coordinates. - Code
gcpamountlessthen2
: There are less then 2 GCPs. - Code
gcpamountlessthen3
: 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 info, warnings and errorsconst info = analyzer.getInfo()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()
License
MIT
API
Table of Contents
Analyzer
Class for Analyzer. This class describes how a georeferenced map is warped using a specific transformation.
Parameters
georeferencedOrWarpedMap
options
analyse
Analyse
Applying extra caution: wrapping the getters in a try catch
Parameters
options
Analysis options
Returns any Analysis with info, warnings and errors
getInfo
Get analysis informations
Parameters
options
Analysis options
Returns any Analysis items with info
getWarnings
Get analysis warnings
Parameters
options
Analysis options
Returns any Analysis items with warning
getErrors
Get analysis errors
Parameters
options
Analysis options
Returns any Analysis items with errors
getMeasures
Get analysis measures
Returns any Analysis measures
getDistortions
Get distortions.
Returns any Analysis distortions