Broken Projections when using proj4js definitions
See original GitHub issueOpenLayers produces broken projections when using ol 6.4.3 and proj4js 2.6.2 for (at least) geographic CRS.
Adding a new definition in proj via defs
with the official strings (from epsg.io or spatialreference.org) works nicely in proj4js.
But using the register
function of ol.proj.proj4
then creates an invalid projection.
Invalid means that required parameters like units
are undefined and axisOrientation
is set to wrong default values.
Example:
proj4.defs('EPSG:4258', '+proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs');
ol.proj.proj4.register(proj4);
The map display / projection is broken when using this ol.Projection.
Expected behavior When having a proj4js definition which does not have a unit set, the default should be “degrees” instead of undefined. In fact, all EPSG definitions for proj4js are missing the unit for geographic projections and there are only “m”, “ft” and “us-ft”.
Besides, the axisOrientation needs to be configured correctly in order to render a map correctly. The broken definition from above needs to have a ‘neu’ order, but the definition has no axis given and openlayers defaults to ‘enu’. There are only 28 definitions for proj4js out of 3910 which have an axis given (“+axis=wsu”)
Am i doing something totally wrong or is this somehow unusable for geographic projections in the current state?
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (5 by maintainers)
Top GitHub Comments
Very nice! I did not know that proj4js also handles “other” definition strings, this becomes very handy here. And yes i think you are right about assuming degrees for longlat definitions should be ok, i had a look at this collection:
https://github.com/yuletide/node-proj4js-defs/blob/master/epsg.js
and it appears that they all miss the units parameter.
So thanks for the solution and the PR!
@weskamm:
Correct. You can use the official EPSG database API instead, e.g. https://apps.epsg.org/api/v1/CoordRefSystem/4258/export/?format=wkt&formatVersion=1. I just published new versions of
wkt-parser
andproj4js
that support their WKT format.