Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ol.proj.transform when moving from 4.6.5 to 5.3.0 #9199

Closed
andrewteg opened this issue Feb 8, 2019 · 2 comments
Closed

ol.proj.transform when moving from 4.6.5 to 5.3.0 #9199

andrewteg opened this issue Feb 8, 2019 · 2 comments

Comments

@andrewteg
Copy link

andrewteg commented Feb 8, 2019

When ol.proj.transform for a proj4 defined projection I get an error of "of Uncaught TypeError: Cannot read property 'getCode' of null on the transform line." on 5.3.0 but it works fine if I roll back to v4.6.5.

To Reproduce

  1. Go to https://jsfiddle.net/rjapzgfd/
  2. See the transformed coordinate.
  3. Change the ol.js Resource from 4.6.5 to 5.3.0 and re-run.
  4. Get a dev console error of "Uncaught TypeError: Cannot read property 'getCode' of null on the transform line."

Expected behavior
This code should still work in 5.3.0 or have a suitable replacement (which I cannot find in the docs):

proj4.defs("EPSG:2284","+proj=lcc +lat_1=37.96666666666667 +lat_2=36.76666666666667 +lat_0=36.33333333333334 +lon_0=-78.5 +x_0=3500000.0001016 +y_0=999999.9998983998 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=us-ft +no_defs");

var test_coordinate = ol.proj.transform([-79.4460,37.7890], 'EPSG:4326', 'EPSG:2284');
console.log(test_coordinate);
document.getElementById("demo").innerHTML = test_coordinate; //transformed!
@ahocevar
Copy link
Member

ahocevar commented Feb 8, 2019

Please always check the release notes when making a major release upgrade:

Applications can be updated by importing the register function from the ol/proj/proj4 module

import {register} from 'ol/proj/proj4'

and calling it before using projections, and any time the proj4 registry was changed by proj4.defs() calls:

register(proj4);

So you have to call

ol.proj.proj4.register(proj4);

before working with projections.

I have update your fiddle with this change: https://jsfiddle.net/dtyrws39/.

@ahocevar ahocevar closed this as completed Feb 8, 2019
@andrewteg
Copy link
Author

Thanks, sorry to trouble you {goes for caffeine to re-brush up on release notes}!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants