index.d.cts 1.5 KB

123456789101112131415161718192021222324252627282930
  1. import { Corners, Coord } from '@turf/helpers';
  2. import { GeoJSON, GeometryCollection } from 'geojson';
  3. /**
  4. * Scale GeoJSON objects from a given point by a scaling factor e.g. factor=2
  5. * would make each object 200% larger.
  6. * If a FeatureCollection is provided, the origin point will be calculated
  7. * based on each individual feature _unless_ an exact
  8. *
  9. * @function
  10. * @param {GeoJSON|GeometryCollection} geojson objects to be scaled
  11. * @param {number} factor of scaling, positive values greater than 0. Numbers between 0 and 1 will shrink the geojson, numbers greater than 1 will expand it, a factor of 1 will not change the geojson.
  12. * @param {Object} [options={}] Optional parameters
  13. * @param {Corners|Coord} [options.origin='centroid'] Point from which the scaling will occur (string options: sw/se/nw/ne/center/centroid)
  14. * @param {boolean} [options.mutate=false] allows GeoJSON input to be mutated (significant performance improvement if true)
  15. * @returns {GeoJSON|GeometryCollection} scaled GeoJSON
  16. * @example
  17. * const poly = turf.polygon([[[0,29],[3.5,29],[2.5,32],[0,29]]]);
  18. * const scaledPoly = turf.transformScale(poly, 3);
  19. *
  20. * //addToMap
  21. * const addToMap = [poly, scaledPoly];
  22. * scaledPoly.properties = {stroke: '#F00', 'stroke-width': 4};
  23. */
  24. declare function transformScale<T extends GeoJSON | GeometryCollection>(geojson: T, factor: number, options?: {
  25. origin?: Corners | Coord;
  26. mutate?: boolean;
  27. }): T;
  28. export { transformScale as default, transformScale };