util.d.ts 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import { Feature, Polygon } from "@turf/helpers";
  2. /**
  3. * Returns the direction of the point q relative to the vector p1 -> p2.
  4. *
  5. * Implementation of geos::algorithm::CGAlgorithm::orientationIndex()
  6. * (same as geos::algorithm::CGAlgorithm::computeOrientation())
  7. *
  8. * @param {number[]} p1 - the origin point of the vector
  9. * @param {number[]} p2 - the final point of the vector
  10. * @param {number[]} q - the point to compute the direction to
  11. *
  12. * @returns {number} - 1 if q is ccw (left) from p1->p2,
  13. * -1 if q is cw (right) from p1->p2,
  14. * 0 if q is colinear with p1->p2
  15. */
  16. export declare function orientationIndex(p1: number[], p2: number[], q: number[]): number;
  17. /**
  18. * Checks if two envelopes are equal.
  19. *
  20. * The function assumes that the arguments are envelopes, i.e.: Rectangular polygon
  21. *
  22. * @param {Feature<Polygon>} env1 - Envelope
  23. * @param {Feature<Polygon>} env2 - Envelope
  24. * @returns {boolean} - True if the envelopes are equal
  25. */
  26. export declare function envelopeIsEqual(env1: Feature<Polygon>, env2: Feature<Polygon>): boolean;
  27. /**
  28. * Check if a envelope is contained in other one.
  29. *
  30. * The function assumes that the arguments are envelopes, i.e.: Convex polygon
  31. * XXX: Envelopes are rectangular, checking if a point is inside a rectangule is something easy,
  32. * this could be further improved.
  33. *
  34. * @param {Feature<Polygon>} self - Envelope
  35. * @param {Feature<Polygon>} env - Envelope
  36. * @returns {boolean} - True if env is contained in self
  37. */
  38. export declare function envelopeContains(self: Feature<Polygon>, env: Feature<Polygon>): boolean;
  39. /**
  40. * Checks if two coordinates are equal.
  41. *
  42. * @param {number[]} coord1 - First coordinate
  43. * @param {number[]} coord2 - Second coordinate
  44. * @returns {boolean} - True if coordinates are equal
  45. */
  46. export declare function coordinatesEqual(coord1: number[], coord2: number[]): boolean;