Class TLcdOGCFilterFactory

java.lang.Object
com.luciad.ogc.filter.model.TLcdOGCFilterFactory

public final class TLcdOGCFilterFactory extends Object
Convenience factory for conditions that define an OGC Filter.
Since:
2012.1
  • Method Details

    • or

      public static TLcdOGCBinaryLogicOperator or(ILcdOGCCondition... aConditions)
      Creates a new 'or' condition that evaluates to true if one of the conditions in aConditions is true.
      Parameters:
      aConditions - One or more conditions.
      Returns:
      A valid 'or' operator
    • and

      public static TLcdOGCBinaryLogicOperator and(ILcdOGCCondition... aConditions)
      Creates a new 'and' condition that evaluates to true if all of the conditions in aConditions are true.
      Parameters:
      aConditions - One or more conditions.
      Returns:
      A valid 'and' operator
    • eq

      public static TLcdOGCBinaryComparisonOperator eq(ILcdOGCExpression aFirstExpression, ILcdOGCExpression aSecondExpression)
      Creates a condition that evaluates to true when aFirstExpression is equal to aSecondExpression.
      Parameters:
      aFirstExpression - The first expression.
      aSecondExpression - The second expression.
      Returns:
      An 'equals' operator.
    • gt

      public static TLcdOGCBinaryComparisonOperator gt(ILcdOGCExpression aFirstExpression, ILcdOGCExpression aSecondExpression)
      Creates a condition that evaluates to true when aFirstExpression is greater then aSecondExpression
      Parameters:
      aFirstExpression - The first expression
      aSecondExpression - The second expression
      Returns:
      A 'greater then' operator
    • gte

      public static TLcdOGCBinaryComparisonOperator gte(ILcdOGCExpression aFirstExpression, ILcdOGCExpression aSecondExpression)
      Creates a condition that evaluates to true when aFirstExpression is greater then or equal to aSecondExpression
      Parameters:
      aFirstExpression - The first expression
      aSecondExpression - The second expression
      Returns:
      A 'greater then or equal' operator
    • lt

      public static TLcdOGCBinaryComparisonOperator lt(ILcdOGCExpression aFirstExpression, ILcdOGCExpression aSecondExpression)
      Creates a condition that evaluates to true when aFirstExpression is less then aSecondExpression
      Parameters:
      aFirstExpression - The first expression
      aSecondExpression - The second expression
      Returns:
      A 'less then' operator
    • lte

      public static TLcdOGCBinaryComparisonOperator lte(ILcdOGCExpression aFirstExpression, ILcdOGCExpression aSecondExpression)
      Creates a condition that evaluates to true when aFirstExpression is less then or equal to aSecondExpression
      Parameters:
      aFirstExpression - The first expression
      aSecondExpression - The second expression
      Returns:
      A 'less then or equal' operator
    • not

      public static TLcdOGCNotOperator not(ILcdOGCCondition aCondition)
      Creates a condition that evaluates to true when the given condition is false and vice versa.
      Parameters:
      aCondition - The condition to invert
      Returns:
      the condition that is the inverse of the given condition
    • isNull

      public static TLcdOGCIsNullOperator isNull(TLcdOGCPropertyName aPropertyName)
      Creates an operator that evaluates to true when the given property is null.
      Parameters:
      aPropertyName - The name of the property to check
      Returns:
      the operator that will check if the given property is null
    • eq

      public static TLcdOGCBinaryComparisonOperator eq(ILcdOGCExpression aExpression, Object aLiteralContent)
      Creates a condition that evaluates to true when aExpression is equal to aLiteralContent, which is a static value.
      Parameters:
      aExpression - The first expression.
      aLiteralContent - An object which can be compared to the result of aFirstExpression
      Returns:
      An 'equals' operator.
    • like

      public static TLcdOGCIsLikeOperator like(TLcdOGCPropertyName aPropertyName, Object aLiteralPatternContent)

      Creates an operator that evaluates to true when the value of aPropertyName matches the pattern specified in aLiteralPatternContent. It uses the OGC default values for a wildcard ('*'), a single char ('?') and the escape character ('\').

      Parameters:
      aPropertyName - The name of the property to check
      aLiteralPatternContent - An object which can be compared to the given property
      Returns:
      the operator that will check whether the property matches the pattern
    • between

      public static TLcdOGCIsBetweenOperator between(ILcdOGCExpression aExpression, ILcdOGCExpression aLowerBounds, ILcdOGCExpression aUpperBounds)

      Creates an operator that evaluates to true when aExpression is contained in the [aLowerBounds, aUpperBounds] interval.

      Parameters:
      aExpression - The expression to check
      aLowerBounds - The lower bounds of the interval (inclusive)
      aUpperBounds - The upper bounds of the interval (inclusive)
      Returns:
      The operator that will check whether the expression is contained in the specified range.
    • function

      public static TLcdOGCFunction function(String aName, ILcdOGCExpression... aArguments)
      Creates a custom OGC function with the given name and arguments. All functions have to be supported by the filter evaluator. For the default TLcdOGCFilterEvaluator, functions can be registered using TLcdOGCFilterEvaluator.registerFunction(com.luciad.format.xml.TLcdXMLName, com.luciad.ogc.filter.evaluator.ILcdEvaluatorFunction) .

      A function that evaluates to a boolean can be used directly as a condition.
      In that case, this:

         function(FUNCTION_NAME, ...)
       
      is equivalent to:
         eq(function(FUNCTION_NAME, ...), literal(true))
       
      If you use a function as condition, but it evaluates to a non-boolean result, you will get errors while evaluating.
      Parameters:
      aName - The name of a custom function, should not be null.
      aArguments - The arguments that should be passed to the function.
      Returns:
      A function with the given name and arguments.
    • add

      public static TLcdOGCBinaryOperator add(ILcdOGCExpression aFirstExpression, ILcdOGCExpression aSecondExpression)

      Creates an operator that corresponds to an arithmetic add operation between aFirstExpression and aSecondExpression.

      Note that the OGC Filter 2.0 standard no longer includes the binary operators. You will get an IllegalArgumentException when you use this operator in OGC Filter 2.0 XML (for example WFS 2.0).
      Parameters:
      aFirstExpression - The first expression
      aSecondExpression - The second expression
      Returns:
      An 'add' operator
    • sub

      public static TLcdOGCBinaryOperator sub(ILcdOGCExpression aFirstExpression, ILcdOGCExpression aSecondExpression)

      Creates an operator that corresponds to an arithmetic subtract operation between aFirstExpression and aSecondExpression.

      Note that the OGC Filter 2.0 standard no longer includes the binary operators. You will get an IllegalArgumentException when you use this operator in OGC Filter 2.0 XML (for example WFS 2.0).
      Parameters:
      aFirstExpression - The first expression
      aSecondExpression - The second expression
      Returns:
      An 'subtract' operator
    • mul

      public static TLcdOGCBinaryOperator mul(ILcdOGCExpression aFirstExpression, ILcdOGCExpression aSecondExpression)

      Creates an operator that corresponds to an arithmetic multiply operation between aFirstExpression and aSecondExpression.

      Note that the OGC Filter 2.0 standard no longer includes the binary operators. You will get an IllegalArgumentException when you use this operator in OGC Filter 2.0 XML (for example WFS 2.0).
      Parameters:
      aFirstExpression - The first expression
      aSecondExpression - The second expression
      Returns:
      An 'multiply' operator
    • div

      public static TLcdOGCBinaryOperator div(ILcdOGCExpression aFirstExpression, ILcdOGCExpression aSecondExpression)

      Creates an operator that corresponds to an arithmetic divide operation between aFirstExpression and aSecondExpression.

      Note that the OGC Filter 2.0 standard no longer includes the binary operators. You will get an IllegalArgumentException when you use this operator in OGC Filter 2.0 XML (for example WFS 2.0).
      Parameters:
      aFirstExpression - The first expression
      aSecondExpression - The second expression
      Returns:
      An 'divide' operator
    • temporal

      public static TLcdOGCBinaryTemporalOperator temporal(TLcdOGCPropertyName aPropertyName, Date aDate, QName aComparison)

      Creates an operator that evaluates to true when aPropertyName matches in the comparison with aDate . The aComparison type determines how the dates are matched.

      Example: Date date = new Date(); TLcdOGCBinaryTemporalOperator operator = temporal(property("timeProperty"), date, TLcdOGCBinaryTemporalOperator.BEFORE);

          Date date = new Date();
          TLcdOGCBinaryTemporalOperator operator = temporal(property("timeProperty"), date, TLcdOGCBinaryTemporalOperator.BEFORE);
      
      Parameters:
      aPropertyName - the name of the property to check
      aDate - the date to compare with
      aComparison - the type of the temporal comparison, see TLcdOGCBinaryTemporalOperator
      Returns:
      An temporal operator
      Since:
      2017.0
    • temporalInterval

      public static TLcdOGCBinaryTemporalOperator temporalInterval(TLcdOGCPropertyName aPropertyName, Date aBegin, Date aEnd, QName aComparison)

      Creates an operator that evaluates to true when aPropertyName matches in the comparison with time interval defined by aBegin and aEnd. The aComparison type determines how the dates are matched.

      Parameters:
      aPropertyName - the name of the property to check
      aBegin - the begin date
      aEnd - the end date
      aComparison - the type of the temporal comparison, see TLcdOGCBinaryTemporalOperator
      Returns:
      An temporal operator
      Since:
      2017.0
    • property

      public static TLcdOGCPropertyName property(TLcdDataType aDataType, TLcdDataProperty... aProperties)
      Creates a property name that points to the last property in aProperties, the xpath will start from an object of type aDataType. Each property in aProperties should be a child property of its preceding property. The first property in the list does not have to be a direct child of aDataType. Returns null if a suitable path could not be found.

      There are some usage considerations:

      • This operation can be costly for large data models, so in general it is recommended to store the resulting property name once it is created.
      • The data property should not be a property of a GML geometry data type, as there is usually no need to reference part of a geometry.

      The missing XPath steps between the TLcdDataType and the first TLcdDataProperty in aDataProperties will be determined based on a best-effort approach. This means that a result is not guaranteed, mostly depending on the complexity of the data model.

      It is only necessary to specify multiple TLcdDataProperty instances if the xpath generation fails to find a path between aDataType and the first property in aProperties.

      Parameters:
      aDataType - A data type from which to reach the property
      aProperties - A list of subsequent properties, each property in the list should be a child property of its preceding property.
      Returns:
      A property name, or null if no suitable path could be found
    • property

      public static TLcdOGCPropertyName property(String aExpression, Map<String,String> aPrefix2Namespace)
      Creates a property name based on an xpath expression and a Map that maps prefixes to namespaces. An empty string can be used to define the default namespace.

      Example, note that the prefix map can be reused for multiple property names:

          Map<String, String> namespaceMap = new HashMap<String, String>(2);
          namespaceMap.put("", "DefaultNS");
          namespaceMap.put("ogc", "http://www.opengis.net/ogc");
          TLcdOGCPropertyName filterProperty = property("MyObject/ogc:Filter", namespaceMap);
      
      Parameters:
      aExpression - An XPath expression
      aPrefix2Namespace - A map containing prefixes.
      Returns:
      A valid property name.
    • property

      public static TLcdOGCPropertyName property(String aExpression)
      Creates a property name based on an xpath expression that only uses the default name space. Functionally equivalent to property(String, java.util.Map) with an empty map.
      Parameters:
      aExpression - An XPath expression
      Returns:
      A valid property name.
    • property

      public static TLcdOGCPropertyName property(String aExpression, String aDefaultNameSpace)

      Creates a property name based on an xpath expression that only uses the default name space. The default name space is specified as a parameter.

      Functionally equivalent to property(String, java.util.Map) with a map containing one entry ("", aDefaultNameSpace).

      Parameters:
      aExpression - An XPath expression
      aDefaultNameSpace - The default name space (which uses an empty prefix)
      Returns:
      A valid property name
    • literal

      public static TLcdOGCLiteral literal(Object aLiteralValue)

      Creates a literal for aLiteralValue.

      Short for new TLcdOGCLiteral( aLiteralValue )

      Parameters:
      aLiteralValue - The literal value
      Returns:
      The TLcdOGCLiteral for aLiteralValue
    • minBoundsSize

      public static ILcdOGCCondition minBoundsSize(double aMinSizeX, double aMinSizeY)
      Creates a condition that passes objects that have a minimum bounds size.

      You can use this for example to discard objects that are too small to see when zoomed out.

      See TLcdOGCVendorSpecificFunctions.MIN_BOUNDS_SIZE_FUNCTION_NAME for details.

      Equivalent to:

         function(MIN_BOUNDS_SIZE_FUNCTION_NAME, literal(aMinSizeX), literal(aMinSizeY))
       
      which is the same as:
         eq(function(MIN_BOUNDS_SIZE_FUNCTION_NAME, literal(aMinSizeX), literal(aMinSizeY)), literal(true))
       
      Parameters:
      aMinSizeX - The minimum X extent objects should have, in model units.
      aMinSizeY - The minimum Y extent objects should have, in model units.
      Returns:
      The condition
      Since:
      2017.0
    • resourceIds

      public static TLcdOGCResourceIdsOperator resourceIds(TLcdOGCResourceId... aResourceIds)
      Creates a condition that can be used in an OGC Filter to match elements based on their ID.

      This operator can be used regardless of what OGC Filter version is used for (de)serialization:

      • When used as an OGC Filter 1.1 (for example WFS 1), this operator will be transformed to/from an OGC Filter with a list of object IDs
      • When used as an OGC Filter 2.0 (for example WFS 2), this operator will be transformed to/from an OGC Filter with a condition with a list of resource IDs
      Returns:
      The condition
      Since:
      2017.0
    • resourceIds

      public static TLcdOGCResourceIdsOperator resourceIds(String... aResourceIds)
      Creates a condition that can be used in an OGC Filter to match elements based on their ID.

      This operator can be used regardless of what OGC Filter version is used for (de)serialization:

      • When used as an OGC Filter 1.1 (for example WFS 1), this operator will be transformed to/from an OGC Filter with a list of object IDs
      • When used as an OGC Filter 2.0 (for example WFS 2), this operator will be transformed to/from an OGC Filter with a condition with a list of resource IDs
      Returns:
      The condition
      Since:
      2017.0
    • bbox

      public static TLcdOGCBBoxOperator bbox(ILcdBounds aBounds)

      Creates a new bounding box operator which can be used to perform a spatial query on an ILcdModel. This method is equivalent to calling:

      
         bbox(aBounds, null)
       
      Parameters:
      aBounds - The bounds
      Returns:
      The condition
      Since:
      2019.1
    • bbox

      public static TLcdOGCBBoxOperator bbox(ILcdBounds aBounds, ILcdGeoReference aBoundsReference)

      Creates a new bounding box operator which can be used to perform a spatial query on an ILcdModel.

      When using the returned TLcdOGCBBoxOperator to filter domain objects from a model intersecting with the specified bounds (e.g. using a TLcdOGCFilter or the query method), the operator will compare the geometry of the domain object with those bounds. The TLcdOGCBBoxOperator supports:

      An example how this method can be used to perform a spatial query on a model using the query method:

          //Start by creating the bbox condition
          TLcdOGCBBoxOperator bbox = bbox(new TLcdLonLatBounds(10, 10, 10, 10),
                                          new TLcdGeodeticReference());
          //use that bbox condition to query the model for all elements that intersect with those bounds
          try (TLcdLockUtil.Lock readLock = TLcdLockUtil.readLock(aModel)) {
            try (Stream<Object> domainObjects = aModel.query(ILcdModel.filter(bbox))) {
              //do something with the found domain objects
              long count = domainObjects.count();
              System.out.println("Found " + count + " domain objects in those bounds");
            }
          }
      
      Parameters:
      aBounds - The bounds.
      aBoundsReference - The reference of those bounds. When using null:
      • The bounds are assumed to be in the model reference when using the condition to query the model directly.
      • The bounds are assumed to be in the default georeference of the filter context when used to evaluate an OGC filter. When that reference is also null, the bounds are assumed to be defined in the same reference as the shape for which the bounds check is happening.
      Returns:
      The condition
      Since:
      2019.1