[fusion-commits] r2656 - in trunk: text widgets/Redline widgets/Redline/classes

svn_fusion at osgeo.org svn_fusion at osgeo.org
Fri Mar 8 02:39:36 PST 2013


Author: jng
Date: 2013-03-08 02:39:35 -0800 (Fri, 08 Mar 2013)
New Revision: 2656

Modified:
   trunk/text/en
   trunk/widgets/Redline/classes/markupcommand.php
   trunk/widgets/Redline/classes/markupeditor.php
   trunk/widgets/Redline/editmarkup.php
   trunk/widgets/Redline/markupmain.php
Log:
#551: Tweak the management UI to expose the refined redline creation options.
 - Ability to choose the type of data store (SDF/SHP/SQLite)
 - Ability to choose the type of geometries that can be recorded (SHP disabled if > 1 checked, all disabled if  0 checked)
 - Disable appropriate redline digitization options based on the redline data store's supported geometry types

Modified: trunk/text/en
===================================================================
--- trunk/text/en	2013-03-08 09:54:46 UTC (rev 2655)
+++ trunk/text/en	2013-03-08 10:39:35 UTC (rev 2656)
@@ -216,18 +216,26 @@
 REDLINEMANAGE           = Manage Redline
 REDLINEAVAILABLELAYERS  = Available Redline Layers
 REDLINELOADEDLAYERS     = Redline Layers on Map
-REDLINENEW              = New
+REDLINENEWSDF           = SDF
+REDLINENEWSHP           = SHP
+REDLINENEWSQLITE        = SQLite
+REDLINECREATENEW        = Create New Redline
+REDLINESELECTED         = Selected Redline
 REDLINEADDTOMAP         = Add To Map
 REDLINEDELETE           = Delete
-REDLINEREFRESH          = Refresh
+REDLINEREFRESH          = Refresh List
 REDLINEEDIT             = Add/Edit Redlines
 REDLINEREMOVEFROMMAP    = Remove From Map
 REDLINEDOWNLOADSDF      = Download Data
-REDLINEUPLOADSDF        = Upload
+REDLINEUPLOADSDF        = Upload Redline
+REDLINEOTHEROPTIONS     = Other Options
 REDLINEEDITSTYLE        = Edit Style
 REDLINECREATEFAILURE    = Failed to create redline
 REDLINEUPLOADUNKNOWNPROVIDER  = Could not determine FDO provider from uploaded file
 REDLINEUPLOADNOGEOMETRY = Could not find geometry property in uploaded file
+REDLINEPOINT            = Point
+REDLINELINE             = Line
+REDLINEPOLY             = Polygon
 
 # Edit Redline Style UI
 REDLINEEDITLAYERSTYLE   = Edit Redline Style

Modified: trunk/widgets/Redline/classes/markupcommand.php
===================================================================
--- trunk/widgets/Redline/classes/markupcommand.php	2013-03-08 09:54:46 UTC (rev 2655)
+++ trunk/widgets/Redline/classes/markupcommand.php	2013-03-08 10:39:35 UTC (rev 2656)
@@ -2,16 +2,18 @@
 
 class MarkupCommand
 {
-    const Create    = 1;
-    const Open      = 2;
-    const Delete    = 3;
-    const Refresh   = 4;
-    const Edit      = 5;
-    const Close     = 6;
-    const Download  = 7;
-    const Upload    = 8;
-    const EditStyle = 9;
-    const DownloadDataFromLayer = 10;
+    const CreateSdf     = 1;
+    const CreateShp     = 2;
+    const CreateSqlite  = 3;
+    const Open          = 4;
+    const Delete        = 5;
+    const Refresh       = 6;
+    const Edit          = 7;
+    const Close         = 8;
+    const Download      = 9;
+    const Upload        = 10;
+    const EditStyle     = 11;
+    const DownloadDataFromLayer = 12;
 }
 
 ?>
\ No newline at end of file

Modified: trunk/widgets/Redline/classes/markupeditor.php
===================================================================
--- trunk/widgets/Redline/classes/markupeditor.php	2013-03-08 09:54:46 UTC (rev 2655)
+++ trunk/widgets/Redline/classes/markupeditor.php	2013-03-08 10:39:35 UTC (rev 2656)
@@ -30,12 +30,31 @@
         return $resId->GetName();
     }
 
+    function GetFeatureSource()
+    {
+        return new MgResourceIdentifier($this->GetResourceIdPrefix() . $this->GetMarkupName() . '.FeatureSource');
+    }
+
+    function GetClassDefinition()
+    {
+        $featureService = $this->site->CreateService(MgServiceType::FeatureService);
+        $featureSourceId = $this->GetFeatureSource();
+
+        $classNames = new MgStringCollection();
+        $classNames->Add("Markup");
+
+        $schemas = $featureService->DescribeSchema($featureSourceId, "", $classNames);
+        $schema = $schemas->GetItem(0);
+        $classes = $schema->GetClasses();
+        return $classes->GetItem(0);
+    }
+
     function GetMarkupFeatures()
     {
         $features = array();
 
         $featureService = $this->site->CreateService(MgServiceType::FeatureService);
-        $featureSourceId = new MgResourceIdentifier($this->GetResourceIdPrefix() . $this->GetMarkupName() . '.FeatureSource');
+        $featureSourceId = $this->GetFeatureSource();
 
         $featureReader = $featureService->SelectFeatures($featureSourceId, 'Markup', null);
         while ($featureReader->ReadNext())
@@ -55,7 +74,7 @@
         $resourceService = $this->site->CreateService(MgServiceType::ResourceService);
         $featureService = $this->site->CreateService(MgServiceType::FeatureService);
 
-        $featureSourceId = new MgResourceIdentifier($this->GetResourceIdPrefix() . $this->GetMarkupName() . '.FeatureSource');
+        $featureSourceId = $this->GetFeatureSource();
         $wkt = null;
 
         //Get the WKT from spatial context, because SDF only supports one spatial context it will be the first one
@@ -196,7 +215,7 @@
     function InsertMarkupFeature($propertyValues)
     {
         $featureService = $this->site->CreateService(MgServiceType::FeatureService);
-        $featureSourceId = new MgResourceIdentifier($this->GetResourceIdPrefix() . $this->GetMarkupName() . '.FeatureSource');
+        $featureSourceId = $this->GetFeatureSource();
 
         $commands = new MgFeatureCommandCollection();
         $commands->Add(new MgInsertFeatures('Markup', $propertyValues));
@@ -208,7 +227,7 @@
     function DeleteMarkup()
     {
         $featureService = $this->site->CreateService(MgServiceType::FeatureService);
-        $featureSourceId = new MgResourceIdentifier($this->GetResourceIdPrefix() . $this->GetMarkupName() . '.FeatureSource');
+        $featureSourceId = $this->GetFeatureSource();
 
         $commands = new MgFeatureCommandCollection();
         $commands->Add(new MgDeleteFeatures('Markup', 'ID = ' . $this->args['MARKUPFEATURE']));
@@ -220,7 +239,7 @@
     function UpdateMarkup()
     {
         $featureService = $this->site->CreateService(MgServiceType::FeatureService);
-        $featureSourceId = new MgResourceIdentifier($this->GetResourceIdPrefix() . $this->GetMarkupName() . '.FeatureSource');
+        $featureSourceId = $this->GetFeatureSource();
 
         $propertyValues = new MgPropertyCollection();
         $propertyValues->Add(new MgStringProperty('Text', trim($this->args['UPDATETEXT'])));

Modified: trunk/widgets/Redline/editmarkup.php
===================================================================
--- trunk/widgets/Redline/editmarkup.php	2013-03-08 09:54:46 UTC (rev 2655)
+++ trunk/widgets/Redline/editmarkup.php	2013-03-08 10:39:35 UTC (rev 2656)
@@ -16,6 +16,9 @@
     $refreshMap = false;
     $errorMsg = null;
     $errorDetail = null;
+    $allowPoint = false;
+    $allowLine = false;
+    $allowPoly = false;
 
     SetLocalizedFilesPath(GetLocalizationPath());
     if(isset($_REQUEST['LOCALE'])) {
@@ -27,7 +30,6 @@
     try
     {
         $markupEditor = new MarkupEditor($args);
-
         if (array_key_exists('EDITCOMMAND', $args))
         {
             $cmd = $args['EDITCOMMAND'];
@@ -59,7 +61,21 @@
         }
 
         $markupFeatures = $markupEditor->GetMarkupFeatures();
+        $clsDef = $markupEditor->GetClassDefinition();
+        $clsProps = $clsDef->GetProperties();
+        if ($clsProps->IndexOf($clsDef->GetDefaultGeometryPropertyName()) >= 0)
+        {
+            $geomProp = $clsProps->GetItem($clsDef->GetDefaultGeometryPropertyName());
+            $geomTypes = $geomProp->GetGeometryTypes();
 
+            if ($geomTypes & MgFeatureGeometricType::Point)
+                $allowPoint = true;
+            if ($geomTypes & MgFeatureGeometricType::Curve)
+                $allowLine = true;
+            if ($geomTypes & MgFeatureGeometricType::Surface)
+                $allowPoly = true;
+        }
+
         $editLocal = GetLocalizedString('REDLINEEDIT', $locale );
         $defaultHelpLocal = GetLocalizedString('REDLINEEDITDEFAULTHELP', $locale );
         $pointHelpLocal = GetLocalizedString('REDLINEEDITPOINTHELP', $locale );
@@ -352,15 +368,15 @@
     <tr><td colspan="2" height="2px"></td></tr>
     <tr>
         <td colspan="2">
-            <input class="Ctrl" id="pointBtn" type="button" onClick="AddPoint()" value="<?=$pointLocal?>" style="width:85px">
-            <input class="Ctrl" id="lineBtn" type="button" onClick="AddLine()" value="<?=$lineLocal?>" style="width:85px">
-            <input class="Ctrl" id="lineStringBtn" type="button" onClick="AddLineString()" value="<?=$lineStringLocal?>" style="width:85px">
+            <input class="Ctrl" id="pointBtn" type="button" onClick="AddPoint()" value="<?=$pointLocal?>" style="width:85px" <?= $allowPoint ? '' : 'disabled="disabled"' ?> />
+            <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>
     </tr>
     <tr>
         <td colspan="2">
-            <input class="Ctrl" id="rectangleBtn" type="button" onClick="AddRectangle()" value="<?=$rectangleLocal?>" style="width:85px">
-            <input class="Ctrl" id="polygonBtn" type="button" onClick="AddPolygon()" value="<?=$polygonLocal?>" style="width:85px">
+            <input class="Ctrl" id="rectangleBtn" type="button" onClick="AddRectangle()" value="<?=$rectangleLocal?>" style="width:85px" <?= $allowPoly ? '' : 'disabled="disabled"'  ?> />
+            <input class="Ctrl" id="polygonBtn" type="button" onClick="AddPolygon()" value="<?=$polygonLocal?>" style="width:85px" <?= $allowPoly ? '' : 'disabled="disabled"'  ?> />
         </td>
     </tr>
     <tr><td colspan="2" height="2px"></td></tr>
@@ -416,7 +432,6 @@
 <input name="GEOMETRY" type="hidden" value="" id="geometryInput">
 <input name="TEXT" type="hidden" value="" id="textInput">
 </form>
-
 <?php } else { ?>
 
 <table class="RegText" border="0" cellspacing="0" width="100%%">

Modified: trunk/widgets/Redline/markupmain.php
===================================================================
--- trunk/widgets/Redline/markupmain.php	2013-03-08 09:54:46 UTC (rev 2655)
+++ trunk/widgets/Redline/markupmain.php	2013-03-08 10:39:35 UTC (rev 2656)
@@ -75,7 +75,9 @@
         $manageLocal = GetLocalizedString('REDLINEMANAGE', $locale );
         $availableLayersLocal = GetLocalizedString('REDLINEAVAILABLELAYERS', $locale );
         $loadedLayersLocal = GetLocalizedString('REDLINELOADEDLAYERS', $locale );
-        $newLocal = GetLocalizedString('REDLINENEW', $locale );
+        $newSdfLocal = GetLocalizedString('REDLINENEWSDF', $locale );
+        $newShpLocal = GetLocalizedString('REDLINENEWSHP', $locale );
+        $newSqliteLocal = GetLocalizedString('REDLINENEWSQLITE', $locale );
         $addToMapLocal = GetLocalizedString('REDLINEADDTOMAP', $locale );
         $deleteLocal = GetLocalizedString('REDLINEDELETE', $locale );
         $refreshLocal = GetLocalizedString('REDLINEREFRESH', $locale );
@@ -86,6 +88,12 @@
         $editStyleLocal = GetLocalizedString('REDLINEEDITSTYLE', $locale );
         $redlineCreateFailureLocal = GetLocalizedString('REDLINECREATEFAILURE', $locale );
         $redlineLayerNameLocal = GetLocalizedString('REDLINENAME', $locale);
+        $newRedlineLayerLocal = GetLocalizedString("REDLINECREATENEW", $locale);
+        $selectedRedlineSourceOptionsLocal = GetLocalizedString("REDLINESELECTED", $locale);
+        $pointLocal = GetLocalizedString("REDLINEPOINT", $locale);
+        $lineLocal = GetLocalizedString("REDLINELINE", $locale);
+        $polyLocal = GetLocalizedString("REDLINEPOLY", $locale);
+        $otherOptionsLocal = GetLocalizedString("REDLINEOTHEROPTIONS", $locale);
     }
     catch (MgException $mge)
     {
@@ -110,7 +118,13 @@
         var session = '<?= $args['SESSION'] ?>';
         var mapName = '<?= $args['MAPNAME'] ?>';
 
-        var CMD_NEW 	= <?= MarkupCommand::Create ?>;
+        var GEOM_POINT  = <?= MgFeatureGeometricType::Point ?>;
+        var GEOM_LINE  = <?= MgFeatureGeometricType::Curve ?>;
+        var GEOM_POLY  = <?= MgFeatureGeometricType::Surface ?>;
+
+        var CMD_NEW_SDF	= <?= MarkupCommand::CreateSdf ?>;
+        var CMD_NEW_SHP = <?= MarkupCommand::CreateShp ?>;
+        var CMD_NEW_SQLITE = <?= MarkupCommand::CreateSqlite ?>;
         var CMD_OPEN	= <?= MarkupCommand::Open ?>;
         var CMD_DELETE	= <?= MarkupCommand::Delete ?>;
         var CMD_REFRESH	= <?= MarkupCommand::Refresh ?>;
@@ -123,12 +137,29 @@
 
         function GetGeometryTypes()
         {
-            return -1;
+            var geomType = 0;
+            var bPoint = document.getElementById("chkPoint").checked;
+            var bLine = document.getElementById("chkLine").checked;
+            var bPoly = document.getElementById("chkPoly").checked;
+
+            if (bPoint)
+                geomType |= GEOM_POINT;
+            if (bLine)
+                geomType |= GEOM_LINE;
+            if (bPoly)
+                geomType |= GEOM_POLY;
+
+            return geomType;
         }
 
-        function GetFdoProvider()
+        function GetFdoProvider(cmd)
         {
-            return "OSGeo.SDF";
+            if (cmd == CMD_NEW_SHP)
+                return "OSGeo.SHP";
+            else if (cmd == CMD_NEW_SQLITE)
+                return "OSGeo.SQLite";
+            else
+                return "OSGeo.SDF";
         }
 
         function SubmitCommand(cmd)
@@ -137,7 +168,7 @@
             commandInput.value = cmd;
 
             var markupForm = document.getElementById("markupForm");
-            if (cmd == CMD_NEW) {
+            if (cmd == CMD_NEW_SDF || cmd == CMD_NEW_SHP || cmd == CMD_NEW_SQLITE) {
                 var widget = Fusion.getWidgetsByType("Redline")[0];
                 if (widget.autogenerateLayerNames) {
                     Fusion.ajaxRequest("widgets/Redline/newmarkup.php", {
@@ -146,7 +177,7 @@
                         parameters: {
                             SESSION: session,
                             MAPNAME: mapName,
-                            MARKUPFDOPROVIDER: GetFdoProvider(),
+                            MARKUPFDOPROVIDER: GetFdoProvider(cmd),
                             MARKUPGEOMTYPE: GetGeometryTypes()
                         }
                     });
@@ -159,7 +190,7 @@
                             SESSION: session,
                             MAPNAME: mapName,
                             NEWLAYERNAME: name,
-                            MARKUPFDOPROVIDER: GetFdoProvider(),
+                            MARKUPFDOPROVIDER: GetFdoProvider(cmd),
                             MARKUPGEOMTYPE: GetGeometryTypes()
                         }
                     });
@@ -220,6 +251,7 @@
                 downloadBtn.disabled = false;
 
                 document.getElementById("markupLayerName").value = availableSelect.options[availableSelect.selectedIndex].text;
+                document.getElementById("selectedMarkupSource").value = availableSelect.options[availableSelect.selectedIndex].text;
             }
             else
             {
@@ -261,10 +293,19 @@
             }
         }
 
+        function CheckApplicableProviders()
+        {
+            var gt = GetGeometryTypes();
+            document.getElementById("newShpBtn").disabled = (gt != GEOM_POINT && gt != GEOM_LINE && gt != GEOM_POLY);
+            document.getElementById("newSdfBtn").disabled = (gt == 0);
+            document.getElementById("newSqliteBtn").disabled = (gt == 0);
+        }
+
         function OnLoad()
         {
             OnAvailableMarkupChange();
             OnOpenMarkupChange();
+            CheckApplicableProviders();
 
         <?php if ($refreshMap) { ?>
             var map = parent.Fusion.getMapByName(mapName);
@@ -282,6 +323,21 @@
 <form action="" method="post" enctype="application/x-www-form-urlencoded" id="markupForm" target="_self">
 <table class="RegText" border="0" cellspacing="0" width="100%">
     <tr><td class="Title"><?=$manageLocal?><hr></td></tr>
+    <tr><td class="SubTitle"><?=$newRedlineLayerLocal?></td></tr>
+    <tr>
+        <td>
+            <?=$pointLocal?> <input class="Ctrl" type="checkbox" id="chkPoint" onClick="CheckApplicableProviders()" checked="checked" />
+            <?=$lineLocal?> <input class="Ctrl" type="checkbox" id="chkLine" onClick="CheckApplicableProviders()" checked="checked" />
+            <?=$polyLocal?> <input class="Ctrl" type="checkbox" id="chkPoly" onClick="CheckApplicableProviders()" checked="checked" />
+        </td>
+    </tr>
+    <tr>
+        <td>
+            <input class="Ctrl" type="button" id="newSdfBtn" onClick="SubmitCommand(CMD_NEW_SDF)" value="<?=$newSdfLocal?>" style="width:85px">
+            <input class="Ctrl" type="button" id="newShpBtn" onClick="SubmitCommand(CMD_NEW_SHP)" value="<?=$newShpLocal?>" style="width:85px">
+            <input class="Ctrl" type="button" id="newSqliteBtn" onClick="SubmitCommand(CMD_NEW_SQLITE)" value="<?=$newSqliteLocal?>" style="width:85px">
+        </td>
+    </tr>
     <tr><td class="SubTitle"><?=$availableLayersLocal?></td></tr>
     <tr>
         <td class="RegText">
@@ -298,17 +354,22 @@
             </select>
         </td>
     </tr>
+    <tr><td class="SubTitle"><?=$selectedRedlineSourceOptionsLocal?> <span id="selectedMarkupSource"></span></td></tr>
     <tr>
         <td>
-            <input class="Ctrl" type="button" id="newBtn" onClick="SubmitCommand(CMD_NEW)" value="<?=$newLocal?>" style="width:85px">
             <input class="Ctrl" type="button" id="openBtn" onClick="SubmitCommand(CMD_OPEN)" value="<?=$addToMapLocal?>" style="width:85px">
             <input class="Ctrl" type="button" id="deleteBtn" onClick="SubmitCommand(CMD_DELETE)" value="<?=$deleteLocal?>" style="width:85px">
-            <input class="Ctrl" type="button" id="refreshBtn" onClick="SubmitCommand(CMD_REFRESH)" value="<?=$refreshLocal?>" style="width:85px">
             <input class="Ctrl" type="button" id="downloadBtn" onClick="SubmitCommand(CMD_DOWNLOAD)" value="<?=$downloadLocal?>" style="width:85px">
-            <input class="Ctrl" type="button" id="uploadBtn" onClick="SubmitCommand(CMD_UPLOAD)" value="<?=$uploadLocal?>" style="width:85px">
             <br><br>
         </td>
     </tr>
+    <tr><td class="SubTitle"><?=$otherOptionsLocal?></td></tr>
+    <tr>
+        <td>
+            <input class="Ctrl" type="button" id="refreshBtn" onClick="SubmitCommand(CMD_REFRESH)" value="<?=$refreshLocal?>" style="width:85px">
+            <input class="Ctrl" type="button" id="uploadBtn" onClick="SubmitCommand(CMD_UPLOAD)" value="<?=$uploadLocal?>" style="width:85px">
+        </td>
+    </tr>
     <tr><td class="SubTitle"><?=$loadedLayersLocal?></td></tr>
     <tr>
         <td class="RegText">



More information about the fusion-commits mailing list