scalePositionBy<C extends num> function
Returns a function to scale positions by the scale
factor.
Implementation
TransformPosition scalePositionBy<C extends num>(C scale) =>
<T extends Position>(T source) {
final dim = source.coordinateDimension;
if (dim == 2) {
// point is (X, Y)
return source.copyWith(
x: scale * source.x,
y: scale * source.y,
) as T;
} else {
// point could be (X, Y, Z), (X, Y, M) or (X, Y, Z, M)
return source.copyWith(
x: scale * source.x,
y: scale * source.y,
z: source.is3D ? scale * source.z : null,
m: source.isMeasured ? scale * source.m : null,
) as T;
}
};