com.mapinfo.midev.language.filter

## Class NearestFilter

- java.lang.Object
- - com.mapinfo.midev.language.filter.NearestFilter

All Implemented Interfaces:
  IFilter

    public final class NearestFilter
    extends Object
    implements IFilter

An `IFilter` that selects `IFeature`s that are within a specified distance from a specified geometry. The `NearestFilter` is different than other `IFilter`s in that it can add items to the projection list. The following attributes can be added to the projection list:

- distanceColumn - the name of the column that will hold the distance from the search geometry to the found geometry. The type will always by double whose units are assumed to be those specified by `NearestFilter.getReturnedDistanceUnit()`.
- tablePointColumn - the name of the column that will hold the `IPoint` that is on the geometry in the table that is the closest point to the search geometry.
- geometryPointColumn - the name of the column that will hold the `IPoint` that is on the search geometry the closest point to the table geometry.

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`Length` `getDistance()` Returns the maximum distance from the search geometry to search within.
`String` `getDistanceColumnName()` Returns the name of the column that will hold the distance between the search geometry and the table geometry.
`DistanceFilterType` `getDistanceFilterType()` Returns the type of distance comparison to perform.
`String` `getGeometryAttributeName()` Returns the the name of geometry column in the table to search.
`String` `getGeometryPointColumnName()` Returns the name of the column that will hold the `IPoint` that is on the search geometry the closest point to the table geometry.
`int` `getNumberOfCandidates()` Returns the maximum number of candidates to return.
`LinearUnit` `getReturnedDistanceUnit()` Returns the units that the `NearestFilter.getDistanceColumnName()` is in.
`IFeatureGeometry` `getSearchGeometry()` Returns the geometry to search from.
`String` `getTablePointColumnName()` Return the name of the column that will hold the `IPoint` that is on the geometry in the table that is the closest point to the search geometry.
`boolean` `isSpatial()` Returns `true`.
`static NearestFilterBuilder` `newBuilder(NearestFilter filter)` Create a filter builder based on an existing filter.
`static NearestFilterBuilder` `newBuilder(String geometryAttributeName, IFeatureGeometry searchGeometry)` Create a filter builder based on the closest features to the specified geometry.

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Method Detail

#### getGeometryAttributeName

    public String getGeometryAttributeName()

Returns the the name of geometry column in the table to search. If `null` the the attribute will not be added to the projection list.

Returns:
  the the name of geometry column in the table to search.

#### getSearchGeometry

    public IFeatureGeometry getSearchGeometry()

Returns the geometry to search from.

Returns:
  the geometry to search from.

#### getNumberOfCandidates

    public int getNumberOfCandidates()

Returns the maximum number of candidates to return. Must be greater than 0.

Returns:
  the maximum number of candidates to return.

#### getDistance

    public Length getDistance()

Returns the maximum distance from the search geometry to search within.

Returns:
  the maximum distance from the search geometry to search within.

#### isSpatial

    public boolean isSpatial()

Returns `true`.

Specified by:
  `isSpatial` in interface `IFilter`
Returns:
  `true`.

#### getDistanceColumnName

    public String getDistanceColumnName()

Returns the name of the column that will hold the distance between the search geometry and the table geometry. If `null` then the attribute will not be added to the projection list.

Returns:
  the name of the column that will hold the distance between the search geometry and the table geometry.

#### getReturnedDistanceUnit

    public LinearUnit getReturnedDistanceUnit()

Returns the units that the `NearestFilter.getDistanceColumnName()` is in.

Returns:
  the units that the `NearestFilter.getDistanceColumnName()` is in.

#### getTablePointColumnName

    public String getTablePointColumnName()

Return the name of the column that will hold the `IPoint` that is on the geometry in the table that is the closest point to the search geometry. If `null` the the attribute will not be added to the projection list.

Returns:
  the name of the column that will hold the `IPoint` that is on the geometry in the table that is the closest point to the search geometry.

#### getGeometryPointColumnName

    public String getGeometryPointColumnName()

Returns the name of the column that will hold the `IPoint` that is on the search geometry the closest point to the table geometry. If `null` the the attribute will not be added to the projection list.

Returns:
  the name of the column that will hold the `IPoint` that is on the search geometry the closest point to the table geometry.

#### getDistanceFilterType

    public DistanceFilterType getDistanceFilterType()

Returns the type of distance comparison to perform.

Returns:
  the type of distance comparison to perform.

#### newBuilder

    public static NearestFilterBuilder newBuilder(String geometryAttributeName,
                                                  IFeatureGeometry searchGeometry)

Create a filter builder based on the closest features to the specified geometry.

Parameters:
  `geometryAttributeName` - Filter this geometry column.
  `searchGeometry` - Filter the column based on the distance to this geometry.

#### newBuilder

    public static NearestFilterBuilder newBuilder(NearestFilter filter)

Create a filter builder based on an existing filter.

Parameters:
  `filter` - Create a builder based on this filter.