index.d.cts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import { Feature, Point, FeatureCollection } from 'geojson';
  2. /**
  3. * calcualte the Minkowski p-norm distance between two features.
  4. *
  5. * @function
  6. * @param feature1 point feature
  7. * @param feature2 point feature
  8. * @param p p-norm 1=<p<=infinity 1: Manhattan distance 2: Euclidean distance
  9. */
  10. declare function pNormDistance(feature1: Feature<Point>, feature2: Feature<Point>, p?: number): number;
  11. /**
  12. *
  13. *
  14. * @function
  15. * @param {FeatureCollection<any>} fc FeatureCollection.
  16. * @param {Object} [options] option object.
  17. * @param {number} [options.threshold=10000] If the distance between neighbor and
  18. * target features is greater than threshold, the weight of that neighbor is 0.
  19. * @param {number} [options.p=2] Minkowski p-norm distance parameter.
  20. * 1: Manhattan distance. 2: Euclidean distance. 1=<p<=infinity.
  21. * @param {boolean} [options.binary=false] If true, weight=1 if d <= threshold otherwise weight=0.
  22. * If false, weight=Math.pow(d, alpha).
  23. * @param {number} [options.alpha=-1] distance decay parameter.
  24. * A big value means the weight decay quickly as distance increases.
  25. * @param {boolean} [options.standardization=false] row standardization.
  26. * @returns {Array<Array<number>>} distance weight matrix.
  27. * @example
  28. *
  29. * var bbox = [-65, 40, -63, 42];
  30. * var dataset = turf.randomPoint(100, { bbox: bbox });
  31. * var result = turf.distanceWeight(dataset);
  32. */
  33. declare function distanceWeight(fc: FeatureCollection<any>, options?: {
  34. threshold?: number;
  35. p?: number;
  36. binary?: boolean;
  37. alpha?: number;
  38. standardization?: boolean;
  39. }): number[][];
  40. export { distanceWeight as default, distanceWeight, pNormDistance };