[Mapbender-commits] r10116 - in trunk/mapbender: http/javascripts http/plugins lib tools
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Wed May 8 07:44:04 PDT 2019
Author: armin11
Date: 2019-05-08 07:44:04 -0700 (Wed, 08 May 2019)
New Revision: 10116
Modified:
trunk/mapbender/http/javascripts/mod_featureInfo.php
trunk/mapbender/http/plugins/kmlTree.php
trunk/mapbender/http/plugins/mb_digitize_widget.php
trunk/mapbender/lib/mb.ui.displayKmlFeatures.js
trunk/mapbender/tools/mod_runScheduler.php
Log:
Rewind revs 10112 and 10113 - til error fixed.
Modified: trunk/mapbender/http/javascripts/mod_featureInfo.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_featureInfo.php 2019-05-03 09:05:46 UTC (rev 10115)
+++ trunk/mapbender/http/javascripts/mod_featureInfo.php 2019-05-08 14:44:04 UTC (rev 10116)
@@ -21,8 +21,6 @@
include '../include/dyn_js.php';
//defaults for element vars
?>
-// <script>
-
var ignoreWms = typeof ignoreWms === "undefined" ? [] : ignoreWms;
if(typeof(featureInfoLayerPopup)==='undefined')
@@ -33,18 +31,15 @@
var featureInfoPopupWidth = '270';
if(typeof(featureInfoPopupPosition)==='undefined')
var featureInfoPopupPosition = 'center';
-if(typeof(reverseInfo)==='undefined' || reverseInfo === 'false')
- var reverseInfo = false;
-if(typeof(featureInfoLayerPreselect)==='undefined' || featureInfoLayerPreselect === 'false')
+var reverseInfo = typeof reverseInfo === "undefined" ? "false" : reverseInfo;
+if(typeof(featureInfoLayerPreselect)==='undefined' || featureInfoLayerPreselect == 'false')
var featureInfoLayerPreselect = false;
if(typeof(featureInfoDrawClick)==='undefined')
var featureInfoDrawClick = false;
if(typeof(featureInfoCircleColor)==='undefined')
var featureInfoCircleColor = '#ff0000';
-if(typeof(featureInfoCollectLayers)==='undefined' || featureInfoCollectLayers === 'false')
+if(typeof(featureInfoCollectLayers)==='undefined' || featureInfoCollectLayers == 'false')
var featureInfoCollectLayers = false;
-if (typeof(featureInfoShowKmlTreeInfo) === 'undefined' || featureInfoShowKmlTreeInfo === 'false')
- var featureInfoShowKmlTreeInfo = false;
var mod_featureInfo_elName = "<?php echo $e_id;?>";
var mod_featureInfo_frameName = "";
@@ -131,158 +126,8 @@
.css("cursor", "default");
}
}
-
-function makeDialog($content, title, dialogPosition, offset) {
- dialogPosition = dialogPosition || featureInfoPopupPosition;
- if(featureInfoPopupPosition.length === 2 && !isNaN(featureInfoPopupPosition[0]) && !isNaN(featureInfoPopupPosition[1])) {
- offset = offset || 0;
- var dialogPosition = [];
- dialogPosition[0] = featureInfoPopupPosition[0] + offset;
- dialogPosition[1] = featureInfoPopupPosition[1] + offset;
- }
- return $content.dialog({
- bgiframe: true,
- autoOpen: true,
- modal: false,
- title: title,
- width: parseInt(featureInfoPopupWidth, 10),
- height: parseInt(featureInfoPopupHeight, 10),
- position: dialogPosition,
- buttons: {
- "Ok": function() {
- if (standingHighlightFeatureInfo !== null) {
- standingHighlightFeatureInfo.clean();
- }
- $(this).dialog('close').remove();
- }
- }
- }).parent().css({ position:"fixed" });
-}
-
-function featureInfoDialog(request, dialogPosition, offset) {
- var title = "<?php echo _mb("Information");?>";
- var $iframe = $("<iframe>")
- .attr("frameborder", 0)
- .attr("height", "100%")
- .attr("width", "100%")
- .attr("id", "featureInfo")
- .attr("title", title)
- .attr("src", request)
- return makeDialog($("<div>").append($iframe), title, dialogPosition, offset);
-}
-
-function ownDataDialog(ownData, dialogPosition, offset) {
- var $box = $('<div>').html(ownData.content);
- return makeDialog($box,
- "<?php echo _mb("Information");?>", dialogPosition, offset);
-}
-
-function featureInfoWindow(request) {
- return window.open(request, "" , "width="+featureInfoPopupWidth+",height="+featureInfoPopupHeight+",scrollbars=yes,resizable=yes");
-}
-
-function ownDataWindow(ownData) {
- var w = featureInfoWindow("");
- var $body = $(w.document.body);
- $body.html(ownData.content);
-}
-
-function makeListLine(url, title, legendurls, onclick) {
- var $row = $("<tr>");
- var $title = $("<td>")
- .attr("valign", "top")
- .appendTo($row);
- var $link = $("<a>")
- .css("text-decoration", "underline")
- .attr("href", url)
- .attr("target", "_blank")
- .html(title)
- .appendTo($title);
- if (onclick) {
- $link.bind('click', onclick);
- }
- var $legend = $("<td>")
- .appendTo($row);
- if (legendurls.length === 0) {
- legendurls = [""];
- }
- legendurls.forEach(function (legendurl) {
- $("<img>")
- .attr("src", legendurl)
- .attr("alt", "<?php echo _mb("No legend available");?>")
- .appendTo($legend);
- $("<br/>")
- .appendTo($legend);
- });
-
- return $row;
-}
-
-function makeFeatureInfoListLine(url, title, legendurls) {
- return makeListLine(url, title, legendurls)
-}
-
-function makeOwnDataListLine(ownData) {
- return makeListLine("#", ownData.title, [], function (e) {
- ownDataWindow(ownData)
- e.preventDefault();
- });
-}
-
-function featureInfoListDialog(urls, ownDataInfos) {
- var $featureInfoList = $("<table>")
- .attr("border", 1);
-
- if (reverseInfo) {
- urls.reverse();
- ownDataInfos.reverse();
-
- ownDataInfos.forEach(function (ownDataInfo) {
- $featureInfoList.append(makeOwnDataListLine(ownDataInfo));
- });
- }
-
- for(var i=0; i < urls.length; i++){
- var $line;
- if (featureInfoCollectLayers) {
- $line = makeFeatureInfoListLine(urls[i].request, urls[i].title, urls[i].legendurl.split(","));
- } else {
- if (urls[i].inBbox) {
- if (urls[i].legendurl !== "empty" ) {
- $line = makeFeatureInfoListLine(urls[i].request, urls[i].title, [urls[i].legendurl]);
- } else {
- $line = makeFeatureInfoListLine(urls[i].request, urls[i].title, [""]);
- }
- }
- }
- if ($line) {
- $featureInfoList.append($line);
- }
- }
-
- if (!reverseInfo) {
- ownDataInfos.forEach(function (ownDataInfo) {
- $featureInfoList.append(makeOwnDataListLine(ownDataInfo));
- });
- }
-
- makeDialog($("<div id='featureInfo_preselect'></div>").append($featureInfoList),
- "<?php echo _mb("Please choose a requestable Layer");?>");
-}
-
function mod_featureInfo_event(e){
- var urls;
var point = mod_featureInfo_mapObj.getMousePosition(e);
- //calculate realworld position
- var realWorldPoint = Mapbender.modules[options.target].convertPixelToReal(point);
- var ownDataInfos = [];
- if (featureInfoShowKmlTreeInfo) {
- if (Mapbender.modules.kmlTree === undefined) {
- console.error('kmltree module is needed if element_var \'featureInfoShowKmlTreeInfo\' is set to true')
- }
- var kmlTree = Mapbender.modules.kmlTree;
- ownDataInfos = kmlTree.getFeatureInfos(e);
- }
if (featureInfoDrawClick) {
var map = Mapbender.modules[options.target];
if(standingHighlightFeatureInfo !== null){
@@ -294,24 +139,24 @@
{"position":"absolute", "top":"0px", "left":"0px", "z-index":100},
2);
}
+ //calculate realworld position
+ realWorldPoint = Mapbender.modules[options.target].convertPixelToReal(point);
//get coordinates from point
var ga = new GeometryArray();
//TODO set current epsg!
ga.importPoint({
coordinates:[realWorldPoint.x,realWorldPoint.y,null]
- }, Mapbender.modules[options.target].getSRS())
+ },Mapbender.modules[options.target].getSRS())
var m = ga.get(-1,-1);
standingHighlightFeatureInfo.add(m, featureInfoCircleColor);
standingHighlightFeatureInfo.paint();
map.setMapRequest();
}
- eventBeforeFeatureInfo.trigger({ "fName": mod_featureInfo_target });
+ eventBeforeFeatureInfo.trigger({"fName":mod_featureInfo_target});
+ //TODO that code should go to featureInfo Redirect module
if(document.getElementById("FeatureInfoRedirect")){
- //TODO this code should go to featureInfo Redirect module
- //FIXME this does not work for multiple urls
- //FIXME this does not work for kmlTree
//fill the frames
- for(var i=0; i < mod_featureInfo_mapObj.wms.length; i++){
+ for(var i=0; i<mod_featureInfo_mapObj.wms.length; i++){
var req = mod_featureInfo_mapObj.wms[i].getFeatureInfoRequest(mod_featureInfo_mapObj, point);
if(req)
window.frames.FeatureInfoRedirect.document.getElementById(mod_featureInfo_mapObj.wms[i].wms_id).src = req;
@@ -322,64 +167,139 @@
if (featureInfoLayerPreselect) {
$("#featureInfo_preselect").remove();
//build list of possible featureInfo requests
- urls = mod_featureInfo_mapObj.getFeatureInfoRequestsForLayers(point, ignoreWms, Mapbender.modules[options.target].getSRS(), realWorldPoint, featureInfoCollectLayers) || [];
- var length = urls.length + ownDataInfos.length;
- if (length === 0) {
+ urls = mod_featureInfo_mapObj.getFeatureInfoRequestsForLayers(point, ignoreWms, Mapbender.modules[options.target].getSRS(), realWorldPoint, featureInfoCollectLayers);
+ if (urls.length == 0 || typeof urls.length =='undefined') {
alert("<?php echo _mb("Please enable some layer to be requestable");?>!");
return false;
}
- if (length === 1) {
+ if (urls.length == 1) {
//don't show interims window!
//open featureInfo directly
- if (featureInfoLayerPopup){
- if (urls.length === 1) {
- featureInfoDialog(urls[0].request);
- } else {
- ownDataDialog(ownDataInfos[0]);
- }
+ if(featureInfoLayerPopup == 'true'){
+ $("<div><iframe frameborder='0' height='100%' width='100%' id='featureInfo' title='<?php echo _mb("Information");?>' src='" + urls[0].request + "'></iframe></div>").dialog({
+ bgiframe: true,
+ autoOpen: true,
+ modal: false,
+ title: '<?php echo _mb("Information");?>',
+ width:parseInt(featureInfoPopupWidth, 10),
+ height:parseInt(featureInfoPopupHeight, 10),
+ position:dialogPosition,
+ buttons: {
+ "Ok": function(){
+ $(this).dialog('close').remove();
+ }
+ }
+ }).parent().css({position:"fixed"});
return false;
} else {
- if (urls.length === 1) {
- featureInfoWindow(urls[0].request);
- } else {
- ownDataWindow(ownDataInfos[0]);
- }
+ window.open(urls[0].request, "" , "width="+featureInfoPopupWidth+",height="+featureInfoPopupHeight+",scrollbars=yes,resizable=yes");
return false;
}
}
- featureInfoListDialog(urls, ownDataInfos);
+ featureInfoList = "<table border='1'>";
+ if (reverseInfo == "true") {
+ for(var i=0;i<urls.length;i++){
+ if (featureInfoCollectLayers) {
+ featureInfoList += "<tr><td valign='top'><a style='text-decoration: underline' href='"+urls[i].request+"' target='_blank'>"+urls[i].title+"</a></td><td>";
+ //get legend urls if available
+ var legend = urls[i].legendurl.split(",");
+ for(var k=0;k<legend.length;k++){
+ featureInfoList +="<img src='"+legend[k]+"' alt='<?php echo _mb("No legend available");?>!'/><br>";
+ }
+ featureInfoList += "</td></tr>";
+ } else {
+ if (urls[i].inBbox) {
+ if (urls[i].legendurl !== "empty" ) {
+ featureInfoList += "<tr><td valign='top'><a style='text-decoration: underline' href='"+urls[i].request+"' target='_blank'>"+urls[i].title+"</a></td><td><img src='"+urls[i].legendurl+"' alt='<?php echo _mb("No legend available");?>!'/></td></tr>";
+ } else {
+ featureInfoList += "<tr><td valign='top'><a style='text-decoration: underline' href='"+urls[i].request+"' target='_blank'>"+urls[i].title+"</a></td><td><img src='' alt='<?php echo _mb("No legend available");?>!'/></td></tr>";
+ }
+ }
+
+ }
+ }
+ } else {
+ for(var i=urls.length-1; i>=0; i--){
+ if (featureInfoCollectLayers) {
+ featureInfoList += "<tr><td valign='top'><a style='text-decoration: underline' href='"+urls[i].request+"' target='_blank'>"+urls[i].title+"</a></td><td>";
+ //get legend urls if available
+ var legend = urls[i].legendurl.split(",");
+ for(var k=0;k<legend.length;k++){
+ featureInfoList +="<img src='"+legend[k]+"' alt='<?php echo _mb("No legend available");?>!'/><br>";
+ }
+ featureInfoList += "</td></tr>";
+ } else {
+ if (urls[i].inBbox) {
+ if (urls[i].legendurl !== "empty" ) {
+ featureInfoList += "<tr><td valign='top'><a style='text-decoration: underline' href='"+urls[i].request+"' target='_blank'>"+urls[i].title+"</a></td><td><img src='"+urls[i].legendurl+"' alt='<?php echo _mb("No legend available");?>!'/></td></tr>";
+ } else {
+ featureInfoList += "<tr><td valign='top'><a style='text-decoration: underline' href='"+urls[i].request+"' target='_blank'>"+urls[i].title+"</a></td><td><img src='' alt='<?php echo _mb("No legend available");?>!'/></td></tr>";
+ }
+ }
+ }
+ }
+ }
+ featureInfoList += "</table>";
+ $("<div id='featureInfo_preselect'></div>").dialog({
+ bgiframe: true,
+ autoOpen: true,
+ modal: false,
+ title: '<?php echo _mb("Please choose a requestable Layer");?>',
+ width:parseInt(featureInfoPopupWidth, 10),
+ height:parseInt(featureInfoPopupHeight, 10),
+ position:dialogPosition,
+ buttons: {
+ "Close": function(){
+ if(standingHighlightFeatureInfo !== null){
+ standingHighlightFeatureInfo.clean();
+ }
+ $(this).dialog('close').remove();
+ }
+ }
+ }).parent().css({position:"fixed"});
+ $("#featureInfo_preselect").append(featureInfoList);
} else {
- urls = mod_featureInfo_mapObj.getFeatureInfoRequests(point, ignoreWms) || [];
- var length = urls.length + ownDataInfos.length;
- if (length > 0){
- for (var i=0; i < urls.length; i++){
+ urls = mod_featureInfo_mapObj.getFeatureInfoRequests(point, ignoreWms);
+ if(urls){
+ for(var i=0;i<urls.length;i++){ //To change order : var i=urls.length-1; i>=0; i--
//TODO: also rewind the LAYERS parameter for a single WMS FeatureInfo REQUEST if needed?
- if (reverseInfo) {
+ var cnt = i;
+ if (reverseInfo == 'true') {
if (typeof(urls[i]) !== "undefined") {
urls[i] = changeURLValueOrder(urls[i], 'LAYERS');
}
}
- if(featureInfoLayerPopup){
- featureInfoDialog(urls[i], dialogPosition, i * 25);
+ if(featureInfoPopupPosition.length == 2 && !isNaN(featureInfoPopupPosition[0]) && !isNaN(featureInfoPopupPosition[1])) {
+ var dialogPosition = [];
+ dialogPosition[0] = featureInfoPopupPosition[0]+cnt*25;
+ dialogPosition[1] = featureInfoPopupPosition[1]+cnt*25;
}
else {
- featureInfoWindow(urls[i]);
- }
- }
-
- for(var i=0; i < ownDataInfos.length; i++){
- if(featureInfoLayerPopup === 'true'){
- ownDataDialog(ownDataInfos[i], dialogPosition, (urls.length + i) * 25);
+ var dialogPosition = featureInfoPopupPosition;
}
- else {
- ownDataWindow(ownDataInfos[i]);
- }
- }
- }
- else {
+ if(featureInfoLayerPopup == 'true'){
+ $("<div><iframe frameborder='0' height='100%' width='100%' id='featureInfo_"+ i + "' title='<?php echo _mb("Information");?>' src='" + urls[i] + "'></iframe></div>").dialog({
+ bgiframe: true,
+ autoOpen: true,
+ modal: false,
+ title: '<?php echo _mb("Information");?>',
+ width:parseInt(featureInfoPopupWidth, 10),
+ height:parseInt(featureInfoPopupHeight, 10),
+ position:dialogPosition,
+ buttons: {
+ "Ok": function(){
+ $(this).dialog('close').remove();
+ }
+ }
+ }).parent().css({position:"fixed"});
+ }
+ else
+ window.open(urls[i], "" , "width="+featureInfoPopupWidth+",height="+featureInfoPopupHeight+",scrollbars=yes,resizable=yes");
+ } //end for
+ } //end if urls
+ else
alert(unescape("Please select a layer! \n Bitte waehlen Sie eine Ebene zur Abfrage aus!"));
- }
}
- setFeatureInfoRequest(mod_featureInfo_target, point.x, point.y);
+ setFeatureInfoRequest(mod_featureInfo_target,point.x,point.y);
}
}
Modified: trunk/mapbender/http/plugins/kmlTree.php
===================================================================
--- trunk/mapbender/http/plugins/kmlTree.php 2019-05-03 09:05:46 UTC (rev 10115)
+++ trunk/mapbender/http/plugins/kmlTree.php 2019-05-08 14:44:04 UTC (rev 10116)
@@ -329,7 +329,7 @@
isPublic = data;
if (isPublic == 1){
- alert('The Guest-User is not allowed to publish a WMC!'+
+ alert('To publicate a WMC is not allowed for the Guest-User!'+
'If you want to use this function, please create an account.');
return false;
}
@@ -868,47 +868,6 @@
}
return data;
};
- // 'area', 'boundary-length', 'track-length'
- var featureInfoFilter = ['title', 'marker-size', 'marker-symbol', 'marker-color',
- 'marker-offset-x', 'marker-offset-y', 'stroke', 'stroke-opacity',
- 'stroke-width', 'fill', 'fill-opacity'];
-
- function escapeHTML(text) {
- return text
- .replace(/&/g, '&')
- .replace(/</g, '<')
- .replace(/>/g, '>')
- .replace(/"/g, '"')
- .replace(/'/g, ''')
- .replace(/\//g, '/');
- }
-
- function createFeatureInfoContent(props) {
- var $table = $("<table>")
- .attr("border", 1);
- for (var key in props) {
- if (props.hasOwnProperty(key) && featureInfoFilter.indexOf(key) < 0) {
- $table
- .append($("<tr>")
- .append($("<td>").html(escapeHTML(key)))
- .append($("<td>").html(escapeHTML(props[key]))))
- }
- }
- return $table.attr('outerHTML');
- }
-
- this.getFeatureInfos = function (click) {
- var map = Mapbender.modules.mapframe1;
- var kml = $('#mapframe1').data('kml');
- return kml.findFeaturesAtClick(click)
- .map(function (locator) {
- var kmlLayer = map.kmls[locator.url];
- return {
- title: kmlLayer.data.title,
- content: createFeatureInfoContent(kmlLayer.data.features[locator.id].properties)
- }
- });
- };
};
Mapbender.events.init.register(function() {
Modified: trunk/mapbender/http/plugins/mb_digitize_widget.php
===================================================================
--- trunk/mapbender/http/plugins/mb_digitize_widget.php 2019-05-03 09:05:46 UTC (rev 10115)
+++ trunk/mapbender/http/plugins/mb_digitize_widget.php 2019-05-08 14:44:04 UTC (rev 10116)
@@ -282,7 +282,6 @@
$('#kmlTree li.kmltree-selected').removeClass('kmltree-selected');
attributesDialog.dialog('close');
editStyleDialog.dialog('close');
-
});
copyDialog = $(copyHtml);
copyDialog.dialog({
@@ -498,6 +497,9 @@
editStyleDialog.find('input[name="marker-symbol"]').val('icon-' + v + '-24');
}
});
+ var cls = $('.digitize-style-predefined .selected-icon i').attr('class');
+ $('.digitize-style-predefined input[name="marker-symbol"]').val(cls);
+ editStyleDialog.find('input').change();
editStyleDialog.find('form input').bind('click', function() {
editStyleDialog.find('.digitize-style-' + $(this).val()).css('display', 'block').siblings('table').css('display', 'none');
@@ -505,14 +507,16 @@
editStyleDialog.find('button[name="digitize-reset-style"]').bind('click', function() {
if(ispoint) {
- editStyleDialog.find('.digitize-style-custom,form').css('display', 'block');
- editStyleDialog.find('.digitize-style-predefined').css('display', 'none');
- editStyleDialog.find('input[value="custom"]').attr('checked', 'checked');
+ editStyleDialog.find('form').css('display', 'block');
+ editStyleDialog.find('.digitize-style-custom').css('display', 'none');
+ editStyleDialog.find('.digitize-style-predefined').css('display', 'block');
editStyleDialog.find('.digitize-style-custom input[name="marker-symbol"]').val('../img/marker/red.png');
editStyleDialog.find('.digitize-style-custom input[name="marker-size"]').val(20);
editStyleDialog.find('.digitize-style-predefined input[name="marker-symbol"]').val('icon-airfield-24');
+ $('.digitize-style-predefined .selected-icon i').attr('class', 'icon-airfield-24');
editStyleDialog.find('.digitize-style-predefined input[name="marker-size"]').val('medium');
editStyleDialog.find('.digitize-style-predefined input[name="marker-color"]').spectrum('set', 'white');
+ editStyleDialog.find('input').change();
}
editStyleDialog.find('input[name="stroke"]').spectrum('set', '#555555');
editStyleDialog.find('.opacity-slider').slider('value', 100);
@@ -529,6 +533,10 @@
return;
}
+ if($(this).attr('name').match(/marker-type/) && !$(this).get(0).checked) {
+ return;
+ }
+
if($(this).attr('name') === 'stroke-width') {
var val = $(this).val();
if(!(!isNaN(parseFloat(val)) && isFinite(val)) || $(this).val() <= 0) {
Modified: trunk/mapbender/lib/mb.ui.displayKmlFeatures.js
===================================================================
--- trunk/mapbender/lib/mb.ui.displayKmlFeatures.js 2019-05-03 09:05:46 UTC (rev 10115)
+++ trunk/mapbender/lib/mb.ui.displayKmlFeatures.js 2019-05-08 14:44:04 UTC (rev 10116)
@@ -57,39 +57,54 @@
self.render();
});
- var delta = 2;
- var lastX, lastY;
- var box;
+ this.element.bind('click', function(e) {
+ if (self.lastWasBox) {
+ self.lastWasBox = false;
+ return;
+ }
+ var map = self.element.mapbender();
+ var pos = map.getMousePosition(e);
+ var clickPoint = map.convertPixelToReal(new Point(pos.x, pos.y));
+ var wgspt = Proj4js.transform(self.targetProj, self.wgs84, {
+ x: clickPoint.x,
+ y: clickPoint.y
+ });
+ var res = map.getScale() / mb_resolution / 100;
- this.element.bind('mousedown', function(e) {
if (!self.queriedLayer) return;
- lastX = e.clientX;
- lastY = e.clientY;
- box = new Mapbender.Box({
+ var matchedIds = self.findFeatures(pos);
+
+ self.updateSelectedFeatures(matchedIds, e.ctrlKey);
+ });
+
+ var boxfun;
+
+ this.element.bind('mousedown', boxfun = function(e) {
+ if (!self.queriedLayer) return;
+ var box = new Mapbender.Box({
target: 'mapframe1'
});
box.start(e);
$('#mapframe1').css("cursor", "crosshair")
- });
-
- $('#mapframe1').mouseup(function(e) {
- if (!self.queriedLayer) return;
- var matchedIds;
- var extent = box.stop(e);
- $('#mapframe1').css("cursor", "default");
- if (Math.abs(lastX - e.clientX) <= delta && Math.abs(lastY - e.clientY) <= delta) {
- // click
- matchedIds = self.findFeaturesAtClick(e);
- } else {
- // drag
- if (typeof extent === "undefined") {
- return;
- }
+ .mouseup(function(e) {
+ box.stop(e, function(extent) {
+ if (typeof extent === "undefined") {
+ return;
+ }
- matchedIds = self.findFeaturesInExtent(extent);
- }
- self.updateSelectedFeatures(matchedIds, e.ctrlKey);
- return false;
+ var matchedIds = self.findFeatures(extent);
+ self.updateSelectedFeatures(matchedIds, e.ctrlKey);
+ self.lastWasBox = true;
+
+ $('#mapframe1')
+ .css("cursor", "default")
+ .unbind("mousedown")
+ .unbind("mouseup")
+ .unbind("mousemove")
+ .bind('mousedown', boxfun);
+ });
+ return false;
+ });
});
self.element.bind('kml:loaded', function(event, obj) {
@@ -134,90 +149,95 @@
self._load(o.url);
}
},
-
- /**
- * Check if the point lies inside the box.
- * @param {type} point
- * @param {type} box
- * @returns {Boolean}
- */
- pointInBox: function (point, box) {
- if (point.x >= box.minx && point.x <= box.maxx
- && point.y >= box.miny && point.y <= box.maxy) {
- return true;
+
+ findFeatures: function(posOrBox) {
+ var matchedIds = [];
+
+ var self = this;
+ var map = self.element.mapbender();
+ var ispoint;
+ var clickPoint, wgspt, clickBox, min, max;
+ if (posOrBox.x) {
+ clickPoint = map.convertPixelToReal(new Point(posOrBox.x, posOrBox.y));
+ wgspt = Proj4js.transform(self.targetProj, self.wgs84, {
+ x: clickPoint.x,
+ y: clickPoint.y
+ });
+ ispoint = true;
} else {
- return false;
+ clickBox = posOrBox;
+ min = Proj4js.transform(self.targetProj, self.wgs84, {
+ x: clickBox.minx,
+ y: clickBox.miny
+ });
+ max = Proj4js.transform(self.targetProj, self.wgs84, {
+ x: clickBox.maxx,
+ y: clickBox.maxy
+ });
+ ispoint = false;
}
- },
+ var res = map.getScale() / mb_resolution / 100;
- /**
- * Checks if value x is between y1 and y2. It works also if y2 < y1.
- * @param {type} x
- * @param {type} y1
- * @param {type} y2
- * @returns {Number}
- */
- valueIsBetween: function (x, y1, y2) {
- return (y1 - x) * (y2 - x) <= 0;
+ $.each(self._kmls, function(_, itm) {
+ $.each(itm.data.features, function(k, v) {
+ if (ispoint) {
+ //console.log( "isPoint" );
+ self.matchFeatureToPoint(v, clickPoint, matchedIds, res, itm, wgspt, k);
+ } else {
+ self.matchFeatureToBox(v, {
+ min: min,
+ max: max
+ }, matchedIds, itm, k);
+ }
+ });
+ });
+ return matchedIds;
},
- /**
- * calculates the Y value of line for a given X.
- * @param {type} line
- * @param {type} y
- * @returns {Number}
- */
- lineYAtX: function (line, x) {
- return line.y2 + (x - line.x2) * (line.y1 - line.y2) / (line.x1 - line.x2)
- },
- /**
- * calculates the X value of line for a given Y.
- * @param {type} line
- * @param {type} y
- * @returns {Number}
- */
- lineXAtY: function (line, y) {
- return line.x2 + (y - line.y2) * (line.x1 - line.x2) / (line.y1 - line.y2)
- },
+ inBox: function(minx, miny, maxx, maxy, selectBoxMinx, selectBoxMaxx, selectBoxMiny, selectBoxMaxy) {
- /**
- * First checks if line is completely contained inside of the box. If not it checks
- * if one of the sides of the box intersects with the line.
- * @param {type} line
- * @param {type} box
- * @returns {Boolean}
- */
- lineIntersectsBox: function (line, box) {
- if (this.pointInBox({ x: line.x1, y: line.y1 }, box)
- || this.pointInBox({ x: line.x1, y: line.y1 }, box)) {
- return true;
+ // ############## proof the min-point ##################
+ // proof hit on the x-axis
+ if ( ( minx >= selectBoxMinx && minx <= selectBoxMaxx ) ) {
+ // if x hit, proof y
+ if ( ( miny >= selectBoxMiny && miny <= selectBoxMaxy ) ) {
+ return true;
+ }
}
-
- if (this.valueIsBetween(box.minx, line.x1, line.x2)) {
- var y = this.lineYAtX(line, box.minx);
- if (y >= box.miny && y <= box.maxy) {
+ // proof hit on the y-axis
+ if ( ( miny >= selectBoxMiny && miny <= selectBoxMaxy ) ) {
+ // if y hit, proof x
+ if ( ( minx >= selectBoxMinx && minx <= selectBoxMaxx ) ) {
return true;
}
}
+ // ############## proof the max-point ##################
+ if ( ( maxx >= selectBoxMinx && maxx <= selectBoxMaxx ) ) {
+ // if x hit, proof y
+ if ( ( maxy >= selectBoxMiny && maxy <= selectBoxMaxy ) ) {
+ return true;
+ }
+ }
- if (this.valueIsBetween(box.maxx, line.x1, line.x2)) {
- var y = this.lineYAtX(line, box.maxx);
- if (y >= box.miny && y <= box.maxy) {
+ if ( ( maxy >= selectBoxMiny && maxy <= selectBoxMaxy ) ) {
+ // if y hit, proof x
+ if ( ( maxx >= selectBoxMinx && maxx <= selectBoxMaxx ) ) {
return true;
}
}
+ // ############## proof if selectbox contains the feature geometry ##################
+ // proof on x-axis
+ if ( minx >= selectBoxMinx && minx <= selectBoxMaxx && maxx >= selectBoxMinx && maxx <= selectBoxMaxx ) {
- if (this.valueIsBetween(box.miny, line.y1, line.y2)) {
- var x = this.lineXAtY(line, box.miny);
- if (x >= box.minx && x <= box.maxx) {
+ if ( miny <= selectBoxMiny && maxy >= selectBoxMaxy ) {
return true;
}
}
+ // proof on y-axis
+ if ( miny >= selectBoxMiny && miny <= selectBoxMaxy && maxy >= selectBoxMiny && maxx <= selectBoxMaxy ) {
- if (this.valueIsBetween(box.maxy, line.y1, line.y2)) {
- var x = this.lineXAtY(line, box.maxy);
- if (x >= box.minx && x <= box.maxx) {
+ if ( minx <= selectBoxMinx && maxx >= selectBoxMaxx ) {
return true;
}
}
@@ -224,209 +244,92 @@
return false;
},
-
- getLines: function (points, connect) {
- lines = [];
- for (var i = 0; i < points.length - 1; i ++) {
- lines.push({
- x1: points[i][0],
- y1: points[i][1],
- x2: points[i + 1][0],
- y2: points[i + 1][1]
- });
- }
- if (connect) {
- lines.push({
- x1: points[points.length - 1][0],
- y1: points[points.length - 1][1],
- x2: points[0][0],
- y2: points[0][1]
- })
- }
- return lines;
- },
-
- lineStringIntersectsBox: function (lineStringPoints, box) {
- var self = this;
- return this.getLines(lineStringPoints).some(function (line) {
- return self.lineIntersectsBox(line, box);
- });
- },
- /**
- * Checks whether a polygon intersects a box.
- * On the one hand it checks if any of the lines on the polygon ring intersect
- * with the box and on the other hand it checks how many times a ray cast outwards
- * from the middle of the box intersects with one of the lines. If it intersects
- * an odd number of times it lays inside the polygon.
- * @param {type} polygon
- * @param {type} box
- * @returns {Boolean}
- */
- polygonIntersectsBox: function (polygonRings, box) {
- var rayPoint = {
- x: box.minx + (box.maxx - box.minx) / 2,
- y: box.miny + (box.maxy - box.miny) / 2
- };
- var rayIntersections = 0;
+ pointInBox: function(pointX, pointY, selectBoxMinx, selectBoxMaxx, selectBoxMiny, selectBoxMaxy) {
- var self = this;
- var lines = polygonRings.reduce(function (lines, ring) {
- Array.prototype.push.apply(lines, self.getLines(ring, true));
- return lines;
- }, [])
-
- for (var i = 0; i < lines.length; i++) {
- if (this.lineIntersectsBox(lines[i], box)) {
- return true;
- }
- if (this.valueIsBetween(rayPoint.y, lines[i].y1, lines[i].y2)) {
- var x = this.lineXAtY(lines[i], rayPoint.y);
- if (x >= rayPoint.x) {
- rayIntersections++;
- }
- }
- }
-
- if (rayIntersections % 2 === 1) {
+ if ( ( pointX >= selectBoxMinx && pointX <= selectBoxMaxx ) && ( pointY >= selectBoxMiny && pointY <= selectBoxMaxy )) {
return true;
- } else {
- return false;
}
},
-
- boxInBox: function (boxA, boxB) {
- return this.pointInBox({ x: boxA.minx, y: boxA.miny }, boxB) &&
- this.pointInBox({ x: boxA.maxx, y: boxA.maxy }, boxB);
- },
-
-
- /**
- * Checks whether the geometry of the feature intersects with the box
- * @param {type} feature
- * @param {type} box
- * @returns {Boolean}
- */
- featureIntersectsBox: function (feature, box) {
- var geometryType = feature.geometry.type.toLowerCase();
- switch (geometryType) {
- case 'point':
- return this.pointInBox({
- x: feature.geometry.coordinates[0],
- y: feature.geometry.coordinates[1]
- }, box);
- case 'linestring':
- return this.lineStringIntersectsBox(feature.geometry.coordinates, box);
- case 'polygon':
- return this.polygonIntersectsBox(feature.geometry.coordinates, box);
- default:
- throw new Error('feature geometry type not supported');
- }
- },
-
- featureInBox: function (feature, box) {
- if (feature.geometry.type.toLowerCase() === 'point') {
- return this.pointInBox({
- x: feature.geometry.coordinates[0],
- y: feature.geometry.coordinates[1]
- }, box);
+
+ matchFeatureToPoint: function(feat, clickPoint, matchedIds, res, itm, wgspt, idx) {
+ //console.log( "point" );
+ if (feat.geometry.type.match(/point/i)) {
+ var pt = Proj4js.transform(this.wgs84, this.targetProj, {
+ x: feat.geometry.coordinates[0],
+ y: feat.geometry.coordinates[1]
+ });
+ var minx = pt.x - 20 * res;
+ var miny = pt.y - 20 * res;
+ var maxx = minx + 40 * res;
+ var maxy = miny + 40 * res;
+ if (minx < clickPoint.x && maxx > clickPoint.x && miny < clickPoint.y && maxy > clickPoint.y) {
+ matchedIds.push({
+ url: itm.url,
+ id: idx
+ });
+ }
} else {
- var arrayBox = this.getBbox(feature);
- return this.boxInBox({
- minx: arrayBox[0],
- miny: arrayBox[1],
- maxx: arrayBox[2],
- maxy: arrayBox[3]
- }, box);
- }
- },
-
-
-
- /**
- * Finds all features that intersect with a buffer around a point or a given box.
- * @param {type} posOrBox
- * @returns {Array|displayFeatures.findIntersectingFeatures.ids}
- */
- findFeaturesAtClick: function (e) {
- var map = this.element.mapbender();
- var pos = map.getMousePosition(e);
-
- var min = {
- x: pos.x - 20,
- y: pos.y + 20 // screen y is in opposite direction of map y
- };
- var max = {
- x: pos.x + 20,
- y: pos.y - 20
- };
-
- min = map.convertPixelToReal(min);
- max = map.convertPixelToReal(max);
-
- min = Proj4js.transform(this.targetProj, this.wgs84, min);
- max = Proj4js.transform(this.targetProj, this.wgs84, max);
-
- var box = {
- minx: min.x,
- miny: min.y,
- maxx: max.x,
- maxy: max.y
- };
-
- var self = this;
- var matches = [];
- for (var kmlId in this._kmls) {
- if (this._kmls.hasOwnProperty(kmlId)) {
- var kml = this._kmls[kmlId];
- matches = kml.data.features.reduce(function (matches, feature, index) {
- if (self.featureIntersectsBox(feature, box)) {
- matches.push({
- url: kml.url,
- id: index
- });
- }
- return matches;
- }, matches);
+ var box = this.getBbox(feat);
+ if (this.inBox(box[0], box[1], box[2], box[3], wgspt.x, wgspt.y)) {
+ matchedIds.push({
+ url: itm.url,
+ id: idx
+ });
}
}
- return matches;
},
- findFeaturesInExtent: function(extent) {
- var min = Proj4js.transform(this.targetProj, this.wgs84, {
- x: extent.minx,
- y: extent.miny
- });
- var max = Proj4js.transform(this.targetProj, this.wgs84, {
- x: extent.maxx,
- y: extent.maxy
- });
-
- var box = {
- minx: min.x,
- miny: min.y,
- maxx: max.x,
- maxy: max.y
- };
-
- var matches = [];
- var self = this;
- for (var kmlId in this._kmls) {
- if (this._kmls.hasOwnProperty(kmlId)) {
- var kml = this._kmls[kmlId];
- matches = kml.data.features.reduce(function (matches, feature, index) {
- if (self.featureInBox(feature, box)) {
- matches.push({
- url: kml.url,
- id: index
- });
- }
- return matches;
- }, matches);
+ matchFeatureToBox: function(feat, wgsbox, matchedIds, itm, idx) {
+ if (feat.geometry.type.match(/point/i)) {
+ //console.log( feat.geometry );
+ if (this.pointInBox(feat.geometry.coordinates[0], feat.geometry.coordinates[1], wgsbox.min.x, wgsbox.max.x, wgsbox.min.y, wgsbox.max.y)) {
+ matchedIds.push({
+ url: itm.url,
+ id: idx
+ });
}
+ } else {
+ var box = this.getBbox(feat);
+ if (this.inBox(box[0], box[1], box[2], box[3], wgsbox.min.x, wgsbox.max.x, wgsbox.min.y, wgsbox.max.y) ) {
+ matchedIds.push({
+ url: itm.url,
+ id: idx
+ });
+ return;
+ }
+ if ( this.inBox(box[0], box[1], box[2], box[3], wgsbox.min.x, wgsbox.max.x, wgsbox.min.x, wgsbox.max.x) ) {
+ matchedIds.push({
+ url: itm.url,
+ id: idx
+ });
+ }
+ // if (wgsbox.min.x < box[0] && wgsbox.max.x > box[2]) {
+ // if (wgsbox.min.y > box[1] && wgsbox.min.y < box[3] || wgsbox.max.y > box[1] && wgsbox.max.y < box[3]) {
+ // matchedIds.push({
+ // url: itm.url,
+ // id: idx
+ // });
+ // return;
+ // }
+ // }
+ // if (wgsbox.min.y < box[1] && wgsbox.max.y > box[3]) {
+ // if (wgsbox.min.x > box[0] && wgsbox.min.x < box[2] || wgsbox.max.x > box[0] && wgsbox.max.x < box[2]) {
+ // matchedIds.push({
+ // url: itm.url,
+ // id: idx
+ // });
+ // return;
+ // }
+ // }
+ // if (wgsbox.min.x < box[0] && wgsbox.max.x > box[2] && wgsbox.min.y > box[1] && wgsbox.max.y < box[3]) {
+ // matchedIds.push({
+ // url: itm.url,
+ // id: idx
+ // });
+ // return;
+ // }
}
- return matches;
},
updateSelectedFeatures: function(ids, append) {
@@ -832,6 +735,8 @@
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
+
+
self.element.trigger('kml:error', "Problem talking to server: " + errorThrown);
}
});
@@ -936,6 +841,7 @@
getBbox: function(feature) {
switch (feature.geometry.type.toLowerCase()) {
case 'point':
+ var map = $(this.element).mapbender();
var minx = feature.geometry.coordinates[0] - 0.001;
var miny = feature.geometry.coordinates[1] - 0.001;
return [minx, miny, minx + 0.002, miny + 0.002];
Modified: trunk/mapbender/tools/mod_runScheduler.php
===================================================================
--- trunk/mapbender/tools/mod_runScheduler.php 2019-05-03 09:05:46 UTC (rev 10115)
+++ trunk/mapbender/tools/mod_runScheduler.php 2019-05-08 14:44:04 UTC (rev 10116)
@@ -70,6 +70,7 @@
for ($i=0; $i<count($wmsToUpdate); $i++) {
//create new wms object
$updateWms = new wms();
+ $updateWms->harvestCoupledDatasetMetadata = true;
try {
$createObjFromXml = $updateWms->createObjFromXML($wmsToUpdate[$i]['wms_upload_url']);
}
More information about the Mapbender_commits
mailing list