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

Add basic support for WMS layers < 1.3.0, improve bbox handling #5266

Open
wants to merge 26 commits into
base: 3.12.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
4ccf057
Exclude all *.log files
GeoSander Dec 14, 2020
c2bed01
Use (reprojected) initialExtent for zoomToMaxExtent
GeoSander Dec 14, 2020
96bd332
Added missing semicolon
GeoSander Dec 14, 2020
9aef45b
Added new WMS failure message
GeoSander Dec 15, 2020
49b1ccd
Improved alerts for WMS services
GeoSander Dec 15, 2020
ec9a748
Added suppport for WMS services
GeoSander Dec 15, 2020
93a84a7
Added isCustomProj4Def function
GeoSander Dec 15, 2020
b0d7a0b
Improved WMS support, removed unused functions
GeoSander Dec 15, 2020
bf1a3cf
Added Proj4 check for viewer map
GeoSander Dec 15, 2020
cf226bd
Added minimal support for WMS layers prior to version 1.3.0
GeoSander Dec 15, 2020
7334aa8
Removed cextent leftovers
GeoSander Dec 15, 2020
120eb6a
Pass on WMS version when updating layer
GeoSander Dec 17, 2020
f372d4e
Removed console log
GeoSander Dec 18, 2020
78e1ef8
Moved style set out of promise
GeoSander Dec 18, 2020
d4697d6
Loop inside changeLayerProjection, use reverse array to preserve laye…
GeoSander Dec 18, 2020
f5b7d9e
Let OL figure out the WMTS matrixSet based on the projection (name mi…
GeoSander Dec 24, 2020
2bce7e4
Fixed isCustomProj4Def() function (compare Projection properties)
GeoSander Dec 24, 2020
5cd1840
Fixed errors when response data is missing
GeoSander Dec 30, 2020
b1fba1d
Do not use gnViewerSettings.initialExtent: it is useless without an i…
GeoSander Dec 30, 2020
1f6bddd
Improved axis orientation handling for certain projections and WMTS l…
GeoSander Dec 30, 2020
a2a5c09
Improved new extent calculation, added reloadOwsLayer function that a…
GeoSander Dec 30, 2020
7207e26
Remove layer only if promise was successful
GeoSander Jan 5, 2021
136aa39
Removed custom projection functionality
GeoSander Jan 5, 2021
9dd92ae
Improved getWmsLayerExtentFromGetCap function
GeoSander Jan 5, 2021
9588d3a
Removed custom projection functionality, simplified WMS extent handling
GeoSander Jan 5, 2021
32b0d3e
Fixed axis order check
GeoSander Jan 5, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*.iml
*.launch
*.old
*.log
.DS_Store
.project
git*.properties
Expand All @@ -26,7 +27,6 @@ docs/schema-loc-*.rst
eclipse/
es/elasticsearch-*
es/es-dashboards/kibana-*
harvesters/harvester_*.log
idea/
jcs_caching/
node_modules
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@
var EPSG_WEB_MERCATOR = 'EPSG:3857';
var EPSG_REGEX = new RegExp('^EPSG:\\d{4,6}$');

var _cachedDefs = {};

module.provider('gnProjService', function() {
this.$get = ['$http', '$q', '$translate', 'gnUrlUtils',
this.$get = ['$http', '$q', '$translate', 'gnUrlUtils',
function($http, $q, $translate, gnUrlUtils) {

var buildRestUrl = function(searchTerm) {
// Add GET query parameters to serviceUrl
if (searchTerm.toUpperCase().startsWith('EPSG:')) {
Expand All @@ -50,6 +52,17 @@
}));
};

var isDefaultProjection = function(code) {
return code === EPSG_LL_WGS84 || code === EPSG_WEB_MERCATOR;
}

var getCachedDef = function(code) {
if (!(code in proj4.defs) || isDefaultProjection(code)) {
return;
}
return _cachedDefs[code];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to exhaust EPSG.io, so we keep a dictionary of cached Proj4 definitions

}

var parseProjDef = function(data) {

var code = 'EPSG:';
Expand All @@ -76,6 +89,8 @@
if (def) {
proj4.defs(code, firstResult.proj4);
ol.proj.proj4.register(proj4);
// cache definition
_cachedDefs[code] = def;
}

// get bounding box and define defaults
Expand All @@ -90,7 +105,7 @@
}
// transform world extent to projected extent
extent = ol.proj.transformExtent(worldExtent, EPSG_LL_WGS84, code, 8);
}
}

return {
label: firstResult.name,
Expand All @@ -101,27 +116,55 @@
}
};

var getProj4Def = function(code) {
var defer = $q.defer();

var cachedDef = getCachedDef(code);
if (cachedDef) {
// return cached Proj4 definition
defer.resolve(cachedDef);
} else {
var url = buildRestUrl(code);

// send EPSG.io request and decode result
if (true) {
$http.get(url, {
cache: true,
timeout: REQUEST_TIMEOUT
})
.success(function(data) {
try {
console.log("Returning EPSG.io result");
defer.resolve(parseProjDef(data).def);
} catch (e) {
console.error(e);
}
})
}
}

return defer.promise;
};

return {

helpers: {
getServiceName: function() {
// Get API service name without http(s) prefix for display purposes
return {
value: SERVICE_REST_URL.substr(SERVICE_REST_URL.indexOf('://') + 3)
}
}
},

isDefaultProjection: function(code) {
return code === EPSG_LL_WGS84 || code === EPSG_WEB_MERCATOR;
},
isDefaultProjection: isDefaultProjection,

isValidEpsgCode: function(code) {
return code.search(EPSG_REGEX) >= 0;
}
},

getProjectionSettings: function(searchTerm) {
var defer = $q.defer();
var defer = $q.defer();
var url = buildRestUrl(searchTerm);

// send request and decode result
Expand All @@ -140,11 +183,21 @@
})
.error(function(data, status) {
defer.reject(
$translate.instant(
status === 401 ? 'checkProjectionUrlUnauthorized' : 'checkProjectionUrl',
{url: url, status: status}));
$translate.instant(
status === 401 ? 'checkProjectionUrlUnauthorized' : 'checkProjectionUrl',
{url: url, status: status}));
});
}
}
return defer.promise;
},

isCustomProj4Def: function(code) {
var defer = $q.defer();

getProj4Def(code).then(function (result) {
defer.resolve(result !== proj4.defs[code]);
});

return defer.promise;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
goog.provide('gn_ui_config');

goog.require('gn_ui_config_directive');
goog.require('gn_projection_service')
goog.require('gn_projection_service');

angular.module('gn_ui_config', [
'gn_ui_config_directive',
Expand Down
Loading