Skip to content
Permalink
Browse files

Fix adding of WMS in ows panel

fixes #211
  • Loading branch information...
raitisbe committed Jun 25, 2019
1 parent 8ecf9d7 commit 4cb7525ee020f7e873e22f0e9e02567efc22d229
@@ -12,7 +12,7 @@ export default {
* @name hs.compositions
* @description Composition module
*/
angular.module('hs.compositions')
angular.module('hs.compositions', ['hs.compositions.config_parsers'])
/**
* @module hs.compositions
* @name hs.compositions.service_parser
@@ -3,7 +3,7 @@ import VectorLayer from 'ol/layer/Vector';
import {Vector} from 'ol/source';
import {transform, transformExtent} from 'ol/proj';
import Feature from 'ol/Feature';
import {Polygon} from 'ol/geom';
import {fromExtent as polygonFromExtent} from 'ol/geom/Polygon';

/**
* @namespace hs.datasource_selector
@@ -265,30 +265,27 @@ angular.module('hs.datasource_selector', ['hs.map', 'hs.ows.wms', 'hs.ows.nonwms
ds.canceler = $q.defer();
$http.get(url, { timeout: ds.canceler.promise }).then(
function (j) {
$("map serviceType value", j).each(function () {
var oParser = new DOMParser();
var oDOM = oParser.parseFromString(j.data, "application/xml");
var doc = oDOM.documentElement;
doc.querySelectorAll("map serviceType value").forEach(function (type) {
ds.code_lists.serviceType.push({
value: $(this).attr('name'),
name: $(this).html()
value: type.attributes.name.value,
name: type.innerHTML
});
})
$("map applicationType value", j).each(function () {
ds.code_lists.applicationType.push({
value: $(this).attr('name'),
name: $(this).html()
});
})
$("map applicationType value", j).each(function () {
});
doc.querySelectorAll("map applicationType value").forEach(function (type) {
ds.code_lists.applicationType.push({
value: $(this).attr('name'),
name: $(this).html()
value: type.attributes.name.value,
name: type.innerHTML
});
})
$("map topicCategory value", j).each(function () {
});
doc.querySelectorAll("map topicCategory value").forEach(function (type) {
ds.code_lists.topicCategory.push({
value: $(this).attr('name'),
name: $(this).html()
value: type.attributes.name.value,
name: type.innerHTML
});
})
});
me.advancedMickaTypeChanged();
}, function (err) { }
);
@@ -440,7 +437,7 @@ angular.module('hs.datasource_selector', ['hs.map', 'hs.ows.wms', 'hs.ows.nonwms
if (!isFinite(second_pair[1])) second_pair[1] = mapProjectionExtent[3];
if (isNaN(first_pair[0]) || isNaN(first_pair[1]) || isNaN(second_pair[0]) || isNaN(second_pair[1])) return;
var extent = [first_pair[0], first_pair[1], second_pair[0], second_pair[1]];
attributes.geometry = Polygon.fromExtent(extent);
attributes.geometry = polygonFromExtent(extent);
var new_feature = new Feature(attributes);
record.feature = new_feature;
extentLayer.getSource().addFeatures([new_feature]);
@@ -564,16 +561,16 @@ angular.module('hs.datasource_selector', ['hs.map', 'hs.ows.wms', 'hs.ows.nonwms
OlMap.map.on('pointermove', function (evt) {
var features = extentLayer.getSource().getFeaturesAtCoordinate(evt.coordinate);
var something_done = false;
angular.forEach(extentLayer.getSource().getFeatures(), function () {
if (this.get("record").highlighted) {
this.get("record").highlighted = false;
angular.forEach(extentLayer.getSource().getFeatures(), function (feature) {
if (feature.get("record").highlighted) {
feature.get("record").highlighted = false;
something_done = true;
}
});
if (features.length) {
$(features).each(function () {
if (!this.get("record").highlighted) {
this.get("record").highlighted = true;
angular.forEach(features, function (feature) {
if (!feature.get("record").highlighted) {
feature.get("record").highlighted = true;
something_done = true;
}
})
@@ -18,6 +18,83 @@ define(['angular', 'map', 'ows_wms', 'ows_wmts', 'ows_wfs', 'ows_nonwms', 'perma
template: require('components/ows/partials/ows.html')
};
}])
/**
* @memberof hs.ows
* @ngdoc directive
* @name hs.ows.wms
* @description Directive for configurating wms layer to add
*/
.directive('hs.ows.wms', ['config', function(config) {
return {
template: config.design == 'md' ? require('components/ows/partials/owswmsmd.html') : require('components/ows/partials/owswms.html')
};
}])

/**
* @memberof hs.ows
* @ngdoc directive
* @name hs.ows.wfs
* @description Directive for configurating wfs layer to add
*/
.directive('hs.ows.wfs', ['config', function(config) {
return {
template: config.design == 'md' ? require('components/ows/partials/owswfsmd.html') : require('components/ows/partials/owswfs.html')
};
}])

/**
* @memberof hs.ows
* @ngdoc directive
* @name hs.ows.wmts
* @description Directive for configurating wmts layer to add
*/
.directive('hs.ows.wmts', ['config', function(config) {
return {
template: require('components/ows/partials/owswms.html')
};
}])

/**
* @memberof hs.ows
* @ngdoc directive
* @name hs.ows.nonwms
* @description TODO
*/
.directive('hs.ows.nonwms', ['config', function(config) {
return {
template: require('components/ows/partials/owsnonwms.html')
};
}])

/**
* @memberof hs.ows
* @ngdoc directive
* @name compile
* @description Directive which compiles a template and includes it in the dome.
* Previously done with ng-bind-html which escaped varaiables and child directives
*/
.directive('compile', ['$compile', function ($compile) {
return function(scope, element, attrs) {
scope.$watch(
function(scope) {
// watch the 'compile' expression for changes
return scope.$eval(attrs.compile);
},
function(value) {
// when the 'compile' expression changes
// assign it into the current DOM
element.html(value);

// compile the new DOM and link it to the current
// scope.
// NOTE: we only compile .childNodes so that
// we don't get into infinite loop compiling ourselves
$compile(element.contents())(scope);
}
);
};
}])

/**
* @memberof hs.ows
* @ngdoc controller
@@ -83,25 +160,22 @@ define(['angular', 'map', 'ows_wms', 'ows_wmts', 'ows_wfs', 'ows_nonwms', 'perma
/**TODO: move variables out of this function. Call $scope.connected = false when template change */
$scope.templateByType = function() {
var template;
var ows_path = config.hsl_path + 'components/ows/partials/';
switch ($scope.type.toLowerCase()) {
case "wms":
template = `${ows_path}owswms${config.design || ''}.html`;
template = '<div hs.ows.wms></div>';
break;
case "wmts":
template = `${ows_path}owswmts${config.design || ''}.html`;
template = '<div hs.ows.wmts></div>';
break;
case "wms with priorities":
template = `${ows_path}owsprioritized${config.design || ''}.html`;
template = require(`${ows_path}owsprioritized${config.design || ''}.html`);
break;
case "wfs":
if (window.allowWFS2) {
template = `${ows_path}owswfs${config.design || ''}.html`;
}
template = '<div hs.ows.wfs></div>';
break;
case "kml":
case "geojson":
template = `${ows_path}owsnonwms${config.design || ''}.html`;
template = '<div hs.ows.nonwms></div>';
$scope.showDetails = true;
break;
default:
@@ -185,7 +259,7 @@ define(['angular', 'map', 'ows_wms', 'ows_wmts', 'ows_wfs', 'ows_nonwms', 'perma
$scope.$emit('scope_loaded', "Ows");
}
]);
if (window.allowWFS2) {
if (window.allowWFS2) {//TODO should not use global variables
ows.requires.push('hs.ows.wfs');
}
})

0 comments on commit 4cb7525

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