gws.base.search.finder

Base finder.

Source code: gws.base.search.finder

Module Contents

class gws.base.search.finder.Config(*args, **kwargs)

Bases: gws.ConfigWithAccess

Finder configuration.

category: str | None

Category assigned to the results.

models: list[gws.ext.config.model] | None

Models used to read the features.

spatialContext: SpatialContext | None

Area searched by keyword searches without a user geometry.

templates: list[gws.ext.config.template] | None

Templates to format the found features.

title: str | None

Finder title.

withFilter: bool = True

Use this finder for filter searches.

withGeometry: bool = True

Use this finder for geometry searches.

withKeyword: bool = True

Use this finder for keyword searches.

class gws.base.search.finder.Object

Bases: gws.Finder

Base class for finders.

Reads the common finder options and decides whether a query can be run. Runs a query by reading the features through a model, within the area given by context_shape. Subclasses declare which kinds of search they support and configure their models and templates, using configure_models and configure_templates.

spatialContext: SpatialContext

Area searched by keyword searches without a user geometry.

can_run(search, user)

Check if the finder can run a search query.

Parameters:
  • search – Search query.

  • user – User running the search.

Returns:

True if the finder can run the query.

configure()

Configuration hook.

Called when the node is initialized. Raising an exception here aborts the creation of the node.

configure_models()

Create the models from the models config.

Returns:

True if models are configured.

configure_templates()

Create the templates from the templates config.

Returns:

True if templates are configured.

context_shape(search: gws.SearchQuery) → gws.Shape

Return the shape to search in.

This is the query shape if given. Otherwise, it is the query bounds if spatialContext is view, or the bounds of the project map.

Parameters:

search – Search query.

Returns:

The search shape, or None if there is none.

run(search, user, layer=None)

Run a search query.

Parameters:
  • search – Search query.

  • user – User running the search.

  • layer – Layer the finder belongs to, if any.

Returns:

Found features.

class gws.base.search.finder.SpatialContext

Bases: gws.Enum

Area searched by keyword searches without a user geometry.

map = 'map'

Search the whole map extent.

view = 'view'

Search the extent currently visible in the client.