diff --git a/src/common/addlayers/ServerService.js b/src/common/addlayers/ServerService.js index c8f7437b..47dbf97c 100644 --- a/src/common/addlayers/ServerService.js +++ b/src/common/addlayers/ServerService.js @@ -176,8 +176,9 @@ var SERVER_SERVICE_USE_PROXY = true; }); } for (var index = 0; index < servers.length; index += 1) { - if (servers[index].name.toLocaleLowerCase() === name.toLowerCase()) { - server = servers[index]; + var currentServer = servers[index]; + if (typeof currentServer.name !== 'undefined' && currentServer.name.toLocaleLowerCase() === name.toLowerCase()) { + server = currentServer; break; } } @@ -232,11 +233,13 @@ var SERVER_SERVICE_USE_PROXY = true; url = goog.isDefAndNotNull(server) ? service_.getMostSpecificUrl(server) : url; var currentDomain = locationService_.host(); if (goog.isDefAndNotNull(url)) { - if (url.indexOf(currentDomain) >= 0 && url.indexOf('geoserver') > 0) { + if (url.indexOf(currentDomain) >= 0 && url.indexOf('geoserver/') > 0) { return '/geoserver/wfs'; } else if (url.indexOf(currentDomain) > -1) { wfsurl = location.protocol + '//' + location.host + '/wfsproxy/'; return wfsurl; + } else if (url.indexOf('/ows') > -1) { + return url.replace('ows', 'wfs'); } } wfsurl = url + '/wfs/WfsDispatcher'; @@ -424,6 +427,7 @@ var SERVER_SERVICE_USE_PROXY = true; } } else { server.username = configService_.username; + server.accessToken = configService_.accessToken; server.isLocal = true; if (server.isVirtualService === true) { diff --git a/src/common/configuration/ConfigService.js b/src/common/configuration/ConfigService.js index 70ab0be6..201e50d6 100644 --- a/src/common/configuration/ConfigService.js +++ b/src/common/configuration/ConfigService.js @@ -116,6 +116,7 @@ fileserviceUrlTemplate: '/api/fileservice/view/{}', fileserviceUploadUrl: '/api/fileservice/', registryEnabled: true, + accessToken: null, searchEnabled: true, nominatimSearchEnabled: false, geoquerySearchEnabled: false, @@ -145,6 +146,7 @@ this.user_profile_name = this.configuration.userprofilename; this.user_profile_email = this.configuration.userprofileemail; this.user_name = this.configuration.username; + this.accessToken = this.configuration.accessToken; this.proxy = this.configuration.proxy; this.csrfToken = $cookies.csrftoken; diff --git a/src/common/legend/LegendDirective.js b/src/common/legend/LegendDirective.js index 8b21cc87..60ddff81 100644 --- a/src/common/legend/LegendDirective.js +++ b/src/common/legend/LegendDirective.js @@ -135,7 +135,7 @@ uri.setParameterValue(key, params[key]); } // kick back the URL as a formatted string. - return uri.toString(); + return uri.toString().replace('ows', 'wms'); }; scope.$on('layer-added', function() { diff --git a/src/common/map/MapService.js b/src/common/map/MapService.js index 0e6bce41..c68306ed 100644 --- a/src/common/map/MapService.js +++ b/src/common/map/MapService.js @@ -345,7 +345,6 @@ var pan = ol.animation.pan({source: map.getView().getCenter()}); map.beforeRender(pan, zoom); } - view.fit(extent, map.getSize()); }; @@ -411,19 +410,48 @@ } return deferredResponse.promise; }; - + this.getLayerExtentFromConfig = function(layer) { + var layerMetadata = layer.get('metadata'); + var targetExtent = null; + if (typeof layerMetadata.bbox !== 'undefined' && layerMetadata.bbox) { + try { + targetExtent = layerMetadata.bbox.extent; + var mapProjection = service_.map.getView().getProjection(); + var layerProjection = ol.proj.get(layerMetadata.bbox.crs); + if (layerProjection !== mapProjection) { + var transform = ol.proj.getTransformFromProjections(layerProjection, mapProjection); + targetExtent = ol.extent.applyTransform(targetExtent, transform); + } + } catch (err) { + console.error(err); + console.warn('Cannot layer projection info in metadata fallback to wps'); + } + } + return targetExtent; + }; this.zoomToLayerFeatures = function(layer) { var deferredResponse = q_.defer(); - if (!goog.isDefAndNotNull(layer)) { deferredResponse.resolve(); return deferredResponse.promise; } - + var layerMetadata = layer.get('metadata'); + var configExtent = service_.getLayerExtentFromConfig(layer); + if (configExtent) { + service_.zoomToExtent(configExtent); + deferredResponse.resolve(); + return deferredResponse.promise; + } if (service_.layerIsEditable(layer)) { - var layerTypeName = layer.get('metadata').name; - var url = layer.get('metadata').url + '/wps?version=' + settings.WPSVersion; - + var layerTypeName = layerMetadata.name; + var url = layerMetadata.url + '/wps?version=' + settings.WPSVersion; + var workspace = layerMetadata.workspace; + if (layerTypeName.indexOf(':') > -1) { + var typeNameArr = layerTypeName.split(':'); + if (typeNameArr.length > 0) { + workspace = typeNameArr[0]; + } + } var wpsPostData = '' + '' + '' + '' + + 'xmlns:' + workspace + '="' + layerMetadata.workspaceURL + '">' + '' + '' + '' + @@ -471,10 +499,22 @@ JSON.parse(lower[1], 10), JSON.parse(upper[0], 10), JSON.parse(upper[1], 10)]; - var transform = ol.proj.getTransformFromProjections(ol.proj.get(layer.get('metadata').projection), - ol.proj.get(service_.map.getView().getProjection())); - var extent900913 = ol.extent.applyTransform(bounds, transform); - service_.zoomToExtent(extent900913, null, null, 0.1); + var targetExtent = bounds; + var layerProjectionCode = layerMetadata.projection; + if (layerMetadata.config && layerMetadata.config.crs) { + var configCRS = layerMetadata.config.crs; + if (configCRS.type === 'name') { + layerProjectionCode = configCRS.properties; + } + // TODO: handle config CRS type + } + var mapProjection = service_.map.getView().getProjection(); + var mapProjectionCode = mapProjection.getCode(); + if (layerProjectionCode !== mapProjectionCode) { + var transform = ol.proj.getTransformFromProjections(ol.proj.get(layerProjectionCode), ol.proj.get(mapProjectionCode)); + targetExtent = ol.extent.applyTransform(targetExtent, transform); + } + service_.zoomToExtent(targetExtent, null, null, 0.1); deferredResponse.resolve(); }).error(function(data, status, headers, config) { service_.zoomToLayerExtent(layer); @@ -509,13 +549,13 @@ newExtent[2] -= xDelta; newExtent[3] -= yDelta; } - - // Create transform and project to current map - var transform = ol.proj.getTransformFromProjections(ol.proj.get(layer_crs), - service_.map.getView().getProjection()); - - newExtent = ol.extent.applyTransform(newExtent, transform); - + var mapProjection = service_.map.getView().getProjection(); + var mapProjectionCode = mapProjection.getCode(); + if (layer_crs !== mapProjectionCode) { + // Create transform and project to current map + var transform = ol.proj.getTransformFromProjections(ol.proj.get(layer_crs), service_.map.getView().getProjection()); + newExtent = ol.extent.applyTransform(newExtent, transform); + } return newExtent; }; @@ -1437,9 +1477,14 @@ this.getMapViewParams = function() { var params = { projection: configService_.configuration.map.projection, - maxZoom: 17 + maxZoom: 17, + zoom: configService_.configuration.map.zoom, + maxResolution: configService_.configuration.map.maxResolution, + extent: configService_.configuration.map.maxExtent }; - + // var mapCenter = ol.proj.transform(configService_.configuration.map.center, params.projection, 'EPSG:4326'); + console.log('>>>>>', configService_.configuration); + // console.log(mapCenter); var default_view = { center: configService_.configuration.map.center, zoom: configService_.configuration.map.zoom @@ -1449,14 +1494,14 @@ // unless the map already has one defined. var hash_view = getHashView(getRealWindow().location.hash, default_view); goog.object.extend(params, hash_view); - - if (configService_.configuration.map.projection === 'EPSG:4326') { - params['extent'] = [-180.0000, -90.0000, 180.0000, 90.0000]; - params['minZoom'] = 3; - } else { - params['extent'] = [-20026376.39, -20048966.10, 20026376.39, 20048966.10]; - params['maxResolution'] = 40075016.68557849 / 2048; - } + //NOTE: I don't why we add the following params as hard coded values + // if (configService_.configuration.map.projection === 'EPSG:4326') { + // params['extent'] = [-180.0000, -90.0000, 180.0000, 90.0000]; + // params['minZoom'] = 3; + // } else { + // params['extent'] = [-20026376.39, -20048966.10, 20026376.39, 20048966.10]; + // params['maxResolution'] = 40075016.68557849 / 2048; + // } return params; }; diff --git a/src/common/tableview/TableViewService.js b/src/common/tableview/TableViewService.js index df76c994..fb2019f8 100644 --- a/src/common/tableview/TableViewService.js +++ b/src/common/tableview/TableViewService.js @@ -275,7 +275,7 @@ } var typeName = metadata.name; - if (!typeName.startsWith(metadata.workspace + ':')) { + if (typeName.indexOf(':') === -1) { typeName = metadata.workspace + ':' + metadata.name; } diff --git a/src/common/tableview/partial/tableview.tpl.html b/src/common/tableview/partial/tableview.tpl.html index 72ee6139..ae191e57 100644 --- a/src/common/tableview/partial/tableview.tpl.html +++ b/src/common/tableview/partial/tableview.tpl.html @@ -61,7 +61,7 @@ e-style="width:160px">{{row.feature.properties[attr.name]}} {{row.feature.properties[attr.name]}} -
+ + {{row.feature.properties[attr.name]}} + {{row.feature.properties[attr.name]}} + {{row.feature.properties[attr.name]}}