NGeoKDBush 1.0.1

Package Description

Install-Package NGeoKDBush -Version 1.0.1
dotnet add package NGeoKDBush --version 1.0.1
<PackageReference Include="NGeoKDBush" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NGeoKDBush --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

NGeoKDBush

This library allows indexing geographical points, and then querying for all points of interest that are some distance from some location.
The points will be returned ordered by being closet to furthest.

It implements fast nearest neighbors queries for locations on Earth, taking Earth curvature and date line wrapping into account. Direct port of geokdbush which itself was inspired by sphere-knn, but uses a different algorithm.

A geographic extension for nkdbush.

Example


var index = new KDBush<City>(cities.ToArray(), p => p.Lon, p => p.Lat);
var geoKdBush = new GeoKDBush<City>();
var nearest = geoKdBush.Around(index, -119.7051, 34.4363, 5);

API

Around(IKDBush<T> index, double lng, double lat, int? maxResults = null, double? maxDistance = null, Predicate<T> predicate = null)

Returns an array of the closest points from a given location in order of increasing distance.

  • index: nkdbush index.
  • lng: query point longitude.
  • lat: query point latitude.
  • maxResults: (optional) maximum number of points to return (int.MaxValue by default).
  • maxDistance: (optional) maximum distance in kilometers to search within (double.MaxValue by default).
  • predicate: (optional) a lambda to filter the results with.
Distance(double lng, double lat, double lng2, double lat2)

Returns great circle distance between two locations in kilometers.

Performance

I have found the performance of this port fast enough for my purposes, so I haven't yet had the justification to run micro-bechmarks.
However, I'm sure many performance improvements are possilbe and I might get to it someday.

NGeoKDBush

This library allows indexing geographical points, and then querying for all points of interest that are some distance from some location.
The points will be returned ordered by being closet to furthest.

It implements fast nearest neighbors queries for locations on Earth, taking Earth curvature and date line wrapping into account. Direct port of geokdbush which itself was inspired by sphere-knn, but uses a different algorithm.

A geographic extension for nkdbush.

Example


var index = new KDBush<City>(cities.ToArray(), p => p.Lon, p => p.Lat);
var geoKdBush = new GeoKDBush<City>();
var nearest = geoKdBush.Around(index, -119.7051, 34.4363, 5);

API

Around(IKDBush<T> index, double lng, double lat, int? maxResults = null, double? maxDistance = null, Predicate<T> predicate = null)

Returns an array of the closest points from a given location in order of increasing distance.

  • index: nkdbush index.
  • lng: query point longitude.
  • lat: query point latitude.
  • maxResults: (optional) maximum number of points to return (int.MaxValue by default).
  • maxDistance: (optional) maximum distance in kilometers to search within (double.MaxValue by default).
  • predicate: (optional) a lambda to filter the results with.
Distance(double lng, double lat, double lng2, double lat2)

Returns great circle distance between two locations in kilometers.

Performance

I have found the performance of this port fast enough for my purposes, so I haven't yet had the justification to run micro-bechmarks.
However, I'm sure many performance improvements are possilbe and I might get to it someday.

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.0.1 110 4/9/2019
1.0.0 281 5/26/2018