Table of Contents

Class DistanceOp

Namespace
NetTopologySuite.Operation.Distance
Assembly
NetTopologySuite.dll

Computes the distance and closest points between two Geometrys. The distance computation finds a pair of points in the input geometries which have minimum distance between them. These points may not be vertices of the geometries, but may lie in the interior of a line segment. In this case the coordinate computed is a close approximation to the exact point.

Empty geometry collection components are ignored.

The algorithms used are straightforward O(n^2) comparisons. This worst-case performance could be improved on by using Voronoi techniques.
public class DistanceOp
Inheritance
DistanceOp
Inherited Members

Constructors

DistanceOp(Geometry, Geometry)

Constructs a DistanceOp that computes the distance and closest points between the two specified geometries.

public DistanceOp(Geometry g0, Geometry g1)

Parameters

g0 Geometry

A geometry

g1 Geometry

A geometry

DistanceOp(Geometry, Geometry, double)

Constructs a DistanceOp that computes the distance and closest points between the two specified geometries.

public DistanceOp(Geometry g0, Geometry g1, double terminateDistance)

Parameters

g0 Geometry

A geometry

g1 Geometry

A geometry

terminateDistance double

The distance on which to terminate the search.

Methods

Distance()

Report the distance between the closest points on the input geometries.

public double Distance()

Returns

double

The distance between the geometries
or 0 if either input geometry is empty.

Exceptions

ApplicationException

if either input geometry is null

Distance(Geometry, Geometry)

Compute the distance between the closest points of two geometries.

public static double Distance(Geometry g0, Geometry g1)

Parameters

g0 Geometry

A Geometry.

g1 Geometry

Another Geometry.

Returns

double

The distance between the geometries.

IsWithinDistance(Geometry, Geometry, double)

Test whether two geometries lie within a given distance of each other.

public static bool IsWithinDistance(Geometry g0, Geometry g1, double distance)

Parameters

g0 Geometry
g1 Geometry
distance double

Returns

bool

NearestLocations()

Report the locations of the nearest points in the input geometries. The locations are presented in the same order as the input Geometries.

public GeometryLocation[] NearestLocations()

Returns

GeometryLocation[]

A pair of GeometryLocations for the nearest points.

NearestPoints()

Report the coordinates of the nearest points in the input geometries. The points are presented in the same order as the input Geometries.

public Coordinate[] NearestPoints()

Returns

Coordinate[]

A pair of Coordinates of the nearest points.

NearestPoints(Geometry, Geometry)

Compute the the closest points of two geometries. The points are presented in the same order as the input Geometries.

public static Coordinate[] NearestPoints(Geometry g0, Geometry g1)

Parameters

g0 Geometry

A Geometry.

g1 Geometry

Another Geometry.

Returns

Coordinate[]

The closest points in the geometries.