decodeIdentify
Decodes a service's answer to a tap into features, keeping at most
MAX_IDENTIFIED_FEATURES. Nothing found is an empty list, not an
error: it is the common answer.
This is a function exported by @mapcairn/core, checked against version 0.2.0.
Signature
import { decodeIdentify } from "@mapcairn/core";
function decodeIdentify(definition: IdentifiableLayerDefinition, raw: unknown, decoders: DecoderRegistry, at: IdentifyTarget): LayerFeature[];
Parameters
definition(IdentifiableLayerDefinition)raw(unknown)decoders(DecoderRegistry)at(IdentifyTarget)
Returns
LayerFeature[]
Throws
LayerErrorinvalidwhen the decoder is not registered, or the answer is not a document the decoder reads.
Remarks
The answer is prepared, then the definition's named decoder runs,
so Decoder keeps its signature. With records, the list at that path
becomes a feature collection whose features sit at the tapped place and
whose properties are the items, whatever the decoder. Without it, the
built-in geojson decoder gets a document with no features list read
as no features, and a feature with a missing or null geometry placed at
the tapped place, because the decoder drops features with none and a
found feature needs a place for its selection ring. A decoder of any
other kind, including one registered under the name geojson, gets the
raw answer. A feature without a usable id takes its position in the
answer: unique for one answer, but not the same from one tap to the next.
The cap applies after decoding, because the decoder drops features it
cannot use, so the work is linear in the size of the answer (a records
list is cut to the cap first). The caller bounds the size of the answer
it fetches.