[mapguide-commits] r4398 - in sandbox/rfc60/MgDev/Server/src/Services: Mapping Rendering

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Wed Dec 9 10:08:50 EST 2009


Author: uvlite
Date: 2009-12-09 10:08:49 -0500 (Wed, 09 Dec 2009)
New Revision: 4398

Modified:
   sandbox/rfc60/MgDev/Server/src/Services/Mapping/MappingUtil.cpp
   sandbox/rfc60/MgDev/Server/src/Services/Mapping/MappingUtil.h
   sandbox/rfc60/MgDev/Server/src/Services/Rendering/ServerRenderingService.cpp
Log:
RFC60 now only executes when image format uses colorpalette

Modified: sandbox/rfc60/MgDev/Server/src/Services/Mapping/MappingUtil.cpp
===================================================================
--- sandbox/rfc60/MgDev/Server/src/Services/Mapping/MappingUtil.cpp	2009-12-09 15:06:58 UTC (rev 4397)
+++ sandbox/rfc60/MgDev/Server/src/Services/Mapping/MappingUtil.cpp	2009-12-09 15:08:49 UTC (rev 4398)
@@ -362,7 +362,8 @@
                                   bool expandExtents,
                                   bool checkRefreshFlag,
                                   double scale,
-                                  bool selection)
+                                  bool selection,
+                                  bool extractColors)
 {
     #ifdef _DEBUG
     long dwStart = GetTickCount();
@@ -569,7 +570,16 @@
                         dr->StartLayer(&layerInfo, &fcinfo);
                         ds->StylizeVectorLayer(vl, dr, rsReader, xformer, scale, NULL, NULL);
                         dr->EndLayer();
-                        ExtractColors(map, scaleRange, ds);
+                        #ifdef _DEBUG
+                        printf("  StylizeLayers() //ExtractColors// -Vector- Name:%S  Time:%6.4f (s)\n\n", (mapLayer->GetName()).c_str(), (GetTickCount()-dwLayerStart)/1000.0);
+                        #endif
+                        // color extraction for RFC60 only when needed
+                        if (extractColors)
+                            ExtractColors(map, scaleRange, ds);
+                        #ifdef _DEBUG
+                        printf("  StylizeLayers() ##ExtractColors## -Vector- Name:%S  Time:%6.4f (s)\n\n", (mapLayer->GetName()).c_str(), (GetTickCount()-dwLayerStart)/1000.0);
+                        #endif
+
                    }
                 }
                 else  // not scaleRange
@@ -1205,6 +1215,7 @@
 
 //-------------------------------------------------------------------------
 /// PURPOSE: Accessor method for the base colors defined in this Layer and scaleRange.
+///          used for RFC60
 /// RETURNS: A pointer to the list of colors of the collected colors (maybe empty but not null)
 //-------------------------------------------------------------------------
 PSTRCOLORLIST MgMappingUtil::GetUsedColorsFromScaleRange(MdfModel::VectorScaleRange* vsr, 

Modified: sandbox/rfc60/MgDev/Server/src/Services/Mapping/MappingUtil.h
===================================================================
--- sandbox/rfc60/MgDev/Server/src/Services/Mapping/MappingUtil.h	2009-12-09 15:06:58 UTC (rev 4397)
+++ sandbox/rfc60/MgDev/Server/src/Services/Mapping/MappingUtil.h	2009-12-09 15:08:49 UTC (rev 4398)
@@ -55,7 +55,8 @@
                               bool expandExtents,
                               bool checkRefreshFlag,
                               double scale,
-                              bool selection = false);
+                              bool selection = false,
+                              bool extractColors = false);
 
     static RSMgFeatureReader * ExecuteFeatureQuery(MgFeatureService* svcFeature,
                                                  RS_Bounds& extent,

Modified: sandbox/rfc60/MgDev/Server/src/Services/Rendering/ServerRenderingService.cpp
===================================================================
--- sandbox/rfc60/MgDev/Server/src/Services/Rendering/ServerRenderingService.cpp	2009-12-09 15:06:58 UTC (rev 4397)
+++ sandbox/rfc60/MgDev/Server/src/Services/Rendering/ServerRenderingService.cpp	2009-12-09 15:08:49 UTC (rev 4398)
@@ -36,6 +36,9 @@
 static const INT32 FILTER_SELECTABLE = 2;
 static const INT32 FILTER_HASTOOLTIPS = 4;
 
+// could go into the utils also??
+inline bool hasColorMap (STRING format) { return format == L"PNG8" || format == L"GIF"; }
+
 IMPLEMENT_CREATE_SERVICE(MgServerRenderingService)
 ///---------------------------------------------------------------------------------
 // used when we want to process a given number of features
@@ -745,6 +748,7 @@
 }
 ///---------------------------------------------------------------------------------
 /// pack options into object and forward call (select Selection AND Layers) maybe keepSelection
+/// called by RenderTile
 MgByteReader* MgServerRenderingService::RenderMapInternal(MgMap* map,
                                                           MgSelection* selection,
                                                           MgReadOnlyLayerCollection* roLayers,
@@ -818,12 +822,14 @@
 
     RS_Color bgcolor(0, 0, 0, 255); //not used -- GDRenderer is already initialized to the correct bgcolor
 
+    STRING format = options->GetImageFormat();
+
     RS_MapUIInfo mapInfo(sessionId, map->GetName(), map->GetObjectId(), srs, units, bgcolor);
 
     // begin map stylization
     dr->StartMap(&mapInfo, b, scale, map->GetDisplayDpi(), map->GetMetersPerUnit(), NULL);
 
-//    MG_TRY()
+//##    MG_TRY()
         // if no layer collection is supplied, then put all layers in a temporary collection
         Ptr<MgReadOnlyLayerCollection> tempLayers = SAFE_ADDREF(roLayers);
         if (tempLayers == NULL)  // if called from renderMap not RenderTile
@@ -838,13 +844,14 @@
         }
 
         INT32 behavior = options->GetBehavior();
-        if (behavior & MgRenderingOptions::RenderLayers)
+        if (behavior & MgRenderingOptions::RenderLayers)    // this is for tiles so observer colormaps
         {
             MgMappingUtil::StylizeLayers(m_svcResource, m_svcFeature, m_svcDrawing, m_pCSFactory, map,
-                                         tempLayers, NULL, &ds, dr, dstCs, expandExtents, false, scale);
+                                         tempLayers, NULL, &ds, dr, dstCs, expandExtents, false, scale,
+                                         false, hasColorMap(format));
         }
 
-        // now we need to stylize the selection on top
+        // now we need to stylize the selection on top (this is not for tiles!)
         if (selection && (behavior & MgRenderingOptions::RenderSelection))
         {
             Ptr<MgReadOnlyLayerCollection> selLayers = selection->GetLayers();
@@ -897,15 +904,15 @@
                     modLayers, overrideFilters, &ds, dr, dstCs, false, false, scale, (behavior & MgRenderingOptions::KeepSelection) != 0);
             }
         }
- //   MG_CATCH(L"MgServerRenderingService.RenderMapInternal-StylizeLayers")
+//##   MG_CATCH(L"MgServerRenderingService.RenderMapInternal-StylizeLayers")
 
     dr->EndMap();   // cleanup??
 
-//    if (mgException.p)
-//    {
-//        throw mgException;  // to skip tile we need to throw an exception as a NULL return
-//                            // will cause a null pointer exception.
-//    }
+//##    if (mgException.p)
+//##    {
+//##        throw mgException;  // to skip a faulty tile we need to throw an exception 
+//##                            // as simply returning NULL will cause a null pointer exception.
+//##    }
 
 /*
     //-------------------------------------------------------
@@ -932,29 +939,26 @@
 
     // get a byte representation of the image
     auto_ptr<RS_ByteData> data;
-
-    STRING imageFormat = options->GetImageFormat();
-    // Both AGG and GD expect the format to be an uppercase string
-    STRING format = MgUtil::ToUpper(imageFormat);
-
 	//-------------------------------------------------------
-	/// PNG8 code by UV
+	/// rfc60 code to correct colormaps by UV
 	//-------------------------------------------------------
 	/// we examine the expressions collected from xml definitions of all layer.
-    /// the color Palette for the renderer is a list<RSColor>
-    PRSCOLORS tileColorPalette = new RSCOLORS();
 	/// the map object has a list from all color entries found in the most recent Layerstylization
     /// TODO currently they are interpreted as ffffffff 32 bit RGBA string values.
     /// adding expresssions and other interpretations could be done here. 
+    /// the color Palette for the renderer is a list<RSColor>
+    PRSCOLORS tileColorPalette;
 	try {
-        ParseColorStrings (tileColorPalette, map);
-		#ifdef _DEBUG_PNG8
-		printf("<<<<<<<<<<<<<<<<<<<<< MgServerRenderingService::ColorPalette->size(): %d\n", mapColorPalette->size());
-		#endif
 		//  call the image renderer to create the image ----------------------------------------
-		if (wcscmp(m_rendererName.c_str(), L"AGG") == 0)
+        if (wcscmp(m_rendererName.c_str(), L"AGG") == 0  && hasColorMap(format))   
+        {    
+            tileColorPalette = new RSCOLORS();
+            ParseColorStrings (tileColorPalette, map);
+		    #ifdef _DEBUG_PNG8
+		    printf("<<<<<<<<<<<<<<<<<<<<< MgServerRenderingService::ColorPalette->size(): %d\n", mapColorPalette->size());
+		    #endif
 			data.reset(((AGGRenderer*)dr)->Save(format, saveWidth, saveHeight, tileColorPalette));
-		else
+        } else
 			data.reset(((GDRenderer*)dr)->Save(format, saveWidth, saveHeight));
 	} catch (exception e) {
         if (tileColorPalette)    // cleanup the bare pointer (its a STL list so we do it by hand
@@ -989,7 +993,7 @@
 }
 ///---------------------------------------------------------------------------------
 //-------------------------------------------------------
-/// PNG8 code by UV
+/// RFC60 code for colormapped tiles by UV
 //-------------------------------------------------------
 /// we examine the expressions collected from xml definitions of all layer.
 /// the color Palette for the renderer is a list<RSColor>



More information about the mapguide-commits mailing list