Class: SpatialFilter

SpatialFilter()

A SpatialFilter represents a spatial constraint on the query to be executed.

Constructor

new SpatialFilter()

Source:

Extends

Members

type :string

The name of this Model
Type:
  • string
Overrides:
Source:

Methods

coversEarth() → {boolean}

Returns true if the bounds set on the filter covers the entire earth
Since:
  • 2.25.0
Source:
Returns:
Type
boolean

createBaseFilter(precisions, hashStrings) → {Filter}

Creates a Filter model that represents the geohashes at a given precision level for a specific set of geohashes
Parameters:
Name Type Description
precisions Array.<number> The geohash precision levels, e.g. [4, 5]
hashStrings Array.<string> The geohashes, e.g. ["9q8yy", "9q8yz"]
Since:
  • 2.25.0
Source:
Returns:
The filter model
Type
Filter

defaults()

Inherits all default properties of Filter
Properties:
Name Type Description
east number The easternmost longitude of the search area
west number The westernmost longitude of the search area
north number The northernmost latitude of the search area
south number The southernmost latitude of the search area
height number The height at which to calculate the geohash precision for the search area
maxGeohashValues number The maximum number of geohash values to use in the filter. If the number of geohashes exceeds this value, the precision will be reduced until the number of geohashes is less than or equal to this value.
Overrides:
Source:

escapeSpecialChar(term) → {string}

Escapes Solr query reserved characters so that search terms can include those characters without throwing an error.
Parameters:
Name Type Description
term string The search term or phrase to escape
Inherited From:
Source:
Returns:
- The search term or phrase, after special characters are escaped
Type
string

getBounds(asopt) → {object|GeoBoundingBox}

Convert the coordinate attributes to a bounds object
Parameters:
Name Type Attributes Default Description
as string <optional>
"object" The format to return the bounds in. Defaults to "object". Can set to GeoBoundingBox to return a Backbone model instead.
Since:
  • 2.25.0
Source:
Returns:
An object with north, south, east, and west props or a GeoBoundingBox model
Type
object | GeoBoundingBox

getQuery(consolidateopt) → {string}

Builds a query string that represents this spatial filter
Parameters:
Name Type Attributes Default Description
consolidate boolean <optional>
false Whether to consolidate the set of geohashes to the smallest set that covers the same area (i.e. merges geohashes together when there are complete groups of 32). This is false by default because geohashes are already consolidated when they are added as the spatial filter is used right now.
Since:
  • 2.25.0
Overrides:
Source:
Returns:
The query fragment
Type
string

getValueQuerySubstring(valuesopt) → {string}

Constructs a query substring for each of the values set on this model
Parameters:
Name Type Attributes Description
values Array.<string> <optional>
The values to use in this query substring. If not provided, the values set on the model are used.
Inherited From:
Source:
Returns:
The query substring
Type
string
Example
values: ["walker", "jones"]
  Returns: "(walker%20OR%20jones)"

hasChangedValues() → {boolean}

Checks if this Filter has values different than the default values.
Inherited From:
Source:
Returns:
- Returns true if this Filter has values set on it, otherwise will return false
Type
boolean

hasCoordinates() → {boolean}

Returns true if the filter has a valid set of coordinates
Since:
  • 2.25.0
Source:
Returns:
True if the filter has coordinates
Type
boolean

initialize()

Initialize the model, calling super
Overrides:
Source:

isCoordinateQuery(fieldsopt) → {Boolean}

Check whether a set of query fields contain only fields that specify latitude and/or longitude
Parameters:
Name Type Attributes Description
fields Array.<string> <optional>
A list of fields to check for coordinate fields. If not provided, the fields set on the model will be used.
Since:
  • 2.21.0
Inherited From:
Source:
Returns:
Returns true if every field is a field that specifies latitude or longitude
Type
Boolean

isDateQuery(value) → {boolean}

Returns true if the given value or value set on this filter is a date range query
Parameters:
Name Type Description
value string The string to test
Inherited From:
Source:
Returns:
Type
boolean

isEmpty() → {boolean}

isEmpty - Checks whether this Filter has any values or fields set
Inherited From:
Source:
Returns:
returns true if the Filter's values and fields are empty
Type
boolean

isIdFilter()

Checks if any of the fields in this Filter match one of the AppConfig#queryIdentifierFields
Since:
  • 2.17.0
Inherited From:
Source:

isLatitudeQuery(fieldsopt) → {Boolean}

Check whether a set of query fields contain only fields that specify latitude
Parameters:
Name Type Attributes Description
fields Array.<string> <optional>
A list of fields to check for coordinate fields. If not provided, the fields set on the model will be used.
Since:
  • 2.21.0
Inherited From:
Source:
Returns:
Returns true if every field is a field that specifies latitude
Type
Boolean

isLongitudeQuery(fieldsopt) → {Boolean}

Check whether a set of query fields contain only fields that specify longitude
Parameters:
Name Type Attributes Description
fields Array.<string> <optional>
A list of fields to check for longitude fields. If not provided, the fields set on the model will be used.
Since:
  • 2.21.0
Inherited From:
Source:
Returns:
Returns true if every field is a field that specifies longitude
Type
Boolean

parse(xml) → {JSON}

Parses the given XML node into a JSON object to be set on the model
Parameters:
Name Type Description
xml Element The XML element that contains all the filter elements
Inherited From:
Source:
Returns:
- The JSON object of all the filter attributes
Type
JSON

parseFilterOptions(filterOptionsNode) → {Object}

Parses the filterOptions XML node into a literal object
Parameters:
Name Type Description
filterOptionsNode Element The filterOptions XML element to parse
Inherited From:
Source:
Returns:
- The parsed filter options, in literal object form
Type
Object

parseTextNode(parentNode, nodeName, isMultiple) → {string|Array}

Gets the text content of the XML node matching the given node name
Parameters:
Name Type Description
parentNode Element The parent node to select from
nodeName string The name of the XML node to parse
isMultiple boolean If true, parses the nodes into an array
Inherited From:
Source:
Returns:
- Returns a string or array of strings of the text content
Type
string | Array

precisionToField(precision) → {string}

Coverts a geohash precision level to a field name for Solr
Parameters:
Name Type Description
precision number The geohash precision level, e.g. 4
Since:
  • 2.25.0
Source:
Returns:
The corresponding field name, e.g. "geohash_4"
Type
string

precisionsToFields(precisions) → {Array.<string>}

Converts an array of geohash precision levels to an array of field names for Solr
Parameters:
Name Type Description
precisions Array.<number> The geohash precision levels, e.g. [4, 5]
Since:
  • 2.25.0
Source:
Returns:
The corresponding field names, e.g. ["geohash_4", "geohash_5"]
Type
Array.<string>

removeListeners()

Remove the listeners.
Since:
  • 2.27.0
Source:

requiresPositiveClause(groupLevelOperatoropt) → {boolean}

For "negative" Filters (filter models where exclude is set to true), detects whether the query requires an additional "positive" query phrase in order to avoid the problem of pure negative queries returning zero results. If this Filter is not part of a collection of Filters, assume it needs the positive clause. If this Filter is part of a collection of Filters, detect whether there are other, "positive" filters in the same query (i.e. filter models where exclude is set to false). If there are other positive queries, then an additional clause is not required. If the Filter is part of a pure negative query, but it is not the last filter, then don't add a clause since it will be added to the last, and only one is required. When looking for other positive and negative filters, exclude empty filters and filters that use any of the identifier fields, as these are appended to the end of the query.
Parameters:
Name Type Attributes Description
groupLevelOperator string <optional>
"AND" or "OR". The operator used in the parent Filters collection to combine the filter query fragments together. If the group level operator is "OR" and this filter has exclude set to TRUE, then a positive clause is required.
Inherited From:
Source:
See:
Returns:
returns true of this Filter needs a positive clause, false otherwise
Type
boolean

resetValue()

Resets the values attribute on this filter
Overrides:
Source:

setListeners()

Set a listener that updates the filter when the coordinates & height change
Since:
  • 2.25.0
Source:

updateDOM(optionsopt) → {Element}

Updates XML DOM with the new values from the model
Parameters:
Name Type Attributes Description
options object <optional>
A literal object with options for this serialization
Overrides:
Source:
Returns:
A new XML element with the updated values
Type
Element

updateFilterFromExtent()

Given the current coordinates and height set on the model, update the fields and values to match the geohashes that cover the area. This will set a consolidated set of geohashes that cover the area at the appropriate precision. It will also validate the coordinates to ensure that they are within the bounds of the map.
Since:
  • 2.25.0
Source:

updateFilterOptionsDOM(filterOptionsNodeopt) → {Element}

Serializes the filter options into an XML DOM and returns it
Parameters:
Name Type Attributes Description
filterOptionsNode Element <optional>
The XML filterOptions node to update
Inherited From:
Source:
Returns:
- The updated DOM
Type
Element

validate() → {object}

Checks if the values set on this model are valid. Some of the attributes are changed during this process if they are found to be invalid, since there aren't any easy ways for users to fix these issues themselves in the UI.
Inherited From:
Source:
Returns:
- Returns a literal object with the invalid attributes and their corresponding error message
Type
object

validateCoordinates(silentopt)

Validate the coordinates, ensuring that the east and west are not greater than 180 and that the north and south are not greater than 90. Coordinates will be adjusted if they are out of bounds.
Parameters:
Name Type Attributes Default Description
silent boolean <optional>
true Whether to trigger a change event in the case where the coordinates are adjusted
Since:
  • 2.25.0
Source: