[mapguide-commits] r9642 - in sandbox/jng/mapstatecache2: . Common/MapGuideCommon/MapLayer Common/MapGuideCommon/Services Server/src/Services/Mapping Server/src/UnitTesting

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Thu Jan 30 02:36:25 PST 2020


Author: jng
Date: 2020-01-30 02:36:25 -0800 (Thu, 30 Jan 2020)
New Revision: 9642

Modified:
   sandbox/jng/mapstatecache2/
   sandbox/jng/mapstatecache2/Common/MapGuideCommon/MapLayer/Map.h
   sandbox/jng/mapstatecache2/Common/MapGuideCommon/Services/MappingDefs.h
   sandbox/jng/mapstatecache2/Common/MapGuideCommon/Services/MappingService.h
   sandbox/jng/mapstatecache2/Common/MapGuideCommon/Services/ProxyMappingService.cpp
   sandbox/jng/mapstatecache2/Common/MapGuideCommon/Services/ProxyMappingService.h
   sandbox/jng/mapstatecache2/Server/src/Services/Mapping/MappingOperationFactory.cpp
   sandbox/jng/mapstatecache2/Server/src/Services/Mapping/ServerMappingService.cpp
   sandbox/jng/mapstatecache2/Server/src/Services/Mapping/ServerMappingService.h
   sandbox/jng/mapstatecache2/Server/src/Services/Mapping/ServerMappingService.vcxproj
   sandbox/jng/mapstatecache2/Server/src/Services/Mapping/ServerMappingService.vcxproj.filters
   sandbox/jng/mapstatecache2/Server/src/Services/Mapping/ServerMappingServiceBuild.cpp
   sandbox/jng/mapstatecache2/Server/src/UnitTesting/TestMappingService.cpp
   sandbox/jng/mapstatecache2/Server/src/UnitTesting/TestMappingService.h
Log:
Merged revision(s) 9558 from sandbox/jng/mapstatecache:
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.
........


Index: sandbox/jng/mapstatecache2
===================================================================
--- sandbox/jng/mapstatecache2	2020-01-30 10:20:10 UTC (rev 9641)
+++ sandbox/jng/mapstatecache2	2020-01-30 10:36:25 UTC (rev 9642)

Property changes on: sandbox/jng/mapstatecache2
___________________________________________________________________
Modified: svn:mergeinfo
## -19,6 +19,7 ##
 /sandbox/jng/fusion_entrypoint_refactor:9400-9406
 /sandbox/jng/geoprocessing:9205-9229
 /sandbox/jng/geos34x:8256-8259
+/sandbox/jng/mapstatecache:9558
 /sandbox/jng/mvt:9527-9528,9535,9537,9546-9547
 /sandbox/jng/mvt_alt:9604-9629
 /sandbox/jng/ogc:9240-9255
Modified: sandbox/jng/mapstatecache2/Common/MapGuideCommon/MapLayer/Map.h
===================================================================
--- sandbox/jng/mapstatecache2/Common/MapGuideCommon/MapLayer/Map.h	2020-01-30 10:20:10 UTC (rev 9641)
+++ sandbox/jng/mapstatecache2/Common/MapGuideCommon/MapLayer/Map.h	2020-01-30 10:36:25 UTC (rev 9642)
@@ -788,6 +788,8 @@
         int dpi, int tileWidth, int tileHeight,
         double &tileMinX, double &tileMaxX, double &tileMinY, double & tileMaxY);
 
+    void InitializeResourceService(MgResourceService* resourceService);
+
 protected:
 
     //////////////////////////////////////////////////////////////////
@@ -822,10 +824,6 @@
     ///
     virtual void Dispose();
 
-private:
-
-    void InitializeResourceService(MgResourceService* resourceService);
-
 CLASS_ID:
     static const INT32 m_cls_id = MapGuide_MapLayer_Map;
 

Modified: sandbox/jng/mapstatecache2/Common/MapGuideCommon/Services/MappingDefs.h
===================================================================
--- sandbox/jng/mapstatecache2/Common/MapGuideCommon/Services/MappingDefs.h	2020-01-30 10:20:10 UTC (rev 9641)
+++ sandbox/jng/mapstatecache2/Common/MapGuideCommon/Services/MappingDefs.h	2020-01-30 10:36:25 UTC (rev 9642)
@@ -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/mapstatecache2/Common/MapGuideCommon/Services/MappingService.h
===================================================================
--- sandbox/jng/mapstatecache2/Common/MapGuideCommon/Services/MappingService.h	2020-01-30 10:20:10 UTC (rev 9641)
+++ sandbox/jng/mapstatecache2/Common/MapGuideCommon/Services/MappingService.h	2020-01-30 10:36:25 UTC (rev 9642)
@@ -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/mapstatecache2/Common/MapGuideCommon/Services/ProxyMappingService.cpp
===================================================================
--- sandbox/jng/mapstatecache2/Common/MapGuideCommon/Services/ProxyMappingService.cpp	2020-01-30 10:20:10 UTC (rev 9641)
+++ sandbox/jng/mapstatecache2/Common/MapGuideCommon/Services/ProxyMappingService.cpp	2020-01-30 10:36:25 UTC (rev 9642)
@@ -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/mapstatecache2/Common/MapGuideCommon/Services/ProxyMappingService.h
===================================================================
--- sandbox/jng/mapstatecache2/Common/MapGuideCommon/Services/ProxyMappingService.h	2020-01-30 10:20:10 UTC (rev 9641)
+++ sandbox/jng/mapstatecache2/Common/MapGuideCommon/Services/ProxyMappingService.h	2020-01-30 10:36:25 UTC (rev 9642)
@@ -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/mapstatecache2/Server/src/Services/Mapping/MappingOperationFactory.cpp
===================================================================
--- sandbox/jng/mapstatecache2/Server/src/Services/Mapping/MappingOperationFactory.cpp	2020-01-30 10:20:10 UTC (rev 9641)
+++ sandbox/jng/mapstatecache2/Server/src/Services/Mapping/MappingOperationFactory.cpp	2020-01-30 10:36:25 UTC (rev 9642)
@@ -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/mapstatecache2/Server/src/Services/Mapping/ServerMappingService.cpp
===================================================================
--- sandbox/jng/mapstatecache2/Server/src/Services/Mapping/ServerMappingService.cpp	2020-01-30 10:20:10 UTC (rev 9641)
+++ sandbox/jng/mapstatecache2/Server/src/Services/Mapping/ServerMappingService.cpp	2020-01-30 10:36:25 UTC (rev 9642)
@@ -1823,4 +1823,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/mapstatecache2/Server/src/Services/Mapping/ServerMappingService.h
===================================================================
--- sandbox/jng/mapstatecache2/Server/src/Services/Mapping/ServerMappingService.h	2020-01-30 10:20:10 UTC (rev 9641)
+++ sandbox/jng/mapstatecache2/Server/src/Services/Mapping/ServerMappingService.h	2020-01-30 10:36:25 UTC (rev 9642)
@@ -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/mapstatecache2/Server/src/Services/Mapping/ServerMappingService.vcxproj
===================================================================
--- sandbox/jng/mapstatecache2/Server/src/Services/Mapping/ServerMappingService.vcxproj	2020-01-30 10:20:10 UTC (rev 9641)
+++ sandbox/jng/mapstatecache2/Server/src/Services/Mapping/ServerMappingService.vcxproj	2020-01-30 10:36:25 UTC (rev 9642)
@@ -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/mapstatecache2/Server/src/Services/Mapping/ServerMappingService.vcxproj.filters
===================================================================
--- sandbox/jng/mapstatecache2/Server/src/Services/Mapping/ServerMappingService.vcxproj.filters	2020-01-30 10:20:10 UTC (rev 9641)
+++ sandbox/jng/mapstatecache2/Server/src/Services/Mapping/ServerMappingService.vcxproj.filters	2020-01-30 10:36:25 UTC (rev 9642)
@@ -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/mapstatecache2/Server/src/Services/Mapping/ServerMappingServiceBuild.cpp
===================================================================
--- sandbox/jng/mapstatecache2/Server/src/Services/Mapping/ServerMappingServiceBuild.cpp	2020-01-30 10:20:10 UTC (rev 9641)
+++ sandbox/jng/mapstatecache2/Server/src/Services/Mapping/ServerMappingServiceBuild.cpp	2020-01-30 10:36:25 UTC (rev 9642)
@@ -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/mapstatecache2/Server/src/UnitTesting/TestMappingService.cpp
===================================================================
--- sandbox/jng/mapstatecache2/Server/src/UnitTesting/TestMappingService.cpp	2020-01-30 10:20:10 UTC (rev 9641)
+++ sandbox/jng/mapstatecache2/Server/src/UnitTesting/TestMappingService.cpp	2020-01-30 10:36:25 UTC (rev 9642)
@@ -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");
@@ -330,6 +333,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(INT32 major, INT32 minor, INT32 rev)
 {
     try

Modified: sandbox/jng/mapstatecache2/Server/src/UnitTesting/TestMappingService.h
===================================================================
--- sandbox/jng/mapstatecache2/Server/src/UnitTesting/TestMappingService.h	2020-01-30 10:20:10 UTC (rev 9641)
+++ sandbox/jng/mapstatecache2/Server/src/UnitTesting/TestMappingService.h	2020-01-30 10:36:25 UTC (rev 9642)
@@ -25,6 +25,7 @@
     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);
@@ -59,6 +60,7 @@
     void TestStart();
     void TestEnd();
 
+    void TestCase_CreateMap();
     void TestCase_CreateRuntimeMap(INT32 major, INT32 minor, INT32 rev);
     void TestCase_CreateRuntimeMap260() { TestCase_CreateRuntimeMap(2, 6, 0); }
     void TestCase_CreateRuntimeMap300() { TestCase_CreateRuntimeMap(3, 0, 0); }
@@ -65,7 +67,6 @@
     void TestCase_CreateRuntimeMap400() { TestCase_CreateRuntimeMap(4, 0, 0); }
     void TestCase_DescribeRuntimeMap();
     void TestCase_SaveMap();
-    void TestCase_GetPlot();
     void TestCase_GetMultiPlot();
     void TestCase_CreateAndDescribeLinkedRuntimeMap();
     void TestCase_GetPlotUsingCurrentCenterAndScale();



More information about the mapguide-commits mailing list