Options
All
  • Public
  • Public/Protected
  • All
Menu

Module ria/ogc/filter/FilterFactory

A module with static functions to create Expression instances or Identifiers instances.

This class can for example be used in combination with a WFSFeatureStore. It allows to create a filter which is interpreted by the WFS server as shown below:

  var geoReference = ...;
  var wfsStore = new WFSFeatureStore({
    serviceURL: "http://localhost:8080/LuciadLightspeedOGC/wfs",
    typeName: "rivers",
    reference: geoReference
  } );
  var wfsModel = new FeatureModel(wfsStore, {reference: geoReference} );

  var ogcFilter = FilterFactory.eq(
      FilterFactory.property("SYSTEM"),
      FilterFactory.literal("Mississippi"));

  var wfsLayer = new FeatureLayer(wfsModel, {
   label: "WFS Layer",
   selectable: true,
   loadingStrategy: new LoadEverything( {query: {filter: ogcFilter}} )
 });

Overview

Functions

add

  • Creates an addition OGC expression. It takes two parameters, each one being an OGC expression.

    Note that arithmetic operators are no longer supported in OGC Filter 2.0. You will get an error when you use them in OGC Filter 2.0 XML (for example WFS 2.0). You can still create them, evaluate them and use them in OGC Filter 1.1 XML though.

      FilterFactory.add(
        FilterFactory.literal(12),
        FilterFactory.property("age")
      );
    throws

    Error if not all parameters are OGCExpression

    Parameters

    Returns OGCCondition

    BinaryOperator

and

  • Creates a boolean AND condition. It represents a boolean AND evaluation of two other conditions.

      FilterFactory.and(
        FilterFactory.gt(
          FilterFactory.property("TOT_POP"),
          FilterFactory.literal(100000)
        ),
        FilterFactory.lt(
          FilterFactory.property("TOT_POP"),
          FilterFactory.literal(500000)
        )
      );
    throws

    Error if not all parameters are OGCCondition

    Parameters

    Returns OGCCondition

    The And Logical Operator.

bbox

  • Create a bounding box expression.

      FilterFactory.bbox(
        createBounds( reference, coordinates ),
        FilterFactory.property("geometry")
      );

    Parameters

    • bounds: Bounds

      the bounds of the bounding box.

    • Optional geometryName: PropertyName | string

    Returns OGCCondition

    A Bbox operator

  • Create a bounding box expression.

      FilterFactory.bbox(0, 0, 20, 40, "EPSG:4326");

    Parameters

    • minX: number

      x coordinate of the box's lower corner

    • minY: number

      y coordinate of the box's lower corner

    • maxX: number

      x coordinate of the box's upper corner

    • maxY: number

      y coordinate of the box's upper corner

    • Optional srsName: string
    • Optional geometryName: PropertyName | string

    Returns OGCCondition

    A Bbox operator

between

  • Creates a Between expression. It evaluates to true when the expression is contained in the [lowerBounds, upperBounds] interval.

      FilterFactory.between(
        FilterFactory.property("total_population"),
        FilterFactory.literal(10000),
        FilterFactory.literal(20000)
      );
    
      FilterFactory.between(
        FilterFactory.func( "getTotalPopulation" ),
        FilterFactory.literal(10000),
        FilterFactory.literal(20000)
      );

    Parameters

    Returns OGCCondition

    The Between expression

div

  • Creates a division OGC expression. It takes two parameters, each one being an OGC expression.

    Note that arithmetic operators are no longer supported in OGC Filter 2.0. You will get an error when you use them in OGC Filter 2.0 XML (for example WFS 2.0). You can still create them, evaluate them and use them in OGC Filter 1.1 XML though.

      FilterFactory.div(
        FilterFactory.property("population"),
        FilterFactory.literal(1000)
      );
    throws

    Error if not all parameters are OGCExpression

    Parameters

    Returns OGCCondition

    BinaryOperator

eq

  • Creates a condition that evaluates to true when both expressions are equal.

      FilterFactory.eq(
        FilterFactory.property( "city_name" ),
        FilterFactory.literal( "New York" )
      );
    
      FilterFactory.eq(
        FilterFactory.func( "getCityNames" ),
        FilterFactory.literal( "New York" ),
        false,
        MatchAction.ANY
      );
    throws

    Error if not both expressions are OGCExpression.

    Parameters

    • firstExpression: Expression

      the first expression

    • secondExpression: Expression

      the second expression

    • Optional matchCase: boolean
    • Optional matchAction: MatchAction

    Returns OGCCondition

    A BinaryComparison of type "Equals".

func

  • Creates a custom OGC function with the given name and arguments.

      FilterFactory.func(
        "getCityName"
      );
      FilterFactory.func(
        "geometryType",
        FilterFactory.property( "geom" )
      );

    Parameters

    • name: string

      The name of a custom function

    • Rest ...args: Expression[]

      The arguments that should be passed to the function. This can be any number of OGCExpression.

    Returns OGCCondition

    The custom OGC function

gt

  • Creates a condition that evaluates to true when the first expression is greater than the second expression.

    Examples:

      FilterFactory.gt(
        FilterFactory.property("total_population"),
        FilterFactory.literal(10000)
      );
      FilterFactory.gt(
        FilterFactory.func("getTotalPopulation"),
        FilterFactory.literal(10000)
      );

    Parameters

    • firstExpression: Expression

      the first expression

    • secondExpression: Expression

      the second expression

    • Optional matchCase: boolean
    • Optional matchAction: MatchAction

    Returns OGCCondition

    A BinaryComparison of type "GreaterThan".

gte

  • Creates a condition that evaluates to true when the first expression is greater than or equal to the second expression.

    Examples:

      FilterFactory.gte(
        FilterFactory.property("total_population"),
        FilterFactory.literal(10000)
      );
      FilterFactory.gte(
        FilterFactory.func("getTotalPopulation"),
        FilterFactory.literal(10000)
      );

    Parameters

    • firstExpression: Expression

      the first expression

    • secondExpression: Expression

      the second expression

    • Optional matchCase: boolean
    • Optional matchAction: MatchAction

    Returns OGCCondition

    A BinaryComparison of type "GreaterThanOrEqual".

identifiers

  • (objectIds: (string | number)[], featureIds?: (string | number)[]): Identifiers
  • Creates an ID filter, which limits a result set to just the features whose ids match the ids represented by the ID filter.

    An arbitrary number of IDs can be passed to the identifier method.

      identifiers( [3, 5, "seven"] );
    throws

    Error when provided input parameters are not arrays

    Parameters

    • objectIds: (string | number)[]

      An array containing id values: ResourceId values (OGC Filter ver. 2.0), or GmlObjectId values (OGC Filter ver. 1.0)

    • Optional featureIds: (string | number)[]

      An array containing FeatureId values (OGC Filter ver. 1.0 only).

    Returns Identifiers

    The ID filter

isNull

  • Creates an "is null" expression. It evaluates to true if the value of the expression is null.

      FilterFactory.isNull( FilterFactory.property( "city_name" ) );
    
      FilterFactory.isNull( FilterFactory.func( "getCityName" ) );

    Parameters

    • expression: Expression

      the expression to evaluate

    Returns OGCCondition

    the isNull expression

like

  • Creates an "is like" expression which evaluates to true when the value of expression matches the specified pattern. It is possible to not specify the wildCard, singleChar and escapeChar arguments. In that case the OGC default values will be used (wildCard: '*', single char: '.' and escapeChar character: '!').

      FilterFactory.like(
        FilterFactory.property('city_name'),
        FilterFactory.literal('New*')
      )

    Parameters

    • propertyName: PropertyName

      the propertyName to check

    • pattern: Literal

      the pattern to match

    • Optional wildCard: string
    • Optional singleChar: string
    • Optional escapeChar: string
    • Optional matchCase: boolean

    Returns OGCCondition

    The "is like" expression.

literal

  • Creates a Literal instance for value.

    Parameters

    • value: string | number | boolean

      The value used for the Literal instance

    Returns OGCExpression

    The Literal instance for value

lt

  • Creates a condition that evaluates to true when the first expression is lesser than the second expression.

    Examples:

      FilterFactory.lt(
        FilterFactory.property("total_population"),
        FilterFactory.literal(10000)
      );
      FilterFactory.lt(
        FilterFactory.func("getTotalPopulation"),
        FilterFactory.literal(10000)
      );

    Parameters

    • firstExpression: Expression

      the first expression

    • secondExpression: Expression

      the second expression

    • Optional matchCase: boolean
    • Optional matchAction: MatchAction

    Returns OGCCondition

    A BinaryComparison of type "LessThan".

lte

  • Creates a condition that evaluates to true when the first expression is lesser than or equal to the second expression.

      FilterFactory.lte(
        FilterFactory.property("total_population"),
        FilterFactory.literal(10000)
      );
    
      FilterFactory.lte(
        FilterFactory.func("getTotalPopulation"),
        FilterFactory.literal(10000)
      );

    Parameters

    • firstExpression: Expression

      the first expression

    • secondExpression: Expression

      the second expression

    • Optional matchCase: boolean
    • Optional matchAction: MatchAction

    Returns OGCCondition

    A BinaryComparison of type "LessThanOrEqual".

mul

  • Creates a multiplication OGC expression. It takes two parameters, each one being an OGC expression.

    Note that arithmetic operators are no longer supported in OGC Filter 2.0. You will get an error when you use them in OGC Filter 2.0 XML (for example WFS 2.0). You can still create them, evaluate them and use them in OGC Filter 1.1 XML though.

      FilterFactory.mul(
        FilterFactory.property("population"),
        FilterFactory.literal(1000)
      );
    throws

    Error if not all parameters are OGCExpression

    Parameters

    Returns OGCCondition

    BinaryOperator

neq

  • Creates a condition that evaluates to true when both expressions are not equal.

      FilterFactory.neq(
        FilterFactory.property( "city_name" ),
        FilterFactory.literal( "New York" )
      );
    
      FilterFactory.neq(
        FilterFactory.func( "getCityName" ),
        FilterFactory.literal( "New York" )
      );

    Parameters

    • firstExpression: Expression

      the first expression

    • secondExpression: Expression

      the second expression

    • Optional matchCase: boolean
    • Optional matchAction: MatchAction

    Returns OGCCondition

    A BinaryComparison of type "NotEquals".

not

  • Creates a boolean NOT expression. It represents the negation of the expression.

      FilterFactory.not(
        FilterFactory.eq(
          FilterFactory.property("city_name"),
          FilterFactory.literal("New York")
        )
      );
    throws

    Error if the parameter is not an expression

    Parameters

    • expression: Expression

      the expression to negate.

    Returns OGCCondition

    The Not expression.

or

  • Creates a boolean OR expression. It represents a boolean OR evaluation of other expressions. It takes any number of parameters, each one being an expression.

      FilterFactory.or(
        FilterFactory.lt(
          FilterFactory.property("TOT_POP"),
          FilterFactory.literal(500000)
        ),
        FilterFactory.eq(
         FilterFactory.property("city_name"),
         FilterFactory.literal("New York")
       );
      );
    throws

    Error if not all parameters are Expression

    Parameters

    Returns OGCCondition

    The Or expression.

property

  • Creates a value reference (OGC Filter version 2.0) or a property name (OGC Filter version 1.0) that represents a value that is to be evaluated by a filter predicate.

    At runtime, a predicate is evaluated by replacing the value reference (property name) by the value it refers to.

    Parameters

    • propertyName: string

      the property name (or path) of a feature

    • Optional namespacesMap: {}
      • [key: string]: string

    Returns PropertyName

    The property instance for the propertyName

sub

  • Creates a subtraction OGC expression. It takes two parameters, each one being an OGC expression.

    Note that arithmetic operators are no longer supported in OGC Filter 2.0. You will get an error when you use them in OGC Filter 2.0 XML (for example WFS 2.0). You can still create them, evaluate them and use them in OGC Filter 1.1 XML though.

      FilterFactory.sub(
        FilterFactory.property("age")
        FilterFactory.literal(18),
      );
    throws

    Error if not all parameters are OGCExpression

    Parameters

    • firstExpression: Expression

      the first expression

    • secondExpression: Expression

      the second expression

    Returns OGCCondition

    BinaryOperator

toFeaturePredicate

  • Converts a feature into a javascript feature filter function, that can be used to filter features on the client side.

    The returned function takes a single argument, a Feature. It returns true when the argument satisfies the condition. It returns false when the argument does not satisfy the condition.

    The condition may not contain function expressions.

      var filter = FilterFactory.gte(
        FilterFactory.property("total_population"),
        FilterFactory.literal(10000)
      );
    
      aFeatureLayer.filter = FilterFactory.toFeaturePredicate( filter );

    Parameters

    Returns (feature: Feature) => boolean

    A predicate function.

      • Parameters

        Returns boolean

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method