[mapguide-commits] r4462 - in sandbox/rfc60/MgDev: Common/MapGuideCommon/MapLayer Common/MapGuideCommon/Resources Common/Renderers Common/Stylization Server/src/Common/Manager Server/src/Services/Kml Server/src/Services/Mapping Server/src/Services/Rendering Server/src/Services/Tile

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Tue Dec 22 19:18:40 EST 2009


Author: uvlite
Date: 2009-12-22 19:18:39 -0500 (Tue, 22 Dec 2009)
New Revision: 4462

Modified:
   sandbox/rfc60/MgDev/Common/MapGuideCommon/MapLayer/Map.cpp
   sandbox/rfc60/MgDev/Common/MapGuideCommon/Resources/mapguide_en.res
   sandbox/rfc60/MgDev/Common/Renderers/AGGImageIO.cpp
   sandbox/rfc60/MgDev/Common/Renderers/AGGImageIO.h
   sandbox/rfc60/MgDev/Common/Renderers/AGGRenderer.cpp
   sandbox/rfc60/MgDev/Common/Stylization/DefaultStylizer.h
   sandbox/rfc60/MgDev/Common/Stylization/RendererStyles.h
   sandbox/rfc60/MgDev/Server/src/Common/Manager/Makefile.am
   sandbox/rfc60/MgDev/Server/src/Common/Manager/ServerManager.vcproj
   sandbox/rfc60/MgDev/Server/src/Services/Kml/ServerKmlService.cpp
   sandbox/rfc60/MgDev/Server/src/Services/Mapping/MappingUtil.cpp
   sandbox/rfc60/MgDev/Server/src/Services/Mapping/MappingUtil.h
   sandbox/rfc60/MgDev/Server/src/Services/Mapping/ServerMappingService.vcproj
   sandbox/rfc60/MgDev/Server/src/Services/Rendering/ServerRenderingService.cpp
   sandbox/rfc60/MgDev/Server/src/Services/Rendering/ServerRenderingService.h
   sandbox/rfc60/MgDev/Server/src/Services/Tile/ServerTileService.cpp
Log:
rfc60 more changes as of Walts review

Modified: sandbox/rfc60/MgDev/Common/MapGuideCommon/MapLayer/Map.cpp
===================================================================
--- sandbox/rfc60/MgDev/Common/MapGuideCommon/MapLayer/Map.cpp	2009-12-22 07:37:23 UTC (rev 4461)
+++ sandbox/rfc60/MgDev/Common/MapGuideCommon/MapLayer/Map.cpp	2009-12-23 00:18:39 UTC (rev 4462)
@@ -35,7 +35,7 @@
     : MgMapBase(),
     m_inSave(false),
     m_unpackedLayersGroups(false),
-	m_colorPalette(new ColorStringList())
+	m_colorPalette(NULL)        // lazy instatiation
 {
 }
 
@@ -47,7 +47,7 @@
     : MgMapBase(),
     m_inSave(false),
     m_unpackedLayersGroups(false),
-	m_colorPalette(new ColorStringList())
+	m_colorPalette(NULL)        // lazy instatiation
 {
     if (NULL == siteConnection)
     {
@@ -119,13 +119,9 @@
     m_mapDefinitionId = SAFE_ADDREF(mapDefinition);
     m_name = mapName;
 
-	// dont forget to reset the colorlist from our layers if there are any left - you never know
-	if (m_colorPalette && !m_colorPalette->empty())
-    {
-		m_colorPalette->clear();
-        delete m_colorPalette;
-    }
-	m_colorPalette = new ColorStringList();
+	// dont forget to reset the colorlist from our layers (std::list dtor clears the list)
+	if (m_colorPalette) delete m_colorPalette;
+	m_colorPalette = NULL;  // initialize to empty (lazy as its only used for 8bit color)
 
     // generate a unique id for this map
     MgUtil::GenerateUuid(m_objectId);
@@ -408,7 +404,6 @@
 
                         // attach the layer to its group
                         rtLayer->SetGroup(rtGroup);
-
                     }
                 }
             }
@@ -470,10 +465,11 @@
     m_name = mapName;
     MgMapBase::Create(mapSRS, mapExtent, mapName);
     m_unpackedLayersGroups = true;
-	m_colorPalette = NULL;
+	// dont forget to reset the colorlist from our layers (std::list dtor clears the list)
+	if (m_colorPalette) delete m_colorPalette;
+	m_colorPalette = NULL;  // initialize to empty (lazy as its only used for 8bit color)
 }
 
-
 //////////////////////////////////////////////////////////////
 // Opens the resource using the specified resource service and resource identifier.
 //
@@ -647,19 +643,13 @@
 //
 MgMap::~MgMap()
 {
-	if (m_colorPalette != NULL) m_colorPalette->clear();  // clear the STL container
-    delete m_colorPalette;          // destroy the container
+	// dont forget to reset the colorlist from our layers (std::list dtor clears the list)
+	if (m_colorPalette) delete m_colorPalette;
 }
 
-
 //////////////////////////////////////////////////////////////
-void MgMap::Dispose()
-{
-	if (m_colorPalette != NULL) m_colorPalette->clear();  // is this enough cleanup?
-    delete this;
-}
+void MgMap::Dispose() {}
 
-
 //////////////////////////////////////////////////////////////////
 /// \brief
 /// Unpacks layers and groups from memory stream - lazy initialization
@@ -1117,7 +1107,7 @@
     }
 }
 
-//////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////
 // RFC60 ColorPalette Accessor uses lazy instantiation as its not used for truecolor tiles
 // used for the map colors collected from the stylization of the visible layers
 ColorStringList& MgMap::GetColorPalette()
@@ -1130,10 +1120,11 @@
     }
 	return *m_colorPalette;
 }
+////////////////////////////////////////////////////////////////////////
 /// RFC60 setter adds list and then sorts and prunes the map colorlist
 void MgMap::AddColorsToPalette(ColorStringList& newColorPalette)
 {
-    if (NULL == m_colorPalette) GetColorPalette();  // this reduces the number of sort operations
+    if (NULL == m_colorPalette) GetColorPalette();  // lazy instantiation
 
     if (!newColorPalette.empty())
 	{
@@ -1143,9 +1134,8 @@
             if (*it != L"")    // filter empty strings
             {   // uppercase the colorcodes (FFABDEFF) 
                 std::transform( (*it).begin(), (*it).end(), (*it).begin(), towupper);
+                m_colorPalette->push_back(*it);
             }
-            m_colorPalette->push_back(*it);
         }
 	}
 }
-

Modified: sandbox/rfc60/MgDev/Common/MapGuideCommon/Resources/mapguide_en.res
===================================================================
--- sandbox/rfc60/MgDev/Common/MapGuideCommon/Resources/mapguide_en.res	2009-12-22 07:37:23 UTC (rev 4461)
+++ sandbox/rfc60/MgDev/Common/MapGuideCommon/Resources/mapguide_en.res	2009-12-23 00:18:39 UTC (rev 4462)
@@ -309,6 +309,7 @@
 MgStringTooLong                                       = The string is too long.
 MgTagFieldNotFound                                    = The tag contained no fields.
 MgUnableToLockTileFile                                = Unable to lock the tile file.
+MgUnableToOpenLockFile																= Unable to open the tile lock file.
 MgUnableToOpenTileFile                                = Unable to open the tile file.
 MgUnsupportedService                                  = The site/resource services cannot be enabled/disabled.
 MgUserAndGroupNotEmpty                                = Both the user and group are not empty.

Modified: sandbox/rfc60/MgDev/Common/Renderers/AGGImageIO.cpp
===================================================================
--- sandbox/rfc60/MgDev/Common/Renderers/AGGImageIO.cpp	2009-12-22 07:37:23 UTC (rev 4461)
+++ sandbox/rfc60/MgDev/Common/Renderers/AGGImageIO.cpp	2009-12-23 00:18:39 UTC (rev 4462)
@@ -14,11 +14,11 @@
 //  License along with this library; if not, write to the Free Software
 //  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
-//#define _DEBUG_PNG8
-//#include "ace/OS.h"
+#define _DEBUG_PNG8
 #include "stdafx.h"
 #include "RendererStyles.h"
 #include "AGGImageIO.h"
+#include "AGGRenderer.h"
 #include "png.h"
 #include "RS_ByteData.h"
 #include "agg_context.h"
@@ -27,14 +27,22 @@
 //NOTE: We do not use gd for reading or writing PNG since internally gd drops a bit
 //from the alpha channel, which is not desirable for high quality output
 #include "GDUtils.h"
+
 #include <assert.h>
+
+#ifdef _DEBUG_PNG8
 #define myassert(COND,L,F) if (!(COND)){ printf ("(%d) failed assertion in %d %s", GetCurrentThreadId(), L,F); throw new exception();}
+#else
+#define myassert(COND,L,F) (COND)
+#endif
 
 //#include "smartalloc.h"
 #pragma warning(disable : 4611)
 
 enum MS_RETURN_VALUE {MS_SUCCESS, MS_FAILURE, MS_DONE};
 
+// in memory switch to permit disabling colormapping at runtime 
+// (could be in debug ifdefs but will be optimized away in release build anyway)
 static bool UseColorMap = true;
 
 struct png_write_context
@@ -862,9 +870,7 @@
         for (it = baseColorPalette->begin();it != baseColorPalette->end(); it++) 
         {
             gdImageColorAllocate(gdPPalette, (*it).red(), (*it).green(), (*it).blue());
-//            delete *it; // the RS_Color is on the heap and needs destruction
         }
-//        delete baseColorPalette;
     }
     myassert(gdImageTrueColor(gdPPalette) == 0,__LINE__, __WFILE__);		// result is not a 8-bit paletted image 
     return gdPPalette;  // this is an empty image with the right color palette
@@ -1008,10 +1014,6 @@
             gdImagePtr gdImgPalette = NULL;
             //  convert to 256 color paletted image for PNG8, GIF
             if (format == L"GIF" || format == L"PNG8") 
-            //{ //former GIF code
-            //  gdImageTrueColorToPalette(gdimg24, 0, 256);
-            //	gdImgPalette = gdimg24;
-            //}
             {	/// skip color quantization if no palette given or empty
                 if (baseColorPalette && !baseColorPalette->empty() && UseColorMap)  // memory based switch
                 {	

Modified: sandbox/rfc60/MgDev/Common/Renderers/AGGImageIO.h
===================================================================
--- sandbox/rfc60/MgDev/Common/Renderers/AGGImageIO.h	2009-12-22 07:37:23 UTC (rev 4461)
+++ sandbox/rfc60/MgDev/Common/Renderers/AGGImageIO.h	2009-12-23 00:18:39 UTC (rev 4462)
@@ -14,8 +14,7 @@
 //  License along with this library; if not, write to the Free Software
 //  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
-//#include "gd.h"
-#include "AGGRenderer.h"
+#include "gd.h"
 
 class RS_ByteData;
 class AGGImageIO

Modified: sandbox/rfc60/MgDev/Common/Renderers/AGGRenderer.cpp
===================================================================
--- sandbox/rfc60/MgDev/Common/Renderers/AGGRenderer.cpp	2009-12-22 07:37:23 UTC (rev 4461)
+++ sandbox/rfc60/MgDev/Common/Renderers/AGGRenderer.cpp	2009-12-23 00:18:39 UTC (rev 4462)
@@ -95,7 +95,7 @@
 bool AGGRenderer::s_bClampPoints    = false;
 bool AGGRenderer::s_bGeneralizeData = false;
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 // constructor that allows a backbuffer
 AGGRenderer::AGGRenderer(int width,
                          int height,
@@ -137,7 +137,7 @@
         m_labeler = new LabelRendererLocal(this, tileExtentOffset);
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 //default constructor
 AGGRenderer::AGGRenderer(int width,
                          int height,
@@ -191,7 +191,7 @@
         m_labeler = new LabelRendererLocal(this, tileExtentOffset);
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 AGGRenderer::~AGGRenderer()
 {
     delete m_context;
@@ -202,7 +202,7 @@
         delete[] m_rows;
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 void AGGRenderer::UpdateBackBuffer(int width, int height, unsigned int* backbuffer){
     if (m_bownbuffer)
         delete[] m_rows;
@@ -217,7 +217,7 @@
     m_context = new agg_context(m_rows, m_width, m_height);
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 unsigned int* AGGRenderer::GetBackBuffer(int &width, int& height)
 {
     width = m_width;
@@ -225,19 +225,19 @@
     return m_rows;
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 /// this one writes into a file not returning a ByteStream using default parameters for the W x H
 void AGGRenderer::Save(const RS_String& filename, const RS_String& format)
 {
     Save(filename, format, m_width, m_height);
 }
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 /// this one writes into a file not returning a ByteStream!!
 void AGGRenderer::Save(const RS_String& filename, const RS_String& format, int width, int height)
 {
     AGGImageIO::Save(filename, format, m_rows, m_width, m_height, width, height, m_bgcolor);
 }
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 /// return the rendered image passed in via the imagebuffer (m_rows) as a bytestream in the given image format
 /// using the provided colorPalette if given
 RS_ByteData* AGGRenderer::Save(const RS_String& format, int width, int height, 
@@ -245,13 +245,13 @@
 {
     return AGGImageIO::Save(format, m_rows, m_width, m_height, width, height, m_bgcolor, baseColorPalette);
 }
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 void AGGRenderer::Combine(const RS_String& fileIn1, const RS_String& fileIn2, const RS_String& fileOut)
 {
     AGGImageIO::Combine(fileIn1, fileIn2, fileOut);
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 void AGGRenderer::StartMap(RS_MapUIInfo* mapInfo,
                            RS_Bounds&    extents,
                            double        mapScale,
@@ -308,7 +308,7 @@
     InitFontEngine(this);
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 void AGGRenderer::EndMap()
 {
     // turn off selection mode so the labels draw normal
@@ -321,7 +321,7 @@
     m_mapInfo = NULL;
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 void AGGRenderer::StartLayer(RS_LayerUIInfo*      legendInfo,
                              RS_FeatureClassInfo* classInfo)
 {
@@ -330,7 +330,7 @@
     m_fcInfo = classInfo;
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 void AGGRenderer::EndLayer()
 {
     // clear the layer/feature info
@@ -338,7 +338,7 @@
     m_fcInfo = NULL;
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 void AGGRenderer::StartFeature(RS_FeatureReader* /*feature*/,
                                bool              /*initialPass*/,
                                const RS_String*  /*tooltip*/,
@@ -350,7 +350,7 @@
 {
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 void AGGRenderer::ProcessPolygon(LineBuffer* lb, RS_FillStyle& fill)
 {
     _ASSERT(NULL != lb);
@@ -494,7 +494,7 @@
     }
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 void AGGRenderer::ProcessPolyline(LineBuffer* lb, RS_LineStroke& lsym)
 {
     _ASSERT(NULL != lb);
@@ -603,7 +603,7 @@
     printf("      minx = %6.4f miny = %6.4f maxx = %6.4f maxy = %6.4f\n", ext.minx, ext.miny, ext.maxx, ext.maxy); \
     printf("      width = %6.4f height = %6.4f\n", ext.width(), ext.height());
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 void AGGRenderer::ProcessRaster(unsigned char* data,
                                 int length,
                                 RS_ImageFormat format,
@@ -633,7 +633,7 @@
     }
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 void AGGRenderer::ProcessMarker(LineBuffer* srclb, RS_MarkerDef& mdef, bool allowOverpost, RS_Bounds* bounds)
 {
     RS_MarkerDef use_mdef = mdef;
@@ -658,7 +658,7 @@
     }
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 void AGGRenderer::ProcessOneMarker(double x, double y, RS_MarkerDef& mdef, bool allowOverpost, RS_Bounds* bounds)
 {
     RS_InputStream* symbol = NULL;
@@ -1038,7 +1038,7 @@
     }
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 void AGGRenderer::ProcessLabelGroup(RS_LabelInfo*    labels,
                                     int              nlabels,
                                     const RS_String& text,
@@ -1055,74 +1055,74 @@
     m_labeler->ProcessLabelGroup(labels, nlabels, text, type, exclude, path, scaleLimit);
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 void AGGRenderer::SetSymbolManager(RS_SymbolManager* manager)
 {
     m_symbolManager = manager;
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 RS_MapUIInfo* AGGRenderer::GetMapInfo()
 {
     return m_mapInfo;
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 RS_LayerUIInfo* AGGRenderer::GetLayerInfo()
 {
     return m_layerInfo;
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 RS_FeatureClassInfo* AGGRenderer::GetFeatureClassInfo()
 {
     return m_fcInfo;
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 double AGGRenderer::GetMapScale()
 {
     return m_mapScale;
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 double AGGRenderer::GetDrawingScale()
 {
     return m_drawingScale;
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 RS_Bounds& AGGRenderer::GetBounds()
 {
     return m_extents;
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 double AGGRenderer::GetDpi()
 {
     return m_dpi;
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 double AGGRenderer::GetMetersPerUnit()
 {
     return m_metersPerUnit;
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 bool AGGRenderer::RequiresClipping()
 {
     return m_bRequiresClipping;
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 bool AGGRenderer::RequiresLabelClipping()
 {
     // always the same value as RequiresClipping
     return m_bRequiresClipping;
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 bool AGGRenderer::SupportsZ()
 {
     // Z values in feature geometry are ignored
@@ -1136,14 +1136,14 @@
     return false;
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 bool AGGRenderer::SupportsHyperlinks()
 {
     // set to false to disable processing of hyperlinks
     return false;
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 bool AGGRenderer::UseLocalOverposting()
 {
     return m_bLocalOverposting;
@@ -1355,13 +1355,13 @@
     return number * scale_factor;
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 void AGGRenderer::SetRenderSelectionMode(bool mode)
 {
     SetRenderSelectionMode(mode, 0x0000FF00);
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 void AGGRenderer::SetRenderSelectionMode(bool mode, int rgba)
 {
     SE_Renderer::SetRenderSelectionMode(mode, rgba);
@@ -1382,7 +1382,7 @@
 // Text drawing
 //////////////////////////////////////////////////////////////////////////////
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 void AGGRenderer::DrawString(const RS_String& s,
                              double           x,
                              double           y,
@@ -1398,7 +1398,7 @@
     DrawString(c(), sConv, x, y, width, height, font, color, angleRad);
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 void AGGRenderer::DrawString(agg_context*     cxt,
                              const RS_String& s,
                              double           x,
@@ -1757,7 +1757,7 @@
     }
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 // Called when applying a line style on a feature geometry.  Line styles can
 // only be applied to linestring and polygon feature geometry types.
 void AGGRenderer::ProcessLine(SE_ApplyContext* ctx, SE_RenderLineStyle* style)
@@ -1840,7 +1840,7 @@
         LineBufferPool::FreeLineBuffer(m_pPool, spLB.release());
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 void AGGRenderer::_TransferPoints(agg_context* c, LineBuffer* srcLB, const SE_Matrix* xform, unsigned int* pathids, bool isPolygon)
 {
     if (s_bClampPoints)
@@ -1945,7 +1945,7 @@
     }
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 void AGGRenderer::_TransferPointsClamped(agg_context* c, LineBuffer* srcLB, const SE_Matrix* xform, unsigned int* pathids, bool isPolygon)
 {
     c->ps.remove_all();
@@ -2095,7 +2095,7 @@
     DrawScreenPolyline(c(), srclb, xform, lineStroke);
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 // copied from WritePolylines, except it doesn't do to screen transform - we should refactor
 void AGGRenderer::DrawScreenPolyline(agg_context* c, LineBuffer* srclb, const SE_Matrix* xform, const SE_LineStroke& lineStroke)
 {
@@ -2169,13 +2169,13 @@
     c->ras.filling_rule(agg::fill_even_odd);
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 void AGGRenderer::DrawScreenPolygon(LineBuffer* polygon, const SE_Matrix* xform, unsigned int color)
 {
     DrawScreenPolygon(c(), polygon, xform, color);
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 void AGGRenderer::DrawScreenPolygon(agg_context* c, LineBuffer* polygon, const SE_Matrix* xform, unsigned int color)
 {
     if ((color & 0xFF000000) == 0)
@@ -2203,59 +2203,59 @@
     }
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 bool AGGRenderer::YPointsUp()
 {
     return true;
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 void AGGRenderer::GetWorldToScreenTransform(SE_Matrix& xform)
 {
     xform = m_xform;
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 void AGGRenderer::SetWorldToScreenTransform(SE_Matrix& xform)
 {
     m_xform = xform;
     m_xform.inverse(m_ixform);
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 void AGGRenderer::WorldToScreenPoint(double& inx, double& iny, double& ox, double& oy)
 {
     m_xform.transform(inx, iny, ox, oy);
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 void AGGRenderer::ScreenToWorldPoint(double& inx, double& iny, double& ox, double& oy)
 {
     m_ixform.transform(inx, iny, ox, oy);
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 // returns number of pixels per millimeter device
 double AGGRenderer::GetScreenUnitsPerMillimeterDevice()
 {
     return m_dpi / MILLIMETERS_PER_INCH;
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 // returns number of pixels per millimeter world
 double AGGRenderer::GetScreenUnitsPerMillimeterWorld()
 {
     return m_dpi / MILLIMETERS_PER_INCH / m_mapScale;
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 // screen units are pixels
 double AGGRenderer::GetScreenUnitsPerPixel()
 {
     return 1.0;
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 RS_FontEngine* AGGRenderer::GetRSFontEngine()
 {
     return this;
@@ -2267,7 +2267,7 @@
     m_labeler->AddExclusionRegion(fpts, npts);
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 // labeling - this is the entry API for adding SE labels
 // to the label mananger
 void AGGRenderer::ProcessSELabelGroup(SE_LabelInfo*   labels,
@@ -2284,7 +2284,7 @@
     m_labeler->ProcessLabelGroup(labels, nlabels, type, exclude, path);
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 void AGGRenderer::DrawScreenRaster(unsigned char* data, int length,
                                    RS_ImageFormat format, int native_width, int native_height,
                                    double x, double y, double w, double h, double angledeg)
@@ -2292,7 +2292,7 @@
     DrawScreenRaster(c(), data, length, format, native_width, native_height, x, y, w, h, angledeg);
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 
 void AGGRenderer::DrawScreenRaster(agg_context* cxt, unsigned char* data, int length,
                                    RS_ImageFormat format, int native_width, int native_height,
@@ -2378,7 +2378,7 @@
     RenderWithTransform(src, cxt, img_mtx, format);
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 void AGGRenderer::DrawScreenRasterTransform(agg_context* cxt, unsigned char* data, int length,
                                             RS_ImageFormat format, int native_width, int native_height,
                                             double x, double y, double w, double h,
@@ -2436,7 +2436,7 @@
 #endif
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 // Renders the mesh rectangle defined by the point mappings at the four supplied mesh indices
 void AGGRenderer::RenderTransformMeshRectangle(mg_rendering_buffer& src, agg_context* cxt,
                                                RS_ImageFormat format, TransformMesh* transformMesh,
@@ -2459,7 +2459,7 @@
         mesh_pt_ur.pt_dest, mesh_pt_ul.pt_dest, mesh_pt_ll.pt_dest);
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 // Renders the triangle in the source image defined by the three source points into
 // the triangle in the supplied context defined by the three destination points.
 void AGGRenderer::RenderTransformedTriangle(mg_rendering_buffer& src, agg_context* cxt, RS_ImageFormat format,
@@ -2487,7 +2487,7 @@
     RenderWithTransform(src, cxt, img_mtx, format, false);
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 // Renders the source image to the destination context, using the specified
 // affine transformation matrix.
 void AGGRenderer::RenderWithTransform(mg_rendering_buffer& src, agg_context* cxt,
@@ -2596,7 +2596,7 @@
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 // Inserts the contents of a given DWF input stream into the current
 // output W2D.  The given coord sys transformation is applied and geometry
 // will be clipped to the RS_Bounds context of the DWFRenderer.
@@ -2721,7 +2721,7 @@
     }
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 void AGGRenderer::AddW2DContent(RS_InputStream* in, CSysTransformer* xformer, const RS_String& w2dfilter)
 {
     WT_Result result;
@@ -2762,7 +2762,7 @@
         m_imw2d = NULL;
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 void AGGRenderer::SetActions(WT_File& file)
 {
     file.set_stream_open_action (agr_open);
@@ -2843,7 +2843,7 @@
     file.set_gouraud_polyline_action(agr_process_gouraudPolyline);
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 // Given an array of points in W2D logical coordinates, this function:
 // 1. Transforms W2D logical coords into their model space using the
 //    W2D file's units structure
@@ -2851,7 +2851,7 @@
 //    map's space
 // 3. Optionally clips the resulting points to the user-requested
 //    data extent of the destination map
-// 4. Transforms clipped points to destination W2D space
+// 4. Transforms clipped points to destination W2D space 
 // 5. Returns a pointer to an array of W2D points with the
 //    total number of output points returned in outNumpts.
 //    If the clipping process of a polyline or polygon resulted
@@ -2966,7 +2966,7 @@
     return spLB.release();
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 // This function scales a W2D space related value from source W2D space
 // to destination.  Since the source W2D file can fit into a small piece
 // of the destination DWF or be much larger, we need to take that scaling
@@ -2997,7 +2997,7 @@
     return dDstSpace;
 }
 
-///-----------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 void AGGRenderer::UpdateSymbolTrans(WT_File& /*file*/, WT_Viewport& viewport)
 {
     _ASSERT(m_xformer);

Modified: sandbox/rfc60/MgDev/Common/Stylization/DefaultStylizer.h
===================================================================
--- sandbox/rfc60/MgDev/Common/Stylization/DefaultStylizer.h	2009-12-22 07:37:23 UTC (rev 4461)
+++ sandbox/rfc60/MgDev/Common/Stylization/DefaultStylizer.h	2009-12-23 00:18:39 UTC (rev 4462)
@@ -25,10 +25,10 @@
 class StylizationEngine;
 class SE_SymbolManager;
 
-//-----------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 // Stylizer used for all types of layers which do not have special
 // Stylizer implementation, which is currently all of them.
-//-----------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 class DefaultStylizer : public Stylizer
 {
 public:

Modified: sandbox/rfc60/MgDev/Common/Stylization/RendererStyles.h
===================================================================
--- sandbox/rfc60/MgDev/Common/Stylization/RendererStyles.h	2009-12-22 07:37:23 UTC (rev 4461)
+++ sandbox/rfc60/MgDev/Common/Stylization/RendererStyles.h	2009-12-23 00:18:39 UTC (rev 4462)
@@ -237,10 +237,6 @@
 /// RFC60 list of colors used to for color quantization
 typedef std::vector<RS_Color>RS_ColorVector;
 
-typedef struct gdImageStruct gdImage;
-typedef gdImage *gdImagePtr;
-
-
 //////////////////////////////////////////////////////////////////////////////
 class RS_LineStroke
 {

Modified: sandbox/rfc60/MgDev/Server/src/Common/Manager/Makefile.am
===================================================================
--- sandbox/rfc60/MgDev/Server/src/Common/Manager/Makefile.am	2009-12-22 07:37:23 UTC (rev 4461)
+++ sandbox/rfc60/MgDev/Server/src/Common/Manager/Makefile.am	2009-12-23 00:18:39 UTC (rev 4462)
@@ -9,15 +9,13 @@
   -I$(map_fdo_include) \
   -I../../../../Oem/dbxml-2.3.10/xerces-c-src/src \
   -I../../../../Common \
+  -I../../../../Common/Security \
   -I../../../../Common/Foundation \
   -I../../../../Common/Geometry \
   -I../../../../Common/MapGuideCommon \
+  -I../../../../Common/PlatformBase \
   -I../../../../Common/MdfModel \
   -I../../../../Common/MdfParser \
-  -I../../../../Common/PlatformBase \
-  -I../../../../Common/Renderers \
-  -I../../../../Common/Security \
-  -I../../../../Common/Stylization \
   -I../../Services/Drawing \
   -I../../Services/Feature \
   -I../../Services/Kml \

Modified: sandbox/rfc60/MgDev/Server/src/Common/Manager/ServerManager.vcproj
===================================================================
--- sandbox/rfc60/MgDev/Server/src/Common/Manager/ServerManager.vcproj	2009-12-22 07:37:23 UTC (rev 4461)
+++ sandbox/rfc60/MgDev/Server/src/Common/Manager/ServerManager.vcproj	2009-12-23 00:18:39 UTC (rev 4462)
@@ -44,7 +44,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="0"
-				AdditionalIncludeDirectories="..;..\..\..\..\Common;..\..\..\..\Common\Foundation;..\..\..\..\Common\PlatformBase;..\..\..\..\Common\MapGuideCommon;..\..\..\..\Common\Geometry;..\..\..\..\Common\MdfModel;..\..\..\..\Common\MdfParser;..\..\..\..\Common\Security;..\..\..\..\Common\Renderers;..\..\..\..\Common\Stylization;..\..\Common\Cache;..\..\Common\Thread;..\..\Services\Drawing;..\..\Services\Feature;..\..\Services\Kml;..\..\Services\Mapping;..\..\Services\Rendering;..\..\Services\Resource;..\..\Services\ServerAdmin;..\..\Services\Site;..\..\Services\Tile;..\..\..\..\Oem\ACE\ACE_wrappers;&quot;..\..\..\..\Oem\dbxml-2.3.10\xerces-c-src\src&quot;;..\..\..\..\Oem\FDO\inc;..\..\..\..\Oem\FDO\Inc\ExpressionEngine"
+				AdditionalIncludeDirectories="..;..\..\..\..\Common;..\..\..\..\Common\Foundation;..\..\..\..\Common\PlatformBase;..\..\..\..\Common\MapGuideCommon;..\..\..\..\Common\Geometry;..\..\..\..\Common\MdfModel;..\..\..\..\Common\MdfParser;..\..\..\..\Common\Security;..\..\Common\Cache;..\..\Common\Thread;..\..\Services\Drawing;..\..\Services\Feature;..\..\Services\Kml;..\..\Services\Mapping;..\..\Services\Rendering;..\..\Services\Resource;..\..\Services\ServerAdmin;..\..\Services\Site;..\..\Services\Tile;..\..\..\..\Oem\ACE\ACE_wrappers;..\..\..\..\Oem\dbxml-2.3.10\xerces-c-src\src;..\..\..\..\Oem\FDO\inc"
 				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;MG_SERVER_MANAGER_EXPORTS"
 				MinimalRebuild="true"
 				ExceptionHandling="2"
@@ -207,7 +207,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="2"
-				AdditionalIncludeDirectories="..;..\..\..\..\Common;..\..\..\..\Common\Foundation;..\..\..\..\Common\PlatformBase;..\..\..\..\Common\MapGuideCommon;..\..\..\..\Common\Geometry;..\..\..\..\Common\MdfModel;..\..\..\..\Common\MdfParser;..\..\..\..\Common\Security;..\..\..\..\Common\Renderers;..\..\..\..\Common\Stylization;..\..\Common\Cache;..\..\Common\Thread;..\..\Services\Drawing;..\..\Services\Feature;..\..\Services\Kml;..\..\Services\Mapping;..\..\Services\Rendering;..\..\Services\Resource;..\..\Services\ServerAdmin;..\..\Services\Site;..\..\Services\Tile;..\..\..\..\Oem\ACE\ACE_wrappers;&quot;..\..\..\..\Oem\dbxml-2.3.10\xerces-c-src\src&quot;;..\..\..\..\Oem\FDO\inc"
+				AdditionalIncludeDirectories="..;..\..\..\..\Common;..\..\..\..\Common\Foundation;..\..\..\..\Common\PlatformBase;..\..\..\..\Common\MapGuideCommon;..\..\..\..\Common\Geometry;..\..\..\..\Common\MdfModel;..\..\..\..\Common\MdfParser;..\..\..\..\Common\Security;..\..\Common\Cache;..\..\Common\Thread;..\..\Services\Drawing;..\..\Services\Feature;..\..\Services\Kml;..\..\Services\Mapping;..\..\Services\Rendering;..\..\Services\Resource;..\..\Services\ServerAdmin;..\..\Services\Site;..\..\Services\Tile;..\..\..\..\Oem\ACE\ACE_wrappers;..\..\..\..\Oem\dbxml-2.3.10\xerces-c-src\src;..\..\..\..\Oem\FDO\inc"
 				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;MG_SERVER_MANAGER_EXPORTS"
 				ExceptionHandling="2"
 				RuntimeLibrary="2"

Modified: sandbox/rfc60/MgDev/Server/src/Services/Kml/ServerKmlService.cpp
===================================================================
--- sandbox/rfc60/MgDev/Server/src/Services/Kml/ServerKmlService.cpp	2009-12-22 07:37:23 UTC (rev 4461)
+++ sandbox/rfc60/MgDev/Server/src/Services/Kml/ServerKmlService.cpp	2009-12-23 00:18:39 UTC (rev 4462)
@@ -15,6 +15,7 @@
 //  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
 
+#include "RendererStyles.h"
 #include "MapGuideCommon.h"
 #include "ServerKmlService.h"
 #include "Services/KmlDefs.h"

Modified: sandbox/rfc60/MgDev/Server/src/Services/Mapping/MappingUtil.cpp
===================================================================
--- sandbox/rfc60/MgDev/Server/src/Services/Mapping/MappingUtil.cpp	2009-12-22 07:37:23 UTC (rev 4461)
+++ sandbox/rfc60/MgDev/Server/src/Services/Mapping/MappingUtil.cpp	2009-12-23 00:18:39 UTC (rev 4462)
@@ -21,7 +21,6 @@
 #include "Bounds.h"
 #include "DefaultStylizer.h"
 #include "Fdo.h"
-#include "Map.h"
 #include "Renderer.h"
 #include "SAX2Parser.h"
 #include "SEMgSymbolManager.h"
@@ -40,8 +39,6 @@
 #include "LogManager.h"
 #include "LogDetail.h"
 
-#define myassert(COND,L,F) if (!(COND)){ printf ("(%d) failed assertion in %d %s", GetCurrentThreadId(), L,F); throw new exception();}
-
 #ifndef _WIN32
 #define _wcsnicmp wcsncasecmp
 
@@ -556,7 +553,7 @@
 
                     // create the reader we'll use
                     rsReader = ExecuteFeatureQuery(svcFeature, extent, vl, overrideFilter.c_str(), dstCs, layerCs, item);
-                    // create an autoPtr around the reader
+                    // create an automatic FdoPtr around the reader
                     FdoPtr<FdoIFeatureReader> fdoReader = (NULL == rsReader) ? NULL : rsReader->GetInternalReader();
 
                     #ifdef _DEBUG
@@ -569,15 +566,17 @@
                         dr->StartLayer(&layerInfo, &fcinfo);
                         ds->StylizeVectorLayer(vl, dr, rsReader, xformer, scale, NULL, NULL);
                         dr->EndLayer();
-                        #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)
+                        {
+                            #ifdef _DEBUG
+                            printf("  StylizeLayers() //ExtractColors// -Vector- Name:%S  Time:%6.4f (s)\n\n", (mapLayer->GetName()).c_str(), (GetTickCount()-dwLayerStart)/1000.0);
+                            #endif
                             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
+                            #ifdef _DEBUG
+                            printf("  StylizeLayers() ##ExtractColors## -Vector- Name:%S  Time:%6.4f (s)\n\n", (mapLayer->GetName()).c_str(), (GetTickCount()-dwLayerStart)/1000.0);
+                            #endif
+                        }
 
                    }
                 }
@@ -840,7 +839,7 @@
             err += L"\n";
             ACE_DEBUG( (LM_DEBUG, err.c_str()) );
 #endif
-            /// this exception can be thrown or not depending on a serverconfig setting
+            /// TODO could throw here depending on a serverconfig setting (RFC64)
             // throw exception;
         } // if exception
     } // for all layers
@@ -1241,12 +1240,14 @@
             Label* label = rule->GetLabel();
             // the legend label is just a string
             // const MdfString& legendLabel = rule->GetLegendLabel();
-
-            // add colors of txtsymbols
-            TextSymbol* txtsym = label->GetSymbol();
-            if (txtsym) {
-                usedColorList.push_back(txtsym->GetForegroundColor().substr());
-                usedColorList.push_back(txtsym->GetBackgroundColor().substr());
+            if (label)
+            {
+                // add colors of txtsymbols
+                TextSymbol* txtsym = label->GetSymbol();
+                if (txtsym) {
+                    usedColorList.push_back(txtsym->GetForegroundColor().substr());
+                    usedColorList.push_back(txtsym->GetBackgroundColor().substr());
+                }
             }
             // do the casting to access the relevant members
             // this is bad style (instead of using the visitor pattern of the Mdfmodel)
@@ -1260,12 +1261,12 @@
             if (paRule != NULL)
             {					
                 AreaSymbolization2D* pasym = paRule->GetSymbolization();
-                if (pasym->GetFill() != NULL) 
+                if (pasym && pasym->GetFill() != NULL) 
                 {	// create copies of all strings!!! so we can safely delete the resulting list later
                     usedColorList.push_back(pasym->GetFill()->GetForegroundColor().substr());
                     usedColorList.push_back(pasym->GetFill()->GetBackgroundColor().substr());
                 }
-                if (pasym->GetEdge() != NULL) 
+                if (pasym && pasym->GetEdge() != NULL) 
                     usedColorList.push_back(pasym->GetEdge()->GetColor().substr());
             }
 
@@ -1365,9 +1366,9 @@
         ColorStringList vLayerColors;
         // parse the scalerange
         GetUsedColorsFromScaleRange(vLayerColors, scaleRange, sman);
-        if (!vLayerColors.empty())
-            map->AddColorsToPalette(vLayerColors); // the property setter canonicalizes the palette
-    } catch (exception e) {
+        map->AddColorsToPalette(vLayerColors); // the property setter canonicalizes the palette
+    } catch (exception e) 
+    {
         ACE_DEBUG((LM_DEBUG, L"(%t) %w caught in MappingUtil.ExtractColors\n", e.what()));
         throw e;
     }
@@ -1382,13 +1383,15 @@
     {
     public:
         ColorStringList* colorList;
-        void VisitPath (Path& path){
+        void VisitPath (Path& path)
+        {
             colorList->push_back(path.GetLineColor().substr());
             colorList->push_back(path.GetFillColor().substr());                       
         };
         void VisitImage(Image& image){};
         void VisitText (Text& text){};
     } visitor;
+    /// TODO other visitors for for VisitImage and VisitText to be added here on a needed basis
     if (symdef)
     {
         MdfModel::LineUsage* lineUsage = symdef->GetLineUsage();
@@ -1436,3 +1439,33 @@
     FindColorInSymDefHelper(colorList, dynamic_cast<MdfModel::SimpleSymbolDefinition*>(symdef));
     FindColorInSymDefHelper(colorList, dynamic_cast<MdfModel::CompoundSymbolDefinition*>(symdef));
 }
+
+//////////////////////////////////////////////////////////////////////////////////////////
+//-------------------------------------------------------
+/// 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>
+//// PRSCOLORLIST tileColorPalette = new RSCOLORLIST();
+/// 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. 
+void MgMappingUtil::ParseColorStrings (RS_ColorVector* tileColorPalette, MgMap* map)
+{
+    assert(tileColorPalette);
+    assert(map);
+    ColorStringList& mapColorList = map->GetColorPalette(); // sorted and uniquified
+    if (!mapColorList.empty()) // add them if they are available
+    {
+        ColorStringList::iterator it = mapColorList.begin();
+        for(; it != mapColorList.end(); it++)
+        {
+            // string color reader for 0xAARRGGBB   "%10X" XML color strings
+            // this is parsed and converted using the MgColor(string) ctor which also uses rgba order
+            // but it* is in argb order ergo => r=a, g=r, b=g, a=b
+            MgColor c(*it); 
+            // set the RS_Color(r,g,b,a) assign the crossed over colors
+            tileColorPalette->push_back(RS_Color(c.GetGreen(), c.GetBlue(), c.GetAlpha(), c.GetRed()));		
+        }
+    }
+}

Modified: sandbox/rfc60/MgDev/Server/src/Services/Mapping/MappingUtil.h
===================================================================
--- sandbox/rfc60/MgDev/Server/src/Services/Mapping/MappingUtil.h	2009-12-22 07:37:23 UTC (rev 4461)
+++ sandbox/rfc60/MgDev/Server/src/Services/Mapping/MappingUtil.h	2009-12-23 00:18:39 UTC (rev 4462)
@@ -36,9 +36,11 @@
 class RSMgFeatureReader;
 class TransformCache;
 class SE_SymbolManager;
-namespace MdfModel {
+namespace MdfModel 
+{
     class SymbolDefinition;
     class CompoundSymbolDefinition;
+    class SimpleSymbolDefinition;
 }
 
 //Common stylization utility code -- used by both the mapping and rendering services
@@ -97,6 +99,12 @@
     static void FindColorInSymDefHelper(ColorStringList& colorList, MdfModel::CompoundSymbolDefinition* symdef);
     static void FindColorInSymDefHelper(ColorStringList& colorList, MdfModel::SimpleSymbolDefinition* symdef);
 
+    /// parse the expressions collected from xml definitions of all layer.
+	/// 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.
+    /// the color Palette passed to the renderer is a std::list<RSColor>
+    static void ParseColorStrings (RS_ColorVector* tileColorPalette, MgMap* map);
+
 };
 
 #endif

Modified: sandbox/rfc60/MgDev/Server/src/Services/Mapping/ServerMappingService.vcproj
===================================================================
--- sandbox/rfc60/MgDev/Server/src/Services/Mapping/ServerMappingService.vcproj	2009-12-22 07:37:23 UTC (rev 4461)
+++ sandbox/rfc60/MgDev/Server/src/Services/Mapping/ServerMappingService.vcproj	2009-12-23 00:18:39 UTC (rev 4462)
@@ -44,7 +44,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="0"
-				AdditionalIncludeDirectories="..\..\Common;..\..\Common\Base;..\..\Common\Manager;..\Feature;..\..\..\..\Common\Foundation;..\..\..\..\Common\Geometry;..\..\..\..\Common\PlatformBase;..\..\..\..\Common\MapGuideCommon;..\..\..\..\Common\MapGuideCommon\MapLayer;..\..\..\..\Common\MdfModel;..\..\..\..\Common\MdfParser;..\..\..\..\Common\Renderers;..\..\..\..\Common\Stylization;..\..\..\..\Oem\ACE\ACE_wrappers;&quot;..\..\..\..\Oem\dbxml-2.3.10\xerces-c-src\src&quot;;..\..\..\..\Oem\FDO\inc;..\..\..\..\Oem\FDO\inc\ExpressionEngine;..\..\Gws\Include"
+				AdditionalIncludeDirectories="..\..\Common;..\..\Common\Base;..\..\Common\Manager;..\Feature;..\..\..\..\Common\Foundation;..\..\..\..\Common\Geometry;..\..\..\..\Common\PlatformBase;..\..\..\..\Common\MapGuideCommon;..\..\..\..\Common\MdfModel;..\..\..\..\Common\MdfParser;..\..\..\..\Common\Renderers;..\..\..\..\Common\Stylization;..\..\..\..\Oem\ACE\ACE_wrappers;..\..\..\..\Oem\dbxml-2.3.10\xerces-c-src\src;..\..\..\..\Oem\FDO\inc;..\..\..\..\Oem\FDO\inc\ExpressionEngine;..\..\Gws\Include"
 				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;MG_SERVER_MAPPING_EXPORTS"
 				MinimalRebuild="true"
 				ExceptionHandling="2"

Modified: sandbox/rfc60/MgDev/Server/src/Services/Rendering/ServerRenderingService.cpp
===================================================================
--- sandbox/rfc60/MgDev/Server/src/Services/Rendering/ServerRenderingService.cpp	2009-12-22 07:37:23 UTC (rev 4461)
+++ sandbox/rfc60/MgDev/Server/src/Services/Rendering/ServerRenderingService.cpp	2009-12-23 00:18:39 UTC (rev 4462)
@@ -36,8 +36,10 @@
 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"; }
+inline bool hasColorMap (STRING format) \
+    { \
+        return format == L"PNG8" || format == L"GIF"; \
+    }
 
 IMPLEMENT_CREATE_SERVICE(MgServerRenderingService)
 //////////////////////////////////////////////////////////////////////////////////////////
@@ -515,6 +517,7 @@
 
     return ret.Detach();
 }
+
 //////////////////////////////////////////////////////////////////////////////////////////
 /// default argument bKeepSelection = true
 MgByteReader* MgServerRenderingService::RenderMap(MgMap* map,
@@ -543,7 +546,8 @@
 {
     return RenderMap(map, selection, center, scale, width, height, backgroundColor, format, bKeepSelection, false);
 }
-///-------------------------------------------------------------------------
+
+//////////////////////////////////////////////////////////////////////////////////////////
 /// render map around center point in given scale
 /// (default args bKeepSelection = true, bClip = false, backgroundColor = map->backgroundColor, width = map->getDisplayWidth, height = map->getDisplayHeight)
 MgByteReader* MgServerRenderingService::RenderMap(MgMap* map,
@@ -746,6 +750,7 @@
 
     return ret.Detach();
 }
+
 //////////////////////////////////////////////////////////////////////////////////////////
 /// pack options into object and forward call (select Selection AND Layers) maybe keepSelection
 /// called by RenderTile
@@ -906,16 +911,9 @@
         }
     MG_CATCH(L"MgServerRenderingService.RenderMapInternal-StylizeLayers")
 
-    dr->EndMap();   // cleanup??
+    dr->EndMap();   // cleanup of DWF Renderer
 
-#ifdef _DEBUG
-    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.
-    }
-#endif
-
+    MG_THROW()  // to skip a faulty tile we need to rethrow the exception which could be thrown in StylizeLayers
 /*
     //-------------------------------------------------------
     // draw a border around the tile - used for debugging
@@ -941,38 +939,32 @@
 
     // get a byte representation of the image
     auto_ptr<RS_ByteData> data;
-/////////////////////////////////////////////////////////////////////////////////////////////////
-	/// rfc60 code to correct colormaps by UV
-/////////////////////////////////////////////////////////////////////////////////////////////////
-	/// we examine the expressions collected from xml definitions of all layer.
-	/// the map object has a list from all color entries found in the most recent Layerstylization
+    /////////////////////////////////////////////////////////////////////////////////////////////////
+    /// rfc60 code to correct colormaps by UV
+    /////////////////////////////////////////////////////////////////////////////////////////////////
+    /// we examine the expressions collected from xml definitions of all layer.
+    /// 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. 
+    /// adding expresssions and other interpretations should be done in ParseColorStrings. 
     /// the color Palette for the renderer is a list<RSColor>
-   RS_ColorVector* tileColorPalette;
-	try {
-		//  call the image renderer to create the image ----------------------------------------
+    RS_ColorVector* tileColorPalette = NULL;
+    try {
+        //  call the image renderer to create the image ----------------------------------------
         if (wcscmp(m_rendererName.c_str(), L"AGG") == 0  && hasColorMap(format))   
         {    
             tileColorPalette = new RS_ColorVector();
-            ParseColorStrings (tileColorPalette, map);
-		    #ifdef _DEBUG_PNG8
-		    printf("<<<<<<<<<<<<<<<<<<<<< MgServerRenderingService::ColorPalette->size(): %d\n", mapColorPalette->size());
-		    #endif
-			data.reset(((AGGRenderer*)dr)->Save(format, saveWidth, saveHeight, tileColorPalette));
+            MgMappingUtil::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
-			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
-        {
-            //RS_ColorVector::iterator it;
-            //for (it = tileColorPalette->begin();it != tileColorPalette->end(); it++) 
-            //    delete *it; // the RS_Color is on the heap and needs destruction
-            delete tileColorPalette;
-        }
+            data.reset(((GDRenderer*)dr)->Save(format, saveWidth, saveHeight));
+    } catch (exception e) 
+    {
         ACE_DEBUG((LM_DEBUG, L"(%t) %w caught in RenderingService ColorPaletteGeneration\n", e.what()));
-		throw e;
-	}
+        throw e;
+    }
     if (NULL != data.get())
     {
         // put this into a byte source
@@ -989,43 +981,13 @@
 
         ret = bs->GetReader();
     }
-	else throw new MgNullArgumentException(L"RenderMapInternal", __LINE__, __WFILE__, NULL, L"No data from Renderer", NULL);
+    else 
+        throw new MgStylizeLayerFailedException(L"RenderMapInternal", __LINE__, __WFILE__, NULL, L"No data from Renderer", NULL);
 
     return ret.Detach();
 }
+
 //////////////////////////////////////////////////////////////////////////////////////////
-//-------------------------------------------------------
-/// 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>
-//// PRSCOLORLIST tileColorPalette = new RSCOLORLIST();
-/// 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. 
-void MgServerRenderingService::ParseColorStrings (RS_ColorVector* tileColorPalette, MgMap* map)
-{
-    assert(tileColorPalette);
-    assert(map);
-    ColorStringList& mapColorList = map->GetColorPalette();
-    if (!mapColorList.empty()) // add them if they are available
-    {
-        // lets sort & uniquify the list
-        mapColorList.sort();
-        mapColorList.unique();
-        ColorStringList::iterator it = mapColorList.begin();
-        for(; it != mapColorList.end(); it++)
-        {
-            // string color reader for 0xAARRGGBB   "%10X" XML color strings
-            // this is parsed and converted using the MgColor(string) ctor which also uses rgba order
-            // but it* is in argb order ergo => r=a, g=r, b=g, a=b
-            MgColor c(*it); 
-            // set the RS_Color(r,g,b,a) assign the crossed over colors
-            tileColorPalette->push_back(RS_Color(c.GetGreen(), c.GetBlue(), c.GetAlpha(), c.GetRed()));		
-        }
-    }
-}
-//////////////////////////////////////////////////////////////////////////////////////////
 MgByteReader* MgServerRenderingService::RenderMapLegend(MgMap* map,
                                                         INT32 width,
                                                         INT32 height,

Modified: sandbox/rfc60/MgDev/Server/src/Services/Rendering/ServerRenderingService.h
===================================================================
--- sandbox/rfc60/MgDev/Server/src/Services/Rendering/ServerRenderingService.h	2009-12-22 07:37:23 UTC (rev 4461)
+++ sandbox/rfc60/MgDev/Server/src/Services/Rendering/ServerRenderingService.h	2009-12-23 00:18:39 UTC (rev 4462)
@@ -18,7 +18,6 @@
 #ifndef MGSERVERRENDERINGSERVICE_H
 #define MGSERVERRENDERINGSERVICE_H
 
-#include "AGGRenderer.h"
 #include "ServerRenderingDllExport.h"
 
 class SE_Renderer;
@@ -204,11 +203,6 @@
                                 bool requiresClipping,
                                 bool localOverposting = false,
                                 double tileExtentOffset = 0.0);
-	/// parse the expressions collected from xml definitions of all layer.
-	/// 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.
-    /// the color Palette passed to the renderer is a std::list<RSColor>
-    void ParseColorStrings (RS_ColorVector* tileColorPalette, MgMap* map);
 
     // member data
     Ptr<MgFeatureService> m_svcFeature;

Modified: sandbox/rfc60/MgDev/Server/src/Services/Tile/ServerTileService.cpp
===================================================================
--- sandbox/rfc60/MgDev/Server/src/Services/Tile/ServerTileService.cpp	2009-12-22 07:37:23 UTC (rev 4461)
+++ sandbox/rfc60/MgDev/Server/src/Services/Tile/ServerTileService.cpp	2009-12-23 00:18:39 UTC (rev 4462)
@@ -116,7 +116,8 @@
 
     return found;
 }
-///--------------------------------------------------------------------
+
+//////////////////////////////////////////////////////////////////////////////////////////
 /// create tilename from mapDefinition, scaleIndex, row&col 
 /// remove lockfile, look for the tile in the cache, 
 /// if not in cache create lockfile and look for map in mapcache
@@ -211,7 +212,6 @@
             {
                 MgStringCollection arguments;
                 arguments.Add(lockPathname);
-                                    // MgUnableToOpenTileFile???? sounds wrong.... lock file maybe?
                 throw new MgFileIoException(L"MgServerTileService.GetTile",
                     __LINE__, __WFILE__, &arguments, L"MgUnableToOpenLockFile", NULL);
             }
@@ -224,7 +224,6 @@
             if (sm_mapCache.end() != iter)
             {
                 cachedMap = SAFE_ADDREF((*iter).second);
-                /// refactored from below
                 cachedMap->Rewind();
                 Ptr<MgStream> stream = new MgStream(cachedMap);
                 map = new MgMap();
@@ -246,14 +245,6 @@
                 sm_mapCache[mapString] = SAFE_ADDREF((MgMemoryStreamHelper*)cachedMap);
             }
 
-            //if (!map)     
-            //{
-            //    cachedMap->Rewind();
-            //    Ptr<MgStream> stream = new MgStream(cachedMap);
-            //    map = new MgMap();
-            //    map->Deserialize(stream);
-            //}
-
         }   // end of mutex scope
 
         double scale = map->GetFiniteDisplayScaleAt(scaleIndex);
@@ -275,7 +266,8 @@
 
     return ret.Detach();
 }
-///---------------------------------------------------------------------------------------
+
+//////////////////////////////////////////////////////////////////////////////////////////
 /// look for the tile in the tilecache first
 MgByteReader* MgServerTileService::GetTile(MgMap* map,
                                            CREFSTRING baseMapLayerGroupName,
@@ -355,7 +347,7 @@
                 arguments.Add(lockPathname);
 
                 throw new MgFileIoException(L"MgServerTileService.GetTile",
-                    __LINE__, __WFILE__, &arguments, L"MgUnableToOpenTileFile", NULL);
+                    __LINE__, __WFILE__, &arguments, L"MgUnableToOpenLockFile", NULL);
             }
             else
             {
@@ -379,7 +371,7 @@
 
     return ret.Detach();
 }
-///---------------------------------------------------------------------------------------
+//////////////////////////////////////////////////////////////////////////////////////////
 /// render a tile and store it in da cache
 MgByteReader* MgServerTileService::GetTile(CREFSTRING tilePathname, MgMap* map, INT32 scaleIndex,
     CREFSTRING baseMapLayerGroupName, INT32 tileColumn, INT32 tileRow)
@@ -413,7 +405,8 @@
 
     return img.Detach();
 }
-///---------------------------------------------------------------------------------------
+
+//////////////////////////////////////////////////////////////////////////////////////////
 /// take a tile image and store it in the tilecache using lockfiles
 void MgServerTileService::SetTile(MgByteReader* img,
                                   MgMap* map,
@@ -469,7 +462,7 @@
             arguments.Add(lockPathname);
 
             throw new MgFileIoException(L"MgServerTileService.SetTile",
-                __LINE__, __WFILE__, &arguments, L"MgUnableToOpenTileFile", NULL);
+                __LINE__, __WFILE__, &arguments, L"MgUnableToOpenLockFile", NULL);
         }
         else
         {
@@ -489,7 +482,8 @@
 
     MG_THROW()
 }
-///-------------------------------------------------------------------------
+
+//////////////////////////////////////////////////////////////////////////////////////////
 /// accessor method for resource service
 MgResourceService* MgServerTileService::GetResourceServiceForMapDef 
                         (MgResourceIdentifier* mapDefinition, CREFSTRING funcName)
@@ -588,11 +582,13 @@
 
     return success;
 }
+///////////////////////////////////////////////////////////////////////////////
 
 void MgServerTileService::SetConnectionProperties(MgConnectionProperties*)
 {
     // Do nothing.  No connection properties are required for Server-side service objects.
 }
+///////////////////////////////////////////////////////////////////////////////
 
 void MgServerTileService::ClearMapCache(CREFSTRING mapDefinition)
 {
@@ -629,6 +625,7 @@
         }
     }
 }
+///////////////////////////////////////////////////////////////////////////////
 
 INT32 MgServerTileService::GetDefaultTileSizeX()
 {



More information about the mapguide-commits mailing list