Skip to content

Takes a point, linestring, polygon, or featurecollection, and translate all of its coordinates according to a given translate function.

License

Notifications You must be signed in to change notification settings

klokoy/turf-translate

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)

About

Takes a point, linestring, polygon, or featurecollection, and translate all of its coordinates according to a given translate function.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%