[mapguide-commits] r9558 - in sandbox/jng/mapstatecache: Common/MapGuideCommon/MapLayer Common/MapGuideCommon/Services Server/src/Services/Mapping Server/src/UnitTesting

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Wed Jun 19 09:14:46 PDT 2019


Author: jng
Date: 2019-06-19 09:14:46 -0700 (Wed, 19 Jun 2019)
New Revision: 9558

Modified:
   sandbox/jng/mapstatecache/Common/MapGuideCommon/MapLayer/Map.h
   sandbox/jng/mapstatecache/Common/MapGuideCommon/Services/MappingDefs.h
   sandbox/jng/mapstatecache/Common/MapGuideCommon/Services/MappingService.h
   sandbox/jng/mapstatecache/Common/MapGuideCommon/Services/ProxyMappingService.cpp
   sandbox/jng/mapstatecache/Common/MapGuideCommon/Services/ProxyMappingService.h
   sandbox/jng/mapstatecache/Server/src/Services/Mapping/MappingOperationFactory.cpp
   sandbox/jng/mapstatecache/Server/src/Services/Mapping/ServerMappingService.cpp
   sandbox/jng/mapstatecache/Server/src/Services/Mapping/ServerMappingService.h
   sandbox/jng/mapstatecache/Server/src/Services/Mapping/ServerMappingService.vcxproj
   sandbox/jng/mapstatecache/Server/src/Services/Mapping/ServerMappingService.vcxproj.filters
   sandbox/jng/mapstatecache/Server/src/Services/Mapping/ServerMappingServiceBuild.cpp
   sandbox/jng/mapstatecache/Server/src/UnitTesting/TestMappingService.cpp
   sandbox/jng/mapstatecache/Server/src/UnitTesting/TestMappingService.h
Log:
Add new CreateMap method to MgMappingService. This method behaves identically to MgMap.Create(), except this method is ultimately executed in the server tier, meaning we have a hook by which we can insert a caching strategy in subsequent commits.

Add a unit test that compares MgMap.Create() vs MgMappingService.CreateMap(). As caching is not layered in yet, the perf numbers should mostly be the same.

Modified: sandbox/jng/mapstatecache/Common/MapGuideCommon/MapLayer/Map.h
===================================================================
--- sandbox/jng/mapstatecache/Common/MapGuideCommon/MapLayer/Map.h	2019-06-19 14:40:47 UTC (rev 9557)
+++ sandbox/jng/mapstatecache/Common/MapGuideCommon/MapLayer/Map.h	2019-06-19 16:14:46 UTC (rev 9558)
@@ -726,6 +726,8 @@
         int dpi, int tileWidth, int tileHeight,
         double &tileMinX, double &tileMaxX, double &tileMinY, double & tileMaxY);
 
+    void InitializeResourceService(MgResourceService* resourceService);
+
 protected:
 
     //////////////////////////////////////////////////////////////////
@@ -760,10 +762,6 @@
     ///
     virtual void Dispose();
 
-private:
-
-    void InitializeResourceService(MgResourceService* resourceService);
-
 CLASS_ID:
     static const INT32 m_cls_id = MapGuide_MapLayer_Map;
 

Modified: sandbox/jng/mapstatecache/Common/MapGuideCommon/Services/MappingDefs.h
===================================================================
--- sandbox/jng/mapstatecache/Common/MapGuideCommon/Services/MappingDefs.h	2019-06-19 14:40:47 UTC (rev 9557)
+++ sandbox/jng/mapstatecache/Common/MapGuideCommon/Services/MappingDefs.h	2019-06-19 16:14:46 UTC (rev 9558)
@@ -109,6 +109,7 @@
     static const int DescribeRuntimeMap2        = 0x1111EE11;
     static const int CreateRuntimeMap3          = 0x1111EE12;
     static const int DescribeRuntimeMap3        = 0x1111EE13;
+    static const int CreateMap                  = 0x1111EE14;
 
 };
 /// \endcond

Modified: sandbox/jng/mapstatecache/Common/MapGuideCommon/Services/MappingService.h
===================================================================
--- sandbox/jng/mapstatecache/Common/MapGuideCommon/Services/MappingService.h	2019-06-19 14:40:47 UTC (rev 9557)
+++ sandbox/jng/mapstatecache/Common/MapGuideCommon/Services/MappingService.h	2019-06-19 16:14:46 UTC (rev 9558)
@@ -454,6 +454,106 @@
                                              INT32 requestedFeatures,
                                              INT32 iconsPerScaleRange) = 0;
 
+    //////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Initializes a new MgMap object given a map definition or tile set
+    /// definition and a name for the map. This method is used for
+    /// MapGuide Viewers or for offline map production.
+    ///
+    /// <!-- Syntax in .Net, Java, and PHP -->
+    /// \htmlinclude DotNetSyntaxTop.html
+    /// void CreateMap(MgResourceIdentifier mapDefinition, string mapName);
+    /// \htmlinclude SyntaxBottom.html
+    /// \htmlinclude JavaSyntaxTop.html
+    /// void CreateMap(MgResourceIdentifier mapDefinition, String mapName);
+    /// \htmlinclude SyntaxBottom.html
+    /// \htmlinclude PHPSyntaxTop.html
+    /// void CreateMap(MgResourceIdentifier mapDefinition, string mapName);
+    /// \htmlinclude SyntaxBottom.html
+    ///
+    /// \param resource
+    /// An MgResourceIdentifier that specifies the
+    /// location of the map definition in a resource
+    /// repository.
+    /// \param mapName
+    /// A string that specifies the name of the map.
+    ///
+    /// \return
+    /// Returns nothing.
+    ///
+    /// <!-- Example (PHP) -->
+    /// \htmlinclude PHPExampleTop.html
+    /// \code
+    /// // Assuming the site connection has already been intialized as $site
+    /// $resourceID = new  MgResourceIdentifier('Library://Calgary/Maps/Calgary.MapDefinition');
+    /// $mappingService = $site->CreateService(MgServiceType::MappingService);
+    /// $map = $mappingService->CreateMap($resourceID, 'Calgary');
+    /// \endcode
+    /// \htmlinclude ExampleBottom.html
+    ///
+    virtual MgMap* CreateMap(MgResourceIdentifier* mapDefinition, 
+                             CREFSTRING mapName) = 0;
+
+    //////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Initializes a new MgMap object given a map definition or tile set
+    /// definition and a name for the map with initial display parameters set.
+    /// This method is used for MapGuide Viewers or for offline map production.
+    ///
+    /// <!-- Syntax in .Net, Java, and PHP -->
+    /// \htmlinclude DotNetSyntaxTop.html
+    /// void CreateMap(MgResourceIdentifier mapDefinition, string mapName, int displayWidth, int displayHeight, double x, double y, double scale, int dpi);
+    /// \htmlinclude SyntaxBottom.html
+    /// \htmlinclude JavaSyntaxTop.html
+    /// void CreateMap(MgResourceIdentifier mapDefinition, String mapName, int displayWidth, int displayHeight, double x, double y, double scale, int dpi);
+    /// \htmlinclude SyntaxBottom.html
+    /// \htmlinclude PHPSyntaxTop.html
+    /// void CreateMap(MgResourceIdentifier mapDefinition, string mapName, int displayWidth, int displayHeight, double x, double y, double scale, int dpi);
+    /// \htmlinclude SyntaxBottom.html
+    ///
+    /// \param resource
+    /// An MgResourceIdentifier that specifies the
+    /// location of the map definition in a resource
+    /// repository.
+    /// \param mapName
+    /// A string that specifies the name of the map.
+    /// \param displayWidth
+    /// The display width to initially set for the map
+    /// \param displayHeight
+    /// The display height to initially set for the map
+    /// \param x
+    /// The view center X coordinate to initially set for the map
+    /// \param y
+    /// The view center Y coordinate to initially set for the map
+    /// \param scale
+    /// The view scale to initially set for the map
+    /// \param dpi
+    /// The display DPI to initially set for the map
+    ///
+    /// \since 4.0
+    ///
+    /// \return
+    /// Returns nothing.
+    ///
+    /// <!-- Example (PHP) -->
+    /// \htmlinclude PHPExampleTop.html
+    /// \code
+    /// // Assuming the site connection has already been intialized as $site
+    /// $resourceID = new  MgResourceIdentifier('Library://Calgary/Maps/Calgary.MapDefinition');
+    /// // Initializes the map to be centered on the Calgary CBD at 1:5000 scale with a DPI of 96
+    /// $map = $site->CreateMap($resourceID, 'Calgary', 640, 480, -114.054565, 51.068369, 5000.0, 96);
+    /// \endcode
+    /// \htmlinclude ExampleBottom.html
+    ///
+    virtual MgMap* CreateMap(MgResourceIdentifier* mapDefinition,
+                             CREFSTRING mapName,
+                             INT32 displayWidth,
+                             INT32 displayHeight,
+                             double x,
+                             double y,
+                             double scale,
+                             INT32 dpi) = 0;
+
 EXTERNAL_API:
 
     //////////////////////////////////////////////////////////////////////////////////////////////////////////

Modified: sandbox/jng/mapstatecache/Common/MapGuideCommon/Services/ProxyMappingService.cpp
===================================================================
--- sandbox/jng/mapstatecache/Common/MapGuideCommon/Services/ProxyMappingService.cpp	2019-06-19 14:40:47 UTC (rev 9557)
+++ sandbox/jng/mapstatecache/Common/MapGuideCommon/Services/ProxyMappingService.cpp	2019-06-19 16:14:46 UTC (rev 9558)
@@ -611,6 +611,58 @@
     return (MgByteReader*)cmd.GetReturnValue().val.m_obj;
 }
 
+MgMap* MgProxyMappingService::CreateMap(MgResourceIdentifier* mapDefinition,
+                                        CREFSTRING mapName)
+{
+    MgCommand cmd;
+
+    cmd.ExecuteCommand(m_connProp,
+        MgCommand::knObject,
+        MgMappingServiceOpId::CreateMap,
+        2,
+        Mapping_Service,
+        BUILD_VERSION(4, 0, 0),
+        MgCommand::knObject, mapDefinition,
+        MgCommand::knString, &mapName,
+        MgCommand::knNone);
+
+    SetWarning(cmd.GetWarningObject());
+
+    return (MgMap*)cmd.GetReturnValue().val.m_obj;
+}
+
+MgMap* MgProxyMappingService::CreateMap(MgResourceIdentifier* mapDefinition,
+                                        CREFSTRING mapName,
+                                        INT32 displayWidth,
+                                        INT32 displayHeight,
+                                        double x,
+                                        double y,
+                                        double scale,
+                                        INT32 dpi)
+{
+    MgCommand cmd;
+
+    cmd.ExecuteCommand(m_connProp,
+        MgCommand::knObject,
+        MgMappingServiceOpId::CreateMap,
+        8,
+        Mapping_Service,
+        BUILD_VERSION(4, 0, 0),
+        MgCommand::knObject, mapDefinition,
+        MgCommand::knString, &mapName,
+        MgCommand::knInt32, displayWidth,
+        MgCommand::knInt32, displayHeight,
+        MgCommand::knDouble, x,
+        MgCommand::knDouble, y,
+        MgCommand::knDouble, scale,
+        MgCommand::knInt32, dpi,
+        MgCommand::knNone);
+
+    SetWarning(cmd.GetWarningObject());
+
+    return (MgMap*)cmd.GetReturnValue().val.m_obj;
+}
+
 //////////////////////////////////////////////////////////////////
 /// \brief
 /// Sets the connection properties for the Proxy Service.  This

Modified: sandbox/jng/mapstatecache/Common/MapGuideCommon/Services/ProxyMappingService.h
===================================================================
--- sandbox/jng/mapstatecache/Common/MapGuideCommon/Services/ProxyMappingService.h	2019-06-19 14:40:47 UTC (rev 9557)
+++ sandbox/jng/mapstatecache/Common/MapGuideCommon/Services/ProxyMappingService.h	2019-06-19 16:14:46 UTC (rev 9558)
@@ -422,6 +422,106 @@
                                              INT32 requestedFeatures,
                                              INT32 iconsPerScaleRange);
 
+    //////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Initializes a new MgMap object given a map definition or tile set
+    /// definition and a name for the map. This method is used for
+    /// MapGuide Viewers or for offline map production.
+    ///
+    /// <!-- Syntax in .Net, Java, and PHP -->
+    /// \htmlinclude DotNetSyntaxTop.html
+    /// void CreateMap(MgResourceIdentifier mapDefinition, string mapName);
+    /// \htmlinclude SyntaxBottom.html
+    /// \htmlinclude JavaSyntaxTop.html
+    /// void CreateMap(MgResourceIdentifier mapDefinition, String mapName);
+    /// \htmlinclude SyntaxBottom.html
+    /// \htmlinclude PHPSyntaxTop.html
+    /// void CreateMap(MgResourceIdentifier mapDefinition, string mapName);
+    /// \htmlinclude SyntaxBottom.html
+    ///
+    /// \param resource
+    /// An MgResourceIdentifier that specifies the
+    /// location of the map definition in a resource
+    /// repository.
+    /// \param mapName
+    /// A string that specifies the name of the map.
+    ///
+    /// \return
+    /// Returns nothing.
+    ///
+    /// <!-- Example (PHP) -->
+    /// \htmlinclude PHPExampleTop.html
+    /// \code
+    /// // Assuming the site connection has already been intialized as $site
+    /// $resourceID = new  MgResourceIdentifier('Library://Calgary/Maps/Calgary.MapDefinition');
+    /// $mappingService = $site->CreateService(MgServiceType::MappingService);
+    /// $map = $mappingService->CreateMap($resourceID, 'Calgary');
+    /// \endcode
+    /// \htmlinclude ExampleBottom.html
+    ///
+    virtual MgMap* CreateMap(MgResourceIdentifier* mapDefinition,
+        CREFSTRING mapName);
+
+    //////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Initializes a new MgMap object given a map definition or tile set
+    /// definition and a name for the map with initial display parameters set.
+    /// This method is used for MapGuide Viewers or for offline map production.
+    ///
+    /// <!-- Syntax in .Net, Java, and PHP -->
+    /// \htmlinclude DotNetSyntaxTop.html
+    /// void CreateMap(MgResourceIdentifier mapDefinition, string mapName, int displayWidth, int displayHeight, double x, double y, double scale, int dpi);
+    /// \htmlinclude SyntaxBottom.html
+    /// \htmlinclude JavaSyntaxTop.html
+    /// void CreateMap(MgResourceIdentifier mapDefinition, String mapName, int displayWidth, int displayHeight, double x, double y, double scale, int dpi);
+    /// \htmlinclude SyntaxBottom.html
+    /// \htmlinclude PHPSyntaxTop.html
+    /// void CreateMap(MgResourceIdentifier mapDefinition, string mapName, int displayWidth, int displayHeight, double x, double y, double scale, int dpi);
+    /// \htmlinclude SyntaxBottom.html
+    ///
+    /// \param resource
+    /// An MgResourceIdentifier that specifies the
+    /// location of the map definition in a resource
+    /// repository.
+    /// \param mapName
+    /// A string that specifies the name of the map.
+    /// \param displayWidth
+    /// The display width to initially set for the map
+    /// \param displayHeight
+    /// The display height to initially set for the map
+    /// \param x
+    /// The view center X coordinate to initially set for the map
+    /// \param y
+    /// The view center Y coordinate to initially set for the map
+    /// \param scale
+    /// The view scale to initially set for the map
+    /// \param dpi
+    /// The display DPI to initially set for the map
+    ///
+    /// \since 4.0
+    ///
+    /// \return
+    /// Returns nothing.
+    ///
+    /// <!-- Example (PHP) -->
+    /// \htmlinclude PHPExampleTop.html
+    /// \code
+    /// // Assuming the site connection has already been intialized as $site
+    /// $resourceID = new  MgResourceIdentifier('Library://Calgary/Maps/Calgary.MapDefinition');
+    /// // Initializes the map to be centered on the Calgary CBD at 1:5000 scale with a DPI of 96
+    /// $map = $site->CreateMap($resourceID, 'Calgary', 640, 480, -114.054565, 51.068369, 5000.0, 96);
+    /// \endcode
+    /// \htmlinclude ExampleBottom.html
+    ///
+    virtual MgMap* CreateMap(MgResourceIdentifier* mapDefinition,
+        CREFSTRING mapName,
+        INT32 displayWidth,
+        INT32 displayHeight,
+        double x,
+        double y,
+        double scale,
+        INT32 dpi);
+
 INTERNAL_API:
     //////////////////////////////////////////////////////////////////
     /// \brief

Modified: sandbox/jng/mapstatecache/Server/src/Services/Mapping/MappingOperationFactory.cpp
===================================================================
--- sandbox/jng/mapstatecache/Server/src/Services/Mapping/MappingOperationFactory.cpp	2019-06-19 14:40:47 UTC (rev 9557)
+++ sandbox/jng/mapstatecache/Server/src/Services/Mapping/MappingOperationFactory.cpp	2019-06-19 16:14:46 UTC (rev 9558)
@@ -18,6 +18,7 @@
 #include "ServerMappingServiceDefs.h"
 #include "MappingOperationFactory.h"
 
+#include "OpCreateMap.h"
 #include "OpCreateRuntimeMap.h"
 #include "OpDescribeRuntimeMap.h"
 #include "OpGeneratePlot.h"
@@ -243,6 +244,18 @@
         }
         break;
 
+    case MgMappingServiceOpId::CreateMap:
+        switch (VERSION_NO_PHASE(operationVersion))
+        {
+        case VERSION_SUPPORTED(4, 0):
+            handler.reset(new MgOpCreateMap());
+            break;
+        default:
+            throw new MgInvalidOperationVersionException(
+                L"MgDrawingOperationFactory.GetOperation", __LINE__, __WFILE__, NULL, L"", NULL);
+        }
+        break;
+
     default:
         throw new MgInvalidOperationException(
             L"MgMappingOperationFactory.GetOperation", __LINE__, __WFILE__, NULL, L"", NULL);

Modified: sandbox/jng/mapstatecache/Server/src/Services/Mapping/ServerMappingService.cpp
===================================================================
--- sandbox/jng/mapstatecache/Server/src/Services/Mapping/ServerMappingService.cpp	2019-06-19 14:40:47 UTC (rev 9557)
+++ sandbox/jng/mapstatecache/Server/src/Services/Mapping/ServerMappingService.cpp	2019-06-19 16:14:46 UTC (rev 9558)
@@ -1790,4 +1790,47 @@
     xml.append("</Layer>");
 
     MG_SERVER_MAPPING_SERVICE_CATCH_AND_THROW(L"MgServerMappingService.CreateLayerItem")
+}
+
+MgMap* MgServerMappingService::CreateMap(MgResourceIdentifier* mapDefinition,
+    CREFSTRING mapName)
+{
+    Ptr<MgMap> map;
+    MG_SERVER_MAPPING_SERVICE_TRY()
+
+    if (m_svcResource == NULL)
+        InitializeResourceService();
+
+    Ptr<MgSiteConnection> siteConn = new MgSiteConnection();
+    siteConn->Open(MgUserInformation::GetCurrentUserInfo());
+    map = new MgMap(siteConn);
+    map->InitializeResourceService(m_svcResource);
+    map->Create(mapDefinition, mapName);
+
+    MG_SERVER_MAPPING_SERVICE_CATCH_AND_THROW(L"MgServerMappingService.CreateMap")
+    return map.Detach();
+}
+
+MgMap* MgServerMappingService::CreateMap(MgResourceIdentifier* mapDefinition,
+    CREFSTRING mapName,
+    INT32 displayWidth,
+    INT32 displayHeight,
+    double x,
+    double y,
+    double scale,
+    INT32 dpi)
+{
+    Ptr<MgMap> map;
+    MG_SERVER_MAPPING_SERVICE_TRY()
+
+    if (m_svcResource == NULL)
+        InitializeResourceService();
+
+    Ptr<MgSiteConnection> siteConn = new MgSiteConnection();
+    siteConn->Open(MgUserInformation::GetCurrentUserInfo());
+    map = new MgMap(siteConn);
+    map->Create(mapDefinition, mapName, displayWidth, displayHeight, x, y, scale, dpi);
+
+    MG_SERVER_MAPPING_SERVICE_CATCH_AND_THROW(L"MgServerMappingService.CreateMap")
+    return map.Detach();
 }
\ No newline at end of file

Modified: sandbox/jng/mapstatecache/Server/src/Services/Mapping/ServerMappingService.h
===================================================================
--- sandbox/jng/mapstatecache/Server/src/Services/Mapping/ServerMappingService.h	2019-06-19 14:40:47 UTC (rev 9557)
+++ sandbox/jng/mapstatecache/Server/src/Services/Mapping/ServerMappingService.h	2019-06-19 16:14:46 UTC (rev 9558)
@@ -156,6 +156,18 @@
 
         void SetConnectionProperties(MgConnectionProperties* connProp);
 
+        virtual MgMap* CreateMap(MgResourceIdentifier* mapDefinition,
+            CREFSTRING mapName);
+
+        virtual MgMap* CreateMap(MgResourceIdentifier* mapDefinition,
+            CREFSTRING mapName,
+            INT32 displayWidth,
+            INT32 displayHeight,
+            double x,
+            double y,
+            double scale,
+            INT32 dpi);
+
 // Data Members
 
     private:

Modified: sandbox/jng/mapstatecache/Server/src/Services/Mapping/ServerMappingService.vcxproj
===================================================================
--- sandbox/jng/mapstatecache/Server/src/Services/Mapping/ServerMappingService.vcxproj	2019-06-19 14:40:47 UTC (rev 9557)
+++ sandbox/jng/mapstatecache/Server/src/Services/Mapping/ServerMappingService.vcxproj	2019-06-19 16:14:46 UTC (rev 9558)
@@ -214,6 +214,12 @@
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
     </ClCompile>
+    <ClCompile Include="OpCreateMap.cpp">
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
+    </ClCompile>
     <ClCompile Include="OpCreateRuntimeMap.cpp">
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
@@ -321,6 +327,7 @@
   <ItemGroup>
     <ClInclude Include="MappingOperation.h" />
     <ClInclude Include="MappingOperationFactory.h" />
+    <ClInclude Include="OpCreateMap.h" />
     <ClInclude Include="OpCreateRuntimeMap.h" />
     <ClInclude Include="OpDescribeRuntimeMap.h" />
     <ClInclude Include="OpGenerateLegendImage.h" />

Modified: sandbox/jng/mapstatecache/Server/src/Services/Mapping/ServerMappingService.vcxproj.filters
===================================================================
--- sandbox/jng/mapstatecache/Server/src/Services/Mapping/ServerMappingService.vcxproj.filters	2019-06-19 14:40:47 UTC (rev 9557)
+++ sandbox/jng/mapstatecache/Server/src/Services/Mapping/ServerMappingService.vcxproj.filters	2019-06-19 16:14:46 UTC (rev 9558)
@@ -46,6 +46,9 @@
     <ClCompile Include="OpDescribeRuntimeMap.cpp">
       <Filter>Ops</Filter>
     </ClCompile>
+    <ClCompile Include="OpCreateMap.cpp">
+      <Filter>Ops</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="MappingOperation.h">
@@ -90,6 +93,9 @@
     <ClInclude Include="OpDescribeRuntimeMap.h">
       <Filter>Ops</Filter>
     </ClInclude>
+    <ClInclude Include="OpCreateMap.h">
+      <Filter>Ops</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="ServerMappingService.rc" />

Modified: sandbox/jng/mapstatecache/Server/src/Services/Mapping/ServerMappingServiceBuild.cpp
===================================================================
--- sandbox/jng/mapstatecache/Server/src/Services/Mapping/ServerMappingServiceBuild.cpp	2019-06-19 14:40:47 UTC (rev 9557)
+++ sandbox/jng/mapstatecache/Server/src/Services/Mapping/ServerMappingServiceBuild.cpp	2019-06-19 16:14:46 UTC (rev 9558)
@@ -21,6 +21,7 @@
 #include "MappingOperation.cpp"
 #include "MappingOperationFactory.cpp"
 #include "MappingServiceHandler.cpp"
+#include "OpCreateMap.cpp"
 #include "OpCreateRuntimeMap.cpp"
 #include "OpDescribeRuntimeMap.cpp"
 #include "OpGeneratePlot.cpp"

Modified: sandbox/jng/mapstatecache/Server/src/UnitTesting/TestMappingService.cpp
===================================================================
--- sandbox/jng/mapstatecache/Server/src/UnitTesting/TestMappingService.cpp	2019-06-19 14:40:47 UTC (rev 9557)
+++ sandbox/jng/mapstatecache/Server/src/UnitTesting/TestMappingService.cpp	2019-06-19 16:14:46 UTC (rev 9558)
@@ -24,6 +24,9 @@
 #include "../Common/Manager/FdoConnectionManager.h"
 #include "CppUnitExtensions.h"
 #include "FoundationDefs.h"
+#include "CacheManager.h"
+#include <chrono>
+
 const STRING TEST_LOCALE = L"en";
 
 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(TestMappingService, "TestMappingService");
@@ -314,6 +317,66 @@
     ACE_DEBUG((LM_INFO, ACE_TEXT("\nMapping Service tests completed.\n\n")));
 }
 
+void TestMappingService::TestCase_CreateMap()
+{
+    try
+    {
+        //make a runtime map
+        Ptr<MgResourceIdentifier> mdfres = new MgResourceIdentifier(L"Library://UnitTests/Maps/Sheboygan.MapDefinition");
+        STRING format = MgImageFormats::Png;
+
+        //Clear all cached data
+        MgCacheManager* cache = MgCacheManager::GetInstance();
+        cache->ClearCaches();
+
+        auto begin = std::chrono::steady_clock::now();
+
+        Ptr<MgMap> map1 = new MgMap(m_siteConnection);
+        map1->Create(mdfres, L"UnitTestSheboygan1Orig");
+
+        auto end = std::chrono::steady_clock::now();
+        printf("MgMap::Create() cold start - %dms\n", std::chrono::duration_cast<std::chrono::milliseconds>(end - begin).count());
+
+        begin = std::chrono::steady_clock::now();
+
+        map1 = new MgMap(m_siteConnection);
+        map1->Create(mdfres, L"UnitTestSheboygan1Orig");
+
+        end = std::chrono::steady_clock::now();
+        printf("MgMap::Create() warm start - %dms\n", std::chrono::duration_cast<std::chrono::milliseconds>(end - begin).count());
+
+        Ptr<MgMap> map2 = new MgMap(m_siteConnection);
+        map1->Create(mdfres, L"UnitTestSheboygan2Orig", 800, 600, -87, 43, 12000, 96);
+
+        //Clear caches again
+        cache->ClearCaches();
+
+        begin = std::chrono::steady_clock::now();
+        Ptr<MgMap> rtMap1 = m_svcMapping->CreateMap(mdfres, L"UnitTestSheboygan1");
+        end = std::chrono::steady_clock::now();
+
+        printf("MgMappingService::CreateMap() cold start - %dms\n", std::chrono::duration_cast<std::chrono::milliseconds>(end - begin).count());
+
+        begin = std::chrono::steady_clock::now();
+        rtMap1 = m_svcMapping->CreateMap(mdfres, L"UnitTestSheboygan1");
+        end = std::chrono::steady_clock::now();
+
+        printf("MgMappingService::CreateMap() warm start - %dms\n", std::chrono::duration_cast<std::chrono::milliseconds>(end - begin).count());
+
+        Ptr<MgMap> rtMap2 = m_svcMapping->CreateMap(mdfres, L"UnitTestSheboygan2", 800, 600, -87, 43, 12000, 96);
+    }
+    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_CreateRuntimeMap()
 {
     try

Modified: sandbox/jng/mapstatecache/Server/src/UnitTesting/TestMappingService.h
===================================================================
--- sandbox/jng/mapstatecache/Server/src/UnitTesting/TestMappingService.h	2019-06-19 14:40:47 UTC (rev 9557)
+++ sandbox/jng/mapstatecache/Server/src/UnitTesting/TestMappingService.h	2019-06-19 16:14:46 UTC (rev 9558)
@@ -25,6 +25,8 @@
     CPPUNIT_TEST_SUITE(TestMappingService);
     CPPUNIT_TEST(TestStart); // This must be the very first unit test
 
+    CPPUNIT_TEST(TestCase_CreateMap);
+    /*
     CPPUNIT_TEST(TestCase_SaveMap);
     CPPUNIT_TEST(TestCase_GetMultiPlot);
     CPPUNIT_TEST(TestCase_GetPlotUsingCurrentCenterAndScale);
@@ -39,11 +41,12 @@
     CPPUNIT_TEST(TestCase_GetLegendImageCompositeConvenience);
     CPPUNIT_TEST(TestCase_GetLegendImageCompositeThemedConvenience);
     CPPUNIT_TEST(TestCase_GetLegendImagePointStyleWithConstRotationsConvenience);
+    CPPUNIT_TEST(TestCase_CreateMap);
     CPPUNIT_TEST(TestCase_CreateRuntimeMap);
     CPPUNIT_TEST(TestCase_DescribeRuntimeMap);
     CPPUNIT_TEST(TestCase_CreateAndDescribeLinkedRuntimeMap);
     //CPPUNIT_TEST(TestCase_QueryFeaturesImageMap);
-
+    */
     CPPUNIT_TEST(TestEnd); // This must be the very last unit test
     CPPUNIT_TEST_SUITE_END();
 
@@ -57,6 +60,7 @@
     void TestStart();
     void TestEnd();
 
+    void TestCase_CreateMap();
     void TestCase_CreateRuntimeMap();
     void TestCase_DescribeRuntimeMap();
     void TestCase_SaveMap();



More information about the mapguide-commits mailing list