[mapguide-commits] r8009 - in trunk/MgDev/Web/src/schemareport: . templatefiles

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Wed Apr 2 07:08:41 PDT 2014


Author: jng
Date: 2014-04-02 07:08:41 -0700 (Wed, 02 Apr 2014)
New Revision: 8009

Added:
   trunk/MgDev/Web/src/schemareport/templatefiles/textwatermark.templ
Modified:
   trunk/MgDev/Web/src/schemareport/displayschemafunctions.php
   trunk/MgDev/Web/src/schemareport/mapdefinitionfactory.php
   trunk/MgDev/Web/src/schemareport/showgeom.php
   trunk/MgDev/Web/src/schemareport/stringconstants.php
   trunk/MgDev/Web/src/schemareport/templatefiles/mapdefinition.templ
Log:
#2421: Add debug watermarks for schema report map previews.

Modified: trunk/MgDev/Web/src/schemareport/displayschemafunctions.php
===================================================================
--- trunk/MgDev/Web/src/schemareport/displayschemafunctions.php	2014-04-01 13:17:43 UTC (rev 8008)
+++ trunk/MgDev/Web/src/schemareport/displayschemafunctions.php	2014-04-02 14:08:41 UTC (rev 8009)
@@ -307,6 +307,58 @@
     return $layerDefinition;
 }
 
+function CreateDebugMapDef($factory, $resourceSrvc, $className, $sessionId, $resId, $coordinate, $minX, $maxX, $minY, $maxY, $featureCount)
+{
+    // The full WKT probably won't fit on the map, so tidy it up for display on a map
+    $csClean = str_replace("[", "[\n    ", $coordinate);
+    $csClean = str_replace("],", "],\n", $csClean);
+    // Make a debug text watermark containing relevant debugging information
+    $message = sprintf(Debug::WatermarkDebugTemplate,
+        $className,
+        $featureCount,
+        $minX,
+        $minY,
+        $maxX,
+        $maxY,
+        $csClean);
+    $wmark = $factory->CreateTextWatermark($message);
+    $wmidstr = "Session:$sessionId//".$className."_DEBUG.WatermarkDefinition";
+    $wmid = new MgResourceIdentifier($wmidstr);
+    $wmSource = new MgByteSource($wmark, strlen($wmark));
+    $wmRdr = $wmSource->GetReader();
+    $resourceSrvc->SetResource($wmid, $wmRdr, null);
+
+    // Inputs for Extents
+    $extents = $factory->CreateExtents($minX, $maxX, $minY, $maxY);
+
+    // Inputs for MapLayer
+    $layerName = $className;
+    $selectable = MapDef::Selectable;
+    $showLegend = MapDef::ShowLegend;
+    $legendLabel = $className;
+    $expandLegend = MapDef::ExpandLegend;
+    $visible = MapDef::Visible;
+    $groupName = MapDef::GroupName;
+    $mapLayer = $factory->CreateMapLayer($layerName, $resId, $selectable, $showLegend, $legendLabel, $expandLegend, $visible, $groupName);
+
+    // Inputs for MapLayerGroup
+    $groupName = MapDef::GroupName;
+    $visible = MapDef::Visible;
+    $showLegend = MapDef::ShowLegend;
+    $expandLegend = MapDef::ExpandLegend;
+    $legendLabel = MapDef::LegendLabel;
+    $mapLayerGroup = $factory->CreateMapLayerGroup($groupName, $visible, $showLegend, $expandLegend, $legendLabel);
+    
+    $dbgWatermarks = "<Watermarks><Watermark><Name>DEBUG</Name><ResourceId>$wmidstr</ResourceId></Watermark></Watermarks>";
+    
+    // Inputs for MapDefinition
+    $mapName = MapDef::MapName;
+    $backgroundColor = MapDef::BgColor;
+    $mapDefinition = $factory->CreateMapDefinition($mapName, $coordinate, $extents, $backgroundColor, $mapLayer, $mapLayerGroup, $dbgWatermarks);
+
+    return $mapDefinition;
+}
+
 function CreateMapDef($factory, $className, $resId, $coordinate, $minX, $maxX, $minY, $maxY)
 {
     // Inputs for Extents
@@ -329,7 +381,7 @@
     $expandLegend = MapDef::ExpandLegend;
     $legendLabel = MapDef::LegendLabel;
     $mapLayerGroup = $factory->CreateMapLayerGroup($groupName, $visible, $showLegend, $expandLegend, $legendLabel);
-
+    
     // Inputs for MapDefinition
     $mapName = MapDef::MapName;
     $backgroundColor = MapDef::BgColor;

Modified: trunk/MgDev/Web/src/schemareport/mapdefinitionfactory.php
===================================================================
--- trunk/MgDev/Web/src/schemareport/mapdefinitionfactory.php	2014-04-01 13:17:43 UTC (rev 8008)
+++ trunk/MgDev/Web/src/schemareport/mapdefinitionfactory.php	2014-04-02 14:08:41 UTC (rev 8009)
@@ -44,12 +44,19 @@
         return $extents;
     }
 
-    static function CreateMapDefinition($name, $coordinate, $extents, $backgroundColor, $mapLayer, $mapLayerGroup)
+    static function CreateMapDefinition($name, $coordinate, $extents, $backgroundColor, $mapLayer, $mapLayerGroup, $watermarks = "")
     {
         $mapDef = file_get_contents("templatefiles/mapdefinition.templ");
-        $mapDef = sprintf($mapDef, $name, $coordinate, $extents, $backgroundColor, $mapLayer, $mapLayerGroup);
+        $mapDef = sprintf($mapDef, $name, $coordinate, $extents, $backgroundColor, $mapLayer, $mapLayerGroup, $watermarks);
         return $mapDef;
     }
+    
+    static function CreateTextWatermark($text)
+    {
+        $wm = file_get_contents("templatefiles/textwatermark.templ");
+        $mw = sprintf($wm, $text);
+        return $mw;
+    }
 }
 
 ?>

Modified: trunk/MgDev/Web/src/schemareport/showgeom.php
===================================================================
--- trunk/MgDev/Web/src/schemareport/showgeom.php	2014-04-01 13:17:43 UTC (rev 8008)
+++ trunk/MgDev/Web/src/schemareport/showgeom.php	2014-04-02 14:08:41 UTC (rev 8009)
@@ -38,6 +38,7 @@
 
         <?php
 
+            $includeDebugWatermark = true;
             $sessionId = $_GET['sessionId'];
             $resName = $_GET['resId'];
             $schemaName = $_GET['schemaName'];
@@ -126,8 +127,11 @@
 
                 // Create a map definition
                 $mapfactory = new MapDefinitionFactory();
-                $mapDefinition = CreateMapDef($mapfactory, $className, $resName, $mbr->coordinateSystem, $minX, $maxX, $minY, $maxY);
-
+                if ($includeDebugWatermark) {
+                    $mapDefinition = CreateDebugMapDef($mapfactory, $resourceSrvc, $className, $sessionId, $resName, $mbr->coordinateSystem, $minX, $maxX, $minY, $maxY, $totalEntries);
+                } else {
+                    $mapDefinition = CreateMapDef($mapfactory, $className, $resName, $mbr->coordinateSystem, $minX, $maxX, $minY, $maxY);
+                }
                 // Save the map definition to a resource stored in the session repository
                 $byteSource = new MgByteSource($mapDefinition, strlen($mapDefinition));
                 $byteSource->SetMimeType(MgMimeType::Xml);

Modified: trunk/MgDev/Web/src/schemareport/stringconstants.php
===================================================================
--- trunk/MgDev/Web/src/schemareport/stringconstants.php	2014-04-01 13:17:43 UTC (rev 8008)
+++ trunk/MgDev/Web/src/schemareport/stringconstants.php	2014-04-02 14:08:41 UTC (rev 8009)
@@ -101,6 +101,11 @@
     const LayoutName = 'Geometry Layout';
 }
 
+class Debug
+{
+    const WatermarkDebugTemplate = 'MapGuide Debugging Information\n==============================\n\nPreviewed Class: %s\nFeature Count: %s\nComputed Extents Min: (%s, %s)\nComputed Extents Max: (%s, %s)\nCoordinate System: \n%s';
+}
+
 class XslStrings
 {
     const Schema = 'Schema:';

Modified: trunk/MgDev/Web/src/schemareport/templatefiles/mapdefinition.templ
===================================================================
--- trunk/MgDev/Web/src/schemareport/templatefiles/mapdefinition.templ	2014-04-01 13:17:43 UTC (rev 8008)
+++ trunk/MgDev/Web/src/schemareport/templatefiles/mapdefinition.templ	2014-04-02 14:08:41 UTC (rev 8009)
@@ -6,4 +6,5 @@
   <BackgroundColor>%s</BackgroundColor>
   %s
   %s
+  %s
 </MapDefinition>

Copied: trunk/MgDev/Web/src/schemareport/templatefiles/textwatermark.templ (from rev 8007, branches/2.5/MgDev/Web/src/schemareport/templatefiles/textwatermark.templ)
===================================================================
--- trunk/MgDev/Web/src/schemareport/templatefiles/textwatermark.templ	                        (rev 0)
+++ trunk/MgDev/Web/src/schemareport/templatefiles/textwatermark.templ	2014-04-02 14:08:41 UTC (rev 8009)
@@ -0,0 +1,38 @@
+<?xml version="1.0"?>
+<WatermarkDefinition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="2.4.0" xsi:noNamespaceSchemaLocation="WatermarkDefinition-2.4.0.xsd">
+  <Content>
+    <SimpleSymbolDefinition>
+      <Name />
+      <Description />
+      <Graphics>
+        <Text>
+          <Content>'%s'</Content>
+          <FontName>'Arial'</FontName>
+          <Height>3</Height>
+          <Justification>'Left'</Justification>
+          <TextColor>FF000000</TextColor>
+          <Frame>
+            <FillColor>CCFFFFFF</FillColor>
+          </Frame>
+        </Text>
+      </Graphics>
+      <PointUsage />
+      <ParameterDefinition />
+    </SimpleSymbolDefinition>
+  </Content>
+  <Appearance />
+  <Position>
+    <XYPosition>
+      <XPosition>
+        <Offset>10</Offset>
+        <Unit>Points</Unit>
+        <Alignment>Left</Alignment>
+      </XPosition>
+      <YPosition>
+        <Offset>10</Offset>
+        <Unit>Points</Unit>
+        <Alignment>Top</Alignment>
+      </YPosition>
+    </XYPosition>
+  </Position>
+</WatermarkDefinition>



More information about the mapguide-commits mailing list