How to use the proj4.transform function in proj4

To help you get started, we’ve selected a few proj4 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github OpenGeoscience / geojs / src / transform.js View on Github external
tmatch = tgtPrj.match(axisPattern);
  // if the two projections only differ in the middle axis
  if (smatch && tmatch && smatch[1] === tmatch[1] && smatch[3] === tmatch[3]) {
    for (i = coordinates.length - 3 + 1; i >= 0; i -= 3) {
      coordinates[i] *= -1;
    }
    return coordinates;
  }
  var src = proj4.Proj(srcPrj),
      tgt = proj4.Proj(tgtPrj),
      projPoint, initPoint = {};
  for (i = coordinates.length - 3; i >= 0; i -= 3) {
    initPoint.x = +coordinates[i];
    initPoint.y = +coordinates[i + 1];
    initPoint.z = +(coordinates[i + 2] || 0.0);
    projPoint = proj4.transform(src, tgt, initPoint);
    coordinates[i] = projPoint.x;
    coordinates[i + 1] = projPoint.y;
    coordinates[i + 2] = projPoint.z === undefined ? initPoint.z : projPoint.z;
  }
  return coordinates;
};
github sentinel-hub / SentinelPlayground / src / utils / coords.js View on Github external
export function wgs84ToMercator(point) {
  var sourceCRS = proj4.Proj('EPSG:4326');
  var destCRS = proj4.Proj('EPSG:3857');
  var pt = new proj4.toPoint([point[1], point[0]]);
  proj4.transform(sourceCRS, destCRS, pt);
  return pt;
}
export function calcBboxFromXY(point, zoomLevel) {

proj4

Proj4js is a JavaScript library to transform point coordinates from one coordinate system to another, including datum transformations.

MIT
Latest version published 1 month ago

Package Health Score

86 / 100
Full package analysis

Similar packages