[mapguide-commits] r8007 - in branches/2.5/MgDev/Web/src/schemareport: . templatefiles

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Mon Mar 31 05:31:54 PDT 2014


Author: jng
Date: 2014-03-31 05:31:54 -0700 (Mon, 31 Mar 2014)
New Revision: 8007

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

Modified: branches/2.5/MgDev/Web/src/schemareport/displayschemafunctions.php
===================================================================
--- branches/2.5/MgDev/Web/src/schemareport/displayschemafunctions.php	2014-03-31 08:09:00 UTC (rev 8006)
+++ branches/2.5/MgDev/Web/src/schemareport/displayschemafunctions.php	2014-03-31 12:31:54 UTC (rev 8007)
@@ -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: branches/2.5/MgDev/Web/src/schemareport/mapdefinitionfactory.php
===================================================================
--- branches/2.5/MgDev/Web/src/schemareport/mapdefinitionfactory.php	2014-03-31 08:09:00 UTC (rev 8006)
+++ branches/2.5/MgDev/Web/src/schemareport/mapdefinitionfactory.php	2014-03-31 12:31:54 UTC (rev 8007)
@@ -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: branches/2.5/MgDev/Web/src/schemareport/showgeom.php
===================================================================
--- branches/2.5/MgDev/Web/src/schemareport/showgeom.php	2014-03-31 08:09:00 UTC (rev 8006)
+++ branches/2.5/MgDev/Web/src/schemareport/showgeom.php	2014-03-31 12:31:54 UTC (rev 8007)
@@ -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: branches/2.5/MgDev/Web/src/schemareport/stringconstants.php
===================================================================
--- branches/2.5/MgDev/Web/src/schemareport/stringconstants.php	2014-03-31 08:09:00 UTC (rev 8006)
+++ branches/2.5/MgDev/Web/src/schemareport/stringconstants.php	2014-03-31 12:31:54 UTC (rev 8007)
@@ -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: branches/2.5/MgDev/Web/src/schemareport/templatefiles/mapdefinition.templ
===================================================================
--- branches/2.5/MgDev/Web/src/schemareport/templatefiles/mapdefinition.templ	2014-03-31 08:09:00 UTC (rev 8006)
+++ branches/2.5/MgDev/Web/src/schemareport/templatefiles/mapdefinition.templ	2014-03-31 12:31:54 UTC (rev 8007)
@@ -6,4 +6,5 @@
   <BackgroundColor>%s</BackgroundColor>
   %s
   %s
+  %s
 </MapDefinition>

Added: branches/2.5/MgDev/Web/src/schemareport/templatefiles/textwatermark.templ
===================================================================
--- branches/2.5/MgDev/Web/src/schemareport/templatefiles/textwatermark.templ	                        (rev 0)
+++ branches/2.5/MgDev/Web/src/schemareport/templatefiles/textwatermark.templ	2014-03-31 12:31:54 UTC (rev 8007)
@@ -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