Skip to content
Permalink
Browse files

Rearrange work with projections to allow setting default projection o…

…f displayed coordinates in settings.js or project.json file
  • Loading branch information...
uprel committed Sep 2, 2019
1 parent b246119 commit 4a1c96caabca19455f868b7ceb08637c24cbd591
@@ -376,9 +376,7 @@ MyViewportUi = Ext.extend(Ext.Viewport, {
//value: projectData.crsComboStore()[0][1],
listeners: {
"select": function(combo, record, index) {
Eqwc.currentMapProjection = projectData.getProjectionsList().filter(function (val) {
return val[0] === record.data.code;
})[0];
Eqwc.currentMapProjection = projectData.getProjectionsList(record.data.code);
}
//"render": function(c) {
// new Ext.ToolTip({
@@ -271,7 +271,7 @@ function getExportWin(layer, geom) {
var crsCombo = formatCombo.cloneConfig({fieldLabel: TR.exportCrs, name: 'crs'});
//set crs values
crsCombo.store.on("load", function () {
crsCombo.setValue(this.data.itemAt(0).data.code);
crsCombo.setValue(Eqwc.currentMapProjection[0]);
});
crsCombo.store.loadData(projectData.crsComboStore());
formatCombo.store.loadData(Eqwc.settings.vectorExportFormats);
@@ -220,23 +220,38 @@ projectData.setLayerLegend = function (layer,node) {
/**
* Array of Projections arrays (0 Code, 1 Title, 2 Openlayers.Projection object) that exist in Proj4js definitions based on crs_list from QGIS project
* Map projection is always first element!
* If parameter code exists, get results only for passed projection, otherwise for all available
*/
projectData.getProjectionsList = function() {
projectData.getProjectionsList = function(code) {
var ret = [];

//first element is map projection
if(Proj4js.defs[projectData.crs]) {
ret.push([projectData.crs, projectData.crs_description, new OpenLayers.Projection(projectData.crs)]);
}
if(code === undefined) {

//first element is map projection
if (Proj4js.defs[projectData.crs]) {
ret.push([projectData.crs, projectData.crs_description, new OpenLayers.Projection(projectData.crs)]);
}

for (var i = 0; i < projectData.crs_list.length; ++i) {
var crs = projectData.crs_list[i];
var olProj = new OpenLayers.Projection(crs);
if (crs != projectData.crs && Proj4js.defs[crs]) {
ret.push([crs, olProj.proj.title, olProj]);
}
}

} else {

for (var i = 0; i < projectData.crs_list.length; ++i) {
var crs = projectData.crs_list[i];
var olProj = new OpenLayers.Projection(crs);
if (crs != projectData.crs && Proj4js.defs[crs]) {
ret.push([crs,olProj.proj.title,olProj]);
var crs = projectData.crs_list.filter(function (val) {
return val === code;
})[0];
if(crs) {
var olProj = new OpenLayers.Projection(crs);
ret.push([crs, olProj.proj.title, olProj]);
}
}
return ret;

return ret.length == 1 ? ret[0] : ret;
};

projectData.crsComboStore = function() {
@@ -648,11 +648,22 @@ function postLoading() {

//set crs values
rightStatusText.store.on("load", function() {
rightStatusText.setValue(this.data.itemAt(0).data.code);

//initial CRS to display coordinates. Take setting if exists or first item crsComboStore which is QGIS project CRS.
var value = this.data.itemAt(0).data.code;
if(projectData.defaultCoordinatesCrsCode) {
var test = projectData.getProjectionsList('EPSG:'+projectData.defaultCoordinatesCrsCode);
if(test.length>0) {
value = test[0];
}
}

rightStatusText.setValue(value);
Eqwc.currentMapProjection = projectData.getProjectionsList(value);
});
rightStatusText.store.loadData(projectData.crsComboStore());

Eqwc.currentMapProjection = [projectData.crs, projectData.crs_description, geoExtMap.map.getProjectionObject()];


if (urlParams.startExtent) {
var startExtentParams = urlParams.startExtent.split(",");
@@ -18,6 +18,9 @@ if(projectData.wsgi === null && projectData.geoCode === null && Eqwc.settings.ws
if(projectData.locationServices === null && Eqwc.settings.locationServices) {
projectData.locationServices = Eqwc.settings.locationServices;
}
if(projectData.defaultCoordinatesCrsCode === null && Eqwc.settings.defaultCoordinatesCrsCode) {
projectData.defaultCoordinatesCrsCode = Eqwc.settings.defaultCoordinatesCrsCode;
}

Eqwc.common = {};

@@ -30,6 +30,9 @@
if (!property_exists($settings, "locationServices")) {
$settings->locationServices = null;
}
if (!property_exists($settings, "defaultCoordinatesCrsCode")) {
$settings->defaultCoordinatesCrsCode = null;
}
if (!property_exists($settings, "editor")) {
$settings->editor = null;
}
@@ -67,6 +70,7 @@
projectData.geoCode = eval(<?php echo json_encode($settings->geoCode) ?>);
projectData.wsgi = eval(<?php echo json_encode($settings->wsgi) ?>);
projectData.locationServices = eval(<?php echo json_encode($settings->locationServices) ?>);
projectData.defaultCoordinatesCrsCode = eval(<?php echo json_encode($settings->defaultCoordinatesCrsCode) ?>);
projectData.editor = eval(<?php echo json_encode($settings->editor) ?>);

projectData.geolocation = <?php echo json_encode($data->geolocation) ?>;
@@ -22,6 +22,7 @@ Eqwc.settings.featureInfoTolerances = {
};
Eqwc.settings.enableHoverPopup = false;
Eqwc.settings.defaultIdentificationMode = "allLayers";
Eqwc.settings.defaultCoordinatesCrsCode = null;
Eqwc.settings.showCoordinatesIdentify = true;
Eqwc.settings.replaceIdentifyLayerWithView = [];
Eqwc.settings.QgisUsersPrintName = "users_print_view";

0 comments on commit 4a1c96c

Please sign in to comment.
You can’t perform that action at this time.