encodeShapes
Writes finished, valid shapes as a short text for a link: one letter for
the kind (p point, l line, g polygon, c circle) and then the
positions as whole units of 0.00001 degrees (about a metre), the first
absolute and each later one as the step from the one before, every number
zigzagged and packed five bits to a character in the alphabet
A-Z a-z 0-9 - _. Shapes are separated by a full stop. Only link-safe characters are
used, so nothing needs escaping. A circle's radius is in whole metres.
This is a function exported by @mapcairn/core, checked against version 0.2.0.
Signature
import { encodeShapes } from "@mapcairn/core";
function encodeShapes(shapes: readonly DrawShape[]): string | null;
Description
A shape the link cannot carry (see unsharableShapes) is left out,
and a caller tells the person.
Parameters
shapes(readonly DrawShape[])
Returns
string | null: The text, an empty string when there is nothing to share, or
null when the result would pass MAX_SHARE_LENGTH characters or
MAX_SHARE_SHAPES shapes. A set is never cut short for its size:
the caller says it is too big.