FunctionGeodist(Single, Single, Single, Single) Method

Calculates the geosphere distance between the two points given by their coordinates. The coordinates must be provided in radians.

Definition

Namespace: SphinxConnector.FluentApi
Assembly: SphinxConnector (in SphinxConnector.dll) Version: 6.1.0
C#
public static float Geodist(
	float latitude1,
	float longitude1,
	float latitude2,
	float longitude2
)

Parameters

latitude1  Single
The latitude of the first point.
longitude1  Single
The longitude of the first point.
latitude2  Single
The latitude of the second point.
longitude2  Single
The longitude of the second point.

Return Value

Single
The geosphere distance in meters.

Example

C#
using (IFulltextSession fulltextSession = fulltextStore.StartSession())
{                
    var results = fulltextSession.Query<Document>().
                                  Select(x => new 
                                  {
                                      Geodistance = Function.Geodist(40.7643929f, -73.9997683f, x.Latitude, x.Longitude)
                                  }).
                                  Where(x => x.Geodistance < 10000).
                                  ToList();        
}

See Also