/usr/share/javascript/proj4/lib/transform.js is in libjs-proj4 2.3.17+ds-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | var D2R = 0.01745329251994329577;
var R2D = 57.29577951308232088;
var PJD_3PARAM = 1;
var PJD_7PARAM = 2;
var datum_transform = require('./datum_transform');
var adjust_axis = require('./adjust_axis');
var proj = require('./Proj');
var toPoint = require('./common/toPoint');
function checkNotWGS(source, dest) {
return ((source.datum.datum_type === PJD_3PARAM || source.datum.datum_type === PJD_7PARAM) && dest.datumCode !== 'WGS84') || ((dest.datum.datum_type === PJD_3PARAM || dest.datum.datum_type === PJD_7PARAM) && source.datumCode !== 'WGS84');
}
module.exports = function transform(source, dest, point) {
var wgs84;
if (Array.isArray(point)) {
point = toPoint(point);
}
// Workaround for datum shifts towgs84, if either source or destination projection is not wgs84
if (source.datum && dest.datum && checkNotWGS(source, dest)) {
wgs84 = new proj('WGS84');
point = transform(source, wgs84, point);
source = wgs84;
}
// DGR, 2010/11/12
if (source.axis !== 'enu') {
point = adjust_axis(source, false, point);
}
// Transform source points to long/lat, if they aren't already.
if (source.projName === 'longlat') {
point = {
x: point.x * D2R,
y: point.y * D2R
};
}
else {
if (source.to_meter) {
point = {
x: point.x * source.to_meter,
y: point.y * source.to_meter
};
}
point = source.inverse(point); // Convert Cartesian to longlat
}
// Adjust for the prime meridian if necessary
if (source.from_greenwich) {
point.x += source.from_greenwich;
}
// Convert datums if needed, and if possible.
point = datum_transform(source.datum, dest.datum, point);
// Adjust for the prime meridian if necessary
if (dest.from_greenwich) {
point = {
x: point.x - dest.grom_greenwich,
y: point.y
};
}
if (dest.projName === 'longlat') {
// convert radians to decimal degrees
point = {
x: point.x * R2D,
y: point.y * R2D
};
} else { // else project
point = dest.forward(point);
if (dest.to_meter) {
point = {
x: point.x / dest.to_meter,
y: point.y / dest.to_meter
};
}
}
// DGR, 2010/11/12
if (dest.axis !== 'enu') {
return adjust_axis(dest, true, point);
}
return point;
};
|