mirror of
https://github.com/FoggedLens/iD.git
synced 2026-03-05 02:41:21 +00:00
27 lines
805 B
JavaScript
27 lines
805 B
JavaScript
export function RotateWay(wayId, pivot, angle, projection) {
|
|
return function(graph) {
|
|
return graph.update(function(graph) {
|
|
var way = graph.entity(wayId);
|
|
|
|
_.uniq(way.nodes).forEach(function(id) {
|
|
|
|
var node = graph.entity(id),
|
|
point = projection(node.loc),
|
|
radial = [0,0];
|
|
|
|
radial[0] = point[0] - pivot[0];
|
|
radial[1] = point[1] - pivot[1];
|
|
|
|
point = [
|
|
radial[0] * Math.cos(angle) - radial[1] * Math.sin(angle) + pivot[0],
|
|
radial[0] * Math.sin(angle) + radial[1] * Math.cos(angle) + pivot[1]
|
|
];
|
|
|
|
graph = graph.replace(node.move(projection.invert(point)));
|
|
|
|
});
|
|
|
|
});
|
|
};
|
|
}
|