## org.opengis.feature
Interface Query

    @XmlElement(value="Query")
    public interface Query

Used by the `getFeatures` method of the data store interface, to encapsulate a request. A query defines which feature type to query, what properties to retrieve and what constraints (spatial and non-spatial) to apply to those properties. It is designed to closesly match a WFS Query element of a `getFeatures` request. A difference is the addition of the `maxFeatures` element, which allows more control over the features selected. It allows a full `getFeatures` request to properly control how many features it gets from each query, instead of requesting and discarding when the max is reached.

Since:
  GeoAPI 2.0
Version:
  Implementation specification 1.1
TODO:
  The following XML elements are not yet defined in this interface: `Function`, `SortBy`.

Method Summary
`CoordinateReferenceSystem` `getCoordinateSystem()` Temporarily override the coordinate reference system.
`CoordinateReferenceSystem` `getCoordinateSystemReproject()` Request data reprojection.
`Filter` `getFilter()` Returns the filter that will limit which features are returned.
`String` `getHandle()` Gives a mnemonic name for use by the client to identify this query.
`int` `getMaxFeatures()` Returns the maximum number of features to be retrieved by the query.
`List<String>` `getPropertyNames()` Returns the list of property names of the features to be retrieved.
`TypeName` `getTypeName()` Returns the name of the type that is to be queried.
`String` `getVersion()` Returns the feature version to query.

Method Detail

### getTypeName

    @XmlElement(value="typeName")
    TypeName getTypeName()

  Returns the name of the type that is to be queried.

  The provided TypeName is used to look up the correct dataset to be querried.

  TODO:
    OGC specification said that a list should be returned. We may add a `getTypeNames()` (plural form) in a future version.

### getFilter

    @XmlElement(value="Filter")
    Filter getFilter()

  Returns the filter that will limit which features are returned. The filter element is used to define spatial and/or non-spatial constraints on query. It may be `null` if there is none.

### getPropertyNames

    @XmlElement(value="Property")
    List<String> getPropertyNames()

  Returns the list of property names of the features to be retrieved. This may be null if all properties are to be retrieved.

  This is used to specify one or more properties of a feature whose values are to be retrieved by a Web Feature Service. While a Web Feature Service should endeavour to satisfy the exact request specified, in some instance this may not be possible. Specifically, a Web Feature Service must generate a valid GML response to a Query operation. The schema used to generate the output may include properties that are mandatory. In order that the output validates, these mandatory properties must be specified in the request. If they are not, a Web Feature Service may add them automatically to the Query before processing it. Thus a client application should, in general, be prepared to receive more properties than it requested. Of course, using `FeatureAttributeDescriptor`, a client application can determine which properties are mandatory and request them in the first place.

### getHandle

    @XmlElement(value="handle")
    String getHandle()

  Gives a mnemonic name for use by the client to identify this query. The handle allows a client application to assign a client-generated identifier for the query. The handle is included to facilitate error reporting. If one query in a `GetFeature` request causes an exception, a WFS may report the handle to indicate which query element failed. If the handle is not present, the WFS may use other means to localize the error (e.g. line numbers).

### getMaxFeatures

    @Extension
    int getMaxFeatures()

  Returns the maximum number of features to be retrieved by the query. Can return zero. Can also return `Integer.MAX_VALUE` to indicate that the maximum number of features is unlimited.

  TODO:
    `maxFeatures` is an attribute of `getFeature` request. We may wish to avoid duplication once WMS interfaces are provided in GeoAPI.

### getVersion

    @XmlElement(value="featureVersion")
    String getVersion()

  Returns the feature version to query. The version attribute is included in order to accommodate systems that support feature versioning. A value of `"ALL"` indicates that all versions of a feature should be fetched. Otherwise an integer, n, can be specified to return the nth version of a feature. The version numbers start at '1' which is the oldest version. If a version value larger than the largest version is specified then the latest version is return. The default action shall be for the query to return the latest version. Systems that do not support versioning can ignore the parameter and return the only version that they have.

  Returns:
    the version of the feature to return, or null for latest.

### getCoordinateSystem

    @Extension
    CoordinateReferenceSystem getCoordinateSystem()

  Temporarily override the coordinate reference system. This denotes a request to temporarily override the coordinate reference system contained in the `FeatureStore` being queried. The same coordinate values will be used, but the features created will appear in this CRS.

  This change is not persistant at all, indeed it is only for the `Feature`s returned by this `Query`. It may be used in conjunction with the reprojection CRS, but this one will always be used first. The reprojection CRS will perform its operation on this crs.

  Returns:
    The coordinate reference system to be returned for `Feature`s from this `Query`.
  TODO:
    JG: Please if you possibly can treat the idea of "forcing" the CRS as a `FeatureCollection` configuration issue (or a `FeatureStore` configuration issue). Recent experience with Geotools shows the added burden on client code to be a pain., MD: This method is misnamed. `CoordinateSystem` and `CoordinateReferenceSystem` are not the same thing.

### getCoordinateSystemReproject

    @Extension
    CoordinateReferenceSystem getCoordinateSystemReproject()

  Request data reprojection. Gets the coordinate reference system to reproject the data contained in the backend feature store to. If the feature store can optimize the reprojection it should. If not then a decorator on the reader should perform the reprojection on the fly.

  Returns:
    The coordinate reference system that features from the feature store should be reprojected to.
  TODO:
    MD: This method is misnamed. `CoordinateSystem` and `CoordinateReferenceSystem` are not the same thing.

Copyright © 1994-2008 Open Geospatial Consortium. All Rights Reserved.