Skip to main content

FeatureQuery

Finds the features that lie inside an area, which a host can often do better than the browser, for example from a server that holds the layers. Optional on Services: a host that supplies none offers no selection by shape, and the ui must not require it. The SDK sends nothing itself, so a host whose query sends a shape or layer ids to a server tells its visitors.

This is an interface exported by @mapcairn/core, checked against version 0.2.0.

Signature​

import type { FeatureQuery } from "@mapcairn/core";

interface FeatureQuery

Description​

It is a port of its own so that FeatureSelection stays synchronous.

Rules for every implementation:

  • Every hit's layerId is one of the request's layerIds, and a feature is listed once.
  • It returns limit hits when at least that many lie inside, and every hit when fewer do. It returns no more than limit, in any order.
  • An empty layerIds resolves with no hits.
  • It rejects only with a FeatureQueryError: network when the request failed, invalid when the request was not valid (an area that is not a polygon with at least one closed ring on the globe, or a limit that is not a whole number of at least 1) or the answer could not be read, unsupported when the host cannot answer for the layers or the area, and aborted when the signal fires first, whether before the call or while it is pending. The ui ignores aborted.
  • The port asks no more of an area than that. It does not check that a hole lies inside the outer ring, that no edge crosses another, or how many positions a ring has, so a host guards against a very large ring itself.

Methods​

within​

within(request: FeatureQueryRequest): Promise<readonly SelectionHit[]>;

Finds the features of the named layers that lie inside the area, at most limit of them.

  • request (FeatureQueryRequest)

See also​

Source: packages/core/src/ports/featureQuery.ts:72