@@ -15,22 +15,25 @@ public interface IGeoDistanceSort : ISort, ICustomJson
1515 string PinLocation { get ; set ; }
1616 IEnumerable < string > Points { get ; set ; }
1717 GeoUnit ? GeoUnit { get ; set ; }
18+ GeoDistance ? DistanceType { get ; set ; }
1819 }
1920
2021 public class GeoDistanceSort : SortBase , IGeoDistanceSort
2122 {
22- internal static List < string > Params = new List < string > { "missing" , "mode" , "order" , "unit" } ;
23+ internal static List < string > Params = new List < string > { "missing" , "mode" , "order" , "unit" , "distance_type" } ;
2324
2425 internal static int MissingIndex = 0 ;
2526 internal static int ModeIndex = 1 ;
2627 internal static int OrderIndex = 2 ;
2728 internal static int UnitIndex = 3 ;
29+ internal static int DistanceTypeIndex = 4 ;
2830
2931 public PropertyPathMarker Field { get ; set ; }
3032 public string PinLocation { get ; set ; }
3133 public IEnumerable < string > Points { get ; set ; }
3234 public GeoUnit ? GeoUnit { get ; set ; }
33-
35+ public GeoDistance ? DistanceType { get ; set ; }
36+
3437 object ICustomJson . GetCustomJson ( )
3538 {
3639 var sort = this . Points . HasAny ( ) ? ( object ) this . Points : this . PinLocation ;
@@ -40,7 +43,8 @@ object ICustomJson.GetCustomJson()
4043 { Params [ MissingIndex ] , this . Missing } ,
4144 { Params [ ModeIndex ] , this . Mode } ,
4245 { Params [ OrderIndex ] , this . Order } ,
43- { Params [ UnitIndex ] , this . GeoUnit }
46+ { Params [ UnitIndex ] , this . GeoUnit } ,
47+ { Params [ DistanceTypeIndex ] , this . DistanceType }
4448 } ;
4549 }
4650 }
@@ -55,7 +59,9 @@ public class SortGeoDistanceDescriptor<T> : SortDescriptorBase<T, SortGeoDistanc
5559 IEnumerable < string > IGeoDistanceSort . Points { get ; set ; }
5660
5761 GeoUnit ? IGeoDistanceSort . GeoUnit { get ; set ; }
58-
62+
63+ GeoDistance ? IGeoDistanceSort . DistanceType { get ; set ; }
64+
5965 public SortGeoDistanceDescriptor < T > PinTo ( string geoLocationHash )
6066 {
6167 geoLocationHash . ThrowIfNullOrEmpty ( "geoLocationHash" ) ;
@@ -93,6 +99,13 @@ public SortGeoDistanceDescriptor<T> Unit(GeoUnit unit)
9399 return this ;
94100 }
95101
102+ public SortGeoDistanceDescriptor < T > DistanceType ( GeoDistance distanceType )
103+ {
104+ distanceType . ThrowIfNull ( "distanceType" ) ;
105+ Self . DistanceType = distanceType ;
106+ return this ;
107+ }
108+
96109 public SortGeoDistanceDescriptor < T > OnField ( string field )
97110 {
98111 Self . Field = field ;
@@ -129,7 +142,8 @@ object ICustomJson.GetCustomJson()
129142 { GeoDistanceSort . Params [ GeoDistanceSort . MissingIndex ] , Self . Missing } ,
130143 { GeoDistanceSort . Params [ GeoDistanceSort . ModeIndex ] , Self . Mode } ,
131144 { GeoDistanceSort . Params [ GeoDistanceSort . OrderIndex ] , Self . Order } ,
132- { GeoDistanceSort . Params [ GeoDistanceSort . UnitIndex ] , Self . GeoUnit }
145+ { GeoDistanceSort . Params [ GeoDistanceSort . UnitIndex ] , Self . GeoUnit } ,
146+ { GeoDistanceSort . Params [ GeoDistanceSort . DistanceTypeIndex ] , Self . DistanceType }
133147 } ;
134148 }
135149 }
0 commit comments