[mapguide-commits] r5920 - in branches/2.2/MgDev/Web/src: mapviewerjava mapviewernet mapviewerphp viewerfiles

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Fri Jun 3 11:26:17 EDT 2011


Author: jng
Date: 2011-06-03 08:26:17 -0700 (Fri, 03 Jun 2011)
New Revision: 5920

Modified:
   branches/2.2/MgDev/Web/src/mapviewerjava/getselectedfeatures.jsp
   branches/2.2/MgDev/Web/src/mapviewernet/getselectedfeatures.aspx
   branches/2.2/MgDev/Web/src/mapviewerphp/getselectedfeatures.php
   branches/2.2/MgDev/Web/src/viewerfiles/ajaxmappane.templ
Log:
#1486: Return the BBOX of each feature instead of its centroid. This way we can re-use the zoom to selection logic already built into the viewer to zoom to a level that encompasses the extent of the feature. This is the 2.2 submission

Modified: branches/2.2/MgDev/Web/src/mapviewerjava/getselectedfeatures.jsp
===================================================================
--- branches/2.2/MgDev/Web/src/mapviewerjava/getselectedfeatures.jsp	2011-06-03 15:24:14 UTC (rev 5919)
+++ branches/2.2/MgDev/Web/src/mapviewerjava/getselectedfeatures.jsp	2011-06-03 15:26:17 UTC (rev 5920)
@@ -60,10 +60,12 @@
         }
     }
 
-    class ZoomPoint
+    class ZoomBox
     {
-        public double X;
-        public double Y;
+        public double MinX;
+        public double MinY;
+        public double MaxX;
+        public double MaxY;
     }
 
     class FeatureProperty
@@ -75,7 +77,7 @@
     class Feature
     {
         public String LayerName;
-        public ZoomPoint Zoom;
+        public ZoomBox Zoom;
 
         private HashMap<String, FeatureProperty> _properties;
 
@@ -290,7 +292,7 @@
                 if (feat.Zoom == null)
                     sb.append("null");
                 else
-                    sb.append(String.format(Locale.ROOT, "{\"x\" : %f, \"y\" : %f }", feat.Zoom.X, feat.Zoom.Y));
+                    sb.append(String.format(Locale.ROOT, "{\"minx\" : %f, \"miny\" : %f, \"maxx\" : %f, \"maxy\" : %f }", feat.Zoom.MinX, feat.Zoom.MinY, feat.Zoom.MaxX, feat.Zoom.MaxY));
                 //end zoom
                 //end feature
                 sb.append("}");
@@ -373,7 +375,7 @@
                 while (reader.ReadNext())
                 {
                     Feature feat = new Feature(layerName);
-                    ZoomPoint zoom = null;
+                    ZoomBox zoom = null;
 
                     for (int k = 0; k < props.GetCount(); k++)
                     {
@@ -395,9 +397,11 @@
                                     MgCoordinate ll = env.GetLowerLeftCoordinate();
                                     MgCoordinate ur = env.GetUpperRightCoordinate();
 
-                                    zoom = new ZoomPoint();
-                                    zoom.X = (ll.GetX() + ur.GetX()) / 2;
-                                    zoom.Y = (ll.GetY() + ur.GetY()) / 2;
+                                    zoom = new ZoomBox();
+                                    zoom.MinX = ll.GetX();
+                                    zoom.MinY = ll.GetY();
+                                    zoom.MaxX = ur.GetX();
+                                    zoom.MaxY = ur.GetY();
 
                                     feat.Zoom = zoom;
                                 }

Modified: branches/2.2/MgDev/Web/src/mapviewernet/getselectedfeatures.aspx
===================================================================
--- branches/2.2/MgDev/Web/src/mapviewernet/getselectedfeatures.aspx	2011-06-03 15:24:14 UTC (rev 5919)
+++ branches/2.2/MgDev/Web/src/mapviewernet/getselectedfeatures.aspx	2011-06-03 15:26:17 UTC (rev 5920)
@@ -41,10 +41,12 @@
         }
     }
 
-    class ZoomPoint
+    class ZoomBox
     {
-        public double X;
-        public double Y;
+        public double MinX;
+        public double MinY;
+        public double MaxX;
+        public double MaxY;
     }
 
     class FeatureProperty
@@ -56,7 +58,7 @@
     class Feature
     {
         public String LayerName;
-        public ZoomPoint Zoom;
+        public ZoomBox Zoom;
 
         private Dictionary<string, FeatureProperty> _properties;
 
@@ -228,7 +230,7 @@
                 if (feat.Zoom == null)
                     sb.Append("null");
                 else
-                    sb.Append("{" + String.Format(CultureInfo.InvariantCulture, "\"x\" : {0}, \"y\" : {1} ", feat.Zoom.X, feat.Zoom.Y) + "}");
+                    sb.Append("{" + String.Format(CultureInfo.InvariantCulture, "\"minx\" : {0}, \"miny\" : {1}, \"maxx\": {2}, \"maxy\": {3}", feat.Zoom.MinX, feat.Zoom.MinY, feat.Zoom.MaxX, feat.Zoom.MaxY) + "}");
                 //end zoom
                 //end feature
                 sb.Append("}");
@@ -318,7 +320,7 @@
                 while (reader.ReadNext())
                 {
                     Feature feat = new Feature(layerName);
-                    ZoomPoint zoom = null;
+                    ZoomBox zoom = null;
 
                     for (int k = 0; k < props.Count; k++)
                     {
@@ -340,9 +342,11 @@
                                     MgCoordinate ll = env.GetLowerLeftCoordinate();
                                     MgCoordinate ur = env.GetUpperRightCoordinate();
 
-                                    zoom = new ZoomPoint();
-                                    zoom.X = (ll.X + ur.X) / 2;
-                                    zoom.Y = (ll.Y + ur.Y) / 2;
+                                    zoom = new ZoomBox();
+                                    zoom.MinX = ll.X;
+                                    zoom.MinY = ll.Y;
+                                    zoom.MaxX = ur.X;
+                                    zoom.MaxY = ur.Y;
 
                                     feat.Zoom = zoom;
                                 }

Modified: branches/2.2/MgDev/Web/src/mapviewerphp/getselectedfeatures.php
===================================================================
--- branches/2.2/MgDev/Web/src/mapviewerphp/getselectedfeatures.php	2011-06-03 15:24:14 UTC (rev 5919)
+++ branches/2.2/MgDev/Web/src/mapviewerphp/getselectedfeatures.php	2011-06-03 15:26:17 UTC (rev 5920)
@@ -53,10 +53,12 @@
     }
 }
 
-class ZoomPoint
+class ZoomBox
 {
-    public $x;
-    public $y;
+    public $minx;
+    public $miny;
+    public $maxx;
+    public $maxy;
 }
 
 //
@@ -196,9 +198,11 @@
                                     $ll = $env->GetLowerLeftCoordinate();
                                     $ur = $env->GetUpperRightCoordinate();
 
-                                    $zoom = new ZoomPoint();
-                                    $zoom->x = ($ll->GetX() + $ur->GetX()) / 2;
-                                    $zoom->y = ($ll->GetY() + $ur->GetY()) / 2;
+                                    $zoom = new ZoomBox();
+                                    $zoom->minx = $ll->GetX();
+                                    $zoom->miny = $ll->GetY();
+                                    $zoom->maxx = $ur->GetX();
+                                    $zoom->maxy = $ur->GetY();
                                     
                                     $feat->zoom = $zoom;
                                     //FB::log("zoom: (".$zoom->x.",".$zoom->y.")");
@@ -317,9 +321,11 @@
                     //Add JSONified feature
                     if($feat->zoom != null)
                     {
-                        $xstr = number_format($feat->zoom->x, 8, '.','');
-                        $ystr = number_format($feat->zoom->y, 8, '.','');
-                        array_push($totalFeaturesOnLayer, "{\"values\" : [".join(",", $featureProperties)."], \"zoom\" : { \"x\": $xstr, \"y\": $ystr } }");
+                        $minxstr = number_format($feat->zoom->minx, 8, '.','');
+                        $minystr = number_format($feat->zoom->miny, 8, '.','');
+                        $maxxstr = number_format($feat->zoom->maxx, 8, '.','');
+                        $maxystr = number_format($feat->zoom->maxy, 8, '.','');
+                        array_push($totalFeaturesOnLayer, "{\"values\" : [".join(",", $featureProperties)."], \"zoom\" : { \"minx\": $minxstr, \"miny\": $minystr,  \"maxx\": $maxxstr, \"maxy\": $maxystr } }");
                     }
                     else
                         array_push($totalFeaturesOnLayer, "{\"values\" : [".join(",", $featureProperties)."], \"zoom\" : null }");

Modified: branches/2.2/MgDev/Web/src/viewerfiles/ajaxmappane.templ
===================================================================
--- branches/2.2/MgDev/Web/src/viewerfiles/ajaxmappane.templ	2011-06-03 15:24:14 UTC (rev 5919)
+++ branches/2.2/MgDev/Web/src/viewerfiles/ajaxmappane.templ	2011-06-03 15:26:17 UTC (rev 5920)
@@ -4049,7 +4049,14 @@
     
     //Get the zoom component of the selected feature, and zoom to that view
     if (feat.zoom)
-        ZoomToView(feat.zoom.x, feat.zoom.y, GetFeatureZoomLevel(), true);
+    {
+        var mcsW = feat.zoom.maxx - feat.zoom.minx;
+        var mcsH = feat.zoom.maxy - feat.zoom.miny;
+        var centerX = feat.zoom.minx + mcsW / 2;
+        var centerY = feat.zoom.miny + mcsH / 2;
+        var scale = CalculateScale1(mcsW*2, mcsH*2, mapDevW, mapDevH);
+        GotoView(centerX, centerY, scale, true, true);
+    }
 }
 
 function HoverButton(eltId, description)



More information about the mapguide-commits mailing list