| SphinxSearchOptionsSetGeoAnchor Method |
Sets an anchor point for geosphere distance calculations.
Namespace:
SphinxConnector.NativeApi
Assembly:
SphinxConnector (in SphinxConnector.dll) Version: 5.4.1
Syntax public void SetGeoAnchor(
string latitudeAttribute,
string longitudeAttribute,
float latitude,
float longitude
)
Public Sub SetGeoAnchor (
latitudeAttribute As String,
longitudeAttribute As String,
latitude As Single,
longitude As Single
)
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);
sphinxClient.SearchOptions.SetFilterRange<SphinxFloat>("@geodist", 0, 20000);
See Also