Click or drag to resize

SphinxSearchOptionsSetGeoAnchor Method

Sets an anchor point for geosphere distance calculations.

Namespace:  SphinxConnector.NativeApi
Assembly:  SphinxConnector (in SphinxConnector.dll) Version: 5.3.0
Syntax
public void SetGeoAnchor(
	string latitudeAttribute,
	string longitudeAttribute,
	float latitude,
	float longitude
)

Parameters

latitudeAttribute
Type: SystemString
The name of the lattitude attribute in the index.
longitudeAttribute
Type: SystemString
The name of the longitude attribute in the index.
latitude
Type: SystemSingle
The latitude of the anchor point in radians.
longitude
Type: SystemSingle
The longitude of the anchor point in radians.
Remarks
Sphinx expects latitude and longitude to be in radians (the attributes in the index and the parameters to SetGeoAnchor). The SphinxHelper class contains methods to convert from degrees to radians and vice versa. The unit of @geodist is meters.
Examples
The following example shows how to filter search results based on a geo distance calculation.
float latitude = 0.678892874f;
float longitue = -1.34454090f;

SphinxClient sphinxClient = new SphinxClient();
sphinxClient.SearchOptions.SetGeoAnchor("latitude", "longitude", latitude, longitude);

//Return all results within 20 km of the anchor point
sphinxClient.SearchOptions.SetFilterRange<SphinxFloat>("@geodist", 0, 20000);
See Also