3liz / lizmap-web-client

Transfer a QGIS project on a server, Lizmap is providing the web interface to browse it
https://www.lizmap.com
Mozilla Public License 2.0
260 stars 143 forks source link

[Bug]: Our custom CRS is not properly added. #3941

Open WouterVermeyenSBE opened 1 year ago

WouterVermeyenSBE commented 1 year ago

What is the bug?

We tried adding the EPSG:31370 to Lizmap, but we keep ending up with not the specific version we need.

Specifically the version with the extra correction : +proj=lcc +lat_1=51.16666723333334 +lat_2=49.83333389999999 +lat_0=90 +lon_0=4.367486666666666 +x_0=150000.013 +y_0=5400088.438 +ellps=intl +units=m +no_defs

Not the standard QGIS version: +proj=lcc +lat_1=51.16666723333334 +lat_2=49.83333389999999 +lat_0=90 +lon_0=4.367486666666666 +x_0=150000.013 +y_0=5400088.438 +ellps=intl +towgs84=-99.1,53.3,-112.5,0.419,-0.83,1.885,-1.0 +units=m +no_defs

In order to facilitate this we looked at 4 things the proj4 def on 4 spots

We added a EPSG31370.php file to /var/www/lizmap-web-client-3.6.7/lizmap/vendor/proj4php/proj4php/src/proj4php/defs

<?php
Proj4php::$defs["EPSG:31370"] = "+proj=lcc +lat_1=51.16666723333334 +lat_2=49.83333389999999 +lat_0=90 +lon_0=4.367486666666666 +x_0=150000.013 +y_0=5400088.438 +ellps=intl +towgs84=-99.1,53.3,-112.5,0.419,-0.83,1.885,-1.0 +units=m +no_defs";

We added a EPSG31370.js file to /var/www/lizmap-web-client-3.6.7/lizmap/www/assets/js/Proj4js/defs

Proj4js.defs["EPSG:31370"] = "+proj=lcc +lat_1=51.16666723333334 +lat_2=49.83333389999999 +lat_0=90 +lon_0=4.367486666666666 +x_0=150000.013 +y_0=5400088.438 +ellps=intl +towgs84=-99.1,53.3,-112.5,0.419,-0.83,1.885,-1.0 +units=m +no_defs"

We checked the value in the qgs project proj4 tag

      <proj4>+proj=lcc +lat_1=51.16666723333334 +lat_2=49.83333389999999 +lat_0=90 +lon_0=4.367486666666666 +x_0=150000.013 +y_0=5400088.438 +ellps=intl +towgs84=-99.1,53.3,-112.5,0.419,-0.83,1.885,-1.0 +units=m +no_defs</proj4>
      <srsid>2640</srsid>
      <srid>31370</srid>

We checked the value in the cfg file "projection": {"proj4": "+proj=lcc +lat_1=51.16666723333334 +lat_2=49.83333389999999 +lat_0=90 +lon_0=4.367486666666666 +x_0=150000.013 +y_0=5400088.438 +ellps=intl +towgs84=-99.1,53.3,-112.5,0.419,-0.83,1.885,-1.0 +units=m +no_defs", "ref": "EPSG:31370"}

We still end up with the following when we load the webpages and we end with the CRS with out the +towgs84=-99.1,53.3,-112.5,0.419,-0.83,1.885,-1.0 part.

image

We have a workaround but we can't figure out where the wrong crs proj4 is coming from.

Workaround JS script:

lizMap.events.on({
   uicreated: function(e) {
      Proj4js.defs["EPSG:31370"] = "+proj=lcc +lat_1=51.16666723333334 +lat_2=49.83333389999999 +lat_0=90 +lon_0=4.367486666666666 +x_0=150000.013 +y_0=5400088.438 +ellps=intl +towgs84=-99.1,53.3,-112.5,0.419,-0.83,1.885,-1.0 +units=m +no_defs";
      Proj4js.defs["EPSG:28992"] = "+proj=sterea +lat_0=52.15616055555555 +lon_0=5.38763888888889 +k=0.9999079 +x_0=155000 +y_0=463000 +ellps=bessel +units=m +no_defs";

      console.log(Proj4js.defs)
      }
   }
);

Steps to reproduce the issue

1) Add the custom epsg files. 2) Load the Lizmap project 3) Open de dev tools and in console type: Proj4js.defs

image

Versions

Versions :

Check Lizmap plugin

QGIS server version, only if the section above doesn't mention the QGIS Server version

No response

Operating system

Ubuntu 20.04.2

Browsers

Firefox, Chrome, Microsoft Edge

Browsers version

Firefox Version 119.0

Relevant log output

No response

nboisteault commented 11 months ago

@rldhont @mdouchin what is the proper way to define a custom projection for Lizmap?

rldhont commented 11 months ago

@WouterVermeyenSBE Lizmap is getting projection definition from within the QGIS project file.

WouterVermeyenSBE commented 11 months ago

@rldhont But we still ended up without the +towgs84=-99.1,53.3,-112.5,0.419,-0.83,1.885,-1.0 parameter on in the proj4js of lizmap. Can there be a bug there?

Gustry commented 11 months ago

So you mean even if both your QGS and QGS.CFG files have the correct definition you would like to use, in the web interface, one part is missing ?

WouterVermeyenSBE commented 11 months ago

Yes, I posted the screenshot of the Proj4js defs after we uploaded the correct string everywhere.