[mapguide-commits] r6731 - in branches/2.4/MgDev/Desktop: DesktopUnmanagedApi/DotNet MapViewer.Desktop MapViewerTest MgDesktop MgDesktop/Services MgDesktop/System SampleExtension UnitTest

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Tue Jun 5 04:26:28 PDT 2012


Author: jng
Date: 2012-06-05 04:26:26 -0700 (Tue, 05 Jun 2012)
New Revision: 6731

Added:
   branches/2.4/MgDev/Desktop/MgDesktop/Services/MappingService.cpp
   branches/2.4/MgDev/Desktop/MgDesktop/Services/MappingService.h
Modified:
   branches/2.4/MgDev/Desktop/DesktopUnmanagedApi/DotNet/MapGuideDesktopApiGen.xml
   branches/2.4/MgDev/Desktop/MapViewer.Desktop/MgDesktopMapViewerProvider.cs
   branches/2.4/MgDev/Desktop/MapViewerTest/MgAppWindow.cs
   branches/2.4/MgDev/Desktop/MgDesktop/MgDesktop.h
   branches/2.4/MgDev/Desktop/MgDesktop/MgDesktop.vcproj
   branches/2.4/MgDev/Desktop/MgDesktop/MgDesktopBuild.cpp
   branches/2.4/MgDev/Desktop/MgDesktop/Services/DrawingService.h
   branches/2.4/MgDev/Desktop/MgDesktop/Services/RenderingService.cpp
   branches/2.4/MgDev/Desktop/MgDesktop/Services/RenderingService.h
   branches/2.4/MgDev/Desktop/MgDesktop/Services/ServiceFactory.cpp
   branches/2.4/MgDev/Desktop/MgDesktop/Services/ServiceFactory.h
   branches/2.4/MgDev/Desktop/MgDesktop/System/ClassId.h
   branches/2.4/MgDev/Desktop/SampleExtension/MgPlotToDwfComponent.cs
   branches/2.4/MgDev/Desktop/UnitTest/TestMappingService.cpp
   branches/2.4/MgDev/Desktop/UnitTest/TestMappingService.h
   branches/2.4/MgDev/Desktop/UnitTest/UnitTest.vcproj
   branches/2.4/MgDev/Desktop/UnitTest/main.cpp
Log:
mg-desktop: Move plotting related APIs into a separate MgdMappingService class (like we should've done from the beginning). Also activate the applicable Mapping Service unit tests.

Modified: branches/2.4/MgDev/Desktop/DesktopUnmanagedApi/DotNet/MapGuideDesktopApiGen.xml
===================================================================
--- branches/2.4/MgDev/Desktop/DesktopUnmanagedApi/DotNet/MapGuideDesktopApiGen.xml	2012-06-04 17:19:37 UTC (rev 6730)
+++ branches/2.4/MgDev/Desktop/DesktopUnmanagedApi/DotNet/MapGuideDesktopApiGen.xml	2012-06-05 11:26:26 UTC (rev 6731)
@@ -107,6 +107,7 @@
     <Header path="../../MgDesktop/Services/DrawingService.h" />
     <Header path="../../MgDesktop/Services/FeatureReader.h" />
     <Header path="../../MgDesktop/Services/FeatureService.h" />
+    <Header path="../../MgDesktop/Services/MappingService.h" />
     <Header path="../../MgDesktop/Services/ProfilingService.h" />
     <Header path="../../MgDesktop/Services/RenderingService.h" />
     <Header path="../../MgDesktop/Services/ResourceService.h" />

Modified: branches/2.4/MgDev/Desktop/MapViewer.Desktop/MgDesktopMapViewerProvider.cs
===================================================================
--- branches/2.4/MgDev/Desktop/MapViewer.Desktop/MgDesktopMapViewerProvider.cs	2012-06-04 17:19:37 UTC (rev 6730)
+++ branches/2.4/MgDev/Desktop/MapViewer.Desktop/MgDesktopMapViewerProvider.cs	2012-06-05 11:26:26 UTC (rev 6731)
@@ -10,6 +10,7 @@
     {
         private MgdMap _implMap;
         private MgRenderingService _renderSvc;
+        private MgdMappingService _mappingSvc;
         private MgServiceFactory _fact;
 
         public MgDesktopMapViewerProvider(MgdMap map) : base(map) 
@@ -101,7 +102,7 @@
 
         public override MgByteReader GenerateLegendImage(MgResourceIdentifier layerDefinition, double viewScale, int width, int height, string format, int geomType, int themeCategory)
         {
-            return _renderSvc.GenerateLegendImage(layerDefinition, viewScale, width, height, format, geomType, themeCategory);
+            return _mappingSvc.GenerateLegendImage(layerDefinition, viewScale, width, height, format, geomType, themeCategory);
         }
 
         public override void SetGroupExpandInLegend(MgLayerGroup group, bool bExpanded)

Modified: branches/2.4/MgDev/Desktop/MapViewerTest/MgAppWindow.cs
===================================================================
--- branches/2.4/MgDev/Desktop/MapViewerTest/MgAppWindow.cs	2012-06-04 17:19:37 UTC (rev 6730)
+++ branches/2.4/MgDev/Desktop/MapViewerTest/MgAppWindow.cs	2012-06-05 11:26:26 UTC (rev 6731)
@@ -87,14 +87,14 @@
                     save.Filter = "DWF Files (*.dwf)|*.dwf";
                     if (save.ShowDialog() == DialogResult.OK)
                     {
-                        var renderSvc = (MgRenderingService)mapViewer.GetProvider().CreateService(MgServiceType.RenderingService);
+                        var mappingSvc = (MgdMappingService)mapViewer.GetProvider().CreateService(MgServiceType.MappingService);
                         var map = (MgdMap)mapViewer.GetMap();
                         var dwfVer = new MgDwfVersion("6.01", "1.2");
 
                         var layout = new MgLayout(layoutId, "TestPlot", MgPageUnitsType.Inches);
                         var plotSpec = new MgPlotSpecification(8.5f, 11.0f, MgPageUnitsType.Inches, 0.5f, 0.5f, 0.5f, 0.5f);
 
-                        var result = renderSvc.GeneratePlot(map, plotSpec, layout, dwfVer);
+                        var result = mappingSvc.GeneratePlot(map, plotSpec, layout, dwfVer);
                         var sink = new MgByteSink(result);
                         sink.ToFile(save.FileName);
 

Modified: branches/2.4/MgDev/Desktop/MgDesktop/MgDesktop.h
===================================================================
--- branches/2.4/MgDev/Desktop/MgDesktop/MgDesktop.h	2012-06-04 17:19:37 UTC (rev 6730)
+++ branches/2.4/MgDev/Desktop/MgDesktop/MgDesktop.h	2012-06-05 11:26:26 UTC (rev 6731)
@@ -49,6 +49,7 @@
 #include "Services/ScrollableFeatureReader.h"
 #include "Services/FeatureService.h"
 #include "Services/ImageFormats.h"
+#include "Services/MappingService.h"
 #include "Services/ProfilingService.h"
 #include "Services/RenderingService.h"
 #include "Services/ResourceService.h"

Modified: branches/2.4/MgDev/Desktop/MgDesktop/MgDesktop.vcproj
===================================================================
--- branches/2.4/MgDev/Desktop/MgDesktop/MgDesktop.vcproj	2012-06-04 17:19:37 UTC (rev 6730)
+++ branches/2.4/MgDev/Desktop/MgDesktop/MgDesktop.vcproj	2012-06-05 11:26:26 UTC (rev 6731)
@@ -2272,6 +2272,42 @@
 				</FileConfiguration>
 			</File>
 			<File
+				RelativePath=".\Services\MappingService.cpp"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					ExcludedFromBuild="true"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|x64"
+					ExcludedFromBuild="true"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					ExcludedFromBuild="true"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|x64"
+					ExcludedFromBuild="true"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
+			</File>
+			<File
 				RelativePath=".\Services\Rendering\MappingUtil.cpp"
 				>
 				<FileConfiguration
@@ -4178,6 +4214,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\Services\MappingService.h"
+				>
+			</File>
+			<File
 				RelativePath=".\Services\Rendering\MappingUtil.h"
 				>
 			</File>

Modified: branches/2.4/MgDev/Desktop/MgDesktop/MgDesktopBuild.cpp
===================================================================
--- branches/2.4/MgDev/Desktop/MgDesktop/MgDesktopBuild.cpp	2012-06-04 17:19:37 UTC (rev 6730)
+++ branches/2.4/MgDev/Desktop/MgDesktop/MgDesktopBuild.cpp	2012-06-05 11:26:26 UTC (rev 6731)
@@ -34,6 +34,7 @@
 #include "Services/FeatureReader.cpp"
 #include "Services/FeatureService.cpp"
 #include "Services/ImageFormats.cpp"
+#include "Services/MappingService.cpp"
 #include "Services/ProfilingService.cpp"
 #include "Services/RenderingService.cpp"
 #include "Services/ResourceService.cpp"

Modified: branches/2.4/MgDev/Desktop/MgDesktop/Services/DrawingService.h
===================================================================
--- branches/2.4/MgDev/Desktop/MgDesktop/Services/DrawingService.h	2012-06-04 17:19:37 UTC (rev 6730)
+++ branches/2.4/MgDev/Desktop/MgDesktop/Services/DrawingService.h	2012-06-05 11:26:26 UTC (rev 6731)
@@ -7,6 +7,19 @@
 {
     DECLARE_CLASSNAME(MgDrawingService)
 
+public:
+    //////////////////////////////////////////////////////////////////
+    /// <summary>
+    /// Destructor
+    /// </summary>
+    virtual ~MgDrawingService();
+
+    //////////////////////////////////////////////////////////////////
+    /// <summary>
+    /// Construct an MgDrawingService object
+    /// </summary>
+    MgDrawingService();
+
 PUBLISHED_API:
     //////////////////////////////////////////////////////////////////
     /// <summary>
@@ -233,22 +246,6 @@
     /// - See MgResourceService for additional exceptions.
     virtual STRING GetCoordinateSpace(MgResourceIdentifier* resource);
 
-    //////////////////////////////////////////////////////////////////
-    /// <summary>
-    /// Destructor
-    /// </summary>
-    virtual ~MgDrawingService();
-
-    //////////////////////////////////////////////////////////////////
-    /// <summary>
-    /// Construct an MgDrawingService object
-    /// </summary>
-    MgDrawingService();
-
-    //DECLARE_CREATE_SERVICE()
-
-    //void SetConnectionProperties(MgConnectionProperties* connProp);
-
 CLASS_ID:
     static const INT32 m_cls_id = MapGuide_Desktop_DrawingService_DrawingService;
 

Added: branches/2.4/MgDev/Desktop/MgDesktop/Services/MappingService.cpp
===================================================================
--- branches/2.4/MgDev/Desktop/MgDesktop/Services/MappingService.cpp	                        (rev 0)
+++ branches/2.4/MgDev/Desktop/MgDesktop/Services/MappingService.cpp	2012-06-05 11:26:26 UTC (rev 6731)
@@ -0,0 +1,934 @@
+#include "MappingService.h"
+#include "EPlotRenderer.h"
+#include "FeatureTypeStyleVisitor.h"
+#include "Rendering/RSMgSymbolManager.h"
+#include "Rendering/icons.h"
+#include "Rendering/LegendPlotUtil.h"
+#include "StylizationUtil.h"
+#include "DefaultStylizer.h"
+#include "Stylization/SEMgSymbolManager.h"
+
+///////////////////////////////////////////////////////////////////////////////
+/// Mg Server Mapping Service try/catch/throw macros.
+///
+#define MG_SERVER_MAPPING_SERVICE_TRY()                                       \
+    MG_TRY()                                                                  \
+
+// For the Mapping service, gracefully handle and remap any Fdo exceptions to MapGuide exceptions.
+// Some Fdo providiers like WMS return useful error strings when a request fails.
+// Without the remap, this information is lost and MapGuide returns an unclassified exception.
+#define MG_SERVER_MAPPING_SERVICE_CATCH(methodName)                         \
+    }                                                                       \
+    catch (MgException* e)                                                  \
+                                                                            \
+    {                                                                       \
+        mgException = e;                                                    \
+        mgException->AddStackTraceInfo(methodName, __LINE__, __WFILE__);    \
+    }                                                                       \
+    catch (exception& e)                                                    \
+    {                                                                       \
+        mgException = MgSystemException::Create(e, methodName, __LINE__, __WFILE__); \
+    }                                                                       \
+    catch (FdoException* e)                                                 \
+    {                                                                       \
+        STRING messageId;                                                   \
+        MgStringCollection arguments;                                       \
+        wchar_t* buf = (wchar_t*)e->GetExceptionMessage();                  \
+        INT64 nativeErrorCode = e->GetNativeErrorCode();                    \
+        if (NULL != buf)                                                    \
+        {                                                                   \
+            messageId = L"MgFormatInnerExceptionMessage";                   \
+            arguments.Add(buf);                                             \
+        }                                                                   \
+        FDO_SAFE_RELEASE(e);                                                \
+        mgException = new MgFdoException(methodName, __LINE__, __WFILE__, NULL, messageId, &arguments, nativeErrorCode); \
+    }                                                                       \
+    catch (...)                                                             \
+    {                                                                       \
+        mgException = new MgUnclassifiedException(methodName, __LINE__, __WFILE__, NULL, L"", NULL); \
+    }                                                                       \
+
+#define MG_SERVER_MAPPING_SERVICE_THROW()                                     \
+    MG_THROW()                                                                \
+
+#define MG_SERVER_MAPPING_SERVICE_CATCH_AND_THROW(methodName)                 \
+    MG_SERVER_MAPPING_SERVICE_CATCH(methodName)                               \
+                                                                              \
+    MG_SERVER_MAPPING_SERVICE_THROW()                                         \
+
+
+MgdMappingService::MgdMappingService() : MgService() 
+{ 
+    m_pCSFactory = new MgCoordinateSystemFactory();
+
+    // store references to the various services we use
+    //MgServiceManager* serviceMan = MgServiceManager::GetInstance();
+    //assert(NULL != serviceMan);
+
+    Ptr<MgServiceFactory> fact = new MgServiceFactory();
+
+    m_svcResource = dynamic_cast<MgResourceService*>(fact->CreateService(MgServiceType::ResourceService));
+    assert(m_svcResource != NULL);
+
+    m_svcFeature = dynamic_cast<MgFeatureService*>(fact->CreateService(MgServiceType::FeatureService));
+    assert(m_svcFeature != NULL);
+
+    m_svcDrawing = dynamic_cast<MgDrawingService*>(fact->CreateService(MgServiceType::DrawingService));
+    assert(m_svcDrawing != NULL);
+
+    MgConfiguration* pConf = MgConfiguration::GetInstance();
+    pConf->GetIntValue(MgConfigProperties::RenderingServicePropertiesSection,
+                          MgConfigProperties::RenderingServicePropertyMaxRasterImageWidth,
+                          m_maxRasterImageWidth,
+                          MgConfigProperties::DefaultRenderingServicePropertyMaxRasterImageWidth);
+
+    pConf->GetIntValue(MgConfigProperties::RenderingServicePropertiesSection,
+                          MgConfigProperties::RenderingServicePropertyMaxRasterImageHeight,
+                          m_maxRasterImageHeight,
+                          MgConfigProperties::DefaultRenderingServicePropertyMaxRasterImageHeight);
+
+    // Set Mapping Service related properties
+	pConf->GetIntValue(MgConfigProperties::RenderingServicePropertiesSection,
+                          MgConfigProperties::RenderingServicePropertyRasterGridSizeForPlot,
+                          m_rasterGridSizeForPlot,
+                          MgConfigProperties::DefaultRenderingServicePropertyRasterGridSizeForPlot);
+
+    pConf->GetIntValue(MgConfigProperties::RenderingServicePropertiesSection,
+                          MgConfigProperties::RenderingServicePropertyMinRasterGridSizeForPlot,
+                          m_minRasterGridSizeForPlot,
+                          MgConfigProperties::DefaultRenderingServicePropertyMinRasterGridSizeForPlot);
+
+    pConf->GetDoubleValue(MgConfigProperties::RenderingServicePropertiesSection,
+                          MgConfigProperties::RenderingServicePropertyRasterGridSizeOverrideRatioForPlot,
+                          m_rasterGridSizeOverrideRatioForPlot,
+                          MgConfigProperties::DefaultRenderingServicePropertyRasterGridSizeOverrideRatioForPlot);
+}
+
+MgdMappingService::~MgdMappingService() { }
+
+// Returns true if the supplied feature type style is compatible with the
+// supplied geometry type: 1=Point, 2=Line, 3=Area, 4=Composite
+bool MgdMappingService::FeatureTypeStyleSupportsGeomType(MdfModel::FeatureTypeStyle* fts, INT32 geomType)
+{
+    if (fts == NULL)
+        return false;
+
+    // if ShowInLegend is false, the legend doesn't need to be shown
+    if(!fts->IsShowInLegend())
+        return false;
+
+    // a value of -1 matches any
+    if (geomType == -1)
+        return true;
+
+    FeatureTypeStyleVisitor::eFeatureTypeStyle ftsType = FeatureTypeStyleVisitor::DetermineFeatureTypeStyle(fts);
+
+    switch (ftsType)
+    {
+        case FeatureTypeStyleVisitor::ftsPoint:
+            return (geomType == 1);
+
+        case FeatureTypeStyleVisitor::ftsLine:
+            return (geomType == 2);
+
+        case FeatureTypeStyleVisitor::ftsArea:
+            return (geomType == 3);
+
+        case FeatureTypeStyleVisitor::ftsComposite:
+            return (geomType == 4);
+    }
+
+    return false;
+}
+
+MgByteReader* MgdMappingService::GenerateLegendImage(MgResourceIdentifier* resource,
+                                                      double     scale,
+                                                      INT32      imgWidth,
+                                                      INT32      imgHeight,
+                                                      CREFSTRING format,
+                                                      INT32      geomType,
+                                                      INT32      themeCategory)
+{
+    Ptr<MgByteReader> byteReader;
+
+    MG_LOG_OPERATION_MESSAGE(L"GenerateLegendImage");
+
+    MG_SERVER_MAPPING_SERVICE_TRY()
+
+    MG_LOG_OPERATION_MESSAGE_INIT(MG_API_VERSION(1, 0, 0), 7);
+    MG_LOG_OPERATION_MESSAGE_PARAMETERS_START();
+    MG_LOG_OPERATION_MESSAGE_ADD_STRING((NULL == resource) ? L"MgResourceIdentifier" : resource->ToString().c_str());
+    MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
+    MG_LOG_OPERATION_MESSAGE_ADD_DOUBLE(scale);
+    MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
+    MG_LOG_OPERATION_MESSAGE_ADD_INT32(imgWidth);
+    MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
+    MG_LOG_OPERATION_MESSAGE_ADD_INT32(imgHeight);
+    MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
+    MG_LOG_OPERATION_MESSAGE_ADD_STRING(format.c_str());
+    MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
+    MG_LOG_OPERATION_MESSAGE_ADD_INT32(geomType);
+    MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
+    MG_LOG_OPERATION_MESSAGE_ADD_INT32(themeCategory);
+    MG_LOG_OPERATION_MESSAGE_PARAMETERS_END();
+
+    MG_LOG_TRACE_ENTRY(L"MgdMappingService::GenerateLegendImage()");
+
+    if (0 == resource)
+    {
+        throw new MgNullArgumentException(
+            L"MgdMappingService::GenerateLegendImage", __LINE__, __WFILE__, NULL, L"", NULL);
+    }
+
+    if (m_svcResource == NULL)
+    {
+        Ptr<MgServiceFactory> fact = new MgServiceFactory();
+        m_svcResource = static_cast<MgResourceService*>(fact->CreateService(MgServiceType::ResourceService));
+    }
+
+    auto_ptr<MdfModel::LayerDefinition> ldf(MgLayerBase::GetLayerDefinition(m_svcResource, resource));
+    MdfModel::VectorLayerDefinition* vl = dynamic_cast<MdfModel::VectorLayerDefinition*>(ldf.get());
+    MdfModel::DrawingLayerDefinition* dl = dynamic_cast<MdfModel::DrawingLayerDefinition*>(ldf.get());
+    MdfModel::GridLayerDefinition* gl = dynamic_cast<MdfModel::GridLayerDefinition*>(ldf.get());
+
+    if (vl) // vector layer
+    {
+        MdfModel::VectorScaleRangeCollection* src = vl->GetScaleRanges();
+
+        MdfModel::VectorScaleRange* range = NULL;
+
+        //find the right scale range
+        for (int i=0; i<src->GetCount(); i++)
+        {
+            MdfModel::VectorScaleRange* r = src->GetAt(i);
+
+            if (scale >= r->GetMinScale() && scale < r->GetMaxScale())
+            {
+                range = r;
+                break;
+            }
+        }
+
+        //we have the scale range... find the feature style
+        if (range)
+        {
+            MdfModel::FeatureTypeStyle* fts = NULL;
+
+            // The "geometry type" specifies which flavor of feature type style to use,
+            // while the theme category is a 0-based value which specifies the actual
+            // type style to use.  So if I have a scale range with two composite type
+            // styles, the first with 3 rules and the second with 2 rules, then the
+            // theme category can range from 0 to 4: 0,1,2 refer to the 3 rules in the
+            // 1st type style, while 3,4 refer to the 2 rules in the 2nd type style.
+            MdfModel::FeatureTypeStyleCollection* ftsc = range->GetFeatureTypeStyles();
+            int numFTS = ftsc->GetCount();
+            for (int j=0; j<numFTS; ++j)
+            {
+                // filter the type styles
+                MdfModel::FeatureTypeStyle* temp = ftsc->GetAt(j);
+                if (!FeatureTypeStyleSupportsGeomType(temp, geomType))
+                    continue;
+
+                // make sure we have rules
+                RuleCollection* rules = temp->GetRules();
+                if (!rules)
+                    continue;
+
+                // check if the theme category refers to one of these rules (note: a
+                // value of -1 matches anything)
+                int numRules = rules->GetCount();
+                if (themeCategory >= -1 && themeCategory < numRules)
+                {
+                    // found it
+                    fts = temp;
+                    break;
+                }
+
+                // adjust the theme category, and move to the next type style
+                themeCategory -= numRules;
+            }
+
+            if (fts)
+                byteReader = MgMappingUtil::DrawFTS(m_svcResource, fts, imgWidth, imgHeight, themeCategory);
+            else
+            {
+                //return the fixed array
+                //MgByteSource will make its own copy of the data
+                Ptr<MgByteSource> src = new MgByteSource((BYTE_ARRAY_IN)BLANK_LAYER_ICON, sizeof(BLANK_LAYER_ICON));
+                byteReader = src->GetReader();
+            }
+        }
+    }
+    else if (dl) // drawing layer
+    {
+        //return the fixed array
+        //MgByteSource will make its own copy of the data
+        Ptr<MgByteSource> src = new MgByteSource((BYTE_ARRAY_IN)DWF_LAYER_ICON, sizeof(DWF_LAYER_ICON));
+        byteReader = src->GetReader();
+    }
+    else if (gl) //grid (raster) layer
+    {
+        //return the fixed array
+        //MgByteSource will make its own copy of the data
+        Ptr<MgByteSource> src = new MgByteSource((BYTE_ARRAY_IN)RASTER_LAYER_ICON, sizeof(RASTER_LAYER_ICON));
+        byteReader = src->GetReader();
+    }
+
+    // Successful operation
+    MG_LOG_OPERATION_MESSAGE_ADD_STRING(MgResources::Success.c_str());
+
+    MG_SERVER_MAPPING_SERVICE_CATCH(L"MgdMappingService::GenerateLegendImage")
+
+    if (mgException != NULL)
+    {
+        // Failed operation
+        MG_LOG_OPERATION_MESSAGE_ADD_STRING(MgResources::Failure.c_str());
+        MG_DESKTOP_LOG_EXCEPTION();
+    }
+
+    // Add access log entry for operation
+    MG_LOG_OPERATION_MESSAGE_ACCESS_ENTRY();
+
+    MG_SERVER_MAPPING_SERVICE_THROW()
+
+    return byteReader.Detach();
+}
+
+MgByteReader* MgdMappingService::GeneratePlot(MgdMap* map,
+                                               MgPlotSpecification* plotSpec,
+                                               MgLayout* layout,
+                                               MgDwfVersion* dwfVersion)
+{
+    Ptr<MgByteReader> byteReader;
+
+    MG_LOG_OPERATION_MESSAGE(L"GeneratePlot");
+
+    MG_SERVER_MAPPING_SERVICE_TRY()
+
+    Ptr<MgResourceIdentifier> mapId;
+    if (NULL != map)
+        mapId = map->GetResourceId();
+    Ptr<MgResourceIdentifier> layoutId;
+    if (NULL != layoutId)
+        layoutId = layout->GetLayout();
+    MG_LOG_OPERATION_MESSAGE_INIT(MG_API_VERSION(1, 0, 0), 4);
+    MG_LOG_OPERATION_MESSAGE_PARAMETERS_START();
+    MG_LOG_OPERATION_MESSAGE_ADD_STRING((NULL == mapId) ? L"MgResourceIdentifier" : mapId->ToString().c_str());
+    MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
+    MG_LOG_OPERATION_MESSAGE_ADD_STRING(L"MgPlotSpecification");
+    MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
+    MG_LOG_OPERATION_MESSAGE_ADD_STRING((NULL == layoutId) ? L"MgResourceIdentifier" : layoutId->ToString().c_str());
+    MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
+    MG_LOG_OPERATION_MESSAGE_ADD_STRING((NULL == dwfVersion) ? L"MgDwfVersion" : dwfVersion->GetLogString());
+    MG_LOG_OPERATION_MESSAGE_PARAMETERS_END();
+
+    MG_LOG_TRACE_ENTRY(L"MgdMappingService::GeneratePlot()");
+
+    if (NULL == map  || NULL == dwfVersion || NULL == plotSpec )
+    {
+        throw new MgNullArgumentException(
+            L"MgdMappingService::GeneratePlot", __LINE__, __WFILE__, NULL, L"", NULL);
+    }
+
+    // Create a MgMapPlot which will be passed to GenerateMultiPlot
+    Ptr<MgMapPlot> mapPlot = new MgMapPlot(map, plotSpec, layout);
+
+    // Add it to a MgMapPlotCollecion
+    Ptr<MgMapPlotCollection> mapPlots = new MgMapPlotCollection();
+    mapPlots->Add(mapPlot);
+
+    // Create the plot
+    byteReader = GenerateMultiPlotInternal(mapPlots, dwfVersion);
+
+    // Successful operation
+    MG_LOG_OPERATION_MESSAGE_ADD_STRING(MgResources::Success.c_str());
+
+    MG_SERVER_MAPPING_SERVICE_CATCH(L"MgdMappingService::GeneratePlot")
+
+    if (mgException != NULL)
+    {
+        // Failed operation
+        MG_LOG_OPERATION_MESSAGE_ADD_STRING(MgResources::Failure.c_str());
+        MG_DESKTOP_LOG_EXCEPTION();
+    }
+
+    // Add access log entry for operation
+    MG_LOG_OPERATION_MESSAGE_ACCESS_ENTRY();
+
+    MG_SERVER_MAPPING_SERVICE_THROW()
+
+    return byteReader.Detach();
+}
+
+MgByteReader* MgdMappingService::GeneratePlot(MgdMap* map,
+                                               MgCoordinate* center,
+                                               double scale,
+                                               MgPlotSpecification* plotSpec,
+                                               MgLayout* layout,
+                                               MgDwfVersion* dwfVersion)
+{
+    Ptr<MgByteReader> byteReader;
+
+    MG_LOG_OPERATION_MESSAGE(L"GeneratePlot");
+
+    MG_SERVER_MAPPING_SERVICE_TRY()
+
+    Ptr<MgResourceIdentifier> mapId;
+    if (NULL != map)
+        mapId = map->GetResourceId();
+    Ptr<MgResourceIdentifier> layoutId;
+    if (NULL != layoutId)
+        layoutId = layout->GetLayout();
+    MG_LOG_OPERATION_MESSAGE_INIT(MG_API_VERSION(1, 0, 0), 6);
+    MG_LOG_OPERATION_MESSAGE_PARAMETERS_START();
+    MG_LOG_OPERATION_MESSAGE_ADD_STRING((NULL == mapId) ? L"MgResourceIdentifier" : mapId->ToString().c_str());
+    MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
+    MG_LOG_OPERATION_MESSAGE_ADD_STRING(L"MgCoordinate")
+    MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
+    MG_LOG_OPERATION_MESSAGE_ADD_DOUBLE(scale)
+    MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
+    MG_LOG_OPERATION_MESSAGE_ADD_STRING(L"MgPlotSpecification");
+    MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
+    MG_LOG_OPERATION_MESSAGE_ADD_STRING((NULL == layoutId) ? L"MgResourceIdentifier" : layoutId->ToString().c_str());
+    MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
+    MG_LOG_OPERATION_MESSAGE_ADD_STRING((NULL == dwfVersion) ? L"MgDwfVersion" : dwfVersion->GetLogString());
+    MG_LOG_OPERATION_MESSAGE_PARAMETERS_END();
+
+    MG_LOG_TRACE_ENTRY(L"MgdMappingService::GeneratePlot()");
+
+    if (NULL == map  || NULL == center || NULL == dwfVersion || NULL == plotSpec )
+    {
+        throw new MgNullArgumentException(
+            L"MgdMappingService::GeneratePlot", __LINE__, __WFILE__, NULL, L"", NULL);
+    }
+
+    // Create a MgMapPlot which will be passed to GenerateMultiPlot
+    Ptr<MgMapPlot> mapPlot = new MgMapPlot(map, center, scale, plotSpec, layout);
+
+    // Add it to a MgMapPlotCollecion
+    Ptr<MgMapPlotCollection> mapPlots = new MgMapPlotCollection();
+    mapPlots->Add(mapPlot);
+
+    // Create the plot
+    byteReader = GenerateMultiPlotInternal(mapPlots, dwfVersion);
+
+    // Successful operation
+    MG_LOG_OPERATION_MESSAGE_ADD_STRING(MgResources::Success.c_str());
+
+    MG_SERVER_MAPPING_SERVICE_CATCH(L"MgdMappingService::GeneratePlot")
+
+    if (mgException != NULL)
+    {
+        // Failed operation
+        MG_LOG_OPERATION_MESSAGE_ADD_STRING(MgResources::Failure.c_str());
+        MG_DESKTOP_LOG_EXCEPTION();
+    }
+
+    // Add access log entry for operation
+    MG_LOG_OPERATION_MESSAGE_ACCESS_ENTRY();
+
+    MG_SERVER_MAPPING_SERVICE_THROW()
+
+    return byteReader.Detach();
+}
+
+MgByteReader* MgdMappingService::GeneratePlot(MgdMap* map,
+                                               MgEnvelope* extents,
+                                               bool expandToFit,
+                                               MgPlotSpecification* plotSpec,
+                                               MgLayout* layout,
+                                               MgDwfVersion* dwfVersion)
+{
+    Ptr<MgByteReader> byteReader;
+
+    MG_LOG_OPERATION_MESSAGE(L"GeneratePlot");
+    MG_SERVER_MAPPING_SERVICE_TRY()
+
+    Ptr<MgResourceIdentifier> mapId;
+    if (NULL != map)
+        mapId = map->GetResourceId();
+    Ptr<MgResourceIdentifier> layoutId;
+    if (NULL != layoutId)
+        layoutId = layout->GetLayout();
+
+    MG_LOG_OPERATION_MESSAGE_INIT(MG_API_VERSION(1, 0, 0), 6);
+    MG_LOG_OPERATION_MESSAGE_PARAMETERS_START();
+    MG_LOG_OPERATION_MESSAGE_ADD_STRING((NULL == mapId) ? L"MgResourceIdentifier" : mapId->ToString().c_str());
+    MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
+    MG_LOG_OPERATION_MESSAGE_ADD_STRING(L"MgEnvelope")
+    MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
+    MG_LOG_OPERATION_MESSAGE_ADD_BOOL(expandToFit)
+    MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
+    MG_LOG_OPERATION_MESSAGE_ADD_STRING(L"MgPlotSpecification");
+    MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
+    MG_LOG_OPERATION_MESSAGE_ADD_STRING((NULL == layoutId) ? L"MgResourceIdentifier" : layoutId->ToString().c_str());
+    MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
+    MG_LOG_OPERATION_MESSAGE_ADD_STRING((NULL == dwfVersion) ? L"MgDwfVersion" : dwfVersion->GetLogString());
+    MG_LOG_OPERATION_MESSAGE_PARAMETERS_END();
+
+    MG_LOG_TRACE_ENTRY(L"MgdMappingService::GeneratePlot()");
+
+    if (NULL == map  || NULL == extents || NULL == plotSpec || NULL == dwfVersion )
+    {
+        throw new MgNullArgumentException(
+            L"MgdMappingService::GeneratePlot", __LINE__, __WFILE__, NULL, L"", NULL);
+    }
+
+    // Make a copy of the extents
+    Ptr<MgCoordinate> oldll = extents->GetLowerLeftCoordinate();
+    Ptr<MgCoordinate> oldur = extents->GetUpperRightCoordinate();
+    Ptr<MgCoordinate> ll = new MgCoordinateXY(oldll->GetX(), oldll->GetY());
+    Ptr<MgCoordinate> ur = new MgCoordinateXY(oldur->GetX(), oldur->GetY());
+    if (ll == NULL || ur == NULL)
+    {
+        throw new MgNullArgumentException(L"MgdMappingService::GeneratePlot", __LINE__, __WFILE__, NULL, L"", NULL);
+    }
+    Ptr<MgEnvelope> env = new MgEnvelope(ll, ur);
+
+    // Create a MgMapPlot which will be passed to GenerateMultiPlot
+    Ptr<MgMapPlot> mapPlot = new MgMapPlot(map, env, expandToFit, plotSpec, layout);
+
+    // Add it to a MgMapPlotCollecion
+    Ptr<MgMapPlotCollection> mapPlots = new MgMapPlotCollection();
+    if (mapPlot == NULL || mapPlots == NULL)
+    {
+        throw new MgNullArgumentException(L"MgdMappingService::GeneratePlot", __LINE__, __WFILE__, NULL, L"", NULL);
+    }
+    mapPlots->Add(mapPlot);
+
+    // Create the plot
+    byteReader = GenerateMultiPlotInternal(mapPlots, dwfVersion);
+
+    // Successful operation
+    MG_LOG_OPERATION_MESSAGE_ADD_STRING(MgResources::Success.c_str());
+
+    MG_SERVER_MAPPING_SERVICE_CATCH(L"MgdMappingService::GeneratePlot")
+
+    if (mgException != NULL)
+    {
+        // Failed operation
+        MG_LOG_OPERATION_MESSAGE_ADD_STRING(MgResources::Failure.c_str());
+        MG_DESKTOP_LOG_EXCEPTION();
+    }
+
+    // Add access log entry for operation
+    MG_LOG_OPERATION_MESSAGE_ACCESS_ENTRY();
+
+    MG_SERVER_MAPPING_SERVICE_THROW()
+
+    return byteReader.Detach();
+}
+
+MgByteReader* MgdMappingService::GenerateMultiPlot(MgMapPlotCollection* mapPlots, MgDwfVersion* dwfVersion)
+{
+    Ptr<MgByteReader> ret;
+    MG_LOG_OPERATION_MESSAGE(L"GenerateMultiPlot");
+
+    MG_SERVER_MAPPING_SERVICE_TRY()
+
+    MG_LOG_OPERATION_MESSAGE_INIT(MG_API_VERSION(1, 0, 0), 2);
+    MG_LOG_OPERATION_MESSAGE_PARAMETERS_START();
+    MG_LOG_OPERATION_MESSAGE_ADD_STRING(L"MgMapPlotCollection");
+    MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
+    MG_LOG_OPERATION_MESSAGE_ADD_STRING((NULL == dwfVersion) ? L"MgDwfVersion" : dwfVersion->GetLogString().c_str());
+    MG_LOG_OPERATION_MESSAGE_PARAMETERS_END();
+
+    MG_LOG_TRACE_ENTRY(L"MgdMappingService::GenerateMultiPlot()");
+
+    ret = GenerateMultiPlotInternal(mapPlots, dwfVersion);
+
+    // Successful operation
+    MG_LOG_OPERATION_MESSAGE_ADD_STRING(MgResources::Success.c_str());
+
+    MG_SERVER_MAPPING_SERVICE_CATCH(L"MgdMappingService::GenerateMultiPlot")
+
+    if (mgException != NULL)
+    {
+        // Failed operation
+        MG_LOG_OPERATION_MESSAGE_ADD_STRING(MgResources::Failure.c_str());
+        MG_DESKTOP_LOG_EXCEPTION();
+    }
+
+    // Add access log entry for operation
+    MG_LOG_OPERATION_MESSAGE_ACCESS_ENTRY();
+
+    MG_SERVER_MAPPING_SERVICE_THROW()
+    return ret.Detach();
+}
+
+MgByteReader* MgdMappingService::GenerateMultiPlotInternal(MgMapPlotCollection* mapPlots, MgDwfVersion* dwfVersion)
+{
+    Ptr<MgByteReader> byteReader;
+
+    MG_SERVER_MAPPING_SERVICE_TRY()
+
+    MG_LOG_TRACE_ENTRY(L"MgdMappingService::GenerateMultiPlot()");
+
+    if (0 == mapPlots || 0 == dwfVersion)
+    {
+        throw new MgNullArgumentException(
+            L"MgdMappingService::GenerateMultiPlot", __LINE__, __WFILE__, NULL, L"", NULL);
+    }
+
+    // get a temporary file to write out EPlot DWF to
+    // TODO: clean the temp file name prefix
+    STRING dwfName = MgFileUtil::GenerateTempFileName(false, L"default_prefix");
+
+    EPlotRenderer dr(dwfName.c_str(), 0, 0, L"inches");  // NOXLATE
+
+    dr.SetRasterGridSize(m_rasterGridSizeForPlot);
+    dr.SetMinRasterGridSize(m_minRasterGridSizeForPlot);
+    dr.SetRasterGridSizeOverrideRatio(m_rasterGridSizeOverrideRatioForPlot);
+    dr.SetMaxRasterImageWidth(m_maxRasterImageWidth);
+    dr.SetMaxRasterImageHeight(m_maxRasterImageHeight);
+
+    RSMgSymbolManager mgr(m_svcResource);
+    dr.SetSymbolManager(&mgr);
+
+    // process the MapPlot collection
+    for (int nMapPlotIndex = 0; nMapPlotIndex < mapPlots->GetCount(); nMapPlotIndex++)
+    {
+        Ptr<MgMapPlot> mapPlot = mapPlots->GetItem(nMapPlotIndex);
+        if (NULL == mapPlot)
+        {
+            throw new MgNullReferenceException(L"MgdMappingService::GenerateMultiPlot", __LINE__, __WFILE__, NULL, L"", NULL);
+        }
+
+        Ptr<MgdMap> map = mapPlot->GetMap();
+        if (NULL == map)
+        {
+            throw new MgNullReferenceException(L"MgdMappingService::GenerateMultiPlot", __LINE__, __WFILE__, NULL, L"", NULL);
+        }
+
+        Ptr<MgPlotSpecification> plotSpec = mapPlot->GetPlotSpecification();
+        if (NULL == plotSpec)
+        {
+            throw new MgNullReferenceException(L"MgdMappingService::GenerateMultiPlot", __LINE__, __WFILE__, NULL, L"", NULL);
+        }
+
+        Ptr<MgLayout> layout = mapPlot->GetLayout();
+
+        double width = plotSpec->GetPaperWidth();
+        double height = plotSpec->GetPaperHeight();
+        STRING pageUnits = plotSpec->GetPageSizeUnits();
+
+        dr.SetPageWidth(width);
+        dr.SetPageHeight(height);
+        dr.SetPageSizeUnits(pageUnits);
+        dr.SetMapWidth(width);
+        dr.SetMapHeight(height);
+        dr.mapBoundsHeight() = height;
+
+        // temporary place for the resId of the Map
+        Ptr<MgResourceIdentifier> mapResId = map->GetMapDefinition();
+
+        // request extenst
+        Ptr<MgEnvelope> env = map->GetDataExtent();
+        if (env == NULL)
+        {
+            throw new MgNullReferenceException(L"MgdMappingService::GenerateMultiPlot", __LINE__, __WFILE__, NULL, L"", NULL);
+        }
+
+        Ptr<MgCoordinate> ll = env->GetLowerLeftCoordinate();
+        Ptr<MgCoordinate> ur = env->GetUpperRightCoordinate();
+        if (ll == NULL || ur == NULL)
+        {
+            throw new MgNullReferenceException(L"MgdMappingService::GenerateMultiPlot", __LINE__, __WFILE__, NULL, L"", NULL);
+        }
+        RS_Bounds b(ll->GetX(), ll->GetY(), ur->GetX(), ur->GetY());
+
+        //if requested data extent is not valid, use map definition extent
+        // this may be removed eventually, but is a good sanity check nonetheless
+        if (!b.IsValid())
+        {
+            Ptr<MgEnvelope> env2 = map->GetMapExtent();
+            if (env2 == NULL)
+            {
+                throw new MgNullReferenceException(L"MgdMappingService::GenerateMultiPlot", __LINE__, __WFILE__, NULL, L"", NULL);
+            }
+
+            Ptr<MgCoordinate> ll2 = env2->GetLowerLeftCoordinate();
+            Ptr<MgCoordinate> ur2 = env2->GetUpperRightCoordinate();
+            if (ll2 == NULL || ur2 == NULL)
+            {
+                throw new MgNullReferenceException(L"MgdMappingService::GenerateMultiPlot", __LINE__, __WFILE__, NULL, L"", NULL);
+            }
+
+            b.minx = ll2->GetX();
+            b.miny = ll2->GetY();
+            b.maxx = ur2->GetX();
+            b.maxy = ur2->GetY();
+        }
+
+        // Create a simple print layout containing only the map
+        Ptr<MgPrintLayout> printLayout = new MgPrintLayout();
+        if (printLayout == NULL)
+        {
+            throw new MgNullReferenceException(L"MgdMappingService::GenerateMultiPlot", __LINE__, __WFILE__, NULL, L"", NULL);
+        }
+
+        if (NULL != layout)
+        {
+            Ptr<MgResourceIdentifier> resID = layout->GetLayout();
+            printLayout->Create(m_svcResource, resID);
+            printLayout->SetPlotSize(plotSpec);
+            printLayout->SetScaleBarUnits(layout->GetUnitType());
+            printLayout->SetPlotTitle(layout->GetTitle());
+
+            Ptr<MgPlotSpecification> spec = printLayout->GetPlotSize();
+
+            width = spec->GetPaperWidth();
+            height = spec->GetPaperHeight();
+            pageUnits = spec->GetPageSizeUnits();
+        }
+        else
+        {
+            printLayout->SetPlotSize(plotSpec);
+        }
+
+        printLayout->PageWidth() = width;
+        printLayout->PageHeight() = height;
+        printLayout->Units() = pageUnits;
+
+        dr.EnableLayoutPlot();
+
+        //get the map coordinate system
+        MdfModel::MdfString srs = map->GetMapSRS();
+        Ptr<MgCoordinateSystem> dstCs;
+        if (!srs.empty())
+        {
+            //let's not fail here if coord sys conversion fails for the
+            //map's coordinate system. Instead we will fail per layer at a later stage
+            try
+            {
+                dstCs = m_pCSFactory->Create(srs);
+            }
+            catch (MgInvalidCoordinateSystemException* e)
+            {
+                e->Release();
+            }
+        }
+
+        double metersPerUnit = (dstCs.p) ? dstCs->ConvertCoordinateSystemUnitsToMeters(1.0) : 1.0;
+        RS_String units = (dstCs.p) ? dstCs->GetUnits() : L"";
+
+        double dMapScale = 0.0;
+        Ptr<MgCoordinate> center = new MgCoordinateXY(0, 0);
+        Ptr<MgEnvelope> extents = map->GetMapExtent();
+        if (center == NULL || extents == NULL)
+        {
+            throw new MgNullReferenceException(L"MgdMappingService::GenerateMultiPlot", __LINE__, __WFILE__, NULL, L"", NULL);
+        }
+
+        switch (mapPlot->GetMapPlotInstruction())
+        {
+        case MgMapPlotInstruction::UseMapCenterAndScale:
+            {
+                dMapScale = map->GetViewScale();
+                if (dMapScale <= 0)
+                {
+                    Ptr<MgEnvelope> extents = map->GetDataExtent();
+                    if (extents == NULL)
+                    {
+                        throw new MgNullReferenceException(L"MgdMappingService::GenerateMultiPlot", __LINE__, __WFILE__, NULL, L"", NULL);
+                    }
+                    printLayout->ComputeMapOffsetAndSize(dMapScale, extents, metersPerUnit, dr.mapOffsetX(), dr.mapOffsetY(), dr.mapWidth(), dr.mapHeight());
+                    double mapWidth = dr.mapWidth();
+                    double mapHeight = dr.mapHeight();
+                    if (_wcsicmp(pageUnits.c_str(), L"mm") == 0 || _wcsicmp(pageUnits.c_str(), L"millimeters") == 0) // NOXLATE
+                    {
+                        mapWidth *= MM_TO_IN;
+                        mapHeight *= MM_TO_IN;
+                    }
+
+                    double scaleToFitX = (extents->GetWidth() * metersPerUnit * M_TO_IN) / mapWidth;
+                    double scaleToFitY = (extents->GetHeight() * metersPerUnit * M_TO_IN) / mapHeight;
+                    dMapScale = rs_max(scaleToFitX, scaleToFitY);
+                }
+
+                Ptr<MgPoint> pt = map->GetViewCenter();
+                center = pt->GetCoordinate();
+                break;
+            }
+        case MgMapPlotInstruction::UseOverriddenCenterAndScale:
+            {
+                dMapScale = mapPlot->GetScale();
+                center = mapPlot->GetCenter();
+                break;
+            }
+        case MgMapPlotInstruction::UseOverriddenExtent:
+            {
+                // Compute the plotCenter and plotScale from the extents
+                extents = mapPlot->GetExtent();
+                //...plotCenter
+                Ptr<MgCoordinate> plotll = extents->GetLowerLeftCoordinate();
+                Ptr<MgCoordinate> plotur = extents->GetUpperRightCoordinate();
+                if (plotll == NULL || plotur == NULL)
+                {
+                    throw new MgNullReferenceException(L"MgdMappingService::GenerateMultiPlot", __LINE__, __WFILE__, NULL, L"", NULL);
+                }
+                double minX = plotll->GetX();
+                double minY = plotll->GetY();
+                double maxX = plotur->GetX();
+                double maxY = plotur->GetY();
+                double centerX = minX + (maxX - minX) * 0.5;
+                double centerY = minY + (maxY - minY) * 0.5;
+                //
+                //...plotScale
+                printLayout->ComputeMapOffsetAndSize(dMapScale, extents, metersPerUnit, dr.mapOffsetX(), dr.mapOffsetY(), dr.mapWidth(), dr.mapHeight());
+                double mapWidth = dr.mapWidth();
+                double mapHeight = dr.mapHeight();
+                if (_wcsicmp(pageUnits.c_str(), L"mm") == 0 || _wcsicmp(pageUnits.c_str(), L"millimeters") == 0)  // NOXLATE
+                {
+                    mapWidth *= MM_TO_IN;
+                    mapHeight *= MM_TO_IN;
+                }
+
+                double scaleToFitX = (extents->GetWidth() * metersPerUnit * M_TO_IN) / mapWidth;
+                double scaleToFitY = (extents->GetHeight() * metersPerUnit * M_TO_IN) / mapHeight;
+                dMapScale = rs_max(scaleToFitX, scaleToFitY);
+
+                map->SetViewScale(dMapScale);
+                center = new MgCoordinateXY(centerX, centerY);
+                if (center == NULL)
+                {
+                    throw new MgNullReferenceException(L"MgdMappingService::GenerateMultiPlot", __LINE__, __WFILE__, NULL, L"", NULL);
+                }
+                Ptr<MgPoint> centerpt = new MgPoint(center);
+                if (centerpt == NULL)
+                {
+                    throw new MgNullReferenceException(L"MgdMappingService::GenerateMultiPlot", __LINE__, __WFILE__, NULL, L"", NULL);
+                }
+                map->SetViewCenter(centerpt);
+                break;
+            }
+        default:
+            {
+                MgStringCollection arguments;
+                arguments.Add(L"1");
+                arguments.Add(L"MgMapPlotCollection");
+
+                throw new MgInvalidArgumentException(L"MgdMappingService::GenerateMultiPlot",
+                    __LINE__, __WFILE__, &arguments, L"MgInvalidMapPlotCollectionMapPlotInstruction", NULL);
+            }
+            break;
+        }
+
+        printLayout->SetPlotCenter(center);
+        printLayout->SetPlotScale(dMapScale);
+
+        // Get the map background color
+        RS_Color bgcolor;
+        StylizationUtil::ParseColor( map->GetBackgroundColor(), bgcolor);
+
+        // Get the layout background color
+        RS_Color layoutColor;
+        Ptr<MgColor> bgColor = printLayout->GetBackgroundColor();
+        layoutColor.red() = bgColor->GetRed();
+        layoutColor.green() = bgColor->GetGreen();
+        layoutColor.blue() = bgColor->GetBlue();
+
+        // Get the session ID
+        STRING sessionId;
+        /*Ptr<MgUserInformation> userInfo = MgUserInformation::GetCurrentUserInfo();
+        if (userInfo != NULL)
+            sessionId = userInfo->GetMgSessionId();*/
+
+        RS_MapUIInfo mapInfo(sessionId, map->GetName(), L"", srs, units, layoutColor);
+
+        // Dynamically adjust the width and height of the map
+        printLayout->ComputeMapOffsetAndSize(dMapScale, extents, metersPerUnit, dr.mapOffsetX(), dr.mapOffsetY(), dr.mapWidth(), dr.mapHeight(), mapPlot->GetExpandToFit());
+
+        Ptr<MgCoordinate> newll;
+        Ptr<MgCoordinate> newur;
+        if (mapPlot->GetMapPlotInstruction() != MgMapPlotInstruction::UseOverriddenExtent || mapPlot->GetExpandToFit())
+        {
+            double mapWidth = dr.mapWidth();
+            double mapHeight = dr.mapHeight();
+            if (_wcsicmp(pageUnits.c_str(), L"mm") == 0 || _wcsicmp(pageUnits.c_str(), L"millimeters") == 0)  // NOXLATE
+            {
+                mapWidth *= MM_TO_IN;
+                mapHeight *= MM_TO_IN;
+            }
+
+            env = printLayout->DetermineLayoutMapExtents(map, metersPerUnit, mapWidth, mapHeight);
+
+            newll = env->GetLowerLeftCoordinate();
+            newur = env->GetUpperRightCoordinate();
+        }
+        else if (mapPlot->GetMapPlotInstruction() == MgMapPlotInstruction::UseOverriddenExtent && !mapPlot->GetExpandToFit())
+        {
+            newll = extents->GetLowerLeftCoordinate();
+            newur = extents->GetUpperRightCoordinate();
+        }
+
+        b.minx = newll->GetX();
+        b.miny = newll->GetY();
+        b.maxx = newur->GetX();
+        b.maxy = newur->GetY();
+
+        SEMgSymbolManager semgr(m_svcResource);
+        DefaultStylizer ds(&semgr);
+
+        double dpi = map->GetDisplayDpi();
+        dr.StartMap(&mapInfo, b, dMapScale, dpi, metersPerUnit);
+
+        Ptr<MgLayerCollection> layers = map->GetLayers();
+        if (layers == NULL)
+        {
+            throw new MgNullReferenceException(L"MgdMappingService::GenerateMultiPlot", __LINE__, __WFILE__, NULL, L"", NULL);
+        }
+
+        // Define a polygon to represent the map extents and fill it with the map background color
+        dr.StartLayer(NULL, NULL);
+        LineBuffer lb(5);
+        lb.MoveTo(b.minx, b.miny);
+        lb.LineTo(b.maxx, b.miny);
+        lb.LineTo(b.maxx, b.maxy);
+        lb.LineTo(b.minx, b.maxy);
+        lb.Close();
+
+        RS_LineStroke lineStroke;
+        RS_FillStyle fillStyle(lineStroke, bgcolor, layoutColor, L"Solid");  // NOXLATE
+        dr.ProcessPolygon(&lb, fillStyle);
+        dr.EndLayer();
+
+        //transfer layers to a temporary collection
+        //here it doesn't matter but in the rendering service it does
+        Ptr<MgReadOnlyLayerCollection> rolc = new MgReadOnlyLayerCollection();
+
+        for (int u=0; u<layers->GetCount(); u++)
+        {
+            Ptr<MgLayerBase> lr = layers->GetItem(u);
+            rolc->Add(lr);
+        }
+
+        //stylize all the map layers
+        MgMappingUtil::StylizeLayers(m_svcResource, m_svcFeature, m_svcDrawing, m_pCSFactory, map,
+                                     rolc, NULL, &ds, &dr, dstCs, false, false, dMapScale);
+
+        // Finish adding the map to the page
+        // Calculate the the height of the map bounds on the page (in page units)
+        dr.mapBoundsHeight() = b.height() * dr.mapWidth()/b.width();
+
+        //construct one every time -- not really a bottleneck
+        MgLegendPlotUtil lu(m_svcResource);
+
+        // Now add the rest of the layout element to the page
+        lu.AddLayoutElements(printLayout, (STRING)mapInfo.name(), mapResId->ToString(), map, layers, b, dMapScale, metersPerUnit, dr);
+
+        dr.EndMap();
+    }
+
+    dr.Done();
+
+    // write out the file
+    Ptr<MgByteSource> bs = new MgByteSource(dwfName, true);
+
+    bs->SetMimeType(MgMimeType::Dwf);
+    byteReader = bs->GetReader();
+
+    MG_SERVER_MAPPING_SERVICE_CATCH_AND_THROW(L"MgdMappingService::GenerateMultiPlot")
+
+    return byteReader.Detach();
+}
\ No newline at end of file

Added: branches/2.4/MgDev/Desktop/MgDesktop/Services/MappingService.h
===================================================================
--- branches/2.4/MgDev/Desktop/MgDesktop/Services/MappingService.h	                        (rev 0)
+++ branches/2.4/MgDev/Desktop/MgDesktop/Services/MappingService.h	2012-06-05 11:26:26 UTC (rev 6731)
@@ -0,0 +1,91 @@
+#ifndef DESKTOP_MAPPING_SERVICE_H
+#define DESKTOP_MAPPING_SERVICE_H
+
+#include "MgDesktop.h"
+
+class MgLayout;
+class MgMapPlotCollection;
+class MgPlotSpecification;
+class MgDwfVersion;
+class MgdMap;
+
+namespace MdfModel
+{
+    class FeatureTypeStyle;
+}
+
+class MG_DESKTOP_API MgdMappingService : public MgService
+{
+    DECLARE_CLASSNAME(MgdMappingService)
+
+public:
+    //////////////////////////////////////////////////////////////////
+    /// <summary>
+    /// Destructor
+    /// </summary>
+    virtual ~MgdMappingService();
+
+    //////////////////////////////////////////////////////////////////
+    /// <summary>
+    /// Construct an MgDrawingService object
+    /// </summary>
+    MgdMappingService();
+
+PUBLISHED_API:
+    virtual MgByteReader* GenerateLegendImage(MgResourceIdentifier* resource,
+                                               double scale,
+                                               INT32 width,
+                                               INT32 height,
+                                               CREFSTRING format,
+                                               INT32 geomType,
+                                               INT32 themeCategory);
+
+    virtual MgByteReader* GeneratePlot(MgdMap* map,
+                                       MgPlotSpecification* plotSpec,
+                                       MgLayout* layout,
+                                       MgDwfVersion* dwfVersion);
+
+    virtual MgByteReader* GeneratePlot(MgdMap* map,
+                                       MgCoordinate* center,
+                                       double scale,
+                                       MgPlotSpecification* plotSpec,
+                                       MgLayout* layout,
+                                       MgDwfVersion* dwfVersion);
+
+    virtual MgByteReader* GeneratePlot(MgdMap* map,
+                                       MgEnvelope* extents,
+                                       bool expandToFit,
+                                       MgPlotSpecification* plotSpec,
+                                       MgLayout* layout,
+                                       MgDwfVersion* dwfVersion);
+
+    virtual MgByteReader* GenerateMultiPlot(MgMapPlotCollection* mapPlots, MgDwfVersion* dwfVersion);
+
+private:
+    virtual MgByteReader* GenerateMultiPlotInternal(MgMapPlotCollection* mapPlots, MgDwfVersion* dwfVersion);
+	bool FeatureTypeStyleSupportsGeomType(MdfModel::FeatureTypeStyle* fts, INT32 geomType);
+
+    // member data
+    Ptr<MgFeatureService> m_svcFeature;
+    Ptr<MgResourceService> m_svcResource;
+    Ptr<MgDrawingService> m_svcDrawing;
+    Ptr<MgCoordinateSystemFactory> m_pCSFactory;
+	
+    // Mapping Service configuration properties
+    INT32 m_rasterGridSizeForPlot;
+    INT32 m_minRasterGridSizeForPlot;
+    double m_rasterGridSizeOverrideRatioForPlot;
+    INT32 m_maxRasterImageWidth;
+    INT32 m_maxRasterImageHeight;
+
+protected:
+
+    virtual INT32 GetClassId() { return m_cls_id; }
+
+    virtual void Dispose() { delete this; }
+
+CLASS_ID:
+    static const INT32 m_cls_id = MapGuide_Desktop_RenderingService_RenderingService;
+};
+
+#endif
\ No newline at end of file

Modified: branches/2.4/MgDev/Desktop/MgDesktop/Services/RenderingService.cpp
===================================================================
--- branches/2.4/MgDev/Desktop/MgDesktop/Services/RenderingService.cpp	2012-06-04 17:19:37 UTC (rev 6730)
+++ branches/2.4/MgDev/Desktop/MgDesktop/Services/RenderingService.cpp	2012-06-05 11:26:26 UTC (rev 6731)
@@ -2,19 +2,19 @@
 #include "System/ConfigProperties.h"
 #include "AGGRenderer.h"
 #include "GDRenderer.h"
-#include "EPlotRenderer.h"
-#include "DefaultStylizer.h"
+//#include "EPlotRenderer.h"
+//#include "DefaultStylizer.h"
 #include "ImageFormats.h"
-#include "FeatureTypeStyleVisitor.h"
+//#include "FeatureTypeStyleVisitor.h"
 #include "SymbolInstance.h"
-#include "Rendering/icons.h"
-#include "Rendering/RSMgSymbolManager.h"
+//#include "Rendering/icons.h"
+//#include "Rendering/RSMgSymbolManager.h"
 #include "Rendering/RSMgFeatureReader.h"
 #include "Rendering/FeatureInfoRenderer.h"
-#include "Stylization/SEMgSymbolManager.h"
-#include "StylizationUtil.h"
+//#include "Stylization/SEMgSymbolManager.h"
+//#include "StylizationUtil.h"
 #include "Rendering/MappingUtil.h"
-#include "Rendering/LegendPlotUtil.h"
+//#include "Rendering/LegendPlotUtil.h"
 #include "MapLayer/Map.h"
 #include "Feature/TransformCache.h"
 #include "ServiceFactory.h"
@@ -22,54 +22,6 @@
 #include "Rendering/MapPlot.h"
 #include "Rendering/MapPlotCollection.h"
 
-///////////////////////////////////////////////////////////////////////////////
-/// Mg Server Mapping Service try/catch/throw macros.
-///
-#define MG_SERVER_MAPPING_SERVICE_TRY()                                       \
-    MG_TRY()                                                                  \
-
-// For the Mapping service, gracefully handle and remap any Fdo exceptions to MapGuide exceptions.
-// Some Fdo providiers like WMS return useful error strings when a request fails.
-// Without the remap, this information is lost and MapGuide returns an unclassified exception.
-#define MG_SERVER_MAPPING_SERVICE_CATCH(methodName)                         \
-    }                                                                       \
-    catch (MgException* e)                                                  \
-                                                                            \
-    {                                                                       \
-        mgException = e;                                                    \
-        mgException->AddStackTraceInfo(methodName, __LINE__, __WFILE__);    \
-    }                                                                       \
-    catch (exception& e)                                                    \
-    {                                                                       \
-        mgException = MgSystemException::Create(e, methodName, __LINE__, __WFILE__); \
-    }                                                                       \
-    catch (FdoException* e)                                                 \
-    {                                                                       \
-        STRING messageId;                                                   \
-        MgStringCollection arguments;                                       \
-        wchar_t* buf = (wchar_t*)e->GetExceptionMessage();                  \
-        INT64 nativeErrorCode = e->GetNativeErrorCode();                    \
-        if (NULL != buf)                                                    \
-        {                                                                   \
-            messageId = L"MgFormatInnerExceptionMessage";                   \
-            arguments.Add(buf);                                             \
-        }                                                                   \
-        FDO_SAFE_RELEASE(e);                                                \
-        mgException = new MgFdoException(methodName, __LINE__, __WFILE__, NULL, messageId, &arguments, nativeErrorCode); \
-    }                                                                       \
-    catch (...)                                                             \
-    {                                                                       \
-        mgException = new MgUnclassifiedException(methodName, __LINE__, __WFILE__, NULL, L"", NULL); \
-    }                                                                       \
-
-#define MG_SERVER_MAPPING_SERVICE_THROW()                                     \
-    MG_THROW()                                                                \
-
-#define MG_SERVER_MAPPING_SERVICE_CATCH_AND_THROW(methodName)                 \
-    MG_SERVER_MAPPING_SERVICE_CATCH(methodName)                               \
-                                                                              \
-    MG_SERVER_MAPPING_SERVICE_THROW()                                         \
-
 // the maximum number of allowed pixels for rendered images
 static const INT32 MAX_PIXELS = 16384*16384;
 static const INT32 FILTER_VISIBLE = 1;
@@ -98,10 +50,6 @@
 {
     m_pCSFactory = new MgCoordinateSystemFactory();
 
-    // store references to the various services we use
-    //MgServiceManager* serviceMan = MgServiceManager::GetInstance();
-    //assert(NULL != serviceMan);
-
     Ptr<MgServiceFactory> fact = new MgServiceFactory();
 
     m_svcResource = dynamic_cast<MgResourceService*>(fact->CreateService(MgServiceType::ResourceService));
@@ -149,22 +97,6 @@
                           m_maxRasterImageHeight,
                           MgConfigProperties::DefaultRenderingServicePropertyMaxRasterImageHeight);
 
-	// Set Mapping Service related properties
-	pConf->GetIntValue(MgConfigProperties::RenderingServicePropertiesSection,
-                          MgConfigProperties::RenderingServicePropertyRasterGridSizeForPlot,
-                          m_rasterGridSizeForPlot,
-                          MgConfigProperties::DefaultRenderingServicePropertyRasterGridSizeForPlot);
-
-    pConf->GetIntValue(MgConfigProperties::RenderingServicePropertiesSection,
-                          MgConfigProperties::RenderingServicePropertyMinRasterGridSizeForPlot,
-                          m_minRasterGridSizeForPlot,
-                          MgConfigProperties::DefaultRenderingServicePropertyMinRasterGridSizeForPlot);
-
-    pConf->GetDoubleValue(MgConfigProperties::RenderingServicePropertiesSection,
-                          MgConfigProperties::RenderingServicePropertyRasterGridSizeOverrideRatioForPlot,
-                          m_rasterGridSizeOverrideRatioForPlot,
-                          MgConfigProperties::DefaultRenderingServicePropertyRasterGridSizeOverrideRatioForPlot);
-
     // there should only be one instance of this class, so it's safe to
     // directly set these static variables
     bool bClampPoints;
@@ -189,839 +121,6 @@
 {
 }
 
-// Returns true if the supplied feature type style is compatible with the
-// supplied geometry type: 1=Point, 2=Line, 3=Area, 4=Composite
-bool MgRenderingService::FeatureTypeStyleSupportsGeomType(MdfModel::FeatureTypeStyle* fts, INT32 geomType)
-{
-    if (fts == NULL)
-        return false;
-
-    // if ShowInLegend is false, the legend doesn't need to be shown
-    if(!fts->IsShowInLegend())
-        return false;
-
-    // a value of -1 matches any
-    if (geomType == -1)
-        return true;
-
-    FeatureTypeStyleVisitor::eFeatureTypeStyle ftsType = FeatureTypeStyleVisitor::DetermineFeatureTypeStyle(fts);
-
-    switch (ftsType)
-    {
-        case FeatureTypeStyleVisitor::ftsPoint:
-            return (geomType == 1);
-
-        case FeatureTypeStyleVisitor::ftsLine:
-            return (geomType == 2);
-
-        case FeatureTypeStyleVisitor::ftsArea:
-            return (geomType == 3);
-
-        case FeatureTypeStyleVisitor::ftsComposite:
-            return (geomType == 4);
-    }
-
-    return false;
-}
-
-MgByteReader* MgRenderingService::GenerateLegendImage(MgResourceIdentifier* resource,
-                                                      double     scale,
-                                                      INT32      imgWidth,
-                                                      INT32      imgHeight,
-                                                      CREFSTRING format,
-                                                      INT32      geomType,
-                                                      INT32      themeCategory)
-{
-    Ptr<MgByteReader> byteReader;
-
-    MG_LOG_OPERATION_MESSAGE(L"GenerateLegendImage");
-
-    MG_SERVER_MAPPING_SERVICE_TRY()
-
-    MG_LOG_OPERATION_MESSAGE_INIT(MG_API_VERSION(1, 0, 0), 7);
-    MG_LOG_OPERATION_MESSAGE_PARAMETERS_START();
-    MG_LOG_OPERATION_MESSAGE_ADD_STRING((NULL == resource) ? L"MgResourceIdentifier" : resource->ToString().c_str());
-    MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
-    MG_LOG_OPERATION_MESSAGE_ADD_DOUBLE(scale);
-    MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
-    MG_LOG_OPERATION_MESSAGE_ADD_INT32(imgWidth);
-    MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
-    MG_LOG_OPERATION_MESSAGE_ADD_INT32(imgHeight);
-    MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
-    MG_LOG_OPERATION_MESSAGE_ADD_STRING(format.c_str());
-    MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
-    MG_LOG_OPERATION_MESSAGE_ADD_INT32(geomType);
-    MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
-    MG_LOG_OPERATION_MESSAGE_ADD_INT32(themeCategory);
-    MG_LOG_OPERATION_MESSAGE_PARAMETERS_END();
-
-    MG_LOG_TRACE_ENTRY(L"MgRenderingService::GenerateLegendImage()");
-
-    if (0 == resource)
-    {
-        throw new MgNullArgumentException(
-            L"MgRenderingService::GenerateLegendImage", __LINE__, __WFILE__, NULL, L"", NULL);
-    }
-
-    if (m_svcResource == NULL)
-    {
-        Ptr<MgServiceFactory> fact = new MgServiceFactory();
-        m_svcResource = static_cast<MgResourceService*>(fact->CreateService(MgServiceType::ResourceService));
-    }
-
-    auto_ptr<MdfModel::LayerDefinition> ldf(MgLayerBase::GetLayerDefinition(m_svcResource, resource));
-    MdfModel::VectorLayerDefinition* vl = dynamic_cast<MdfModel::VectorLayerDefinition*>(ldf.get());
-    MdfModel::DrawingLayerDefinition* dl = dynamic_cast<MdfModel::DrawingLayerDefinition*>(ldf.get());
-    MdfModel::GridLayerDefinition* gl = dynamic_cast<MdfModel::GridLayerDefinition*>(ldf.get());
-
-    if (vl) // vector layer
-    {
-        MdfModel::VectorScaleRangeCollection* src = vl->GetScaleRanges();
-
-        MdfModel::VectorScaleRange* range = NULL;
-
-        //find the right scale range
-        for (int i=0; i<src->GetCount(); i++)
-        {
-            MdfModel::VectorScaleRange* r = src->GetAt(i);
-
-            if (scale >= r->GetMinScale() && scale < r->GetMaxScale())
-            {
-                range = r;
-                break;
-            }
-        }
-
-        //we have the scale range... find the feature style
-        if (range)
-        {
-            MdfModel::FeatureTypeStyle* fts = NULL;
-
-            // The "geometry type" specifies which flavor of feature type style to use,
-            // while the theme category is a 0-based value which specifies the actual
-            // type style to use.  So if I have a scale range with two composite type
-            // styles, the first with 3 rules and the second with 2 rules, then the
-            // theme category can range from 0 to 4: 0,1,2 refer to the 3 rules in the
-            // 1st type style, while 3,4 refer to the 2 rules in the 2nd type style.
-            MdfModel::FeatureTypeStyleCollection* ftsc = range->GetFeatureTypeStyles();
-            int numFTS = ftsc->GetCount();
-            for (int j=0; j<numFTS; ++j)
-            {
-                // filter the type styles
-                MdfModel::FeatureTypeStyle* temp = ftsc->GetAt(j);
-                if (!FeatureTypeStyleSupportsGeomType(temp, geomType))
-                    continue;
-
-                // make sure we have rules
-                RuleCollection* rules = temp->GetRules();
-                if (!rules)
-                    continue;
-
-                // check if the theme category refers to one of these rules (note: a
-                // value of -1 matches anything)
-                int numRules = rules->GetCount();
-                if (themeCategory >= -1 && themeCategory < numRules)
-                {
-                    // found it
-                    fts = temp;
-                    break;
-                }
-
-                // adjust the theme category, and move to the next type style
-                themeCategory -= numRules;
-            }
-
-            if (fts)
-                byteReader = MgMappingUtil::DrawFTS(m_svcResource, fts, imgWidth, imgHeight, themeCategory);
-            else
-            {
-                //return the fixed array
-                //MgByteSource will make its own copy of the data
-                Ptr<MgByteSource> src = new MgByteSource((BYTE_ARRAY_IN)BLANK_LAYER_ICON, sizeof(BLANK_LAYER_ICON));
-                byteReader = src->GetReader();
-            }
-        }
-    }
-    else if (dl) // drawing layer
-    {
-        //return the fixed array
-        //MgByteSource will make its own copy of the data
-        Ptr<MgByteSource> src = new MgByteSource((BYTE_ARRAY_IN)DWF_LAYER_ICON, sizeof(DWF_LAYER_ICON));
-        byteReader = src->GetReader();
-    }
-    else if (gl) //grid (raster) layer
-    {
-        //return the fixed array
-        //MgByteSource will make its own copy of the data
-        Ptr<MgByteSource> src = new MgByteSource((BYTE_ARRAY_IN)RASTER_LAYER_ICON, sizeof(RASTER_LAYER_ICON));
-        byteReader = src->GetReader();
-    }
-
-    // Successful operation
-    MG_LOG_OPERATION_MESSAGE_ADD_STRING(MgResources::Success.c_str());
-
-    MG_SERVER_MAPPING_SERVICE_CATCH(L"MgRenderingService::GenerateLegendImage")
-
-    if (mgException != NULL)
-    {
-        // Failed operation
-        MG_LOG_OPERATION_MESSAGE_ADD_STRING(MgResources::Failure.c_str());
-        MG_DESKTOP_LOG_EXCEPTION();
-    }
-
-    // Add access log entry for operation
-    MG_LOG_OPERATION_MESSAGE_ACCESS_ENTRY();
-
-    MG_SERVER_MAPPING_SERVICE_THROW()
-
-    return byteReader.Detach();
-}
-
-///////////////////////////////////////////////////////////////////////////////
-void MgRenderingService::SetConnectionProperties(MgConnectionProperties*)
-{
-    // Do nothing.  No connection properties are required for server-side service objects.
-}
-
-MgByteReader* MgRenderingService::GeneratePlot(MgdMap* map,
-                                               MgPlotSpecification* plotSpec,
-                                               MgLayout* layout,
-                                               MgDwfVersion* dwfVersion)
-{
-    Ptr<MgByteReader> byteReader;
-
-    MG_LOG_OPERATION_MESSAGE(L"GeneratePlot");
-
-    MG_SERVER_MAPPING_SERVICE_TRY()
-
-    Ptr<MgResourceIdentifier> mapId;
-    if (NULL != map)
-        mapId = map->GetResourceId();
-    Ptr<MgResourceIdentifier> layoutId;
-    if (NULL != layoutId)
-        layoutId = layout->GetLayout();
-    MG_LOG_OPERATION_MESSAGE_INIT(MG_API_VERSION(1, 0, 0), 4);
-    MG_LOG_OPERATION_MESSAGE_PARAMETERS_START();
-    MG_LOG_OPERATION_MESSAGE_ADD_STRING((NULL == mapId) ? L"MgResourceIdentifier" : mapId->ToString().c_str());
-    MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
-    MG_LOG_OPERATION_MESSAGE_ADD_STRING(L"MgPlotSpecification");
-    MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
-    MG_LOG_OPERATION_MESSAGE_ADD_STRING((NULL == layoutId) ? L"MgResourceIdentifier" : layoutId->ToString().c_str());
-    MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
-    MG_LOG_OPERATION_MESSAGE_ADD_STRING((NULL == dwfVersion) ? L"MgDwfVersion" : dwfVersion->GetLogString());
-    MG_LOG_OPERATION_MESSAGE_PARAMETERS_END();
-
-    MG_LOG_TRACE_ENTRY(L"MgRenderingService::GeneratePlot()");
-
-    if (NULL == map  || NULL == dwfVersion || NULL == plotSpec )
-    {
-        throw new MgNullArgumentException(
-            L"MgRenderingService::GeneratePlot", __LINE__, __WFILE__, NULL, L"", NULL);
-    }
-
-    // Create a MgMapPlot which will be passed to GenerateMultiPlot
-    Ptr<MgMapPlot> mapPlot = new MgMapPlot(map, plotSpec, layout);
-
-    // Add it to a MgMapPlotCollecion
-    Ptr<MgMapPlotCollection> mapPlots = new MgMapPlotCollection();
-    mapPlots->Add(mapPlot);
-
-    // Create the plot
-    byteReader = GenerateMultiPlotInternal(mapPlots, dwfVersion);
-
-    // Successful operation
-    MG_LOG_OPERATION_MESSAGE_ADD_STRING(MgResources::Success.c_str());
-
-    MG_SERVER_MAPPING_SERVICE_CATCH(L"MgRenderingService::GeneratePlot")
-
-    if (mgException != NULL)
-    {
-        // Failed operation
-        MG_LOG_OPERATION_MESSAGE_ADD_STRING(MgResources::Failure.c_str());
-        MG_DESKTOP_LOG_EXCEPTION();
-    }
-
-    // Add access log entry for operation
-    MG_LOG_OPERATION_MESSAGE_ACCESS_ENTRY();
-
-    MG_SERVER_MAPPING_SERVICE_THROW()
-
-    return byteReader.Detach();
-}
-
-MgByteReader* MgRenderingService::GeneratePlot(MgdMap* map,
-                                               MgCoordinate* center,
-                                               double scale,
-                                               MgPlotSpecification* plotSpec,
-                                               MgLayout* layout,
-                                               MgDwfVersion* dwfVersion)
-{
-    Ptr<MgByteReader> byteReader;
-
-    MG_LOG_OPERATION_MESSAGE(L"GeneratePlot");
-
-    MG_SERVER_MAPPING_SERVICE_TRY()
-
-    Ptr<MgResourceIdentifier> mapId;
-    if (NULL != map)
-        mapId = map->GetResourceId();
-    Ptr<MgResourceIdentifier> layoutId;
-    if (NULL != layoutId)
-        layoutId = layout->GetLayout();
-    MG_LOG_OPERATION_MESSAGE_INIT(MG_API_VERSION(1, 0, 0), 6);
-    MG_LOG_OPERATION_MESSAGE_PARAMETERS_START();
-    MG_LOG_OPERATION_MESSAGE_ADD_STRING((NULL == mapId) ? L"MgResourceIdentifier" : mapId->ToString().c_str());
-    MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
-    MG_LOG_OPERATION_MESSAGE_ADD_STRING(L"MgCoordinate")
-    MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
-    MG_LOG_OPERATION_MESSAGE_ADD_DOUBLE(scale)
-    MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
-    MG_LOG_OPERATION_MESSAGE_ADD_STRING(L"MgPlotSpecification");
-    MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
-    MG_LOG_OPERATION_MESSAGE_ADD_STRING((NULL == layoutId) ? L"MgResourceIdentifier" : layoutId->ToString().c_str());
-    MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
-    MG_LOG_OPERATION_MESSAGE_ADD_STRING((NULL == dwfVersion) ? L"MgDwfVersion" : dwfVersion->GetLogString());
-    MG_LOG_OPERATION_MESSAGE_PARAMETERS_END();
-
-    MG_LOG_TRACE_ENTRY(L"MgRenderingService::GeneratePlot()");
-
-    if (NULL == map  || NULL == center || NULL == dwfVersion || NULL == plotSpec )
-    {
-        throw new MgNullArgumentException(
-            L"MgRenderingService::GeneratePlot", __LINE__, __WFILE__, NULL, L"", NULL);
-    }
-
-    // Create a MgMapPlot which will be passed to GenerateMultiPlot
-    Ptr<MgMapPlot> mapPlot = new MgMapPlot(map, center, scale, plotSpec, layout);
-
-    // Add it to a MgMapPlotCollecion
-    Ptr<MgMapPlotCollection> mapPlots = new MgMapPlotCollection();
-    mapPlots->Add(mapPlot);
-
-    // Create the plot
-    byteReader = GenerateMultiPlotInternal(mapPlots, dwfVersion);
-
-    // Successful operation
-    MG_LOG_OPERATION_MESSAGE_ADD_STRING(MgResources::Success.c_str());
-
-    MG_SERVER_MAPPING_SERVICE_CATCH(L"MgRenderingService::GeneratePlot")
-
-    if (mgException != NULL)
-    {
-        // Failed operation
-        MG_LOG_OPERATION_MESSAGE_ADD_STRING(MgResources::Failure.c_str());
-        MG_DESKTOP_LOG_EXCEPTION();
-    }
-
-    // Add access log entry for operation
-    MG_LOG_OPERATION_MESSAGE_ACCESS_ENTRY();
-
-    MG_SERVER_MAPPING_SERVICE_THROW()
-
-    return byteReader.Detach();
-}
-
-MgByteReader* MgRenderingService::GeneratePlot(MgdMap* map,
-                                               MgEnvelope* extents,
-                                               bool expandToFit,
-                                               MgPlotSpecification* plotSpec,
-                                               MgLayout* layout,
-                                               MgDwfVersion* dwfVersion)
-{
-    Ptr<MgByteReader> byteReader;
-
-    MG_LOG_OPERATION_MESSAGE(L"GeneratePlot");
-    MG_SERVER_MAPPING_SERVICE_TRY()
-
-    Ptr<MgResourceIdentifier> mapId;
-    if (NULL != map)
-        mapId = map->GetResourceId();
-    Ptr<MgResourceIdentifier> layoutId;
-    if (NULL != layoutId)
-        layoutId = layout->GetLayout();
-
-    MG_LOG_OPERATION_MESSAGE_INIT(MG_API_VERSION(1, 0, 0), 6);
-    MG_LOG_OPERATION_MESSAGE_PARAMETERS_START();
-    MG_LOG_OPERATION_MESSAGE_ADD_STRING((NULL == mapId) ? L"MgResourceIdentifier" : mapId->ToString().c_str());
-    MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
-    MG_LOG_OPERATION_MESSAGE_ADD_STRING(L"MgEnvelope")
-    MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
-    MG_LOG_OPERATION_MESSAGE_ADD_BOOL(expandToFit)
-    MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
-    MG_LOG_OPERATION_MESSAGE_ADD_STRING(L"MgPlotSpecification");
-    MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
-    MG_LOG_OPERATION_MESSAGE_ADD_STRING((NULL == layoutId) ? L"MgResourceIdentifier" : layoutId->ToString().c_str());
-    MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
-    MG_LOG_OPERATION_MESSAGE_ADD_STRING((NULL == dwfVersion) ? L"MgDwfVersion" : dwfVersion->GetLogString());
-    MG_LOG_OPERATION_MESSAGE_PARAMETERS_END();
-
-    MG_LOG_TRACE_ENTRY(L"MgRenderingService::GeneratePlot()");
-
-    if (NULL == map  || NULL == extents || NULL == plotSpec || NULL == dwfVersion )
-    {
-        throw new MgNullArgumentException(
-            L"MgRenderingService::GeneratePlot", __LINE__, __WFILE__, NULL, L"", NULL);
-    }
-
-    // Make a copy of the extents
-    Ptr<MgCoordinate> oldll = extents->GetLowerLeftCoordinate();
-    Ptr<MgCoordinate> oldur = extents->GetUpperRightCoordinate();
-    Ptr<MgCoordinate> ll = new MgCoordinateXY(oldll->GetX(), oldll->GetY());
-    Ptr<MgCoordinate> ur = new MgCoordinateXY(oldur->GetX(), oldur->GetY());
-    if (ll == NULL || ur == NULL)
-    {
-        throw new MgNullArgumentException(L"MgRenderingService::GeneratePlot", __LINE__, __WFILE__, NULL, L"", NULL);
-    }
-    Ptr<MgEnvelope> env = new MgEnvelope(ll, ur);
-
-    // Create a MgMapPlot which will be passed to GenerateMultiPlot
-    Ptr<MgMapPlot> mapPlot = new MgMapPlot(map, env, expandToFit, plotSpec, layout);
-
-    // Add it to a MgMapPlotCollecion
-    Ptr<MgMapPlotCollection> mapPlots = new MgMapPlotCollection();
-    if (mapPlot == NULL || mapPlots == NULL)
-    {
-        throw new MgNullArgumentException(L"MgRenderingService::GeneratePlot", __LINE__, __WFILE__, NULL, L"", NULL);
-    }
-    mapPlots->Add(mapPlot);
-
-    // Create the plot
-    byteReader = GenerateMultiPlotInternal(mapPlots, dwfVersion);
-
-    // Successful operation
-    MG_LOG_OPERATION_MESSAGE_ADD_STRING(MgResources::Success.c_str());
-
-    MG_SERVER_MAPPING_SERVICE_CATCH(L"MgRenderingService::GeneratePlot")
-
-    if (mgException != NULL)
-    {
-        // Failed operation
-        MG_LOG_OPERATION_MESSAGE_ADD_STRING(MgResources::Failure.c_str());
-        MG_DESKTOP_LOG_EXCEPTION();
-    }
-
-    // Add access log entry for operation
-    MG_LOG_OPERATION_MESSAGE_ACCESS_ENTRY();
-
-    MG_SERVER_MAPPING_SERVICE_THROW()
-
-    return byteReader.Detach();
-}
-
-MgByteReader* MgRenderingService::GenerateMultiPlot(MgMapPlotCollection* mapPlots, MgDwfVersion* dwfVersion)
-{
-    Ptr<MgByteReader> ret;
-    MG_LOG_OPERATION_MESSAGE(L"GenerateMultiPlot");
-
-    MG_SERVER_MAPPING_SERVICE_TRY()
-
-    MG_LOG_OPERATION_MESSAGE_INIT(MG_API_VERSION(1, 0, 0), 2);
-    MG_LOG_OPERATION_MESSAGE_PARAMETERS_START();
-    MG_LOG_OPERATION_MESSAGE_ADD_STRING(L"MgMapPlotCollection");
-    MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
-    MG_LOG_OPERATION_MESSAGE_ADD_STRING((NULL == dwfVersion) ? L"MgDwfVersion" : dwfVersion->GetLogString().c_str());
-    MG_LOG_OPERATION_MESSAGE_PARAMETERS_END();
-
-    MG_LOG_TRACE_ENTRY(L"MgRenderingService::GenerateMultiPlot()");
-
-    ret = GenerateMultiPlotInternal(mapPlots, dwfVersion);
-
-    // Successful operation
-    MG_LOG_OPERATION_MESSAGE_ADD_STRING(MgResources::Success.c_str());
-
-    MG_SERVER_MAPPING_SERVICE_CATCH(L"MgRenderingService::GenerateMultiPlot")
-
-    if (mgException != NULL)
-    {
-        // Failed operation
-        MG_LOG_OPERATION_MESSAGE_ADD_STRING(MgResources::Failure.c_str());
-        MG_DESKTOP_LOG_EXCEPTION();
-    }
-
-    // Add access log entry for operation
-    MG_LOG_OPERATION_MESSAGE_ACCESS_ENTRY();
-
-    MG_SERVER_MAPPING_SERVICE_THROW()
-    return ret.Detach();
-}
-
-MgByteReader* MgRenderingService::GenerateMultiPlotInternal(MgMapPlotCollection* mapPlots, MgDwfVersion* dwfVersion)
-{
-    Ptr<MgByteReader> byteReader;
-
-    MG_SERVER_MAPPING_SERVICE_TRY()
-
-    MG_LOG_TRACE_ENTRY(L"MgRenderingService::GenerateMultiPlot()");
-
-    if (0 == mapPlots || 0 == dwfVersion)
-    {
-        throw new MgNullArgumentException(
-            L"MgRenderingService::GenerateMultiPlot", __LINE__, __WFILE__, NULL, L"", NULL);
-    }
-
-    // get a temporary file to write out EPlot DWF to
-    // TODO: clean the temp file name prefix
-    STRING dwfName = MgFileUtil::GenerateTempFileName(false, L"default_prefix");
-
-    EPlotRenderer dr(dwfName.c_str(), 0, 0, L"inches");  // NOXLATE
-
-    dr.SetRasterGridSize(m_rasterGridSizeForPlot);
-    dr.SetMinRasterGridSize(m_minRasterGridSizeForPlot);
-    dr.SetRasterGridSizeOverrideRatio(m_rasterGridSizeOverrideRatioForPlot);
-    dr.SetMaxRasterImageWidth(m_maxRasterImageWidth);
-    dr.SetMaxRasterImageHeight(m_maxRasterImageHeight);
-
-    RSMgSymbolManager mgr(m_svcResource);
-    dr.SetSymbolManager(&mgr);
-
-    // process the MapPlot collection
-    for (int nMapPlotIndex = 0; nMapPlotIndex < mapPlots->GetCount(); nMapPlotIndex++)
-    {
-        Ptr<MgMapPlot> mapPlot = mapPlots->GetItem(nMapPlotIndex);
-        if (NULL == mapPlot)
-        {
-            throw new MgNullReferenceException(L"MgRenderingService::GenerateMultiPlot", __LINE__, __WFILE__, NULL, L"", NULL);
-        }
-
-        Ptr<MgdMap> map = mapPlot->GetMap();
-        if (NULL == map)
-        {
-            throw new MgNullReferenceException(L"MgRenderingService::GenerateMultiPlot", __LINE__, __WFILE__, NULL, L"", NULL);
-        }
-
-        Ptr<MgPlotSpecification> plotSpec = mapPlot->GetPlotSpecification();
-        if (NULL == plotSpec)
-        {
-            throw new MgNullReferenceException(L"MgRenderingService::GenerateMultiPlot", __LINE__, __WFILE__, NULL, L"", NULL);
-        }
-
-        Ptr<MgLayout> layout = mapPlot->GetLayout();
-
-        double width = plotSpec->GetPaperWidth();
-        double height = plotSpec->GetPaperHeight();
-        STRING pageUnits = plotSpec->GetPageSizeUnits();
-
-        dr.SetPageWidth(width);
-        dr.SetPageHeight(height);
-        dr.SetPageSizeUnits(pageUnits);
-        dr.SetMapWidth(width);
-        dr.SetMapHeight(height);
-        dr.mapBoundsHeight() = height;
-
-        // temporary place for the resId of the Map
-        Ptr<MgResourceIdentifier> mapResId = map->GetMapDefinition();
-
-        // request extenst
-        Ptr<MgEnvelope> env = map->GetDataExtent();
-        if (env == NULL)
-        {
-            throw new MgNullReferenceException(L"MgRenderingService::GenerateMultiPlot", __LINE__, __WFILE__, NULL, L"", NULL);
-        }
-
-        Ptr<MgCoordinate> ll = env->GetLowerLeftCoordinate();
-        Ptr<MgCoordinate> ur = env->GetUpperRightCoordinate();
-        if (ll == NULL || ur == NULL)
-        {
-            throw new MgNullReferenceException(L"MgRenderingService::GenerateMultiPlot", __LINE__, __WFILE__, NULL, L"", NULL);
-        }
-        RS_Bounds b(ll->GetX(), ll->GetY(), ur->GetX(), ur->GetY());
-
-        //if requested data extent is not valid, use map definition extent
-        // this may be removed eventually, but is a good sanity check nonetheless
-        if (!b.IsValid())
-        {
-            Ptr<MgEnvelope> env2 = map->GetMapExtent();
-            if (env2 == NULL)
-            {
-                throw new MgNullReferenceException(L"MgRenderingService::GenerateMultiPlot", __LINE__, __WFILE__, NULL, L"", NULL);
-            }
-
-            Ptr<MgCoordinate> ll2 = env2->GetLowerLeftCoordinate();
-            Ptr<MgCoordinate> ur2 = env2->GetUpperRightCoordinate();
-            if (ll2 == NULL || ur2 == NULL)
-            {
-                throw new MgNullReferenceException(L"MgRenderingService::GenerateMultiPlot", __LINE__, __WFILE__, NULL, L"", NULL);
-            }
-
-            b.minx = ll2->GetX();
-            b.miny = ll2->GetY();
-            b.maxx = ur2->GetX();
-            b.maxy = ur2->GetY();
-        }
-
-        // Create a simple print layout containing only the map
-        Ptr<MgPrintLayout> printLayout = new MgPrintLayout();
-        if (printLayout == NULL)
-        {
-            throw new MgNullReferenceException(L"MgRenderingService::GenerateMultiPlot", __LINE__, __WFILE__, NULL, L"", NULL);
-        }
-
-        if (NULL != layout)
-        {
-            Ptr<MgResourceIdentifier> resID = layout->GetLayout();
-            printLayout->Create(m_svcResource, resID);
-            printLayout->SetPlotSize(plotSpec);
-            printLayout->SetScaleBarUnits(layout->GetUnitType());
-            printLayout->SetPlotTitle(layout->GetTitle());
-
-            Ptr<MgPlotSpecification> spec = printLayout->GetPlotSize();
-
-            width = spec->GetPaperWidth();
-            height = spec->GetPaperHeight();
-            pageUnits = spec->GetPageSizeUnits();
-        }
-        else
-        {
-            printLayout->SetPlotSize(plotSpec);
-        }
-
-        printLayout->PageWidth() = width;
-        printLayout->PageHeight() = height;
-        printLayout->Units() = pageUnits;
-
-        dr.EnableLayoutPlot();
-
-        //get the map coordinate system
-        MdfModel::MdfString srs = map->GetMapSRS();
-        Ptr<MgCoordinateSystem> dstCs;
-        if (!srs.empty())
-        {
-            //let's not fail here if coord sys conversion fails for the
-            //map's coordinate system. Instead we will fail per layer at a later stage
-            try
-            {
-                dstCs = m_pCSFactory->Create(srs);
-            }
-            catch (MgInvalidCoordinateSystemException* e)
-            {
-                e->Release();
-            }
-        }
-
-        double metersPerUnit = (dstCs.p) ? dstCs->ConvertCoordinateSystemUnitsToMeters(1.0) : 1.0;
-        RS_String units = (dstCs.p) ? dstCs->GetUnits() : L"";
-
-        double dMapScale = 0.0;
-        Ptr<MgCoordinate> center = new MgCoordinateXY(0, 0);
-        Ptr<MgEnvelope> extents = map->GetMapExtent();
-        if (center == NULL || extents == NULL)
-        {
-            throw new MgNullReferenceException(L"MgRenderingService::GenerateMultiPlot", __LINE__, __WFILE__, NULL, L"", NULL);
-        }
-
-        switch (mapPlot->GetMapPlotInstruction())
-        {
-        case MgMapPlotInstruction::UseMapCenterAndScale:
-            {
-                dMapScale = map->GetViewScale();
-                if (dMapScale <= 0)
-                {
-                    Ptr<MgEnvelope> extents = map->GetDataExtent();
-                    if (extents == NULL)
-                    {
-                        throw new MgNullReferenceException(L"MgRenderingService::GenerateMultiPlot", __LINE__, __WFILE__, NULL, L"", NULL);
-                    }
-                    printLayout->ComputeMapOffsetAndSize(dMapScale, extents, metersPerUnit, dr.mapOffsetX(), dr.mapOffsetY(), dr.mapWidth(), dr.mapHeight());
-                    double mapWidth = dr.mapWidth();
-                    double mapHeight = dr.mapHeight();
-                    if (_wcsicmp(pageUnits.c_str(), L"mm") == 0 || _wcsicmp(pageUnits.c_str(), L"millimeters") == 0) // NOXLATE
-                    {
-                        mapWidth *= MM_TO_IN;
-                        mapHeight *= MM_TO_IN;
-                    }
-
-                    double scaleToFitX = (extents->GetWidth() * metersPerUnit * M_TO_IN) / mapWidth;
-                    double scaleToFitY = (extents->GetHeight() * metersPerUnit * M_TO_IN) / mapHeight;
-                    dMapScale = rs_max(scaleToFitX, scaleToFitY);
-                }
-
-                Ptr<MgPoint> pt = map->GetViewCenter();
-                center = pt->GetCoordinate();
-                break;
-            }
-        case MgMapPlotInstruction::UseOverriddenCenterAndScale:
-            {
-                dMapScale = mapPlot->GetScale();
-                center = mapPlot->GetCenter();
-                break;
-            }
-        case MgMapPlotInstruction::UseOverriddenExtent:
-            {
-                // Compute the plotCenter and plotScale from the extents
-                extents = mapPlot->GetExtent();
-                //...plotCenter
-                Ptr<MgCoordinate> plotll = extents->GetLowerLeftCoordinate();
-                Ptr<MgCoordinate> plotur = extents->GetUpperRightCoordinate();
-                if (plotll == NULL || plotur == NULL)
-                {
-                    throw new MgNullReferenceException(L"MgRenderingService::GenerateMultiPlot", __LINE__, __WFILE__, NULL, L"", NULL);
-                }
-                double minX = plotll->GetX();
-                double minY = plotll->GetY();
-                double maxX = plotur->GetX();
-                double maxY = plotur->GetY();
-                double centerX = minX + (maxX - minX) * 0.5;
-                double centerY = minY + (maxY - minY) * 0.5;
-                //
-                //...plotScale
-                printLayout->ComputeMapOffsetAndSize(dMapScale, extents, metersPerUnit, dr.mapOffsetX(), dr.mapOffsetY(), dr.mapWidth(), dr.mapHeight());
-                double mapWidth = dr.mapWidth();
-                double mapHeight = dr.mapHeight();
-                if (_wcsicmp(pageUnits.c_str(), L"mm") == 0 || _wcsicmp(pageUnits.c_str(), L"millimeters") == 0)  // NOXLATE
-                {
-                    mapWidth *= MM_TO_IN;
-                    mapHeight *= MM_TO_IN;
-                }
-
-                double scaleToFitX = (extents->GetWidth() * metersPerUnit * M_TO_IN) / mapWidth;
-                double scaleToFitY = (extents->GetHeight() * metersPerUnit * M_TO_IN) / mapHeight;
-                dMapScale = rs_max(scaleToFitX, scaleToFitY);
-
-                map->SetViewScale(dMapScale);
-                center = new MgCoordinateXY(centerX, centerY);
-                if (center == NULL)
-                {
-                    throw new MgNullReferenceException(L"MgRenderingService::GenerateMultiPlot", __LINE__, __WFILE__, NULL, L"", NULL);
-                }
-                Ptr<MgPoint> centerpt = new MgPoint(center);
-                if (centerpt == NULL)
-                {
-                    throw new MgNullReferenceException(L"MgRenderingService::GenerateMultiPlot", __LINE__, __WFILE__, NULL, L"", NULL);
-                }
-                map->SetViewCenter(centerpt);
-                break;
-            }
-        default:
-            {
-                MgStringCollection arguments;
-                arguments.Add(L"1");
-                arguments.Add(L"MgMapPlotCollection");
-
-                throw new MgInvalidArgumentException(L"MgRenderingService::GenerateMultiPlot",
-                    __LINE__, __WFILE__, &arguments, L"MgInvalidMapPlotCollectionMapPlotInstruction", NULL);
-            }
-            break;
-        }
-
-        printLayout->SetPlotCenter(center);
-        printLayout->SetPlotScale(dMapScale);
-
-        // Get the map background color
-        RS_Color bgcolor;
-        StylizationUtil::ParseColor( map->GetBackgroundColor(), bgcolor);
-
-        // Get the layout background color
-        RS_Color layoutColor;
-        Ptr<MgColor> bgColor = printLayout->GetBackgroundColor();
-        layoutColor.red() = bgColor->GetRed();
-        layoutColor.green() = bgColor->GetGreen();
-        layoutColor.blue() = bgColor->GetBlue();
-
-        // Get the session ID
-        STRING sessionId;
-        /*Ptr<MgUserInformation> userInfo = MgUserInformation::GetCurrentUserInfo();
-        if (userInfo != NULL)
-            sessionId = userInfo->GetMgSessionId();*/
-
-        RS_MapUIInfo mapInfo(sessionId, map->GetName(), L"", srs, units, layoutColor);
-
-        // Dynamically adjust the width and height of the map
-        printLayout->ComputeMapOffsetAndSize(dMapScale, extents, metersPerUnit, dr.mapOffsetX(), dr.mapOffsetY(), dr.mapWidth(), dr.mapHeight(), mapPlot->GetExpandToFit());
-
-        Ptr<MgCoordinate> newll;
-        Ptr<MgCoordinate> newur;
-        if (mapPlot->GetMapPlotInstruction() != MgMapPlotInstruction::UseOverriddenExtent || mapPlot->GetExpandToFit())
-        {
-            double mapWidth = dr.mapWidth();
-            double mapHeight = dr.mapHeight();
-            if (_wcsicmp(pageUnits.c_str(), L"mm") == 0 || _wcsicmp(pageUnits.c_str(), L"millimeters") == 0)  // NOXLATE
-            {
-                mapWidth *= MM_TO_IN;
-                mapHeight *= MM_TO_IN;
-            }
-
-            env = printLayout->DetermineLayoutMapExtents(map, metersPerUnit, mapWidth, mapHeight);
-
-            newll = env->GetLowerLeftCoordinate();
-            newur = env->GetUpperRightCoordinate();
-        }
-        else if (mapPlot->GetMapPlotInstruction() == MgMapPlotInstruction::UseOverriddenExtent && !mapPlot->GetExpandToFit())
-        {
-            newll = extents->GetLowerLeftCoordinate();
-            newur = extents->GetUpperRightCoordinate();
-        }
-
-        b.minx = newll->GetX();
-        b.miny = newll->GetY();
-        b.maxx = newur->GetX();
-        b.maxy = newur->GetY();
-
-        SEMgSymbolManager semgr(m_svcResource);
-        DefaultStylizer ds(&semgr);
-
-        double dpi = map->GetDisplayDpi();
-        dr.StartMap(&mapInfo, b, dMapScale, dpi, metersPerUnit);
-
-        Ptr<MgLayerCollection> layers = map->GetLayers();
-        if (layers == NULL)
-        {
-            throw new MgNullReferenceException(L"MgRenderingService::GenerateMultiPlot", __LINE__, __WFILE__, NULL, L"", NULL);
-        }
-
-        // Define a polygon to represent the map extents and fill it with the map background color
-        dr.StartLayer(NULL, NULL);
-        LineBuffer lb(5);
-        lb.MoveTo(b.minx, b.miny);
-        lb.LineTo(b.maxx, b.miny);
-        lb.LineTo(b.maxx, b.maxy);
-        lb.LineTo(b.minx, b.maxy);
-        lb.Close();
-
-        RS_LineStroke lineStroke;
-        RS_FillStyle fillStyle(lineStroke, bgcolor, layoutColor, L"Solid");  // NOXLATE
-        dr.ProcessPolygon(&lb, fillStyle);
-        dr.EndLayer();
-
-        //transfer layers to a temporary collection
-        //here it doesn't matter but in the rendering service it does
-        Ptr<MgReadOnlyLayerCollection> rolc = new MgReadOnlyLayerCollection();
-
-        for (int u=0; u<layers->GetCount(); u++)
-        {
-            Ptr<MgLayerBase> lr = layers->GetItem(u);
-            rolc->Add(lr);
-        }
-
-        //stylize all the map layers
-        MgMappingUtil::StylizeLayers(m_svcResource, m_svcFeature, m_svcDrawing, m_pCSFactory, map,
-                                     rolc, NULL, &ds, &dr, dstCs, false, false, dMapScale);
-
-        // Finish adding the map to the page
-        // Calculate the the height of the map bounds on the page (in page units)
-        dr.mapBoundsHeight() = b.height() * dr.mapWidth()/b.width();
-
-        //construct one every time -- not really a bottleneck
-        MgLegendPlotUtil lu(m_svcResource);
-
-        // Now add the rest of the layout element to the page
-        lu.AddLayoutElements(printLayout, (STRING)mapInfo.name(), mapResId->ToString(), map, layers, b, dMapScale, metersPerUnit, dr);
-
-        dr.EndMap();
-    }
-
-    dr.Done();
-
-    // write out the file
-    Ptr<MgByteSource> bs = new MgByteSource(dwfName, true);
-
-    bs->SetMimeType(MgMimeType::Dwf);
-    byteReader = bs->GetReader();
-
-    MG_SERVER_MAPPING_SERVICE_CATCH_AND_THROW(L"MgRenderingService::GenerateMultiPlot")
-
-    return byteReader.Detach();
-}
-
 // ---------------------------------- BEGIN Rendering Service APIs ----------------------------------------------- //
 
 ///////////////////////////////////////////////////////////////////////////////

Modified: branches/2.4/MgDev/Desktop/MgDesktop/Services/RenderingService.h
===================================================================
--- branches/2.4/MgDev/Desktop/MgDesktop/Services/RenderingService.h	2012-06-04 17:19:37 UTC (rev 6730)
+++ branches/2.4/MgDev/Desktop/MgDesktop/Services/RenderingService.h	2012-06-05 11:26:26 UTC (rev 6731)
@@ -1,10 +1,6 @@
 #ifndef DESKTOP_RENDERING_SERVICE_H
 #define DESKTOP_RENDERING_SERVICE_H
 
-class MgLayout;
-class MgMapPlotCollection;
-class MgPlotSpecification;
-class MgDwfVersion;
 class MgdMap;
 class SE_Renderer;
 class MgRenderingOptions;
@@ -36,7 +32,7 @@
 
     DECLARE_CREATE_SERVICE()
 
-    void SetConnectionProperties(MgConnectionProperties* connProp);
+    //void SetConnectionProperties(MgConnectionProperties* connProp);
 
 PUBLISHED_API:
 
@@ -78,42 +74,6 @@
                                           INT32 height,
                                           MgColor* backgroundColor,
                                           CREFSTRING format);
-
-    // --------------- BEGIN: DWF Rendering and miscellaneous APIs from MgMappingService -----------------------//
-	 virtual MgByteReader* GenerateLegendImage(MgResourceIdentifier* resource,
-                                               double scale,
-                                               INT32 width,
-                                               INT32 height,
-                                               CREFSTRING format,
-                                               INT32 geomType,
-                                               INT32 themeCategory);
-
-    virtual MgByteReader* GeneratePlot(MgdMap* map,
-                                       MgPlotSpecification* plotSpec,
-                                       MgLayout* layout,
-                                       MgDwfVersion* dwfVersion);
-
-    virtual MgByteReader* GeneratePlot(MgdMap* map,
-                                       MgCoordinate* center,
-                                       double scale,
-                                       MgPlotSpecification* plotSpec,
-                                       MgLayout* layout,
-                                       MgDwfVersion* dwfVersion);
-
-    virtual MgByteReader* GeneratePlot(MgdMap* map,
-                                       MgEnvelope* extents,
-                                       bool expandToFit,
-                                       MgPlotSpecification* plotSpec,
-                                       MgLayout* layout,
-                                       MgDwfVersion* dwfVersion);
-
-    virtual MgByteReader* GenerateMultiPlot(MgMapPlotCollection* mapPlots, MgDwfVersion* dwfVersion);
-
-private:
-    virtual MgByteReader* GenerateMultiPlotInternal(MgMapPlotCollection* mapPlots, MgDwfVersion* dwfVersion);
-	bool FeatureTypeStyleSupportsGeomType(MdfModel::FeatureTypeStyle* fts, INT32 geomType);
-	// --------------- END: DWF Rendering and miscellaneous APIs from MgMappingService -----------------------//
-
 INTERNAL_API:
 
     virtual MgByteReader* RenderDynamicOverlay(MgdMap* map,
@@ -309,19 +269,13 @@
     INT32 m_maxRasterImageWidth;
     INT32 m_maxRasterImageHeight;
 
-	// Mapping Service configuration properties
-    INT32 m_rasterGridSizeForPlot;
-    INT32 m_minRasterGridSizeForPlot;
-    double m_rasterGridSizeOverrideRatioForPlot;
-
 protected:
-
     virtual INT32 GetClassId() { return m_cls_id; }
 
     virtual void Dispose() { delete this; }
 
 CLASS_ID:
-    static const INT32 m_cls_id = MapGuide_Desktop_RenderingService_RenderingService;
+    static const INT32 m_cls_id = MapGuide_Desktop_MappingService_MappingService;
 };
 
 #endif
\ No newline at end of file

Modified: branches/2.4/MgDev/Desktop/MgDesktop/Services/ServiceFactory.cpp
===================================================================
--- branches/2.4/MgDev/Desktop/MgDesktop/Services/ServiceFactory.cpp	2012-06-04 17:19:37 UTC (rev 6730)
+++ branches/2.4/MgDev/Desktop/MgDesktop/Services/ServiceFactory.cpp	2012-06-05 11:26:26 UTC (rev 6731)
@@ -1,6 +1,7 @@
 #include "ServiceFactory.h"
 #include "ResourceService.h"
 #include "FeatureService.h"
+#include "MappingService.h"
 #include "ProfilingService.h"
 #include "RenderingService.h"
 #include "DrawingService.h"
@@ -60,6 +61,8 @@
         return new MgDrawingService();
     case MgServiceType::FeatureService:
         return new MgdFeatureService();
+    case MgServiceType::MappingService:
+        return new MgdMappingService();
 	case MgServiceType::ProfilingService:
 		return new MgProfilingService();
     case MgServiceType::RenderingService:

Modified: branches/2.4/MgDev/Desktop/MgDesktop/Services/ServiceFactory.h
===================================================================
--- branches/2.4/MgDev/Desktop/MgDesktop/Services/ServiceFactory.h	2012-06-04 17:19:37 UTC (rev 6730)
+++ branches/2.4/MgDev/Desktop/MgDesktop/Services/ServiceFactory.h	2012-06-05 11:26:26 UTC (rev 6731)
@@ -4,6 +4,7 @@
 class MgService;
 class MgTileService;
 class MgdFeatureService;
+class MgdMappingService;
 class MgdResourceService;
 class MgDrawingService;
 class MgRenderingService;

Modified: branches/2.4/MgDev/Desktop/MgDesktop/System/ClassId.h
===================================================================
--- branches/2.4/MgDev/Desktop/MgDesktop/System/ClassId.h	2012-06-04 17:19:37 UTC (rev 6730)
+++ branches/2.4/MgDev/Desktop/MgDesktop/System/ClassId.h	2012-06-05 11:26:26 UTC (rev 6731)
@@ -101,7 +101,7 @@
 #define MapGuide_Desktop_DrawingService_DrawingService          MAPGUIDE_DESKTOP_DRAWINGSERVICE_ID+0
 
 // Mapping Service
-//#define MapGuide_Desktop_MappingService_MappingService                      MAPGUIDE_DESKTOP_MAPPINGSERVICE_ID+0
+#define MapGuide_Desktop_MappingService_MappingService                      MAPGUIDE_DESKTOP_MAPPINGSERVICE_ID+0
 #define MapGuide_Desktop_MappingService_DwfVersion                          MAPGUIDE_DESKTOP_MAPPINGSERVICE_ID+1
 #define MapGuide_Desktop_MappingService_PlotSpecification                   MAPGUIDE_DESKTOP_MAPPINGSERVICE_ID+2
 #define MapGuide_Desktop_MappingService_PrintLayout                         MAPGUIDE_DESKTOP_MAPPINGSERVICE_ID+3

Modified: branches/2.4/MgDev/Desktop/SampleExtension/MgPlotToDwfComponent.cs
===================================================================
--- branches/2.4/MgDev/Desktop/SampleExtension/MgPlotToDwfComponent.cs	2012-06-04 17:19:37 UTC (rev 6730)
+++ branches/2.4/MgDev/Desktop/SampleExtension/MgPlotToDwfComponent.cs	2012-06-05 11:26:26 UTC (rev 6731)
@@ -25,14 +25,14 @@
                     save.Filter = "DWF Files (*.dwf)|*.dwf";
                     if (save.ShowDialog() == DialogResult.OK)
                     {
-                        var renderSvc = (MgRenderingService)this.Viewer.GetProvider().CreateService(MgServiceType.RenderingService);
+                        var mappingSvc = (MgdMappingService)this.Viewer.GetProvider().CreateService(MgServiceType.MappingService);
                         var map = (MgdMap)this.Viewer.GetMap();
                         var dwfVer = new MgDwfVersion("6.01", "1.2");
 
                         var layout = new MgLayout(layoutId, "TestPlot", MgPageUnitsType.Inches);
                         var plotSpec = new MgPlotSpecification(8.5f, 11.0f, MgPageUnitsType.Inches, 0.5f, 0.5f, 0.5f, 0.5f);
 
-                        var result = renderSvc.GeneratePlot(map, plotSpec, layout, dwfVer);
+                        var result = mappingSvc.GeneratePlot(map, plotSpec, layout, dwfVer);
                         var sink = new MgByteSink(result);
                         sink.ToFile(save.FileName);
 

Modified: branches/2.4/MgDev/Desktop/UnitTest/TestMappingService.cpp
===================================================================
--- branches/2.4/MgDev/Desktop/UnitTest/TestMappingService.cpp	2012-06-04 17:19:37 UTC (rev 6730)
+++ branches/2.4/MgDev/Desktop/UnitTest/TestMappingService.cpp	2012-06-05 11:26:26 UTC (rev 6731)
@@ -17,11 +17,6 @@
 
 #include "MgDesktop.h"
 #include "TestMappingService.h"
-#include "ServiceManager.h"
-#include "ServerResourceService.h"
-#include "ServerMappingService.h"
-#include "ServerSiteService.h"
-#include "../Common/Manager/FdoConnectionManager.h"
 #include "CppUnitExtensions.h"
 
 const STRING TEST_LOCALE = L"en";
@@ -32,38 +27,16 @@
 TestMappingService::TestMappingService()
 {
     // Initialize service objects.
-    MgServiceManager* serviceManager = MgServiceManager::GetInstance();
+    //MgServiceManager* serviceManager = MgServiceManager::GetInstance();
+    Ptr<MgServiceFactory> factory = new MgServiceFactory();
 
-    m_svcResource = dynamic_cast<MgResourceService*>(
-        serviceManager->RequestService(MgServiceType::ResourceService));
+    m_svcResource = dynamic_cast<MgdResourceService*>(
+        factory->CreateService(MgServiceType::ResourceService));
     assert(m_svcResource != NULL);
 
-    m_svcMapping = dynamic_cast<MgMappingService*>(
-        serviceManager->RequestService(MgServiceType::MappingService));
+    m_svcMapping = dynamic_cast<MgdMappingService*>(
+        factory->CreateService(MgServiceType::MappingService));
     assert(m_svcMapping != NULL);
-
-    // Initialize a site connection.
-    Ptr<MgServerSiteService> svcSite = dynamic_cast<MgServerSiteService*>(
-        serviceManager->RequestService(MgServiceType::SiteService));
-    assert(svcSite != NULL);
-
-    Ptr<MgUserInformation> userInfo = new MgUserInformation(
-        L"Administrator", L"admin");
-    userInfo->SetLocale(TEST_LOCALE);
-
-    // Set the current MgUserInformation
-    // This must be done before calling CreateSession()
-    MgUserInformation::SetCurrentUserInfo(userInfo);
-
-    STRING session = svcSite->CreateSession();
-    assert(!session.empty());
-    userInfo->SetMgSessionId(session);
-
-    // Set the current MgUserInformation
-    MgUserInformation::SetCurrentUserInfo(userInfo);
-
-    m_siteConnection = new MgSiteConnection();
-    m_siteConnection->Open(userInfo);
 }
 
 
@@ -88,19 +61,6 @@
 
     try
     {
-        #ifdef _DEBUG
-        MgFdoConnectionManager* pFdoConnectionManager = MgFdoConnectionManager::GetInstance();
-        if(pFdoConnectionManager)
-        {
-            pFdoConnectionManager->ShowCache();
-        }
-        #endif
-
-        //set user info
-        Ptr<MgUserInformation> userInfo = new MgUserInformation(L"Administrator", L"admin");
-        userInfo->SetLocale(TEST_LOCALE);
-        MgUserInformation::SetCurrentUserInfo(userInfo);
-
         //publish the map definition
         Ptr<MgResourceIdentifier> mapres = new MgResourceIdentifier(L"Library://UnitTests/Maps/Sheboygan.MapDefinition");
         Ptr<MgByteSource> mdfsrc = new MgByteSource(L"../UnitTestFiles/UT_Sheboygan.mdf", false);
@@ -189,11 +149,6 @@
 {
     try
     {
-        //set user info
-        Ptr<MgUserInformation> userInfo = new MgUserInformation(L"Administrator", L"admin");
-        userInfo->SetLocale(TEST_LOCALE);
-        MgUserInformation::SetCurrentUserInfo(userInfo);
-
         //delete the map definition
         Ptr<MgResourceIdentifier> mapres = new MgResourceIdentifier(L"Library://UnitTests/Maps/Sheboygan.MapDefinition");
         m_svcResource->DeleteResource(mapres);
@@ -228,14 +183,6 @@
         // delete the symbol library
         Ptr<MgResourceIdentifier> slres1 = new MgResourceIdentifier(L"Library://UnitTests/Symbols/SymbolMart.SymbolLibrary");
         m_svcResource->DeleteResource(slres1);
-
-        #ifdef _DEBUG
-        MgFdoConnectionManager* pFdoConnectionManager = MgFdoConnectionManager::GetInstance();
-        if(pFdoConnectionManager)
-        {
-            pFdoConnectionManager->ShowCache();
-        }
-        #endif
     }
     catch (MgException* e)
     {
@@ -251,118 +198,28 @@
     ACE_DEBUG((LM_INFO, ACE_TEXT("\nMapping Service tests completed.\n\n")));
 }
 
-
-void TestMappingService::TestCase_GetMap()
-{
-    try
-    {
-        //make a runtime map
-        Ptr<MgResourceIdentifier> mdfres = new MgResourceIdentifier(L"Library://UnitTests/Maps/Sheboygan.MapDefinition");
-        Ptr<MgMap> map = new MgMap(m_siteConnection);
-        map->Create(mdfres, L"UnitTestSheboygan");
-
-        Ptr<MgDwfVersion> version = new MgDwfVersion();
-
-        //call the API
-        Ptr<MgByteReader> emap = m_svcMapping->GenerateMap(map, L"blurple", L"clump", version);
-    }
-    catch(MgException* e)
-    {
-        STRING message = e->GetDetails(TEST_LOCALE);
-        SAFE_RELEASE(e);
-        CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
-    }
-    catch(...)
-    {
-        throw;
-    }
-}
-
-
-void TestMappingService::TestCase_GetMapUpdate()
-{
-    try
-    {
-        //make a runtime map
-        Ptr<MgResourceIdentifier> mdfres = new MgResourceIdentifier(L"Library://UnitTests/Maps/Sheboygan.MapDefinition");
-        Ptr<MgMap> map = new MgMap(m_siteConnection);
-        map->Create(mdfres, L"UnitTestSheboygan");
-
-        Ptr<MgDwfVersion> version = new MgDwfVersion();
-
-        //call the API
-        Ptr<MgByteReader> emapupdate = m_svcMapping->GenerateMapUpdate(map, 42, version);
-
-        INT64 len = emapupdate->GetLength();
-
-        //CPPUNIT_ASSERT(len == 7000); //TODO: determine correct length
-    }
-    catch(MgException* e)
-    {
-        STRING message = e->GetDetails(TEST_LOCALE);
-        SAFE_RELEASE(e);
-        CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
-    }
-    catch(...)
-    {
-        throw;
-    }
-}
-
-void TestMappingService::TestCase_SaveMap()
-{
-    try
-    {
-        // Create a runtime map, save it, then open it.
-        Ptr<MgResourceIdentifier> mapDefId = new MgResourceIdentifier(L"Library://UnitTests/Maps/Sheboygan.MapDefinition");
-        STRING mapName = L"UnitTestSheboygan";
-        Ptr<MgMap> map = new MgMap(m_siteConnection);
-
-        map->Create(mapDefId, mapName);
-        map->Save();
-        map->Open(mapName);
-
-        Ptr<MgLayerCollection> layers = map->GetLayers();
-        assert(layers->GetCount() > 0);
-    }
-    catch (MgException* e)
-    {
-        STRING message = e->GetDetails(TEST_LOCALE);
-        SAFE_RELEASE(e);
-        CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
-    }
-    catch (...)
-    {
-        throw;
-    }
-}
-
 void TestMappingService::TestCase_GetMultiPlot()
 {
     try
     {
         // make a runtime map
         Ptr<MgResourceIdentifier> mapRes1 = new MgResourceIdentifier(L"Library://UnitTests/Maps/Sheboygan.MapDefinition");
-        Ptr<MgMap> map1 = new MgMap(m_siteConnection);
-        map1->Create(mapRes1, L"UnitTestSheboygan1");
+        Ptr<MgdMap> map1 = new MgdMap(mapRes1, L"UnitTestSheboygan1");
         map1->SetViewScale(200e+6);
 
         // make another runtime map
         Ptr<MgResourceIdentifier> mapRes2 = new MgResourceIdentifier(L"Library://UnitTests/Maps/Sheboygan.MapDefinition");
-        Ptr<MgMap> map2 = new MgMap(m_siteConnection);
-        map2->Create(mapRes2, L"UnitTestSheboygan2");
+        Ptr<MgdMap> map2 = new MgdMap(mapRes2, L"UnitTestSheboygan2");
         map2->SetViewScale(100e+6);
 
         // make yet another runtime map
         Ptr<MgResourceIdentifier> mapRes3 = new MgResourceIdentifier(L"Library://UnitTests/Maps/Sheboygan.MapDefinition");
-        Ptr<MgMap> map3 = new MgMap(m_siteConnection);
-        map3->Create(mapRes3, L"UnitTestSheboygan3");
+        Ptr<MgdMap> map3 = new MgdMap(mapRes3, L"UnitTestSheboygan3");
         map3->SetViewScale(20e+6);
 
         // make a 4th runtime map
         Ptr<MgResourceIdentifier> mapRes4 = new MgResourceIdentifier(L"Library://UnitTests/Maps/Sheboygan.MapDefinition");
-        Ptr<MgMap> map4 = new MgMap(m_siteConnection);
-        map4->Create(mapRes4, L"UnitTestSheboygan4");
+        Ptr<MgdMap> map4 = new MgdMap(mapRes4, L"UnitTestSheboygan4");
         map4->SetViewScale(20e+6);
 
         // Create the DwfVersion
@@ -427,8 +284,7 @@
     {
         // make a runtime map
         Ptr<MgResourceIdentifier> mapRes1 = new MgResourceIdentifier(L"Library://UnitTests/Maps/Sheboygan.MapDefinition");
-        Ptr<MgMap> map1 = new MgMap(m_siteConnection);
-        map1->Create(mapRes1, L"UnitTestSheboygan1");
+        Ptr<MgdMap> map1 = new MgdMap(mapRes1, L"UnitTestSheboygan1");
         map1->SetViewScale(400e+6);
 
         Ptr<MgDwfVersion> version = new MgDwfVersion();
@@ -473,8 +329,7 @@
     {
         // make a runtime map
         Ptr<MgResourceIdentifier> mapRes1 = new MgResourceIdentifier(L"Library://UnitTests/Maps/Sheboygan.MapDefinition");
-        Ptr<MgMap> map1 = new MgMap(m_siteConnection);
-        map1->Create(mapRes1, L"UnitTestSheboygan1");
+        Ptr<MgdMap> map1 = new MgdMap(mapRes1, L"UnitTestSheboygan1");
         map1->SetViewScale(400e+6);
 
         Ptr<MgDwfVersion> version = new MgDwfVersion();
@@ -518,8 +373,7 @@
     {
         // make a runtime map
         Ptr<MgResourceIdentifier> mapRes1 = new MgResourceIdentifier(L"Library://UnitTests/Maps/Sheboygan.MapDefinition");
-        Ptr<MgMap> map1 = new MgMap(m_siteConnection);
-        map1->Create(mapRes1, L"UnitTestSheboygan1");
+        Ptr<MgdMap> map1 = new MgdMap(mapRes1, L"UnitTestSheboygan1");
         map1->SetViewScale(400e+6);
 
         Ptr<MgDwfVersion> version = new MgDwfVersion();
@@ -563,8 +417,7 @@
     {
         // make a runtime map
         Ptr<MgResourceIdentifier> mapRes1 = new MgResourceIdentifier(L"Library://UnitTests/Maps/Sheboygan.MapDefinition");
-        Ptr<MgMap> map1 = new MgMap(m_siteConnection);
-        map1->Create(mapRes1, L"UnitTestSheboygan1");
+        Ptr<MgdMap> map1 = new MgdMap(mapRes1, L"UnitTestSheboygan1");
         map1->SetViewScale(400e+6);
 
         Ptr<MgDwfVersion> version = new MgDwfVersion();
@@ -599,87 +452,4 @@
     {
         throw;
     }
-}
-
-
-void TestMappingService::TestCase_GetLegendPlot()
-{
-    try
-    {
-        // make a runtime map
-        Ptr<MgResourceIdentifier> mapRes1 = new MgResourceIdentifier(L"Library://UnitTests/Maps/Sheboygan.MapDefinition");
-        Ptr<MgMap> map1 = new MgMap(m_siteConnection);
-        map1->Create(mapRes1, L"UnitTestSheboygan1");
-        map1->SetViewScale(200e+6);
-
-        Ptr<MgDwfVersion> version = new MgDwfVersion();
-
-        Ptr<MgPlotSpecification> plotSpec = new MgPlotSpecification(8.5f, 11.f, L"in", 1, 1, 1, 1);
-
-        double dMapScale = 200e+6;
-        // call the API
-        Ptr<MgByteReader> eplot = m_svcMapping->GenerateLegendPlot(map1, dMapScale, plotSpec, version);
-
-        INT64 len = eplot->GetLength();
-
-        //CPPUNIT_ASSERT(len == 7000); // TODO: determine correct length
-
-        //Ptr<MgByteSink> byteSink = new MgByteSink(eplot);
-        //byteSink->ToFile(L"UTNewLegendPlot.dwf");
-    }
-    catch (MgException* e)
-    {
-        STRING message = e->GetDetails(TEST_LOCALE);
-        SAFE_RELEASE(e);
-        CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
-    }
-    catch (...)
-    {
-        throw;
-    }
-}
-
-
-void TestMappingService::TestCase_QueryFeaturesImageMap()
-{
-    try
-    {
-        // make a runtime map
-        Ptr<MgResourceIdentifier> mdfres = new MgResourceIdentifier(L"Library://UnitTests/Maps/Sheboygan.MapDefinition");
-        Ptr<MgMap> map = new MgMap(m_siteConnection);
-        map->Create(mdfres, L"UnitTestSheboygan");
-
-        Ptr<MgCoordinate> c1 = new MgCoordinateXY(-180,0);
-        Ptr<MgCoordinate> c2 = new MgCoordinateXY(0,90);
-        Ptr<MgEnvelope> extent = new MgEnvelope(c1, c2);
-
-        map->SetDataExtent(extent);
-
-        Ptr<MgCoordinate> coordNewCenter = new MgCoordinateXY(-90,45);
-        Ptr<MgPoint> ptNewCenter = new MgPoint(coordNewCenter);
-        map->SetViewCenter(ptNewCenter);
-
-        map->SetViewScale(100000000);
-
-        map->SetDisplayDpi(96);
-        map->SetDisplayWidth(800);
-        map->SetDisplayHeight(600);
-
-        // call the API
-        Ptr<MgByteReader> features = m_svcMapping->QueryFeatures(map, L"Parcels", L"Display"/*MgCoordinateSpace::Display*/);
-
-        // delete result from QueryFeatures test
-        Ptr<MgResourceIdentifier> qfres1 = new MgResourceIdentifier(L"Library://UnitTests/Data/Parcels.FeatureSource");
-        m_svcResource->DeleteResource(qfres1);
-    }
-    catch (MgException* e)
-    {
-        STRING message = e->GetDetails(TEST_LOCALE);
-        SAFE_RELEASE(e);
-        CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
-    }
-    catch (...)
-    {
-        throw;
-    }
-}
+}
\ No newline at end of file

Modified: branches/2.4/MgDev/Desktop/UnitTest/TestMappingService.h
===================================================================
--- branches/2.4/MgDev/Desktop/UnitTest/TestMappingService.h	2012-06-04 17:19:37 UTC (rev 6730)
+++ branches/2.4/MgDev/Desktop/UnitTest/TestMappingService.h	2012-06-05 11:26:26 UTC (rev 6731)
@@ -25,15 +25,15 @@
     CPPUNIT_TEST_SUITE(TestMappingService);
     CPPUNIT_TEST(TestStart); // This must be the very first unit test
 
-    CPPUNIT_TEST(TestCase_GetMap);
-    CPPUNIT_TEST(TestCase_GetMapUpdate);
-    CPPUNIT_TEST(TestCase_SaveMap);
+    //CPPUNIT_TEST(TestCase_GetMap);
+    //CPPUNIT_TEST(TestCase_GetMapUpdate);
+    //CPPUNIT_TEST(TestCase_SaveMap);
     CPPUNIT_TEST(TestCase_GetMultiPlot);
     CPPUNIT_TEST(TestCase_GetPlotUsingCurrentCenterAndScale);
     CPPUNIT_TEST(TestCase_GetPlotUsingOverriddenCenterAndScale);
     CPPUNIT_TEST(TestCase_GetPlotUsingExtents);
     CPPUNIT_TEST(TestCase_GetPlotUsingExtentsAndExpandToFit);
-    CPPUNIT_TEST(TestCase_GetLegendPlot);
+    //CPPUNIT_TEST(TestCase_GetLegendPlot);
     //CPPUNIT_TEST(TestCase_QueryFeaturesImageMap);
 
     CPPUNIT_TEST(TestEnd); // This must be the very last unit test
@@ -49,25 +49,24 @@
     void TestStart();
     void TestEnd();
 
-    void TestCase_GetMap();
-    void TestCase_GetMapUpdate();
-    void TestCase_SaveMap();
+    //void TestCase_GetMap();
+    //void TestCase_GetMapUpdate();
+    //void TestCase_SaveMap();
     void TestCase_GetPlot();
     void TestCase_GetMultiPlot();
     void TestCase_GetPlotUsingCurrentCenterAndScale();
     void TestCase_GetPlotUsingOverriddenCenterAndScale();
     void TestCase_GetPlotUsingExtents();
     void TestCase_GetPlotUsingExtentsAndExpandToFit();
-    void TestCase_GetLegendPlot();
-    void TestCase_QueryFeaturesImageMap();
+    //void TestCase_GetLegendPlot();
+    //void TestCase_QueryFeaturesImageMap();
 
 private:
 
     void PublishTheResources();
 
-    Ptr<MgSiteConnection> m_siteConnection;
-    Ptr<MgResourceService> m_svcResource;
-    Ptr<MgMappingService> m_svcMapping;
+    Ptr<MgdResourceService> m_svcResource;
+    Ptr<MgdMappingService> m_svcMapping;
 };
 
 #endif // TESTMAPPINGSERVICE_H_

Modified: branches/2.4/MgDev/Desktop/UnitTest/UnitTest.vcproj
===================================================================
--- branches/2.4/MgDev/Desktop/UnitTest/UnitTest.vcproj	2012-06-04 17:19:37 UTC (rev 6730)
+++ branches/2.4/MgDev/Desktop/UnitTest/UnitTest.vcproj	2012-06-05 11:26:26 UTC (rev 6731)
@@ -382,7 +382,6 @@
 				>
 				<FileConfiguration
 					Name="Debug|Win32"
-					ExcludedFromBuild="true"
 					>
 					<Tool
 						Name="VCCLCompilerTool"
@@ -390,7 +389,6 @@
 				</FileConfiguration>
 				<FileConfiguration
 					Name="Debug|x64"
-					ExcludedFromBuild="true"
 					>
 					<Tool
 						Name="VCCLCompilerTool"
@@ -398,7 +396,6 @@
 				</FileConfiguration>
 				<FileConfiguration
 					Name="Release|Win32"
-					ExcludedFromBuild="true"
 					>
 					<Tool
 						Name="VCCLCompilerTool"
@@ -406,7 +403,6 @@
 				</FileConfiguration>
 				<FileConfiguration
 					Name="Release|x64"
-					ExcludedFromBuild="true"
 					>
 					<Tool
 						Name="VCCLCompilerTool"

Modified: branches/2.4/MgDev/Desktop/UnitTest/main.cpp
===================================================================
--- branches/2.4/MgDev/Desktop/UnitTest/main.cpp	2012-06-04 17:19:37 UTC (rev 6730)
+++ branches/2.4/MgDev/Desktop/UnitTest/main.cpp	2012-06-05 11:26:26 UTC (rev 6731)
@@ -68,6 +68,7 @@
     runner.addTest(CppUnit::TestFactoryRegistry::getRegistry("TestResourceService").makeTest());
     runner.addTest(CppUnit::TestFactoryRegistry::getRegistry("TestRenderingService").makeTest());
     runner.addTest(CppUnit::TestFactoryRegistry::getRegistry("TestFeatureService").makeTest());
+    runner.addTest(CppUnit::TestFactoryRegistry::getRegistry("TestMappingService").makeTest());
 	runner.addTest(CppUnit::TestFactoryRegistry::getRegistry("TestProfilingService").makeTest());
     
     //This causes access violations in Visual Leak Detector when run in debug mode. Only uncommment



More information about the mapguide-commits mailing list