JSPM

turf-translate

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 72
  • Score
    100M100P100Q85770F
  • License MIT

turf translate module

Package Exports

  • turf-translate

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (turf-translate) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

turf-translate

Build Status

Takes a point, linestring, polygon, or featurecollection, and translates all of its coordinates with the given translator function. The translator function is called with each coord in the argument and should return a new translated point.

###Install

npm install turf-translate

###Parameters

name description
fc a geojson feature or featurecollection

###Usage

translate(fc, translator)

###Example

var translate = require('turf-translate')
var polygon = require('turf-polygon')

var poly = polygon([[[1,0], [1,0], [1,2]], [[.2,.2], [.3,.3],[.1,.2]]])

//move the polygon 1, 1
var translator = function(point) {
    return [point[0] + 1, point[1] + 1];
}

var translated = translate(poly, translator)

console.log(translated)