transform method
Implementation
Point transform(Projection dest, Point point) {
var source = this;
point = Point.copy(point); // make sure we don't mutate incoming point
var shouldRemoveZ = point.z == null;
utils.checkSanity(point);
// Workaround for datum shifts towgs84, if either source or destination projection is not wgs84
if (/*source.datum != null &&
dest.datum != null &&*/
_checkNotWGS(source, dest)) {
var wgs84 = WGS84;
point = source.transform(wgs84, point);
source = wgs84;
}
// DGR, 2010/11/12
if (source.axis != 'enu') {
point = utils.adjust_axis(source, false, point);
}
// Transform source points to long/lat, if they aren't already.
if (source.projName == 'longlat') {
point = Point.withZ(
x: point.x * consts.D2R,
y: point.y * consts.D2R,
z: point.z ?? 0,
);
} else {
if (source.to_meter != null) {
point = Point.withZ(
x: point.x * source.to_meter!,
y: point.y * source.to_meter!,
z: point.z ?? 0.0);
}
point = source.inverse(point); // Convert Cartesian to longlat
}
if (source.from_greenwich != null) {
point.x += source.from_greenwich!;
}
// Convert datums if needed, and if possible.
point = dt.transform(source.datum, dest.datum, point);
// Adjust for the prime meridian if necessary
if (dest.from_greenwich != null) {
point = Point.withZ(
x: point.x - dest.from_greenwich!,
y: point.y,
z: point.z ?? 0.0,
);
}
if (dest.projName == 'longlat') {
// convert radians to decimal degrees
point = Point.withZ(
x: point.x * consts.R2D,
y: point.y * consts.R2D,
z: point.z ?? 0.0,
);
} else {
// else project
point = dest.forward(point);
if (dest.to_meter != null) {
point = Point.withZ(
x: point.x / dest.to_meter!,
y: point.y / dest.to_meter!,
z: point.z ?? 0.0);
}
}
// DGR, 2010/11/12
if (dest.axis != 'enu') {
point = utils.adjust_axis(dest, true, point);
}
if (shouldRemoveZ) {
point.z = null;
point.m = null;
return point;
} else {
return point;
}
}