Monday 28 September 2015

coordinate system - Custom CRS in Qgis web - client


Hello I'm abit new here and I hope I'll even set the question right.


Recently I've started to work on a project that will include displaying maps in qgis-web-client. At the moment I've set up the server to display the basic examples. But now I'm trying to import my own qgis project. This specific project has an custom CRS. So far I've discovered on this site that the webclient does support custom CRSs. So without hesitating I've followed the guide and did the steps. The custom CRS file I created was Proj4js.defs["EPSG:4800"] = "+title=nevem +proj=tmerc +lat_0=0.0 +lon_0=15.0 +k=0.9999 +x_0=500000 +y_0=-5000000 +units=m +no_defs";


This CRS was copied from the project in the qgis desktop application. And I edited it so it would match with the other ones. After I run the web-client I get an error from the browser console that this.resolutions is undefined. Also I should mention that the layer names load properly. For the sake of testing I tried using the default CRS just to test my qgis project with it and it loaded the layers, but they were projected incorrectly because of the CRS.


So now the question is: How to make this CRS work with qgis-web-client? And what do the a and b variables mean in:Proj4js.defs["EPSG:3857"]= "+title=WGS 84 / Pseudo Mercator +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs";



Answer



SO I'll start with how to set the CRS in your QGIS-webclient. First of all I got pink tiles over my project if the default background layers can't be projected with your CRS. Thats why I disabled the background layers and the client loaded without pink tiles. You can disable background layers in GlobalOptions.js file


var enableBingCommercialMaps = false;


var enableGoogleCommercialMaps = false;

var enableOSMMaps = false;

Now to the part where you set the CRS. First you should go check if the CRS you need is already in the CRS folder. You can find the definitions in the apache\htdocs\site\libs\proj4js\defs folder. If the CRS doesnt exist like in my case, then you need to make your own. I used the website http://spatialreference.org/ to find the desired CRS and when you do, use the Proj4js link and copy that to your definition in apache\htdocs\site\libs\proj4js\defs folder. After that you need to tell the client what projection to use. Simply change the line:


//EPSG projection code of your QGIS project var authid = "EPSG:"+3787;


After that the client should project with the correct CRS.


PS: If you are using PostGIS as your datasource, there is a possibility your CRS could be missing in the spatial_ref_sys. In that case use the link for PostGIS spatial_ref_sys INSERT statement, to insert your CRS into the table.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...