From 114b144ee09ddb3aa8f27c335fc2d61982ff1041 Mon Sep 17 00:00:00 2001 From: David Manthey Date: Thu, 7 Jun 2018 13:03:22 -0400 Subject: [PATCH] Proj4 doesn't include some projections by default. Include them. --- examples/reprojection/main.js | 4 ++-- src/transform.js | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/examples/reprojection/main.js b/examples/reprojection/main.js index ebe82c5c9d..22811ee7ee 100644 --- a/examples/reprojection/main.js +++ b/examples/reprojection/main.js @@ -114,7 +114,7 @@ $(function () { node: '#map', center: {x: 0, y: 0}, zoom: 2.5, - gcs: gcsTable[gcs], + gcs: gcsTable[gcs] || gcs, unitsPerPixel: (range[1].x - range[0].x) / 256, clampBoundsX: false, clampBoundsY: false, @@ -131,7 +131,7 @@ $(function () { gcs: 'EPSG:3857', attribution: $('#url-list [value="' + $('#layer-url').val() + '"]').attr( 'credit'), - minLevel: 4, + minLevel: query.minLevel ? parseInt(query.minLevel, 10) : 4, keepLower: true, wrapX: false, wrapY: false diff --git a/src/transform.js b/src/transform.js index ed44620072..38fa271540 100644 --- a/src/transform.js +++ b/src/transform.js @@ -1,4 +1,9 @@ var proj4 = require('proj4'); +/* These projections exist in proj4 but aren't included by default. */ +proj4.Proj.projections.add(require('proj4/projections/equi')); +proj4.Proj.projections.add(require('proj4/projections/gauss')); +proj4.Proj.projections.add(require('proj4/projections/gstmerc')); +proj4.Proj.projections.add(require('proj4/projections/ortho')); var util = require('./util'); /** @@ -614,4 +619,7 @@ transform.vincentyDistance = function (pt1, pt2, gcs, baseGcs, ellipsoid, maxIte }; }; +/* Expose proj4 to make it easier to debug */ +transform.proj4 = proj4; + module.exports = transform;