[fusion-commits] r2729 - in trunk: layers/MapGuide text widgets/Redline widgets/Redline/classes

svn_fusion at osgeo.org svn_fusion at osgeo.org
Mon Jun 3 22:15:39 PDT 2013


Author: jng
Date: 2013-06-03 22:15:38 -0700 (Mon, 03 Jun 2013)
New Revision: 2729

Modified:
   trunk/layers/MapGuide/MapGuideViewerApi.js
   trunk/text/en
   trunk/widgets/Redline/classes/editcommand.php
   trunk/widgets/Redline/editmarkup.php
Log:
#574: Add circle support for Redline widget. All the data stores in question do not support curves, so the digitized circles are actually 40-sided approximated polygons (just like the AJAX viewer)

Modified: trunk/layers/MapGuide/MapGuideViewerApi.js
===================================================================
--- trunk/layers/MapGuide/MapGuideViewerApi.js	2013-06-04 03:57:39 UTC (rev 2728)
+++ trunk/layers/MapGuide/MapGuideViewerApi.js	2013-06-04 05:15:38 UTC (rev 2729)
@@ -33,6 +33,16 @@
 var Class = MainFusionWindow.Class;
 var Object = MainFusionWindow.Object;
 
+//Polygon circle approximation borrowed from the AJAX viewer
+var simulateCirclePoints = [];
+var simulateCircleHalfPointNumber = 40;
+(function () {
+    for (var index = 0; index < 2 * simulateCircleHalfPointNumber + 1; index++) {
+        simulateCirclePoints[2 * index] = Math.cos(Math.PI * index / simulateCircleHalfPointNumber);
+        simulateCirclePoints[2 * index + 1] = Math.sin(Math.PI * index / simulateCircleHalfPointNumber);
+    }
+})();
+
 function Refresh() {
     //var Fusion = window.top.Fusion;
     var mapWidget = GetFusionMapWidget();
@@ -88,6 +98,12 @@
     });
 }
 
+function DigitizeCircle(handler) {
+    GetFusionMapWidget().digitizeCircle({}, function(circle) {
+        mgApiCallHandler(circle, 'circle', handler);
+    });
+}
+
 function ClearDigitization(bCancelHandler) {
     GetFusionMapWidget().cancelDigitization();
 }
@@ -150,6 +166,10 @@
     if (geomType == 'rect') {
         var v = geom.getVertices();
         apiGeom = new Rectangle(new Point(v[0].x, v[0].y), new Point(v[2].x, v[2].y));
+    } else if (geomType == 'circle') {
+        apiGeom = new Circle();
+        apiGeom.Center = new Point(geom.x, geom.y);
+        apiGeom.Radius = geom.r;
     } else {
         switch (geom.CLASS_NAME) {
             case 'OpenLayers.Geometry.Point':

Modified: trunk/text/en
===================================================================
--- trunk/text/en	2013-06-04 03:57:39 UTC (rev 2728)
+++ trunk/text/en	2013-06-04 05:15:38 UTC (rev 2729)
@@ -316,10 +316,12 @@
 REDLINEEDITLINESTRINGHELP = Click the map to define each point of the line, Double Click on the final point to end.
 REDLINEEDITRECTANGLEHELP = Click on the map to specify the first corner and drag the mouse to define the rectangle.
 REDLINEEDITPOLYGONHELP  = Click the map to define each point of the polygon, Double Click on the final point to end.
+REDLINEEDITCIRCLEHELP   = Click on the map and drag the mouse out to the desired radius to defined your circle. Release the mouse button to finish.
 REDLINEPROMPTLABEL      = Enter a label for the redline item
 REDLINEADD              = Add Redline
 REDLINEDIGITIZE         = Digitize Redline
 REDLINEOBJECTPOINT      = Point
+REDLINEOBJECTCIRCLE     = Circle
 REDLINEOBJECTLINE       = Line
 REDLINEOBJECTLINESTRING = Line String
 REDLINEOBJECTRECTANGLE  = Rectangle

Modified: trunk/widgets/Redline/classes/editcommand.php
===================================================================
--- trunk/widgets/Redline/classes/editcommand.php	2013-06-04 03:57:39 UTC (rev 2728)
+++ trunk/widgets/Redline/classes/editcommand.php	2013-06-04 05:15:38 UTC (rev 2729)
@@ -9,6 +9,7 @@
     const AddPolygon    = 5;
     const Delete        = 6;
     const Update        = 7;
+    const AddCircle     = 8;
 }
 
 ?>
\ No newline at end of file

Modified: trunk/widgets/Redline/editmarkup.php
===================================================================
--- trunk/widgets/Redline/editmarkup.php	2013-06-04 03:57:39 UTC (rev 2728)
+++ trunk/widgets/Redline/editmarkup.php	2013-06-04 05:15:38 UTC (rev 2729)
@@ -60,6 +60,7 @@
                 $markupEditor->AddLineString();
                 $refreshMap = true;
                 break;
+            case EditCommand::AddCircle:
             case EditCommand::AddRectangle:
             case EditCommand::AddPolygon:
                 $markupEditor->AddPolygon();
@@ -100,9 +101,11 @@
         $lineStringHelpLocal = GetLocalizedString('REDLINEEDITLINESTRINGHELP', $locale );
         $rectangleHelpLocal = GetLocalizedString('REDLINEEDITRECTANGLEHELP', $locale );
         $polygonHelpLocal = GetLocalizedString('REDLINEEDITPOLYGONHELP', $locale );
+        $circleHelpLocal = GetLocalizedString('REDLINEEDITCIRCLEHELP', $locale );
         $addLocal = GetLocalizedString('REDLINEADD', $locale );
         $digitizeLocal = GetLocalizedString('REDLINEDIGITIZE', $locale );
         $pointLocal = GetLocalizedString('REDLINEOBJECTPOINT', $locale );
+        $circleLocal = GetLocalizedString('REDLINEOBJECTCIRCLE', $locale );
         $lineLocal = GetLocalizedString('REDLINEOBJECTLINE', $locale );
         $lineStringLocal = GetLocalizedString('REDLINEOBJECTLINESTRING', $locale );
         $rectangleLocal = GetLocalizedString('REDLINEOBJECTRECTANGLE', $locale );
@@ -142,6 +145,7 @@
         var CMD_ADD_LINESTRING 	= <?= EditCommand::AddLineString ?>;
         var CMD_ADD_RECTANGLE 	= <?= EditCommand::AddRectangle ?>;
         var CMD_ADD_POLYGON 	= <?= EditCommand::AddPolygon ?>;
+        var CMD_ADD_CIRCLE      = <?= EditCommand::AddCircle ?>;
         var CMD_DELETE 			= <?= EditCommand::Delete ?>;
         var CMD_UPDATE 			= <?= EditCommand::Update ?>;
 
@@ -151,6 +155,7 @@
         var EDIT_LINESTRING_HELP = "<?=$lineStringHelpLocal?>";
         var EDIT_RECTANGLE_HELP = "<?=$rectangleHelpLocal?>";
         var EDIT_POLYGON_HELP = "<?=$polygonHelpLocal?>";
+        var EDIT_CIRCLE_HELP = "<?=$circleHelpLocal?>";
 
         function SetDigitizeInfo(text)
         {
@@ -189,6 +194,12 @@
             SetDigitizeInfo(EDIT_POINT_HELP);
             DigitizePoint(OnPointDigitized);
         }
+        
+        function AddCircle()
+        {
+            SetDigitizeInfo(EDIT_CIRCLE_HELP);
+            DigitizeCircle(OnCircleDigitized);
+        }
 
         function AddLine()
         {
@@ -235,6 +246,23 @@
 
             SubmitCommand(CMD_ADD_POINT);
         }
+        
+        function OnCircleDigitized(circle)
+        {
+            PromptAndSetMarkupText();
+            var geometryInput = document.getElementById("geometryInput");
+            var x = circle.Center.X;
+            var y = circle.Center.Y;
+            var r = circle.Radius;
+            
+            var coords = [];
+            for (var index = 0; index < 2 * simulateCircleHalfPointNumber + 1; index++) {
+                coords.push(x + r * simulateCirclePoints[2 * index]);
+                coords.push(y + r * simulateCirclePoints[2 * index + 1]);
+            }
+            geometryInput.value = (coords.length / 2) + "," + coords.join(",");
+            SubmitCommand(CMD_ADD_CIRCLE);
+        }
 
         function OnLineStringDigitized(lineString)
         {
@@ -404,6 +432,11 @@
     <tr>
         <td colspan="2">
             <input class="Ctrl" id="pointBtn" type="button" onClick="AddPoint()" value="<?=$pointLocal?>" style="width:85px" <?= $allowPoint ? '' : 'disabled="disabled"' ?> />
+            <input class="Ctrl" id="circleBtn" type="button" onClick="AddCircle()" value="<?=$circleLocal?>" style="width:85px" <?= $allowPoly ? '' : 'disabled="disabled"' ?> />
+        </td>
+    </tr>
+    <tr>
+        <td colspan="2">
             <input class="Ctrl" id="lineBtn" type="button" onClick="AddLine()" value="<?=$lineLocal?>" style="width:85px" <?= $allowLine ? '' : 'disabled="disabled"'  ?> />
             <input class="Ctrl" id="lineStringBtn" type="button" onClick="AddLineString()" value="<?=$lineStringLocal?>" style="width:85px" <?= $allowLine ? '' : 'disabled="disabled"'  ?> />
         </td>



More information about the fusion-commits mailing list