require(["esri/geometry/operators/support/Transformation"], (Transformation) => { /* code goes here */ });
import Transformation from "@arcgis/core/geometry/operators/support/Transformation.js";
esri/geometry/operators/support/Transformation
The Transformation class represents 2D transformations that can be applied to geometries using the affineTransformOperator. All transformations are applied in the spatial reference units of the input geometries.
Method Overview
Name | Return Type | Summary | Class |
---|---|---|---|
Calculates distance errors for a transformation on a given set of the input points to the output points. | Transformation | ||
Flips all the | Transformation | ||
Flips all the | Transformation | ||
Initializes a new transformation from the input and output control points. | Transformation | ||
Determines if the transformation is in its default state, which is an identity matrix. | Transformation | ||
Rotates the geometries by the specified angle in degrees around the point specified by the x and y coordinates. | Transformation | ||
Resizes the geometries by the specified scale factors defined by the x and y coordinates. | Transformation | ||
Use this method to reset the transformation to its default state, which is an identity matrix. | Transformation | ||
Use this method to swap the x and y coordinate values in the transformation. | Transformation | ||
Shifts a geometry's points by the specified proportion in parallel to the x and y directions, except those points that are along the shear axis, which is a line defined by the x and y coordinates. | Transformation | ||
Shifts all the coordinates of the geometries by the distance and direction between the specified | Transformation |
Method Details
-
calculateErrors
calculateErrors(input, output){ErrorResult}
-
Calculates distance errors for a transformation on a given set of the input points to the output points. This method is usually used to calculate errors for the transformation initialized by initializeFromControlPoints.
The length of the
input
andoutput
arrays must be the same.ParametersReturnsType Description ErrorResult Returns an object representing the errors incurred during transformation. Example// Calculate the errors for a transformation const errors = transformation.calculateErrors(inputPoints, outputPoints); // Example returned object: // { rms: 0.5, errorsOut: [0.1, 0.2, 0.3, 0.4, 0.5] }
-
Flips all the
x
coordinates of geometries on the vertical y-axis (right or left) that is centered betweenx0
andx1
. For example, ifx0
is 0 andx1
is 10, all thex
coordinates of the geometries will be flipped, or mirrored, on the vertical axis centered atx = 5
.ParametersExample// Flip the x-coordinates of a geometry on the vertical axis const transform = new Transformation(); transform.flipX(0, 10); const result = affineTransformOperator.execute(polygon, transform); // Flip the x-coordinates of a geometry on the vertical axis centered at the geometry's center const centerX = polygon.extent.center.x; transform.flipX(centerX, centerX); const result = affineTransformOperator.execute(polygon, transform);
-
Flips all the
y
coordinates of geometries on the horizontal x-axis (up or down) that is centered betweeny0
andy1
. For example, ify0
is 0 andy1
is 10, all they
coordinates of the geometries will be flipped, or mirrored, on the horizontal axis centered aty = 5
.ParametersExample// Flip the y-coordinates of a geometry on the vertical axis transformation.flipY(0, 10); const result = affineTransformOperator.execute(polygon, transform); // Flip the y-coordinates of a geometry on the horizontal axis centered at the geometry's center const centerY = polygon.extent.center.y; transform.flipY(centerY, centerY); const result = affineTransformOperator.execute(polygon, transform);
-
Initializes a new transformation from the input and output control points. Uses least squares method to find the best fit transformation. Adding control points allows you to snap lines and polygons to the input and output points on a map.
The length of the
input
andoutput
arrays must be the same.Parameterstype StringThe type of transformation to initialize.
Value Description "conformal" Preserves the angles between curves. "general" Preserves lines and parallelisms. Does not preserve angles or lengths. Possible Values:"conformal"|"general"
The input points to transform from.
The output points to transform to.
inverseOut TransformationoptionalThe transformation instance that is the inverse of the calculated transformation.
Example// Initialize a transformation from control points transformation.initializeFromControlPoints("conformal", inputPoints, outputPoints);
-
isIdentity
isIdentity(){Boolean}
-
Determines if the transformation is in its default state, which is an identity matrix.
ReturnsType Description Boolean Returns true
if the transformation is the default and has not been changed. There will be no change in the geometries when applying the transformation.- See also
-
Rotates the geometries by the specified angle in degrees around the point specified by the x and y coordinates. The point can be the center of the geometries or any other point.
ParametersExample// Rotate a geometry transformation.rotate(90, 0, 0); const result = affineTransformOperator.execute(polygon, transform);
-
Resizes the geometries by the specified scale factors defined by the x and y coordinates. The coordinates define how much scaling is applied to the geometries in the x and y directions.
ParametersExample// Scale a geometry transformation.scale(2, 2); const result = affineTransformOperator.execute(polygon, transform);
-
Use this method to reset the transformation to its default state, which is an identity matrix. This method is useful when reusing the class instance for multiple transformations.
- See also
-
Use this method to swap the x and y coordinate values in the transformation. An example usage is when slicing vertically with the polgonSlicerOperator.findSlicesByArea() method.
-
Shifts a geometry's points by the specified proportion in parallel to the x and y directions, except those points that are along the shear axis, which is a line defined by the x and y coordinates. This transformation preserves lines and parallelisms, however it may distort angles and distances. Applying this transformation will not change a geometry's area.
ParametersExample// Shear a geometry transformation.shear(0.5, 0.5); const result = affineTransformOperator.execute(polygon, transform);
-
Shifts all the coordinates of the geometries by the distance and direction between the specified
x
andy
coordinates and their current location. This operation does not change the size or shape of the geometries.Example// Shift the coordinates of a geometry transformation.shift(5, 2); const result = affineTransformOperator.execute(polygon, transform);
Type Definitions
-
Object returned from the calculateErrors() method.