[Mapbender-commits] r9241 - trunk/mapbender/lib

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Jul 7 07:35:11 PDT 2015


Author: syed
Date: 2015-07-07 07:35:11 -0700 (Tue, 07 Jul 2015)
New Revision: 9241

Modified:
   trunk/mapbender/lib/mb.ui.displayKmlFeatures.js
Log:
fix select feature

Modified: trunk/mapbender/lib/mb.ui.displayKmlFeatures.js
===================================================================
--- trunk/mapbender/lib/mb.ui.displayKmlFeatures.js	2015-07-07 12:04:35 UTC (rev 9240)
+++ trunk/mapbender/lib/mb.ui.displayKmlFeatures.js	2015-07-07 14:35:11 UTC (rev 9241)
@@ -181,6 +181,7 @@
         $.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, {
@@ -196,18 +197,63 @@
 
     inBox: function(minx, miny, maxx, maxy, selectBoxMinx, selectBoxMaxx, selectBoxMiny, selectBoxMaxy) {
 
-        // Erster Punk (minx,miny)
-        // Zweiter Punk (maxx,maxy)
-        if ( ( minx >= selectBoxMinx && minx <= selectBoxMaxx ) || ( miny >= selectBoxMiny && miny <= selectBoxMaxy )) {
-            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 ( ( maxx >= selectBoxMinx && maxx <= selectBoxMaxx ) || ( maxy > selectBoxMiny && maxy < selectBoxMaxy )) {
-            return true;
+        // 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 ( ( 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 ( miny <= selectBoxMiny && maxy >= selectBoxMaxy ) {
+                return true;
+            }
+        }
+        // proof on y-axis
+        if (  miny >= selectBoxMiny && miny <= selectBoxMaxy  && maxy >= selectBoxMiny && maxx <= selectBoxMaxy ) {
+
+            if ( minx <= selectBoxMinx && maxx >= selectBoxMaxx ) {
+                return true;
+            }
+        }
+
         return false;
     },
 
+    pointInBox: function(pointX, pointY, selectBoxMinx, selectBoxMaxx, selectBoxMiny, selectBoxMaxy) {
+
+        if ( ( pointX >= selectBoxMinx && pointX <= selectBoxMaxx ) && ( pointY >= selectBoxMiny && pointY <= selectBoxMaxy )) {
+            return true;
+        }
+    },
+
     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],
@@ -236,7 +282,8 @@
 
     matchFeatureToBox: function(feat, wgsbox, matchedIds, itm, idx) {
         if (feat.geometry.type.match(/point/i)) {
-            if (this.inBox(wgsbox.min.x, wgsbox.min.y, wgsbox.max.x, wgsbox.max.y, feat.geometry.coordinates[0], feat.geometry.coordinates[1])) {
+            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
@@ -244,7 +291,7 @@
             }
         } else {
             var box = this.getBbox(feat);
-            if (this.inBox(box[0], box[1], box[2], box[3], wgsbox.min.x, wgsbox.min.y) || this.inBox(box[0], box[1], box[2], box[3], wgsbox.min.x, wgsbox.max.y) || this.inBox(box[0], box[1], box[2], box[3], wgsbox.max.x, wgsbox.max.y) || this.inBox(box[0], box[1], box[2], box[3], wgsbox.max.x, wgsbox.min.y)) {
+            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



More information about the Mapbender_commits mailing list