GeoLocation is a double for lat/long as expected but GeoDistance is an Abstract class with the int value that seems to have 2 implementations.
// Decompiled with JetBrains decompiler
// Type: EPiServer.Find.Api.Querying.Filters.Miles
// Assembly: EPiServer.Find, Version=13.4.1.0, Culture=neutral, PublicKeyToken=8fe83dea738b45b7
// MVID: B8987D14-EA4E-414B-843A-06C36F6AAF0C
// Assembly location: D:\Niteco\ThinkMax\Repo\StewMac-Episerver\.packages\EPiServer.Find.13.4.1\lib\net461\EPiServer.Find.dll
namespace EPiServer.Find.Api.Querying.Filters
{
public class Miles : GeoDistance
{
public Miles(int value)
: base(value)
{
}
internal override string Unit => "mi";
}
}
// Decompiled with JetBrains decompiler
// Type: EPiServer.Find.Api.Querying.Filters.Kilometers
// Assembly: EPiServer.Find, Version=13.4.1.0, Culture=neutral, PublicKeyToken=8fe83dea738b45b7
// MVID: B8987D14-EA4E-414B-843A-06C36F6AAF0C
// Assembly location: D:\Niteco\ThinkMax\Repo\StewMac-Episerver\.packages\EPiServer.Find.13.4.1\lib\net461\EPiServer.Find.dll
namespace EPiServer.Find.Api.Querying.Filters
{
public class Kilometers : GeoDistance
{
public Kilometers(int value)
: base(value)
{
}
internal override string Unit => "km";
}
}
If these are not accurate enough for you I think you can create you're own classes that Inhert GeoDistance and set different Unit values. To match what Elastic can do
https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/distance-units.html
Thanks Scott, it might be the solution
what is the different between Kilometers & Kilometer , miles and mile?
#region Assembly EPiServer.Find, Version=13.4.3.0, Culture=neutral, PublicKeyToken=8fe83dea738b45b7
namespace EPiServer.Find
{
public static class GeoExtensions
{
public static GeoDistance Kilometer(this int distance);
public static GeoDistance Kilometers(this int distance);
public static GeoDistance Mile(this int distance);
public static GeoDistance Miles(this int distance);
}
}
When you decompile them you see they are just extension methods for creating the types. Really not sure why there's 2 as they both do the same thing.
public static class GeoExtensions
{
public static GeoDistance Kilometer(this int distance) => distance.Kilometers();
public static GeoDistance Kilometers(this int distance) => (GeoDistance) new EPiServer.Find.Api.Querying.Filters.Kilometers(distance);
public static GeoDistance Mile(this int distance) => distance.Miles();
public static GeoDistance Miles(this int distance) => (GeoDistance) new EPiServer.Find.Api.Querying.Filters.Miles(distance);
}
If you've not used it I'd suggest downloading https://github.com/icsharpcode/ILSpy from here or the Windows store. You can add any assemblies in and decompile to see this. Also if you're company is willing to pay the Resharper tools also have it built in with native Visual Studio integration. I use a combination of the 2 for getting to the bottom of these things.
We have a web API that passes the distance as a float value which is used by Episerver find below the method
publicstatic DelegateFilterBuilder WithinDistanceFrom(this GeoLocation value, GeoLocation fromLocation, GeoDistance distance);
but the GeoLocation and GeoDistance only accepting integer, so any float value converted to the nearest integer kilomteres that could cause inaccurate result some time
is there any way to in Epi find to search the distance with the actual float value
GeoLocation
GeoDistance
WithinDistanceFrom